EgtGraphics 1.5c5 :

- nel disegno si tiene conto dello stato dell'oggetto (ON, SEL, OFF)
- gli oggetti selezionati vengono evidenziati.
This commit is contained in:
Dario Sassi
2014-03-14 18:40:18 +00:00
parent 46df22d5ed
commit ec813123d0
9 changed files with 73 additions and 27 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -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 ;
} ;
//----------------------------------------------------------------------------
+19 -1
View File
@@ -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 ;
}
+1 -1
View File
@@ -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) {}
+15 -1
View File
@@ -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 ;
}
+1 -1
View File
@@ -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) {}
+3 -3
View File
@@ -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) ;
+2 -2
View File
@@ -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) ;
+31 -17
View File
@@ -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<IGdbIterator> 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<IGdbIterator*>(&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 ;