EgtMachKernel 1.6e1 :
- aggiunta prima versione di caricamento delle macchine.
This commit is contained in:
Binary file not shown.
@@ -207,6 +207,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="EMkDllMain.cpp" />
|
||||
<ClCompile Include="MachMgrBasic.cpp" />
|
||||
<ClCompile Include="MachMgrMachGroups.cpp" />
|
||||
<ClCompile Include="MachMgrMachines.cpp" />
|
||||
<ClCompile Include="MachMgrParts.cpp" />
|
||||
<ClCompile Include="MachMgrRawParts.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
<ClCompile Include="MachMgrParts.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MachMgrMachines.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DllMain.h">
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
@@ -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 ;
|
||||
} ;
|
||||
|
||||
+55
-2
@@ -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 <new>
|
||||
@@ -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<int&>( 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 ;
|
||||
}
|
||||
|
||||
+19
-17
@@ -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<IGdbIterator> 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 ;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<IGdbIterator> 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 ;
|
||||
}
|
||||
+1
-1
@@ -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) ;
|
||||
|
||||
+1
-1
@@ -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() ;
|
||||
|
||||
Reference in New Issue
Block a user