diff --git a/EgtGraphics.rc b/EgtGraphics.rc index 25a60d7..f4ec3fb 100644 Binary files a/EgtGraphics.rc and b/EgtGraphics.rc differ diff --git a/ObjEGrGraphics.h b/ObjEGrGraphics.h index e1590b7..1e2ae61 100644 --- a/ObjEGrGraphics.h +++ b/ObjEGrGraphics.h @@ -41,7 +41,7 @@ class ObjEGrGraphics : public IObjGraphics virtual bool StartTriangles( int nNum, bool bAux = false) = 0 ; virtual bool AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms) = 0 ; virtual bool EndTriangles( void) = 0 ; - virtual bool Draw( int nStat, int nMark, bool ShowAux) = 0 ; + virtual bool Draw( int nStat, int nMark, bool bSurfSha, bool ShowAux) = 0 ; } ; //---------------------------------------------------------------------------- diff --git a/ObjNewGraphics.cpp b/ObjNewGraphics.cpp index ae69087..2750169 100644 --- a/ObjNewGraphics.cpp +++ b/ObjNewGraphics.cpp @@ -273,7 +273,7 @@ ObjNewGraphics::EndTriangles( void) //---------------------------------------------------------------------------- bool -ObjNewGraphics::Draw( int nStat, int nMark, bool bShowAux) +ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux) { if ( ! m_bValid || m_pScene == nullptr || ! m_pScene->MakeCurrent()) return false ; @@ -290,6 +290,22 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bShowAux) glLineWidth( 3) ; } + // colore speciale per superficie shading selezionata o marcata + bool bStdCol = true ; + float fSelMarkCol[4] = { 1, 1, 1, 1} ; + if ( bSurfSha) { + if ( nMark == GDB_MK_ON) { + bStdCol = false ; + Color colMark = ( ( GetScene() != nullptr) ? GetScene()->GetMark() : Color( 192, 192, 0)) ; + colMark.GetFloat( fSelMarkCol) ; + } + else if ( nStat == GDB_ST_SEL) { + bStdCol = false ; + Color colSelSurf = ( ( GetScene() != nullptr) ? GetScene()->GetSelSurf() : Color( 255, 255, 192)) ; + colSelSurf.GetFloat( fSelMarkCol) ; + } + } + // ciclo di disegno NGALIST::iterator iIter ; for ( iIter = m_ngaList.begin() ; iIter != m_ngaList.end() ; ++ iIter) { @@ -309,16 +325,16 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bShowAux) } break ; case NgAtom::COLOR : - glColor4fv( iIter->m_fCol) ; + glColor4fv( ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ; break ; case NgAtom::MAT_A : - glMaterialfv( GL_FRONT, GL_AMBIENT, iIter->m_fCol) ; + glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ; break ; case NgAtom::MAT_D : - glMaterialfv( GL_FRONT, GL_DIFFUSE, iIter->m_fCol) ; + glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ; break ; case NgAtom::MAT_S : - glMaterialfv( GL_FRONT, GL_SPECULAR, iIter->m_fCol) ; + glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ; break ; case NgAtom::MAT_SH : glMaterialf( GL_FRONT, GL_SHININESS, iIter->m_fCol[0]) ; @@ -329,8 +345,8 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bShowAux) } } - // se marcato, disegno halo - if ( nMark == GDB_MK_ON) { + // se marcato e non superficie in shading, disegno halo + if ( nMark == GDB_MK_ON && ! bSurfSha) { // cambio test di depth per non sovrascrivere il disegno appena fatto glDepthFunc( GL_LESS) ; diff --git a/ObjNewGraphics.h b/ObjNewGraphics.h index 39f9fc6..d258d48 100644 --- a/ObjNewGraphics.h +++ b/ObjNewGraphics.h @@ -76,7 +76,7 @@ class ObjNewGraphics : public ObjEGrGraphics virtual bool StartTriangles( int nNum, bool bAux = false) ; virtual bool AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms) ; virtual bool EndTriangles( void) ; - virtual bool Draw( int nStat, int nMark, bool bShowAux) ; + virtual bool Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux) ; public : ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false) {} diff --git a/ObjOldGraphics.cpp b/ObjOldGraphics.cpp index bc90626..aba64f2 100644 --- a/ObjOldGraphics.cpp +++ b/ObjOldGraphics.cpp @@ -178,7 +178,7 @@ ObjOldGraphics::EndTriangles( void) //---------------------------------------------------------------------------- bool -ObjOldGraphics::Draw( int nStat, int nMark, bool bShowAux) +ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux) { // se vuoto non faccio alcunché if ( m_ogaList.size() == 0) @@ -192,6 +192,22 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bShowAux) glLineWidth( 3) ; } + // colore speciale per superficie shading selezionata o marcata + bool bStdCol = true ; + float fSelMarkCol[4] = { 1, 1, 1, 1} ; + if ( bSurfSha) { + if ( nMark == GDB_MK_ON) { + bStdCol = false ; + Color colMark = ( ( GetScene() != nullptr) ? GetScene()->GetMark() : Color( 255, 255, 0)) ; + colMark.GetFloat( fSelMarkCol) ; + } + else if ( nStat == GDB_ST_SEL) { + bStdCol = false ; + Color colSelSurf = ( ( GetScene() != nullptr) ? GetScene()->GetSelSurf() : Color( 255, 255, 192)) ; + colSelSurf.GetFloat( fSelMarkCol) ; + } + } + // ciclo di disegno bool bStartA = false ; OGALIST::iterator iIter ; @@ -220,16 +236,16 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bShowAux) glNormal3fv( iIter->m_fVal) ; break ; case OgAtom::COLOR : - glColor4fv( iIter->m_fVal) ; + glColor4fv( ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ; break ; case OgAtom::MAT_A : - glMaterialfv( GL_FRONT, GL_AMBIENT, iIter->m_fVal) ; + glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ; break ; case OgAtom::MAT_D : - glMaterialfv( GL_FRONT, GL_DIFFUSE, iIter->m_fVal) ; + glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ; break ; case OgAtom::MAT_S : - glMaterialfv( GL_FRONT, GL_SPECULAR, iIter->m_fVal) ; + glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ; break ; case OgAtom::MAT_SH : glMaterialf( GL_FRONT, GL_SHININESS, iIter->m_fVal[0]) ; @@ -240,8 +256,8 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bShowAux) } } - // se marcato, disegno halo - if ( nMark == GDB_MK_ON) { + // se marcato e non superficie in shading, disegno halo + if ( nMark == GDB_MK_ON && ! bSurfSha) { // cambio test di depth per non sovrascrivere il disegno appena fatto glDepthFunc( GL_LESS) ; diff --git a/ObjOldGraphics.h b/ObjOldGraphics.h index 40d9d17..318535c 100644 --- a/ObjOldGraphics.h +++ b/ObjOldGraphics.h @@ -79,7 +79,7 @@ class ObjOldGraphics : public ObjEGrGraphics virtual bool StartTriangles( int nNum, bool bAux = false) ; virtual bool AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms) ; virtual bool EndTriangles( void) ; - virtual bool Draw( int nStat, int nMark, bool bShowAux) ; + virtual bool Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux) ; public : ObjOldGraphics( void) : m_pScene( nullptr), m_nCurrMode( GL_NONE), m_bValid( false) {} diff --git a/Scene.h b/Scene.h index 1fd40d1..149c0a5 100644 --- a/Scene.h +++ b/Scene.h @@ -105,6 +105,7 @@ class Scene : public IEGrScene virtual bool SetExtension( const BBox3d& b3Ext) ; virtual bool UpdateExtension( void) ; virtual bool SetMark( Color colMark) ; + virtual bool SetSelSurf( Color colSelSurf) ; // Grid virtual bool SetGridShow( bool bShowGrid, bool bShowFrame) ; virtual bool SetGridFrame( const Frame3d& frFrame) ; @@ -132,6 +133,8 @@ class Scene : public IEGrScene // Geometry Color GetMark( void) { return m_colMark ; } + Color GetSelSurf( void) + { return m_colSelSurf ; } private : // Basic @@ -198,6 +201,7 @@ class Scene : public IEGrScene IGeomDB* m_pGeomDB ; // puntatore al DB geometrico Color m_colDef ; // colore di default Color m_colMark ; // colore per marcatura + Color m_colSelSurf ; // colore di superficie selezionata BBox3d m_b3ExtWorld ; // estensione della geometria nel riferimento globale (mondo) BBox3d m_b3ExtView ; // estensione nel riferimento di vista diff --git a/SceneBasic.cpp b/SceneBasic.cpp index 5ccd937..ea08b69 100644 --- a/SceneBasic.cpp +++ b/SceneBasic.cpp @@ -63,7 +63,8 @@ Scene::Scene( void) // GeomData m_pGeomDB = nullptr ; m_colDef.Set( 0, 0, 0) ; - m_colMark.Set( 192, 192, 0) ; + m_colMark.Set( 255, 255, 0) ; + m_colSelSurf.Set( 255, 255, 192) ; // Extension SetExtension( BBox3d( -MIN_EXTENSION, -MIN_EXTENSION, -MIN_EXTENSION, MIN_EXTENSION, MIN_EXTENSION, MIN_EXTENSION)) ; @@ -719,10 +720,14 @@ Scene::Draw( void) glEnable( GL_LIGHT1) ; // disegno le geometrie del DB // prima passata per superfici con illuminazione abilitata + glEnable( GL_POLYGON_OFFSET_FILL) ; + glPolygonOffset( 1.0, 1.0) ; glEnable( GL_LIGHTING) ; DrawGroup( GDB_ID_ROOT, 1, MdStMk( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF)) ; + glDisable( GL_POLYGON_OFFSET_FILL) ; // seconda passata per 0dim e curve con illuminazione disabilitata glDisable( GL_LIGHTING) ; + glPolygonMode( GL_FRONT_AND_BACK, GL_LINE) ; DrawGroup( GDB_ID_ROOT, 2, MdStMk( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF)) ; break ; } diff --git a/SceneGeom.cpp b/SceneGeom.cpp index 08ed5be..3895c9e 100644 --- a/SceneGeom.cpp +++ b/SceneGeom.cpp @@ -56,6 +56,15 @@ Scene::SetMark( Color colMark) return true ; } +//---------------------------------------------------------------------------- +bool +Scene::SetSelSurf( Color colSelSurf) +{ + m_colSelSurf = colSelSurf ; + + return true ; +} + //---------------------------------------------------------------------------- bool Scene::DrawGroup( int nId, int nPass, MdStMk cParent) @@ -302,11 +311,15 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj) return true ; } - // se shading e non selezione + // se shading e non modalità selezione + bool bSurfSha = false ; if ( m_nShowMode == SM_SHADING && ! m_bSelect) { // in prima passata disegno solo le superfici - if ( nPass == 1 && ( nGeoType & GEO_SURF) == 0) - return true ; + if ( nPass == 1) + if ( ( nGeoType & GEO_SURF) != 0) + bSurfSha = true ; + else + return true ; // in seconda passata disegno solo dimensioni 0 e curve if ( nPass == 2 && ( nGeoType & GEO_SURF) != 0) return true ; @@ -320,7 +333,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj) bool bShowAux = false ; if ( ( nGeoType & GEO_CURVE) != 0 && m_bShowCurveDirection) bShowAux = true ; - return pGraphics->Draw( siObj.nStat, siObj.nMark, bShowAux) ; + return pGraphics->Draw( siObj.nStat, siObj.nMark, bSurfSha, bShowAux) ; } //----------------------------------------------------------------------------