EgtGeomKernel 1.5j6 :

- corretta e migliorata gestione ID delle entità.
This commit is contained in:
Dario Sassi
2014-10-30 08:48:08 +00:00
parent cf8fbdc335
commit dd0496d5eb
10 changed files with 139 additions and 39 deletions
+80 -24
View File
@@ -49,6 +49,7 @@ CreateGeomDB( void)
//----------------------------------------------------------------------------
GeomDB::GeomDB( void)
{
m_GrpRadix.SetGeomDB( this) ;
m_GrpRadix.m_nId = GDB_ID_ROOT ;
m_GrpRadix.SetMaterial( Color()) ;
}
@@ -56,6 +57,7 @@ GeomDB::GeomDB( void)
//----------------------------------------------------------------------------
GeomDB::~GeomDB( void)
{
// pulisco tutto
Clear() ;
}
@@ -77,14 +79,14 @@ GeomDB::Init( void)
bool
GeomDB::Clear( void)
{
// pulisco mappa degli identificatori
m_IdManager.Clear() ;
// pulisco lista dei selezionati
m_SelManager.Clear() ;
// cancello i materiali custom
m_MatManager.Clear() ;
// disalloco i gruppi e gli oggetti
m_GrpRadix.Clear() ;
// pulisco lista dei selezionati
m_SelManager.Clear() ;
// pulisco mappa degli identificatori
m_IdManager.Clear() ;
// cancello i materiali custom
m_MatManager.Clear() ;
return true ;
}
@@ -331,7 +333,7 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTe
if ( pGObj == nullptr)
return false ;
// se richista, verifica validità e unicità del nome
// se richiesta, verifica validità e unicità del nome
if ( bTestId && ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId)))
return false ;
@@ -344,6 +346,9 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTe
if ( pGRef == nullptr)
return false ;
// assegno il riferimento al DB geometrico
pGObj->SetGeomDB( this) ;
// inserisco prima del riferimento
if ( nSonBeforeAfter <= GDB_BEFORE) {
if ( ! pGObj->InsertBefore( pGRef))
@@ -511,6 +516,70 @@ GeomDB::GetPrev( int nId) const
return ( pGdbPrev->m_nId) ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetFirstGroupInGroup( int nIdGroup) const
{
// recupero il primo oggetto del gruppo
int nIdFirst = GetFirstInGroup( nIdGroup) ;
while ( nIdFirst != GDB_ID_NULL) {
// se di tipo gruppo
if ( GetGdbType( nIdFirst) == GDB_TY_GROUP)
return nIdFirst ;
// passo al successivo
nIdFirst = GetNext( nIdFirst) ;
}
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetNextGroup( int nId) const
{
// recupero il prossimo oggetto
int nIdNext = GetNext( nId) ;
while ( nIdNext != GDB_ID_NULL) {
// se di tipo gruppo
if ( GetGdbType( nIdNext) == GDB_TY_GROUP)
return nIdNext ;
// passo al successivo
nIdNext = GetNext( nIdNext) ;
}
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetLastGroupInGroup( int nIdGroup) const
{
// recupero l'ultimo oggetto del gruppo
int nIdLast = GetLastInGroup( nIdGroup) ;
while ( nIdLast != GDB_ID_NULL) {
// se di tipo gruppo
if ( GetGdbType( nIdLast) == GDB_TY_GROUP)
return nIdLast ;
// passo al successivo
nIdLast = GetPrev( nIdLast) ;
}
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetPrevGroup( int nId) const
{
// recupero il precedente oggetto
int nIdPrev = GetPrev( nId) ;
while ( nIdPrev != GDB_ID_NULL) {
// se di tipo gruppo
if ( GetGdbType( nIdPrev) == GDB_TY_GROUP)
return nIdPrev ;
// passo al successivo
nIdPrev = GetPrev( nIdPrev) ;
}
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetGdbType( int nId) const
@@ -715,7 +784,7 @@ GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGl
return false ;
// eseguo la copia
PtrOwner<GdbObj> pGdODest( pGdOSou->Clone( nIdDest, m_IdManager)) ;
PtrOwner<GdbObj> pGdODest( pGdOSou->Clone( nIdDest)) ;
if ( IsNull( pGdODest))
return GDB_ID_NULL ;
@@ -823,27 +892,14 @@ GeomDB::Erase( int nId)
bool
GeomDB::Erase( GdbObj* pGdbObj)
{
// deve essere valido
if ( pGdbObj == nullptr)
// deve essere valido e non il gruppo radice
if ( pGdbObj == nullptr || pGdbObj == &m_GrpRadix)
return false ;
// non si può cancellare il gruppo radice
if ( pGdbObj == &m_GrpRadix)
return false ;
// elimino da mappa dei nomi
m_IdManager.RemoveObj( pGdbObj->m_nId) ;
// eliminazione eventuale da lista dei selezionati
m_SelManager.RemoveObj( pGdbObj) ;
// sistemazioni in eventuali GdbIterator con quell'oggetto corrente
m_IterManager.ResetObjIfSame( pGdbObj) ;
// lo tolgo dalla lista
pGdbObj->Remove() ;
// lo disalloco (distruttore virtuale)
// lo disalloco (distruttore virtuale) con sistemazione mappa nomi, lista selezionati e GdbIterator
delete pGdbObj ;
return true ;