EgtGeomKernel 1.5c9 :

- migliorata gestione colori standard
- aggiunta gestione attributi Mark
- aggiunta gestione degli oggetti selezionati
- modifiche ad esecutore per selezionati  e variabile $SEL.
This commit is contained in:
Dario Sassi
2014-03-23 12:33:48 +00:00
parent 13aadeb788
commit 155c722466
17 changed files with 949 additions and 353 deletions
+231 -9
View File
@@ -50,6 +50,8 @@ GeomDB::~GeomDB( void)
bool
GeomDB::Init( void)
{
// pulizia
Clear() ;
// imposto numero minimo buckets del map degli Id
m_IdManager.Init( 1024) ;
// imposto materiale di default
@@ -62,9 +64,10 @@ GeomDB::Init( void)
bool
GeomDB::Clear( void)
{
// elimino mappa degli identificatori
// pulisco mappa degli identificatori
m_IdManager.Clear() ;
// pulisco lista dei selezionati
m_SelManager.Clear() ;
// disalloco i gruppi e gli oggetti
m_GrpRadix.Clear() ;
@@ -247,7 +250,7 @@ GeomDB::SaveHeader( ostream& osOut) const
{
// intestazione
osOut << "START" << endl ;
osOut << "GeomDB,1.5.3.7;" << endl ;
osOut << "GeomDB,1.5.3.8;" << endl ;
// materiale di default come colore
osOut << "MAT_DEF" << endl ;
@@ -607,15 +610,12 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
bool
GeomDB::Erase( int nId)
{
INTPGDBO_UMAP::const_iterator Iter ;
GdbObj* pGdbObj ;
// non si può cancellare il gruppo radice (escludo anche Id non validi)
if ( nId <= GDB_ID_ROOT)
return false ;
// recupero l'oggetto
GdbObj* pGdbObj ;
pGdbObj = m_IdManager.FindObj( nId) ;
if ( pGdbObj == nullptr)
return false ;
@@ -623,6 +623,9 @@ GeomDB::Erase( int nId)
// elimino da mappa dei nomi
m_IdManager.RemoveObj( nId) ;
// eliminazione eventuale da lista dei selezionati
m_SelManager.RemoveObj( pGdbObj) ;
// lo tolgo dalla lista
pGdbObj->Remove() ;
@@ -766,6 +769,130 @@ GeomDB::MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
return pGdbObj->Mirror( ptOnLoc, vtNormLoc) ;
}
//----------------------------------------------------------------------------
// Selection
//----------------------------------------------------------------------------
bool
GeomDB::SelectObj( int nId)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
return SetStatus( pGdbObj, GDB_ST_SEL) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::DeselectObj( int nId)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// se selezionato, lo deseleziono
if ( pGdbObj->IsSelected())
return SetStatus( pGdbObj, GDB_ST_ON) ;
// altrimenti, va già bene
else
return true ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SelectGroupObjs( int nId)
{
// recupero il gruppo Gdb
GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr)
return false ;
// ciclo sugli oggetti del gruppo e li seleziono
GdbObj* pGdbObj = pGdbGroup->GetFirstObj() ;
while ( pGdbObj != nullptr) {
if ( ! SetStatus( pGdbObj, GDB_ST_SEL))
return false ;
pGdbObj = pGdbObj->GetNext() ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GeomDB::DeselectGroupObjs( int nId)
{
// recupero il gruppo Gdb
GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr)
return false ;
// ciclo sugli oggetti del gruppo e li seleziono
GdbObj* pGdbObj = pGdbGroup->GetFirstObj() ;
while ( pGdbObj != nullptr) {
// se selezionato, lo deseleziono
if ( pGdbObj->IsSelected()) {
if ( ! SetStatus( pGdbObj, GDB_ST_ON))
return false ;
}
pGdbObj = pGdbObj->GetNext() ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GeomDB::IsSelectedObj( int nId) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero lo stato
return pGdbObj->IsSelected() ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetSelectedObjNbr( void) const
{
return m_SelManager.GetSize() ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetFirstSelectedObj( void) const
{
GdbObj* pGObj = m_SelManager.GetFirstObj() ;
return (( pGObj == nullptr) ? GDB_ID_NULL : pGObj->m_nId) ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetNextSelectedObj( void) const
{
GdbObj* pGObj = m_SelManager.GetNextObj() ;
return (( pGObj == nullptr) ? GDB_ID_NULL : pGObj->m_nId) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::ClearSelection( void)
{
GdbObj* pGObj = m_SelManager.GetFirstObj() ;
while ( pGObj != nullptr) {
m_SelManager.RemoveObj( pGObj) ;
pGObj->SetStatus( GDB_ST_ON) ;
pGObj = m_SelManager.GetFirstObj() ;
}
return true ;
}
//----------------------------------------------------------------------------
// Attributes
//----------------------------------------------------------------------------
@@ -899,8 +1026,29 @@ GeomDB::SetStatus( int nId, int nStat)
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
return SetStatus( pGdbObj, nStat) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetStatus( GdbObj* pGdbObj, int nStat)
{
// verifico validità oggetto
if ( pGdbObj == nullptr)
return false ;
// assegno lo stato
return pGdbObj->SetStatus( nStat) ;
if ( ! pGdbObj->SetStatus( nStat))
return false ;
// se il nuovo stato è selezionato, inserisco oggetto in lista selezionati
if ( nStat == GDB_ST_SEL)
m_SelManager.AddObj( pGdbObj) ;
// altrimenti provo a toglierlo
else
m_SelManager.RemoveObj( pGdbObj) ;
return true ;
}
//----------------------------------------------------------------------------
@@ -912,8 +1060,30 @@ GeomDB::RevertStatus( int nId)
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
return RevertStatus( pGdbObj) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::RevertStatus( GdbObj* pGdbObj)
{
// verifico validità oggetto
if ( pGdbObj == nullptr)
return false ;
// ripristino lo stato precedente
return pGdbObj->RevertStatus() ;
if ( ! pGdbObj->RevertStatus())
return false ;
// se il nuovo stato è selezionato, inserisco oggetto in lista selezionati
int nStat = GDB_ST_ON ;
if ( pGdbObj->GetStatus( nStat) && nStat == GDB_ST_SEL)
m_SelManager.AddObj( pGdbObj) ;
// altrimenti provo a toglierlo
else
m_SelManager.RemoveObj( pGdbObj) ;
return true ;
}
//----------------------------------------------------------------------------
@@ -942,6 +1112,58 @@ GeomDB::GetCalcStatus( int nId, int& nStat) const
return pGdbObj->GetCalcStatus( nStat) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetMark( int nId)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// imposto la marcatura
return pGdbObj->SetMark() ;
}
//----------------------------------------------------------------------------
bool
GeomDB::ResetMark( int nId)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// cancello la marcatura
return pGdbObj->ResetMark() ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetMark( int nId, int& nMark) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero la marcatura
return pGdbObj->GetMark( nMark) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetCalcMark( int nId, int& nMark) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero la marcatura calcolata
return pGdbObj->GetCalcMark( nMark) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetDefaultMaterial( Color cCol)