EgtGeomKernel :
- aggiunta relocate sia locale sia globale (per spostare oggetti da un gruppo ad un altro).
This commit is contained in:
+61
-6
@@ -306,10 +306,7 @@ GeomDB::AddToGeomDB( GdbObj* pGObj, int nParentId)
|
||||
if ( ! pGObj->AddTail( pGroup))
|
||||
return false ;
|
||||
|
||||
// aggiorno gestore Id
|
||||
m_IdManager.UpdateMaxId( pGObj->m_nId) ;
|
||||
|
||||
// inserisco in mappa nomi
|
||||
// inserisco in mappa Id
|
||||
return m_IdManager.AddObj( pGObj->m_nId, pGObj) ;
|
||||
}
|
||||
|
||||
@@ -572,8 +569,8 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// verifico esistenza del sorgente
|
||||
GdbObj* pGdOSou ;
|
||||
if ( ( pGdOSou = GetGdbObj( nIdSou)) == nullptr)
|
||||
GdbObj* pGdOSou = GetGdbObj( nIdSou) ;
|
||||
if ( pGdOSou == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// recupero il riferimento del sorgente
|
||||
@@ -606,6 +603,64 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
|
||||
return nIdDest ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Relocate( int nId, int nNewParentId, bool bGlob)
|
||||
{
|
||||
// verifico esistenza dell'oggetto
|
||||
GdbObj* pGdbObj = GetGdbObj( nId) ;
|
||||
if ( pGdbObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// verifico esistenza del padre
|
||||
GdbGroup* pGroup = pGdbObj->GetParent() ;
|
||||
if ( pGroup == nullptr)
|
||||
return false ;
|
||||
|
||||
// cerco il nuovo padre
|
||||
GdbGroup* pNewGroup = GetGdbGroup( nNewParentId) ;
|
||||
if ( pNewGroup == nullptr)
|
||||
return false ;
|
||||
|
||||
// se vecchio e nuovo padre coincidono, non devo fare alcunché
|
||||
if ( pGroup->m_nId == pNewGroup->m_nId)
|
||||
return true ;
|
||||
|
||||
// se rilocazione in globale
|
||||
if ( bGlob) {
|
||||
// recupero il riferimento del sorgente
|
||||
Frame3d frCurr ;
|
||||
if ( ! pGroup->GetGlobFrame( frCurr))
|
||||
return false ;
|
||||
// recupero il riferimento del nuovo padre
|
||||
Frame3d frNew ;
|
||||
if ( ! pNewGroup->GetGlobFrame( frNew))
|
||||
return false ;
|
||||
// porto l'oggetto dal riferimento originale a quello nuovo
|
||||
if ( ! AreSameFrame( frCurr, frNew)) {
|
||||
pGdbObj->ToGlob( frCurr) ;
|
||||
pGdbObj->ToLoc( frNew) ;
|
||||
}
|
||||
}
|
||||
|
||||
// sistemazioni in eventuali GdbIterator con quell'oggetto corrente
|
||||
m_IterManager.ResetObjIfSame( pGdbObj) ;
|
||||
|
||||
// lo estraggo dalla posizione corrente del DB geometrico
|
||||
pGdbObj->Remove() ;
|
||||
|
||||
// lo inserisco in coda alla lista del padre
|
||||
if ( ! pGdbObj->AddTail( pNewGroup)) {
|
||||
// in caso di errore (condizione assai remota qui) cancello tutto
|
||||
m_IdManager.RemoveObj( pGdbObj->m_nId) ;
|
||||
m_SelManager.RemoveObj( pGdbObj) ;
|
||||
delete pGdbObj ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Erase( int nId)
|
||||
|
||||
Reference in New Issue
Block a user