From ec813123d038d8e3b14532d4e5a277e267ac491a Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 14 Mar 2014 18:40:18 +0000 Subject: [PATCH] EgtGraphics 1.5c5 : - nel disegno si tiene conto dello stato dell'oggetto (ON, SEL, OFF) - gli oggetti selezionati vengono evidenziati. --- EgtGraphics.rc | Bin 11390 -> 11390 bytes ObjEGrGraphics.h | 2 +- ObjNewGraphics.cpp | 20 ++++++++++++++++++- ObjNewGraphics.h | 2 +- ObjOldGraphics.cpp | 16 ++++++++++++++- ObjOldGraphics.h | 2 +- Scene.h | 6 +++--- SceneBasic.cpp | 4 ++-- SceneGeom.cpp | 48 +++++++++++++++++++++++++++++---------------- 9 files changed, 73 insertions(+), 27 deletions(-) diff --git a/EgtGraphics.rc b/EgtGraphics.rc index b0152270ee57709e173437dbdcf6e7ed5f981b0a..a729a6acfe488df9524cd915716e1617dfaa8a49 100644 GIT binary patch delta 94 zcmewt@h@V-H#SDo&G%&mnI{)XOKeu)N@D@@_cKj)6U>8(=`e2oA!NmjRbq)0R03{- L9^+;+B@ZqDJRcsD delta 81 zcmewt@h@V-H#SC-&G%&mnSs F+yKA78{Yr` diff --git a/ObjEGrGraphics.h b/ObjEGrGraphics.h index c3ce081..e402c24 100644 --- a/ObjEGrGraphics.h +++ b/ObjEGrGraphics.h @@ -31,7 +31,7 @@ class ObjEGrGraphics : public IObjGraphics virtual bool AddColor( const Color& colC) = 0 ; virtual bool AddPoint( const Point3d& ptP) = 0 ; virtual bool AddPolyLine( const PolyLine& PL) = 0 ; - virtual bool Draw( void) = 0 ; + virtual bool Draw( int nStat) = 0 ; } ; //---------------------------------------------------------------------------- diff --git a/ObjNewGraphics.cpp b/ObjNewGraphics.cpp index 9c39984..61afa7f 100644 --- a/ObjNewGraphics.cpp +++ b/ObjNewGraphics.cpp @@ -17,7 +17,11 @@ #include "Scene.h" #include "GraphObjs.h" #include "/EgtDev/Include/EGkPolyLine.h" +#include "/EgtDev/Include/EGkGdbConst.h" + +//--------------------------- Macro ------------------------------------------ +// Per funzioni glew dipendenti dal context #define glewGetContext() (( m_pScene != nullptr) ? m_pScene->glewGetContext() : nullptr) @@ -129,11 +133,19 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL) //---------------------------------------------------------------------------- bool -ObjNewGraphics::Draw( void) +ObjNewGraphics::Draw( int nStat) { if ( m_pScene == nullptr || ! m_pScene->MakeCurrent()) return false ; + // gestione stato di visualizzazione + if ( nStat == GDB_ST_OFF) + return true ; + if ( nStat == GDB_ST_SEL) { + glPointSize( 5) ; + glLineWidth( 3) ; + } + // ciclo di disegno NGALIST::iterator iIter ; for ( iIter = m_ngaList.begin() ; iIter != m_ngaList.end() ; ++ iIter) { @@ -151,6 +163,12 @@ ObjNewGraphics::Draw( void) } } + // se necessario, ripristino la normale visualizzazione + if ( nStat == GDB_ST_SEL) { + glPointSize( 3) ; + glLineWidth( 1) ; + } + return true ; } diff --git a/ObjNewGraphics.h b/ObjNewGraphics.h index 601df9d..c7a2ca2 100644 --- a/ObjNewGraphics.h +++ b/ObjNewGraphics.h @@ -69,7 +69,7 @@ class ObjNewGraphics : public ObjEGrGraphics virtual bool AddColor( const Color& colC) ; virtual bool AddPoint( const Point3d& ptP) ; virtual bool AddPolyLine( const PolyLine& PL) ; - virtual bool Draw( void) ; + virtual bool Draw( int nStat) ; public : ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false) {} diff --git a/ObjOldGraphics.cpp b/ObjOldGraphics.cpp index 6eb7b83..83037aa 100644 --- a/ObjOldGraphics.cpp +++ b/ObjOldGraphics.cpp @@ -17,6 +17,7 @@ #include "OpenGL.h" #include "/EgtDev/Include/EGkColor.h" #include "/EgtDev/Include/EGkPolyLine.h" +#include "/EgtDev/Include/EGkGdbConst.h" //---------------------------------------------------------------------------- ObjOldGraphics::~ObjOldGraphics( void) @@ -82,12 +83,19 @@ ObjOldGraphics::AddPolyLine( const PolyLine& PL) //---------------------------------------------------------------------------- bool -ObjOldGraphics::Draw( void) +ObjOldGraphics::Draw( int nStat) { // se vuoto non faccio alcunché if ( m_ogaList.size() == 0) return true ; + if ( nStat == GDB_ST_OFF) + return true ; + if ( nStat == GDB_ST_SEL) { + glPointSize( 5) ; + glLineWidth( 3) ; + } + // ciclo di disegno OGALIST::iterator iIter ; for ( iIter = m_ogaList.begin() ; iIter != m_ogaList.end() ; ++ iIter) { @@ -107,5 +115,11 @@ ObjOldGraphics::Draw( void) } } + // se necessario, ripristino la normale visualizzazione + if ( nStat == GDB_ST_SEL) { + glPointSize( 3) ; + glLineWidth( 1) ; + } + return true ; } diff --git a/ObjOldGraphics.h b/ObjOldGraphics.h index 346b986..07a1b2c 100644 --- a/ObjOldGraphics.h +++ b/ObjOldGraphics.h @@ -70,7 +70,7 @@ class ObjOldGraphics : public ObjEGrGraphics virtual bool AddColor( const Color& colC) ; virtual bool AddPoint( const Point3d& ptP) ; virtual bool AddPolyLine( const PolyLine& PL) ; - virtual bool Draw( void) ; + virtual bool Draw( int nStat) ; public : ObjOldGraphics( void) : m_pScene( nullptr), m_bValid( false) {} diff --git a/Scene.h b/Scene.h index 9ca798e..ddde264 100644 --- a/Scene.h +++ b/Scene.h @@ -85,9 +85,9 @@ class Scene : public IEGrScene bool CalcDirUp( void) ; bool CalcCameraFrame( Frame3d& frView) ; // Geometry - bool DrawGroup( int nId) ; - bool DrawGroup( const IGdbIterator& iIter) ; - bool DrawGeoObj( const IGdbIterator& iIter) ; + bool DrawGroup( int nId, int nParentMode, int nParentStat) ; + bool DrawGroup( const IGdbIterator& iIter, int nParentMode, int nParentStat) ; + bool DrawGeoObj( const IGdbIterator& iIter, int nObjStat) ; bool DeleteObjGraphicsGroup( int nId) ; // Aux bool DrawWinRect( void) ; diff --git a/SceneBasic.cpp b/SceneBasic.cpp index 3ec0785..1e1a744 100644 --- a/SceneBasic.cpp +++ b/SceneBasic.cpp @@ -625,11 +625,11 @@ Scene::Draw( void) if ( m_pGeomDB != nullptr) m_pGeomDB->GetDefaultColor( m_colDef) ; - // imposto la dimensione dei punti + // imposto la dimensione standard dei punti glPointSize( 3) ; // disegno le geometrie del DB - DrawGroup( GDB_ID_ROOT) ; + DrawGroup( GDB_ID_ROOT, GDB_MD_STD, GDB_ST_ON) ; // aggiungo disegni diretti (senza test Zbuffer) glDisable( GL_DEPTH_TEST) ; diff --git a/SceneGeom.cpp b/SceneGeom.cpp index e6d26e5..037ce24 100644 --- a/SceneGeom.cpp +++ b/SceneGeom.cpp @@ -24,6 +24,7 @@ #include "/EgtDev/Include/EGkGeoVector3d.h" #include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkGdbFunct.h" using namespace std ; @@ -80,7 +81,7 @@ Scene::UpdateExtension( void) //---------------------------------------------------------------------------- bool -Scene::DrawGroup( int nId) +Scene::DrawGroup( int nId, int nParentMode, int nParentStat) { // creo un iteratore PtrOwner pIter( CreateGdbIterator()) ; @@ -93,12 +94,12 @@ Scene::DrawGroup( int nId) return false ; // eseguo il disegno - return DrawGroup( *pIter) ; + return DrawGroup( *pIter, nParentMode, nParentStat) ; } //---------------------------------------------------------------------------- bool -Scene::DrawGroup( const IGdbIterator& iIter) +Scene::DrawGroup( const IGdbIterator& iIter, int nParentMode, int nParentStat) { // recupero il riferimento del gruppo Frame3d frFrame ; @@ -120,19 +121,32 @@ Scene::DrawGroup( const IGdbIterator& iIter) pIter->SetGDB( m_pGeomDB) ; bool bNext = pIter->GoToFirstInGroup( iIter) ; while ( bNext) { - // leggo il tipo di nodo + // leggo il tipo di oggetto int nGdbType = pIter->GetGdbType() ; + // recupero e aggiorno il modo dell'oggetto + int nMode = GDB_MD_STD ; + pIter->GetMode( nMode) ; + nMode = ::CalcMode( nMode, nParentMode) ; + // recupero e aggiorno lo stato dell'oggetto + int nStat = GDB_ST_ON ; + pIter->GetStatus( nStat) ; + nStat = ::CalcStatus( nStat, nParentStat) ; + nStat = ::AdjustStatusWithMode( nStat, nMode) ; // se oggetto geometrico - if ( nGdbType == GDB_GEO) { - // lo disegno - if ( ! DrawGeoObj( *pIter)) - return false ; + if ( nGdbType == GDB_TY_GEO) { + // se non nascosto, lo disegno + if ( nStat != GDB_ST_OFF) { + if ( ! DrawGeoObj( *pIter, nStat)) + return false ; + } } // se gruppo - else if ( nGdbType == GDB_GROUP) { - // lo disegno - if ( ! DrawGroup( *pIter)) - return false ; + else if ( nGdbType == GDB_TY_GROUP) { + // se non nascosto, lo disegno + if ( nStat != GDB_ST_OFF) { + if ( ! DrawGroup( *pIter, nMode, nStat)) + return false ; + } } // passo al successivo bNext = pIter->GoToNext() ; @@ -146,7 +160,7 @@ Scene::DrawGroup( const IGdbIterator& iIter) //---------------------------------------------------------------------------- bool -Scene::DrawGeoObj( const IGdbIterator& iIter) +Scene::DrawGeoObj( const IGdbIterator& iIter, int nObjStat) { // recupero l'oggetto geometrico IGeoObj* pGeoObj = (const_cast(&iIter))->GetGeoObj() ; @@ -169,7 +183,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter) int nGeoType = pGeoObj->GetType() ; // recupero il colore Color cCol ; - if ( ! iIter.GetColor( cCol)) + if ( ! iIter.GetCalcColor( cCol)) cCol = m_colDef ; // se vettore if ( nGeoType == GEO_VECT3D) { @@ -228,7 +242,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter) } // visualizzo la grafica associata - return pGraphics->Draw() ; + return pGraphics->Draw( nObjStat) ; } //---------------------------------------------------------------------------- @@ -246,7 +260,7 @@ Scene::DeleteObjGraphicsGroup( int nId) // leggo il tipo di nodo int nGdbType = pIter->GetGdbType() ; // se oggetto geometrico - if ( nGdbType == GDB_GEO) { + if ( nGdbType == GDB_TY_GEO) { // lo recupero IGeoObj* pGeoObj = pIter->GetGeoObj() ; if ( pGeoObj == nullptr) @@ -257,7 +271,7 @@ Scene::DeleteObjGraphicsGroup( int nId) pGeoObj->SetObjGraphics( nullptr) ; } // se gruppo - else if ( nGdbType == GDB_GROUP) { + else if ( nGdbType == GDB_TY_GROUP) { // ripeto sugli oggetti dello stesso if ( ! DeleteObjGraphicsGroup( pIter->GetId())) return false ;