diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc
index 0cc0023..ed21170 100644
Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ
diff --git a/EgtMachKernel.vcxproj b/EgtMachKernel.vcxproj
index 880acf5..81f414d 100644
--- a/EgtMachKernel.vcxproj
+++ b/EgtMachKernel.vcxproj
@@ -207,6 +207,7 @@ copy $(TargetPath) \EgtProg\Dll64
+
diff --git a/EgtMachKernel.vcxproj.filters b/EgtMachKernel.vcxproj.filters
index 0a5dfa0..0d8429d 100644
--- a/EgtMachKernel.vcxproj.filters
+++ b/EgtMachKernel.vcxproj.filters
@@ -39,6 +39,9 @@
Source Files
+
+ Source Files
+
diff --git a/MachConst.h b/MachConst.h
index 7004b77..cfaa4be 100644
--- a/MachConst.h
+++ b/MachConst.h
@@ -17,8 +17,10 @@
//----------------------------------------------------------------------------
-// Radice di tutta la gestione delle lavorazioni
+// Radice della gestione delle lavorazioni
const std::string MACH_BASE = "MachBase" ;
+// Direttorio ausiliario per la gestione delle lavorazioni
+const std::string MACH_AUX = "MachAux" ;
// Chiave per nome macchina in macchinata
const std::string MACH_MACHINE_KEY = "Machine" ;
// Gruppo della macchina in una macchinata
diff --git a/MachMgr.h b/MachMgr.h
index ebdc44c..c848870 100644
--- a/MachMgr.h
+++ b/MachMgr.h
@@ -20,15 +20,15 @@
//----------------------------------------------------------------------------
struct MachGrp {
- int MGeoGroupId ;
+ std::string MGeoName ;
int SetupGroupId ;
int RawGroupId ;
int OperGroupId ;
MachGrp( void)
- : MGeoGroupId( GDB_ID_NULL), SetupGroupId( GDB_ID_NULL),
+ : MGeoName(), SetupGroupId( GDB_ID_NULL),
RawGroupId( GDB_ID_NULL), OperGroupId( GDB_ID_NULL) {}
- MachGrp( int MgId, int GgId, int SgId, int RgId, int OgId)
- : MGeoGroupId( GgId), SetupGroupId( SgId),
+ MachGrp( std::string MgName, int SgId, int RgId, int OgId)
+ : MGeoName( MgName), SetupGroupId( SgId),
RawGroupId( RgId), OperGroupId( OgId) {}
} ;
@@ -37,7 +37,7 @@ class MachMgr : public IMachMgr
{
public :
// Basic
- virtual bool Init( IGeomDB* pGeomDB) ;
+ virtual bool Init( IGeomDB* pGeomDB, const std::string& sMachinesDir) ;
virtual bool Update( void) ;
virtual bool Insert( int nInsGrp) ;
// MachGroups
@@ -78,15 +78,18 @@ class MachMgr : public IMachMgr
private :
// Basic
- inline bool IsMachBase( int nId) const ;
+ bool IsMachBase( int nId) const ;
int FindMachBase( int nGroupId) const ;
bool VerifyMachBase( void) const ;
bool CreateMachBase( void) ;
+ bool IsMachAux( int nId) const ;
+ bool VerifyMachAux( void) const ;
+ bool CreateMachAux( void) ;
// MachGroups
bool VerifyMachGroup( int nId, MachGrp& mgData) const ;
- int GetCurrMGeoId( void) const
- { return ( m_pGeomDB == nullptr) ? GDB_ID_NULL :
- (( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.MGeoGroupId) ; }
+ std::string GetCurrMGeoName( void) const
+ { return ( m_pGeomDB == nullptr) ? "" :
+ (( m_nCurrMGrpId == GDB_ID_NULL) ? "" : m_cCurrMGrp.MGeoName) ; }
int GetCurrSetupId( void) const
{ return ( m_pGeomDB == nullptr) ? GDB_ID_NULL :
(( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.SetupGroupId) ; }
@@ -96,6 +99,9 @@ class MachMgr : public IMachMgr
int GetCurrOperId( void) const
{ return ( m_pGeomDB == nullptr) ? GDB_ID_NULL :
(( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.OperGroupId) ; }
+ // Machines
+ bool LoadMachine( const std::string& sMachineName) ;
+ int GetMachineId( const std::string& sMachineName) const ;
// RawParts
int AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol) ;
int AddRawPart( int nSurfId, Color cCol) ;
@@ -110,8 +116,11 @@ class MachMgr : public IMachMgr
bool ShowRootParts( bool bShow) ;
private :
- IGeomDB* m_pGeomDB ;
- int m_nMachBaseId ;
- int m_nCurrMGrpId ;
- MachGrp m_cCurrMGrp ;
+ IGeomDB* m_pGeomDB ;
+ std::string m_sMachinesDir ;
+ int m_nMachBaseId ;
+ int m_nMachAuxId ;
+ int m_nCurrMGrpId ;
+ MachGrp m_cCurrMGrp ;
+ int m_nCurrMGeoId ;
} ;
diff --git a/MachMgrBasic.cpp b/MachMgrBasic.cpp
index b65768b..c6d68b6 100644
--- a/MachMgrBasic.cpp
+++ b/MachMgrBasic.cpp
@@ -17,6 +17,7 @@
#include "MachMgr.h"
#include "MachConst.h"
#include "/EgtDev/Include/EGnStringUtils.h"
+#include "/EgtDev/Include/EgnFileUtils.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include
@@ -53,17 +54,22 @@ MachMgr::MachMgr( void)
{
m_pGeomDB = nullptr ;
m_nMachBaseId = GDB_ID_NULL ;
+ m_nMachAuxId = GDB_ID_NULL ;
m_nCurrMGrpId = GDB_ID_NULL ;
+ m_nCurrMGeoId = GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
bool
-MachMgr::Init( IGeomDB* pGeomDB)
+MachMgr::Init( IGeomDB* pGeomDB, const string& sMachinesDir)
{
m_pGeomDB = pGeomDB ;
+ m_sMachinesDir = sMachinesDir ;
m_nMachBaseId = GDB_ID_NULL ;
+ m_nMachAuxId = GDB_ID_NULL ;
m_nCurrMGrpId = GDB_ID_NULL ;
- return ( m_pGeomDB != nullptr) ;
+ m_nCurrMGeoId = GDB_ID_NULL ;
+ return ( m_pGeomDB != nullptr && ExistsDirectory( m_sMachinesDir)) ;
}
//----------------------------------------------------------------------------
@@ -190,3 +196,50 @@ MachMgr::CreateMachBase( void)
m_pGeomDB->SetLevel( m_nMachBaseId, GDB_LV_SYSTEM) ;
return true ;
}
+
+//----------------------------------------------------------------------------
+bool
+MachMgr::IsMachAux( int nId) const
+{
+ int nLevel ;
+ std::string sName ;
+ return ( m_pGeomDB != nullptr &&
+ m_pGeomDB->GetLevel( nId, nLevel) && nLevel == GDB_LV_TEMP &&
+ m_pGeomDB->GetName( nId, sName) && sName == MACH_AUX) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+MachMgr::VerifyMachAux( void) const
+{
+ // verifica collegamento a DB geometrico
+ if ( m_pGeomDB == nullptr)
+ return false ;
+ // verifica validità indice del gruppo base
+ if ( m_nMachAuxId == GDB_ID_NULL)
+ return false ;
+ // verifica esistenza gruppo di base per macchinate
+ if ( ! IsMachAux( m_nMachAuxId)) {
+ const_cast( m_nMachAuxId) = GDB_ID_NULL ;
+ return false ;
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+MachMgr::CreateMachAux( void)
+{
+ // se già esiste, esco con successo
+ if ( VerifyMachAux())
+ return true ;
+ // non trovato, devo creare il gruppo di base delle lavorazioni
+ m_nMachAuxId = m_pGeomDB->InsertGroup( GDB_ID_NULL, GDB_ID_ROOT, GDB_FIRST_SON, GLOB_FRM) ;
+ if ( m_nMachAuxId == GDB_ID_NULL)
+ return false ;
+ // imposto nome del gruppo
+ m_pGeomDB->SetName( m_nMachAuxId, MACH_AUX) ;
+ // imposto livello del gruppo a Temp
+ m_pGeomDB->SetLevel( m_nMachAuxId, GDB_LV_TEMP) ;
+ return true ;
+}
diff --git a/MachMgrMachGroups.cpp b/MachMgrMachGroups.cpp
index e641f5d..dfc5531 100644
--- a/MachMgrMachGroups.cpp
+++ b/MachMgrMachGroups.cpp
@@ -93,8 +93,9 @@ MachMgr::AddMachGroup( const string& sName, const string& sMachineName)
// verifico nome non vuoto e non esista già un gruppo con lo stesso nome
if ( sName.empty() || GetMachGroupId( sName) != GDB_ID_NULL)
return GDB_ID_NULL ;
- // verifico esistenza della macchina
- // !!!! TO DO !!!!
+ // verifica ed eventuale caricamento della macchina
+ if ( ! LoadMachine( sMachineName))
+ return GDB_ID_NULL ;
// inserisco il gruppo in coda
int nNewId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nMachBaseId, GLOB_FRM) ;
if ( nNewId == GDB_ID_NULL)
@@ -103,9 +104,6 @@ MachMgr::AddMachGroup( const string& sName, const string& sMachineName)
m_pGeomDB->SetName( nNewId, sName) ;
// assegno la macchina
m_pGeomDB->SetInfo( nNewId, MACH_MACHINE_KEY, sMachineName) ;
- // creo il sottogruppo per la macchina
- int nGeoMachId = m_pGeomDB->AddGroup( GDB_ID_NULL, nNewId, GLOB_FRM) ;
- m_pGeomDB->SetName( nGeoMachId, MACH_GEOM_GROUP) ;
// creo il sottogruppo per l'attrezzaggio
int nSetupId = m_pGeomDB->AddGroup( GDB_ID_NULL, nNewId, GLOB_FRM) ;
m_pGeomDB->SetName( nSetupId, MACH_SETUP_GROUP) ;
@@ -161,11 +159,12 @@ MachMgr::VerifyMachGroup( int nId, MachGrp& mgData) const
// verifica collegamento a DB geometrico
if ( m_pGeomDB == nullptr)
return false ;
+ // verifica della macchina
+ bool bMName = m_pGeomDB->GetInfo( nId, MACH_MACHINE_KEY, mgData.MGeoName) ;
// scansiono i sottogruppi
PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter))
return false ;
- bool bMGeo = false ;
bool bSetup = false ;
bool bRaw = false ;
bool bOper = false ;
@@ -173,12 +172,7 @@ MachMgr::VerifyMachGroup( int nId, MachGrp& mgData) const
while ( bIter) {
string sName ;
if ( pIter->GetName( sName)) {
- if ( sName == MACH_GEOM_GROUP) {
- if ( ! bMGeo)
- mgData.MGeoGroupId = pIter->GetId() ;
- bMGeo = true ;
- }
- else if ( sName == MACH_SETUP_GROUP) {
+ if ( sName == MACH_SETUP_GROUP) {
if ( ! bSetup)
mgData.SetupGroupId = pIter->GetId() ;
bSetup = true ;
@@ -197,7 +191,7 @@ MachMgr::VerifyMachGroup( int nId, MachGrp& mgData) const
// passo al successivo
bIter = pIter->GoToNextGroup() ;
}
- return ( bMGeo && bSetup && bRaw && bOper) ;
+ return ( bMName && bSetup && bRaw && bOper) ;
}
//----------------------------------------------------------------------------
@@ -255,22 +249,28 @@ MachMgr::SetCurrMachGroup( int nId)
m_nCurrMGrpId = GDB_ID_NULL ;
return false ;
}
+ // verifica ed eventuale caricamento della macchina
+ if ( ! LoadMachine( mgData.MGeoName))
+ return GDB_ID_NULL ;
// se esiste gruppo corrente, lo disabilito
if ( m_nCurrMGrpId != GDB_ID_NULL) {
// riporto i pezzi nei grezzi precedenti nella loro posizione standard
SwapParts( false) ;
- // nascondo precedente gruppo corrente
+ // nascondo precedente gruppo corrente e la relativa macchina
m_pGeomDB->SetStatus( m_nCurrMGrpId, GDB_ST_OFF) ;
+ m_pGeomDB->SetStatus( m_nCurrMGeoId, GDB_ST_OFF) ;
}
// imposto i dati del nuovo gruppo corrente
m_nCurrMGrpId = nId ;
m_cCurrMGrp = mgData ;
+ m_nCurrMGeoId = GetMachineId( m_cCurrMGrp.MGeoName) ;
// porto i pezzi dalla loro posizione standard nei grezzi nuovi
SwapParts( true) ;
// nascondo pezzi rimasti sotto la radice
ShowRootParts( false) ;
- // rendo visibile il nuovo gruppo corrente
+ // rendo visibile il nuovo gruppo corrente e la relativa macchina
m_pGeomDB->SetStatus( m_nCurrMGrpId, GDB_ST_ON) ;
+ m_pGeomDB->SetStatus( m_nCurrMGeoId, GDB_ST_ON) ;
return true ;
}
@@ -288,10 +288,12 @@ MachMgr::ResetCurrMachGroup( void)
SwapParts( false) ;
// visualizzo pezzi rimasti sotto la radice
ShowRootParts( true) ;
- // nascondo gruppo corrente
+ // nascondo gruppo corrente e la relativa macchina
m_pGeomDB->SetStatus( m_nCurrMGrpId, GDB_ST_OFF) ;
- // dichiaro nessun gruppo corrente
+ m_pGeomDB->SetStatus( m_nCurrMGeoId, GDB_ST_OFF) ;
+ // dichiaro nessun gruppo corrente e la relativa macchina
m_nCurrMGrpId = GDB_ID_NULL ;
+ m_nCurrMGeoId = GDB_ID_NULL ;
return true ;
}
diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp
new file mode 100644
index 0000000..bda41da
--- /dev/null
+++ b/MachMgrMachines.cpp
@@ -0,0 +1,78 @@
+//----------------------------------------------------------------------------
+// EgalTech 2015-2015
+//----------------------------------------------------------------------------
+// File : MachMgrMachines.cpp Data : 02.05.15 Versione : 1.6e1
+// Contenuto : Implementazione gestione macchine della classe MachMgr.
+//
+//
+//
+// Modifiche : 02.05.15 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "MachMgr.h"
+#include "MachConst.h"
+#include "/EgtDev/Include/EGkGdbIterator.h"
+#include "/EgtDev/Include/EgnStringUtils.h"
+#include "/EgtDev/Include/EgnFileUtils.h"
+#include "/EgtDev/Include/EgtPointerOwner.h"
+
+using namespace std ;
+
+//----------------------------------------------------------------------------
+bool
+MachMgr::LoadMachine( const string& sMachineName)
+{
+ // verifico validità del nome
+ if ( ! IsValidName( sMachineName))
+ return false ;
+ // se macchina già caricata, non devo fare alcunchè
+ if ( GetMachineId( sMachineName) != GDB_ID_NULL)
+ return true ;
+ // verifico esistenza macchina
+ string sMachineDir = m_sMachinesDir + "\\" + sMachineName ;
+ string sMachineMde = sMachineDir + "\\" + sMachineName + ".Mde" ;
+ if ( ! ExistsFile( sMachineMde))
+ return false ;
+ // carico la macchina
+ if ( ! CreateMachAux())
+ return false ;
+ // creo il gruppo per la macchina
+ int nId = m_pGeomDB->InsertGroup( GDB_ID_NULL, m_nMachAuxId, GDB_LAST_SON, GLOB_FRM) ;
+ if ( nId == GDB_ID_NULL)
+ return false ;
+ // imposto nome del gruppo
+ m_pGeomDB->SetName( nId, sMachineName) ;
+ // inserisco la geometria della macchina !!! PROVVISORIO !!!
+ string sMachineNge = sMachineDir + "\\" + sMachineName + ".Nge" ;
+ return m_pGeomDB->Load( sMachineNge, nId) ;
+}
+
+//----------------------------------------------------------------------------
+int
+MachMgr::GetMachineId( const string& sMachineName) const
+{
+ // verifico validità del nome
+ if ( ! IsValidName( sMachineName))
+ return GDB_ID_NULL ;
+ // se non c'è il gruppo ausiliario per le macchine, non ci può essere la macchina
+ if ( ! VerifyMachAux())
+ return GDB_ID_NULL ;
+ // recupero l'identificativo del gruppo con il nome indicato
+ PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ;
+ if ( IsNull( pIter))
+ return GDB_ID_NULL ;
+ bool bIter = pIter->GoToFirstGroupInGroup( m_nMachAuxId) ;
+ while( bIter) {
+ // verifico il nome
+ string sMGroupName ;
+ if ( pIter->GetName( sMGroupName) && sMGroupName == sMachineName)
+ return pIter->GetId() ;
+ // passo al successivo
+ bIter = pIter->GoToNextGroup() ;
+ }
+ return GDB_ID_NULL ;
+}
diff --git a/MachMgrParts.cpp b/MachMgrParts.cpp
index 9d75c72..5b10699 100644
--- a/MachMgrParts.cpp
+++ b/MachMgrParts.cpp
@@ -264,7 +264,7 @@ MachMgr::ShowRootParts( bool bShow)
int nId = m_pGeomDB->GetFirstGroupInGroup( GDB_ID_ROOT) ;
while ( nId != GDB_ID_NULL) {
// se pezzo, lo nascondo
- if ( ! IsMachBase( nId))
+ if ( ! IsMachBase( nId) && ! IsMachAux( nId))
m_pGeomDB->SetStatus( nId, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
// passo al successivo
nId = m_pGeomDB->GetNextGroup( nId) ;
diff --git a/MachMgrRawParts.cpp b/MachMgrRawParts.cpp
index 224d2fc..25f7c74 100644
--- a/MachMgrRawParts.cpp
+++ b/MachMgrRawParts.cpp
@@ -378,7 +378,7 @@ MachMgr::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag)
vtMove = ptP - Point3d( b3Raw.GetMin().x, b3Raw.GetMax().y, b3Raw.GetMin().z) ;
break ;
case RPCR_TR :
- vtMove = ptP - b3Raw.GetMax() ;
+ vtMove = ptP - Point3d( b3Raw.GetMax().x, b3Raw.GetMax().y, b3Raw.GetMin().z) ;
break ;
default : // RPCP_BL
vtMove = ptP - b3Raw.GetMin() ;