EgtExecutor :
- aggiunta gestione copia di pezzo (Duplo*) in Exe e Lua.
This commit is contained in:
+202
-1
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "EXE.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "EXE_Macro.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
@@ -614,4 +615,204 @@ ExeSelectPathObjs( int nId, bool bHaltOnFork)
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeIsDuploBase( IGeomDB* pGeomDB, int nId)
|
||||
{
|
||||
if ( pGeomDB == nullptr)
|
||||
return false ;
|
||||
int nLevel ;
|
||||
string sName ;
|
||||
return ( pGeomDB->GetLevel( nId, nLevel) && nLevel == GDB_LV_SYSTEM &&
|
||||
pGeomDB->GetName( nId, sName) && sName == DUPLO_BASE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static int
|
||||
GetDuploBase( IGeomDB* pGeomDB, bool bCreate = false)
|
||||
{
|
||||
// verifica collegamento a DB geometrico
|
||||
if ( pGeomDB == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// cerco il gruppo di base dei duplicati nella radice
|
||||
int nId = pGeomDB->GetFirstGroupInGroup( GDB_ID_ROOT) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
// verifico se gruppo cercato
|
||||
if ( ExeIsDuploBase( pGeomDB, nId))
|
||||
return nId ;
|
||||
// passo al successivo
|
||||
nId = pGeomDB->GetNextGroup( nId) ;
|
||||
}
|
||||
// non trovato, se non richiesta creazione ritorno
|
||||
if ( ! bCreate)
|
||||
return GDB_ID_NULL ;
|
||||
// devo creare il gruppo di base delle lavorazioni
|
||||
int nDuploBaseId = pGeomDB->InsertGroup( GDB_ID_NULL, GDB_ID_ROOT, GDB_FIRST_SON, GLOB_FRM) ;
|
||||
if ( nDuploBaseId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// imposto nome del gruppo
|
||||
pGeomDB->SetName( nDuploBaseId, DUPLO_BASE) ;
|
||||
// imposto livello del gruppo a System
|
||||
pGeomDB->SetLevel( nDuploBaseId, GDB_LV_SYSTEM) ;
|
||||
// imposto visualizzazione a nascosto
|
||||
pGeomDB->SetStatus( nDuploBaseId, GDB_ST_OFF) ;
|
||||
return nDuploBaseId ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
ExeDuploNew( int nSouId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// Verifico sia un pezzo
|
||||
if ( ! ExeIsPart( nSouId))
|
||||
return GDB_ID_NULL ;
|
||||
// Recupero il gruppo base dei duplicati
|
||||
int nDuploBaseId = GetDuploBase( pGeomDB, true) ;
|
||||
if ( nDuploBaseId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// Eseguo la copia del pezzo
|
||||
int nNewId = pGeomDB->Copy( nSouId, GDB_ID_NULL, nDuploBaseId) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// Aggiorno info del sorgente
|
||||
INTVECTOR vnRef ;
|
||||
pGeomDB->GetInfo( nSouId, GDB_SI_DUPLIST, vnRef) ;
|
||||
if ( find( vnRef.begin(), vnRef.end(), nNewId) == vnRef.end()) {
|
||||
vnRef.push_back( nNewId) ;
|
||||
pGeomDB->SetInfo( nSouId, GDB_SI_DUPLIST, vnRef) ;
|
||||
}
|
||||
// Aggiorno info del duplicato
|
||||
pGeomDB->SetInfo( nNewId, GDB_SI_DUPSOU, nSouId) ;
|
||||
pGeomDB->RemoveInfo( nNewId, GDB_SI_DUPLIST) ;
|
||||
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeDuploCount( int nSouId, int& nCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// Verifico sia un pezzo
|
||||
if ( ! ExeIsPart( nSouId))
|
||||
return false ;
|
||||
// Recupero info del sorgente
|
||||
INTVECTOR vnRef ;
|
||||
pGeomDB->GetInfo( nSouId, GDB_SI_DUPLIST, vnRef) ;
|
||||
nCount = int( vnRef.size()) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeDuploList( int nSouId, INTVECTOR& vnRef)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// Verifico sia un pezzo
|
||||
if ( ! ExeIsPart( nSouId))
|
||||
return false ;
|
||||
// Recupero info del sorgente
|
||||
pGeomDB->GetInfo( nSouId, GDB_SI_DUPLIST, vnRef) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeDuploSetModified( int nSouId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// Verifico sia un pezzo
|
||||
if ( ! ExeIsPart( nSouId))
|
||||
return false ;
|
||||
// Imposto il flag di modificato
|
||||
return pGeomDB->SetInfo( nSouId, GDB_SI_DUPMODIF, true) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeDuploUpdate( int nSouId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// Verifico sia un pezzo
|
||||
if ( ! ExeIsPart( nSouId))
|
||||
return false ;
|
||||
// Verifico se modificato da ultimo update
|
||||
bool bModif = false ;
|
||||
pGeomDB->GetInfo( nSouId, GDB_SI_DUPMODIF, bModif) ;
|
||||
if ( ! bModif)
|
||||
return true ;
|
||||
// Recupero il gruppo base dei duplicati
|
||||
int nDuploBaseId = GetDuploBase( pGeomDB) ;
|
||||
if ( nDuploBaseId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// recupero le copie
|
||||
INTVECTOR vnRef ;
|
||||
pGeomDB->GetInfo( nSouId, GDB_SI_DUPLIST, vnRef) ;
|
||||
// verifico siano aggiornabili
|
||||
bool bAllOk = true ;
|
||||
for ( int nCopyId : vnRef) {
|
||||
if ( pGeomDB->GetParentId( nCopyId) != nDuploBaseId)
|
||||
bAllOk = false ;
|
||||
}
|
||||
if ( ! bAllOk)
|
||||
return false ;
|
||||
// eseguo gli aggiornamenti
|
||||
for ( int nCopyId : vnRef) {
|
||||
pGeomDB->Erase( nCopyId) ;
|
||||
int nNewId = pGeomDB->Copy( nSouId, nCopyId, nDuploBaseId) ;
|
||||
pGeomDB->SetInfo( nNewId, GDB_SI_DUPSOU, nSouId) ;
|
||||
pGeomDB->RemoveInfo( nNewId, GDB_SI_DUPLIST) ;
|
||||
pGeomDB->RemoveInfo( nNewId, GDB_SI_DUPMODIF) ;
|
||||
}
|
||||
// reset flag di modificato
|
||||
pGeomDB->RemoveInfo( nSouId, GDB_SI_DUPMODIF) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeIsDuplo( int nDupId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// Recupero il gruppo base dei duplicati
|
||||
int nDuploBaseId = GetDuploBase( pGeomDB) ;
|
||||
if ( nDuploBaseId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// Verifico sia un duplicato (gruppo sotto quello dei duplicati con riferimento a originale)
|
||||
if ( pGeomDB->GetGdbType( nDupId) == GDB_TY_GROUP &&
|
||||
pGeomDB->GetParentId( nDupId) == nDuploBaseId &&
|
||||
pGeomDB->ExistsInfo( nDupId, GDB_SI_DUPSOU))
|
||||
return true ;
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
ExeDuploGetOriginal( int nDupId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// Recupero il gruppo base dei duplicati
|
||||
int nDuploBaseId = GetDuploBase( pGeomDB) ;
|
||||
if ( nDuploBaseId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// Verifico sia un duplicato (gruppo sotto quello dei duplicati con riferimento a originale)
|
||||
if ( pGeomDB->GetGdbType( nDupId) != GDB_TY_GROUP ||
|
||||
pGeomDB->GetParentId( nDupId) != nDuploBaseId ||
|
||||
! pGeomDB->ExistsInfo( nDupId, GDB_SI_DUPSOU))
|
||||
return GDB_ID_NULL ;
|
||||
// Recupero l'indice dell'originale
|
||||
int nOrigId = GDB_ID_NULL ;
|
||||
pGeomDB->GetInfo( nDupId, GDB_SI_DUPSOU, nOrigId) ;
|
||||
return nOrigId ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user