From 950a2b90af39d5b6d94f0ffc47cc7d24eb06f166 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 25 Apr 2015 20:32:37 +0000 Subject: [PATCH] EgtGeomKernel 1.6d6 : - modifica radicale della gestione dei selezionati (ora lista parallela su oggetti di GDB). --- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes GdbObj.cpp | 10 ++--- GdbObj.h | 6 +++ GeomDB.cpp | 2 - SelManager.h | 101 ++++++++++++++++++++++++++--------------------- 5 files changed, 68 insertions(+), 51 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 65bf2ea811421888ee6ed3fbf8172b993d63e690..b5ef0d2e98eb45dca28af5d46924b820ef73d956 100644 GIT binary patch delta 94 zcmdlNy)SyhFE&QA&A-_cnHkL{D{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-XmlGI delta 94 zcmdlNy)SyhFE&Qg&A-_cnHfzdD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-X4V@L diff --git a/GdbObj.cpp b/GdbObj.cpp index fe219d5..4c90a85 100644 --- a/GdbObj.cpp +++ b/GdbObj.cpp @@ -25,7 +25,7 @@ using namespace std ; //---------------------------------------------------------------------------- GdbObj::GdbObj( void) - : m_nId( GDB_ID_NULL), m_pAttribs( nullptr), + : m_nId( GDB_ID_NULL), m_pAttribs( nullptr), m_pSelPrev( nullptr), m_pSelNext( nullptr), m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr) { } @@ -39,11 +39,11 @@ GdbObj::~GdbObj( void) m_pAttribs = nullptr ; // aggiorno managers del Db geometrico di appartenenza if ( m_pGDB != nullptr) { - // elimino da mappa dei nomi + // elimino da mappa dei nomi m_pGDB->m_IdManager.RemoveObj( m_nId) ; - // eliminazione eventuale da lista dei selezionati - m_pGDB->m_SelManager.RemoveObj( this) ; - // sistemazioni in eventuali GdbIterator con quell'oggetto corrente + // eventuale rimozione da lista selezionati + m_pGDB->m_SelManager.RemoveObj(this) ; + // sistemazioni in eventuali GdbIterator con quell'oggetto corrente m_pGDB->m_IterManager.ResetObjIfSame( this) ; } m_pGDB = nullptr ; diff --git a/GdbObj.h b/GdbObj.h index 53e3eb8..f562270 100644 --- a/GdbObj.h +++ b/GdbObj.h @@ -29,6 +29,8 @@ class NgeReader ; //---------------------------------------------------------------------------- class GdbObj { + friend class SelManager ; + public : virtual ~GdbObj( void) ; virtual GdbObj* Clone( int nId) const = 0 ; @@ -144,4 +146,8 @@ class GdbObj GdbObj* m_pNext ; GdbObj* m_pPrev ; GdbGroup* m_pParent ; + + private : + GdbObj* m_pSelNext ; + GdbObj* m_pSelPrev ; } ; diff --git a/GeomDB.cpp b/GeomDB.cpp index 1a25e18..d148010 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -86,8 +86,6 @@ GeomDB::Clear( void) ClearSelection() ; // 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 diff --git a/SelManager.h b/SelManager.h index 88bd82d..2598d37 100644 --- a/SelManager.h +++ b/SelManager.h @@ -14,70 +14,83 @@ #pragma once -#include class GdbObj ; -//---------------------------------------------------------------------------- -typedef std::list PGDBO_LIST ; - //---------------------------------------------------------------------------- class SelManager { public : SelManager( void) - { m_Iter = m_SelList.end() ; } - void Clear( void) - { m_SelList.clear() ; - m_Iter = m_SelList.end() ; } + : m_nCount( 0), m_pFirst( nullptr), m_pLast( nullptr), m_pCurr( nullptr) {} int GetSize( void) const - { return int ( m_SelList.size()) ; } + { return m_nCount ; } bool AddObj( GdbObj* pGObj) { if ( pGObj == nullptr) return false ; - try { m_SelList.push_back( pGObj) ; } - catch (...) { return false ;} + if ( m_pLast == nullptr) { + m_pLast = pGObj ; + m_pFirst = pGObj ; + pGObj->m_pSelNext = nullptr ; + pGObj->m_pSelPrev = nullptr ; + } + else { + pGObj->m_pSelNext = nullptr ; + pGObj->m_pSelPrev = m_pLast ; + m_pLast->m_pSelNext = pGObj ; + m_pLast = pGObj ; + } + ++ m_nCount ; return true ; } bool RemoveObj( GdbObj* pGObj) - { PGDBO_LIST::iterator Iter ; - for ( Iter = m_SelList.begin() ; Iter != m_SelList.end() ; ++ Iter) { - if ( *Iter == pGObj) { - if ( Iter == m_Iter) - m_Iter = m_SelList.end() ; - m_SelList.erase( Iter) ; - return true ; - } + { if ( pGObj == nullptr) + return false ; + if ( m_pCurr == pGObj) + m_pCurr = nullptr ; + if ( m_pFirst == pGObj && m_pLast == pGObj) { + m_pFirst = nullptr ; + m_pLast = nullptr ; } + else if ( m_pFirst == pGObj) { + m_pFirst = pGObj->m_pSelNext ; + if ( m_pFirst != nullptr) + m_pFirst->m_pSelPrev = nullptr ; + } + else if ( m_pLast == pGObj) { + m_pLast = pGObj->m_pSelPrev ; + if ( m_pLast != nullptr) + m_pLast->m_pSelNext = nullptr ; + } + else { + if ( pGObj->m_pSelNext == nullptr && pGObj->m_pSelPrev == nullptr) + return false ; + if ( pGObj->m_pSelPrev != nullptr) + pGObj->m_pSelPrev->m_pSelNext = pGObj->m_pSelNext ; + if ( pGObj->m_pSelNext != nullptr) + pGObj->m_pSelNext->m_pSelPrev = pGObj->m_pSelPrev ; + } + pGObj->m_pSelNext = nullptr ; + pGObj->m_pSelPrev = nullptr ; + -- m_nCount ; return true ; } GdbObj* GetFirstObj( void) const - { m_Iter = m_SelList.begin() ; - if ( m_Iter == m_SelList.end()) - return nullptr ; - return (*m_Iter) ; } + { m_pCurr = m_pFirst ; + return m_pCurr ; } GdbObj* GetNextObj( void) const - { if ( m_Iter == m_SelList.end()) - return nullptr ; - ++ m_Iter ; - if ( m_Iter == m_SelList.end()) - return nullptr ; - return (*m_Iter) ; } + { if ( m_pCurr != nullptr) + m_pCurr = m_pCurr->m_pSelNext ; + return m_pCurr ; } GdbObj* GetLastObj( void) const - { m_Iter = m_SelList.end() ; - if ( m_Iter == m_SelList.begin()) - return nullptr ; - -- m_Iter ; - if ( m_Iter == m_SelList.end()) - return nullptr ; - return (*m_Iter) ; } + { m_pCurr = m_pLast ; + return m_pCurr ; } GdbObj* GetPrevObj( void) const - { if ( m_Iter == m_SelList.begin()) - return nullptr ; - -- m_Iter ; - if ( m_Iter == m_SelList.end()) - return nullptr ; - return (*m_Iter) ; } + { if ( m_pCurr != nullptr) + m_pCurr = m_pCurr->m_pSelPrev ; + return m_pCurr ; } private : - PGDBO_LIST m_SelList ; - mutable PGDBO_LIST::const_iterator m_Iter ; + int m_nCount ; + GdbObj* m_pFirst ; + GdbObj* m_pLast ; + mutable GdbObj* m_pCurr ; } ;