From e1e4af8792d5fd0bfb6e6ae775f8735c1cb52011 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 21 Oct 2014 10:50:02 +0000 Subject: [PATCH] =?UTF-8?q?EgtGraphics=201.5j5=20:=20-=20aggiunta=20gestio?= =?UTF-8?q?ne=20entit=C3=A0=20da=20non=20selezionare=20(Unselectable).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EgtGraphics.rc | Bin 11398 -> 11398 bytes Scene.h | 5 +++++ SceneBasic.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- SceneGeom.cpp | 12 ++++++++---- 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/EgtGraphics.rc b/EgtGraphics.rc index 22c6441fbc74060b542475b6690044db13309b9b..b2c3c51a217a9dd7bd13658f177a4748e8472499 100644 GIT binary patch delta 102 zcmZpRY>V9RgN@O2b2s09rpY@vgBVRGPZZMKY{3=80v6R}hKqV9RgN@O6b2s09rpY@vgBXn`PZZMKY{3=80v6R}hKqk diff --git a/Scene.h b/Scene.h index 2a4ef25..84dd11b 100644 --- a/Scene.h +++ b/Scene.h @@ -60,6 +60,10 @@ class Scene : public IEGrScene virtual bool SetBackground( Color colBackTop, Color colBackBottom) ; virtual bool Draw( void) ; virtual bool Select( const Point3d& ptView, int nW, int nH, int& nSel) ; + virtual bool UnselectableAdd( int nId) ; + virtual bool UnselectableRemove( int nId) ; + virtual bool UnselectableClearAll( void) ; + virtual bool UnselectableFind( int nId) ; virtual bool GetSelectedObjs( INTVECTOR& nIds) ; virtual int GetFirstSelectedObj( void) ; virtual int GetNextSelectedObj( void) ; @@ -170,6 +174,7 @@ class Scene : public IEGrScene bool m_bShowCurveDirection ; // flag di visualizzazione direzione curve bool m_bSelect ; // flag di selezione attiva + INTVECTOR m_Unsel ; // vettore indici oggetti non selezionabili Point3d m_ptSelCent ; // centro di selezione int m_nSelW ; // larghezza finestra di selezione int m_nSelH ; // altezza finestra di selezione diff --git a/SceneBasic.cpp b/SceneBasic.cpp index 4358723..da7ed11 100644 --- a/SceneBasic.cpp +++ b/SceneBasic.cpp @@ -7,7 +7,7 @@ // // // Modifiche : 29.01.14 DS Creazione modulo. -// +// 21.10.14 DS Aggiunta gestione Unselectable. // //---------------------------------------------------------------------------- @@ -58,6 +58,7 @@ Scene::Scene( void) m_nShowMode = SM_WIREFRAME ; // Selezione m_bSelect = false ; + m_Unsel.reserve( 50) ; m_nSelCurr = - 1 ; // GeomData m_pGeomDB = nullptr ; @@ -849,6 +850,52 @@ Scene::GetSelectedObjWinZ( int nSel) return 0.5 * ( double( m_nSelBuff[nSel].nZmin) + double( m_nSelBuff[nSel].nZmax)) / UINT_MAX ; } +/*------------------------------------------------------------------------------------------*/ +bool +Scene::UnselectableAdd( int nId) +{ + // non si ammettono radice e id negativi + if ( nId <= GDB_ID_ROOT) + return false ; + // inserisco l'elemento + m_Unsel.push_back( nId) ; + // ordino in senso crescente + stable_sort( m_Unsel.begin(), m_Unsel.end()) ; + return true ; +} + +/*------------------------------------------------------------------------------------------*/ +bool +Scene::UnselectableRemove( int nId) +{ + // non si ammettono radice e id negativi + if ( nId <= GDB_ID_ROOT) + return false ; + // cerco l'elemento + INTVECTOR::iterator Iter = find( m_Unsel.begin(), m_Unsel.end(), nId) ; + if ( Iter == m_Unsel.end()) + return true ; + m_Unsel.erase( Iter) ; + return true ; +} + +/*------------------------------------------------------------------------------------------*/ +bool +Scene::UnselectableClearAll( void) +{ + // cancello tutto + m_Unsel.clear() ; + return true ; +} + +/*------------------------------------------------------------------------------------------*/ +bool +Scene::UnselectableFind( int nId) +{ + // eseguo ricerca su vettore ordinato in senso crescente + return binary_search( m_Unsel.begin(), m_Unsel.end(), nId) ; +} + /*------------------------------------------------------------------------------------------*/ bool Scene::Project( const Point3d& ptWorld, Point3d& ptView) diff --git a/SceneGeom.cpp b/SceneGeom.cpp index d6302d3..1b3802e 100644 --- a/SceneGeom.cpp +++ b/SceneGeom.cpp @@ -116,18 +116,22 @@ Scene::DrawGroup( const IGdbIterator& iIter, int nPass, MdStMk cParent) int nMark = GDB_MK_OFF ; pIter->GetMark( nMark) ; nMark = ::CalcMark( nMark, cParent.nMark) ; + // se in modalità selezione, verifico sia selezionabile + bool bSel = true ; + if ( m_bSelect && UnselectableFind( pIter->GetId())) + bSel = false ; // se oggetto geometrico if ( nGdbType == GDB_TY_GEO) { - // se non nascosto, lo disegno - if ( nStat != GDB_ST_OFF) { + // se non nascosto e selezionabile, lo disegno + if ( nStat != GDB_ST_OFF && bSel) { if ( ! DrawGeoObj( *pIter, nPass, MdStMk( nMode, nStat, nMark))) bOk = false ; } } // se gruppo else if ( nGdbType == GDB_TY_GROUP) { - // se non nascosto, lo disegno - if ( nStat != GDB_ST_OFF) { + // se non nascosto e selezionabile, lo disegno + if ( nStat != GDB_ST_OFF && bSel) { if ( ! DrawGroup( *pIter, nPass, MdStMk( nMode, nStat, nMark))) bOk = false ; }