diff --git a/EgtGraphics.rc b/EgtGraphics.rc
index 106f38b..1654b8e 100644
Binary files a/EgtGraphics.rc and b/EgtGraphics.rc differ
diff --git a/EgtGraphics.vcxproj b/EgtGraphics.vcxproj
index 9c150ea..7ff730a 100644
--- a/EgtGraphics.vcxproj
+++ b/EgtGraphics.vcxproj
@@ -188,15 +188,24 @@ copy $(TargetPath) \EgtProg\Dll64
+
+
+
-
+
+
+
+
+
+
+
diff --git a/EgtGraphics.vcxproj.filters b/EgtGraphics.vcxproj.filters
index ea4dbd0..18c2162 100644
--- a/EgtGraphics.vcxproj.filters
+++ b/EgtGraphics.vcxproj.filters
@@ -30,7 +30,28 @@
File di intestazione
-
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
File di intestazione
@@ -50,6 +71,12 @@
File di origine
+
+ File di origine
+
+
+ File di origine
+
diff --git a/EGrGraphObjs.h b/GraphObjs.h
similarity index 92%
rename from EGrGraphObjs.h
rename to GraphObjs.h
index 01f1d90..0a15649 100644
--- a/EGrGraphObjs.h
+++ b/GraphObjs.h
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
-// File : EGrGraphObjs.h Data : 06.02.14 Versione : 1.5b4
+// File : GraphObjs.h Data : 06.02.14 Versione : 1.5b4
// Contenuto : Oggetti grafici e loro raccolte.
//
//
diff --git a/ObjEGrGraphics.h b/ObjEGrGraphics.h
new file mode 100644
index 0000000..5ab7839
--- /dev/null
+++ b/ObjEGrGraphics.h
@@ -0,0 +1,38 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : ObjEGrGraphics.h Data : 13.02.14 Versione : 1.5b2
+// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
+//
+//
+//
+// Modifiche : 13.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#include "GraphObjs.h"
+#include "/EgtDev/Include/EgkObjGraphics.h"
+#include "/EgtDev/Include/EgkGeoObj.h"
+#include "/EgtDev/Include/EGkPolyLine.h"
+
+class Scene ;
+
+//----------------------------------------------------------------------------
+class ObjEGrGraphics : public IObjGraphics
+{
+ public :
+ virtual bool IsValid( void) = 0 ;
+ virtual void SetScene( Scene* pScene) = 0 ;
+ virtual Scene* GetScene( void) = 0 ;
+ virtual bool AddPolyLine( const PolyLine& PL) = 0 ;
+ virtual bool Draw( void) = 0 ;
+} ;
+
+//----------------------------------------------------------------------------
+inline const ObjEGrGraphics* GetObjEGrGraphics( const IGeoObj* pGObj)
+ { return (dynamic_cast(pGObj->GetObjGraphics())) ; }
+inline ObjEGrGraphics* GetObjEGrGraphics( IGeoObj* pGObj)
+ { return (dynamic_cast(pGObj->GetObjGraphics())) ; }
diff --git a/ObjNewGraphics.cpp b/ObjNewGraphics.cpp
new file mode 100644
index 0000000..f17e793
--- /dev/null
+++ b/ObjNewGraphics.cpp
@@ -0,0 +1,107 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : ObjNewGraphics.cpp Data : 10.02.14 Versione : 1.5b1
+// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
+//
+//
+//
+// Modifiche : 10.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "ObjNewGraphics.h"
+#include "Scene.h"
+
+#define glewGetContext() (( m_pScene != nullptr) ? m_pScene->glewGetContext() : nullptr)
+
+
+//----------------------------------------------------------------------------
+ObjNewGraphics::~ObjNewGraphics( void)
+{
+ // cancello eventuali vecchi vertici
+ DeleteVaoVbo() ;
+}
+
+//----------------------------------------------------------------------------
+void
+ObjNewGraphics::Invalidate( void)
+{
+ m_bValid = false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+ObjNewGraphics::AddPolyLine( const PolyLine& PL)
+{
+ if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
+ return false ;
+
+ // cancello eventuali vecchi vertici
+ DeleteVaoVbo() ;
+ // imposto il nuovo stato
+ m_bValid = true ;
+ m_nMode = GL_LINE_STRIP ;
+ // inserisco i nuovi vertici
+ glGenVertexArrays( 1, &m_nVaoId) ;
+ if ( m_nVaoId == 0)
+ return false ;
+ glBindVertexArray( m_nVaoId) ;
+ glGenBuffers( 1, &m_nVboId) ;
+ glBindBuffer( GL_ARRAY_BUFFER, m_nVboId) ;
+ glBufferData( GL_ARRAY_BUFFER, PL.GetPointNbr() * SIZEV3F, NULL, GL_STATIC_DRAW) ;
+ Point3d ptP ;
+ Vert3f v3V ;
+ m_nCount = 0 ;
+ for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
+ v3V.Set( ptP.x, ptP.y, ptP.z) ;
+ glBufferSubData( GL_ARRAY_BUFFER, m_nCount * SIZEV3F, SIZEV3F, &v3V) ;
+ ++ m_nCount ;
+ }
+ glVertexAttribPointer( (GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0) ;
+ glEnableVertexAttribArray( 0) ;
+ glBindVertexArray( 0) ;
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+ObjNewGraphics::Draw( void)
+{
+ if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
+ return false ;
+
+ // se vuoto non faccio alcunché
+ if ( m_nCount == 0)
+ return true ;
+
+ if ( m_nVaoId != 0) {
+ glBindVertexArray( m_nVaoId) ;
+ glDrawArrays( m_nMode, 0, m_nCount) ;
+ }
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+ObjNewGraphics::DeleteVaoVbo( void)
+{
+ if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
+ return false ;
+
+ // cancellazione VAO/VBO
+ if ( m_nCount > 0) {
+ glBindBuffer( GL_ARRAY_BUFFER, 0) ;
+ glDeleteBuffers( 1, &m_nVboId) ;
+ glBindVertexArray( 0) ;
+ glDeleteVertexArrays( 1, &m_nVaoId) ;
+ m_nCount = 0 ;
+ }
+
+ return true ;
+}
diff --git a/ObjNewGraphics.h b/ObjNewGraphics.h
new file mode 100644
index 0000000..1170f45
--- /dev/null
+++ b/ObjNewGraphics.h
@@ -0,0 +1,52 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : ObjNewGraphics.h Data : 13.02.14 Versione : 1.5b1
+// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
+//
+//
+//
+// Modifiche : 13.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#include "ObjEGrGraphics.h"
+
+//----------------------------------------------------------------------------
+class ObjNewGraphics : public ObjEGrGraphics
+{
+ public :
+ ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false), m_nMode( 0), m_nCount( 0) {}
+ virtual ~ObjNewGraphics( void) ;
+ virtual void Invalidate( void) ;
+
+ public :
+ virtual bool IsValid( void)
+ { return m_bValid ; }
+ virtual void SetScene( Scene* pScene)
+ { m_pScene = pScene ; }
+ virtual Scene* GetScene( void)
+ { return m_pScene ; }
+ virtual bool AddPolyLine( const PolyLine& PL) ;
+ virtual bool Draw( void) ;
+
+ private :
+ bool DeleteVaoVbo( void) ;
+
+ private :
+ Scene* m_pScene ; // puntatore alla scena
+ bool m_bValid ; // flag
+ int m_nMode ; // modo di utilizzo dei vertici
+ int m_nCount ; // numero di vertici nel VBO
+ unsigned int m_nVaoId ; // Id del VAO
+ unsigned int m_nVboId ; // Id del VBO
+} ;
+
+//----------------------------------------------------------------------------
+inline const ObjNewGraphics* GetObjNewGraphics( const IGeoObj* pGObj)
+ { return (dynamic_cast(pGObj->GetObjGraphics())) ; }
+inline ObjNewGraphics* GetObjNewGraphics( IGeoObj* pGObj)
+ { return (dynamic_cast(pGObj->GetObjGraphics())) ; }
diff --git a/ObjOldGraphics.cpp b/ObjOldGraphics.cpp
new file mode 100644
index 0000000..5cffa97
--- /dev/null
+++ b/ObjOldGraphics.cpp
@@ -0,0 +1,66 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : ObjOldGraphics.cpp Data : 10.02.14 Versione : 1.5b1
+// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
+//
+//
+//
+// Modifiche : 10.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "ObjOldGraphics.h"
+#include "OpenGL.h"
+
+//----------------------------------------------------------------------------
+ObjOldGraphics::~ObjOldGraphics( void)
+{
+ m_v3fList.clear() ;
+}
+
+//----------------------------------------------------------------------------
+void
+ObjOldGraphics::Invalidate( void)
+{
+ m_bValid = false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+ObjOldGraphics::AddPolyLine( const PolyLine& PL)
+{
+ // cancello eventuali vecchi vertici
+ m_v3fList.clear() ;
+ // imposto il nuovo stato
+ m_bValid = true ;
+ m_nMode = GL_LINE_STRIP ;
+ // inserisco i nuovi vertici
+ Point3d ptP ;
+ for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP))
+ m_v3fList.push_back( Vert3f( (float)ptP.x, (float)ptP.y, (float)ptP.z)) ;
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+ObjOldGraphics::Draw( void)
+{
+ // se vuoto non faccio alcunché
+ if ( m_v3fList.size() == 0)
+ return true ;
+
+ // ciclo di disegno
+ glBegin( m_nMode) ;
+ V3FLIST::iterator iIter ;
+ for ( iIter = m_v3fList.begin() ; iIter != m_v3fList.end() ; ++ iIter) {
+ glVertex3f( iIter->x, iIter->y, iIter->z) ;
+ }
+ glEnd() ;
+
+ return true ;
+}
diff --git a/ObjOldGraphics.h b/ObjOldGraphics.h
new file mode 100644
index 0000000..60c92c6
--- /dev/null
+++ b/ObjOldGraphics.h
@@ -0,0 +1,47 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : ObjOldGraphics.h Data : 13.02.14 Versione : 1.5b1
+// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
+//
+//
+//
+// Modifiche : 13.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#include "ObjEGrGraphics.h"
+
+//----------------------------------------------------------------------------
+class ObjOldGraphics : public ObjEGrGraphics
+{
+ public :
+ ObjOldGraphics( void) : m_pScene( nullptr), m_bValid( false), m_nMode( 0) {}
+ virtual ~ObjOldGraphics( void) ;
+ virtual void Invalidate( void) ;
+
+ public :
+ virtual bool IsValid( void)
+ { return m_bValid ; }
+ virtual void SetScene( Scene* pScene)
+ { m_pScene = pScene ; }
+ virtual Scene* GetScene( void)
+ { return m_pScene ; }
+ virtual bool AddPolyLine( const PolyLine& PL) ;
+ virtual bool Draw( void) ;
+
+ private :
+ Scene* m_pScene ; // puntatore alla scena
+ bool m_bValid ; // flag
+ int m_nMode ; // modo di utilizzo dei vertici
+ V3FLIST m_v3fList ; // lista di vertici
+} ;
+
+//----------------------------------------------------------------------------
+inline const ObjOldGraphics* GetObjOldGraphics( const IGeoObj* pGObj)
+ { return (dynamic_cast(pGObj->GetObjGraphics())) ; }
+inline ObjOldGraphics* GetObjOldGraphics( IGeoObj* pGObj)
+ { return (dynamic_cast(pGObj->GetObjGraphics())) ; }
diff --git a/OpenGL.h b/OpenGL.h
new file mode 100644
index 0000000..58361ea
--- /dev/null
+++ b/OpenGL.h
@@ -0,0 +1,18 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : OpenGL.h Data : 14.02.14 Versione : 1.5b2
+// Contenuto : Include per OpenGL.
+//
+//
+//
+// Modifiche : 14.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#define GLEW_MX
+#include "/EgtDev/Extern/GLEW/Include/glew.h"
+#include "/EgtDev/Extern/GLEW/Include/wglew.h"
diff --git a/Scene.h b/Scene.h
index 1d1cd67..42e54f9 100644
--- a/Scene.h
+++ b/Scene.h
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
-// File : EGrScene.h Data : 03.02.14 Versione : 1.5b1
+// File : Scene.h Data : 03.02.14 Versione : 1.5b1
// Contenuto : Dichiarazione della classe gestione scena.
//
//
@@ -15,10 +15,9 @@
//----------------------------------------------------------------------------
#include "/EgtDev/Include/EGrScene.h"
-#include "EGrGraphObjs.h"
-#define GLEW_MX
-#include "/EgtDev/Extern/GLEW/Include/glew.h"
-#include "/EgtDev/Extern/GLEW/Include/wglew.h"
+#include "OpenGL.h"
+
+class IGeoObj ;
//----------------------------------------------------------------------------
class Scene : public IEGrScene
@@ -40,7 +39,7 @@ class Scene : public IEGrScene
virtual bool Project( const Point3d& ptWorld, Point3d& ptView) ;
virtual bool UnProject( const Point3d& ptView, Point3d& ptWorld) ;
virtual void Destroy( void) ;
- // Camera
+ // Camera
virtual bool SetCenter( const Point3d& ptCenter) ;
virtual bool SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist) ;
virtual bool SetCamera( int nDir, double dDist = 0) ;
@@ -54,17 +53,19 @@ class Scene : public IEGrScene
virtual bool ZoomAll( void) ;
virtual bool ZoomChange( double dCoeff) ;
virtual bool ZoomOnPoint( const Point3d& ptWin, double dCoeff) ;
+ // Geometry
+ virtual bool UpdateExtension( void) ;
public :
// Basic
Scene( void) ;
+ bool MakeCurrent( void) ;
+ GLEWContext* glewGetContext( void)
+ { return &m_glewc ; }
private :
// Basic
int ChooseGenPixelFormat( int nPfd, bool b2Buff, int nColorBits, int nDepthBits) ;
- bool MakeCurrent( void) ;
- GLEWContext* glewGetContext( void)
- { return &m_glewc ; }
WGLEWContext* wglewGetContext( void)
{ return &m_wglewc ; }
bool CalcExtView( void) ;
@@ -75,6 +76,8 @@ class Scene : public IEGrScene
bool CalcDirUp( void) ;
// Geometry
bool DrawGroup( int nId) ;
+ bool DrawGeoObj( IGeoObj* pGeoObj) ;
+ bool DeleteObjGraphicsGroup( int nId) ;
private :
IGeomDB* m_pGeomDB ;
@@ -94,7 +97,7 @@ class Scene : public IEGrScene
int m_nViewportW ; // larghezza della finestra
int m_nViewportH ; // altezza della finestra
- BBox3d m_b3ExtWorld ; // estensione della geometria
+ BBox3d m_b3ExtWorld ; // estensione della geometria nel riferimento globale (mondo)
BBox3d m_b3ExtView ; // estensione nel riferimento di vista
bool m_bExtViewOk ; // flag per stato aggiornamento di EView
double m_dHalfWidth ;
diff --git a/SceneBasic.cpp b/SceneBasic.cpp
index 94d9251..a6f3835 100644
--- a/SceneBasic.cpp
+++ b/SceneBasic.cpp
@@ -23,6 +23,7 @@ using namespace std ;
//--------------------------- Constants --------------------------------------
static const double MIN_EXTENSION = 50 ;
+static const double MIN_ZCLIP_EXT = 5000 ;
//----------------------------------------------------------------------------
@@ -420,8 +421,8 @@ Scene::CalcClippingPlanesFromExtView( void)
if ( ! m_b3ExtView.GetCenterExtent( ptCenter, vtExtent))
return false ;
// ricavo la posizione dei piani di clipping sull'asse Z di vista
- const double EXP_COEFF = 1.05 ;
- double dExtent = __max( ( EXP_COEFF * vtExtent.z), MIN_EXTENSION) ;
+ const double EXP_COEFF = 1.1 ;
+ double dExtent = __max( ( EXP_COEFF * vtExtent.z), MIN_ZCLIP_EXT) ;
m_dZNear = - ( ptCenter.z + dExtent) ;
m_dZFar = - ( ptCenter.z - dExtent) ;
return true ;
@@ -496,9 +497,6 @@ Scene::Prepare( void)
bool
Scene::Draw( void)
{
- // provvisorio
- SetExtension( BBox3d( -1000, -1000, -1000, 1000, 1000, 1000)) ;
-
// imposto
if ( ! Prepare())
return false ;
@@ -581,6 +579,10 @@ Scene::UnProject( const Point3d& ptView, Point3d& ptWorld)
void
Scene::Destroy( void)
{
+ // cancellazione eventuali ObjEgrGraphics attaccati a oggetti geometrici
+ DeleteObjGraphicsGroup( GDB_ID_ROOT) ;
+
+ // cancellazione rendering context
wglMakeCurrent( nullptr, nullptr) ;
if ( m_hRC != nullptr) {
wglDeleteContext( m_hRC) ;
diff --git a/SceneCamera.cpp b/SceneCamera.cpp
index 27f2957..a22b57c 100644
--- a/SceneCamera.cpp
+++ b/SceneCamera.cpp
@@ -245,6 +245,9 @@ Scene::RotateCamera( const Point3d& ptWinOld, const Point3d& ptWinNew)
bool
Scene::ZoomAll( void)
{
+ // aggiorno l'ingombro
+ UpdateExtension() ;
+
// traslo il centro di vista nel centro del box
Point3d ptExtCent ;
if ( ! m_b3ExtWorld.GetCenter( ptExtCent))
diff --git a/SceneGeom.cpp b/SceneGeom.cpp
index b417cc4..b5cad4a 100644
--- a/SceneGeom.cpp
+++ b/SceneGeom.cpp
@@ -14,6 +14,8 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "Scene.h"
+#include "ObjOldGraphics.h"
+#include "ObjNewGraphics.h"
#include "/EgtDev/Include/EgtILogger.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGkFrame3d.h"
@@ -54,6 +56,26 @@ FrameToOpenGlMatrix( const Frame3d& frFrame, double Matrix[OGLMAT_DIM])
return true ;
}
+//----------------------------------------------------------------------------
+ObjEGrGraphics*
+CreateObjEGrGraphics( bool bNewWay)
+{
+ if ( bNewWay)
+ return ( new ObjNewGraphics) ;
+ else
+ return ( new ObjOldGraphics) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+Scene::UpdateExtension( void)
+{
+ BBox3d b3Ext ;
+ if ( ! m_pGeomDB->GetLocalBBox( GDB_ID_ROOT, b3Ext))
+ return false ;
+ return SetExtension( b3Ext) ;
+}
+
//----------------------------------------------------------------------------
bool
Scene::DrawGroup( int nId)
@@ -62,7 +84,7 @@ Scene::DrawGroup( int nId)
Frame3d frFrame ;
if ( ! m_pGeomDB->GetGroupFrame( nId, frFrame))
return false ;
- // se non è identità, lo imposto nello stack delle matrici MODELVIEW di OpenGL
+ // se non è identità, lo aggiungo sullo stack delle matrici MODELVIEW di OpenGL
bool bMatrix = ( frFrame.GetType() != Frame3d::TOP || ! frFrame.Orig().IsSmall()) ;
if ( bMatrix) {
glPushMatrix() ;
@@ -78,26 +100,25 @@ Scene::DrawGroup( int nId)
pIter->SetGDB( m_pGeomDB) ;
bool bNext = pIter->GoToFirstInGroup( nId) ;
while ( bNext) {
+ // leggo il tipo di nodo
int nGdbType = pIter->GetGdbType() ;
+ // se oggetto geometrico
if ( nGdbType == GDB_GEO) {
- const ICurve* pCurve ;
- // se curva, la emetto
- if ( ( pCurve = GetCurve( pIter->GetGeoObj())) != nullptr) {
- bool bFound ;
- PolyLine PL ;
- Point3d ptP ;
- pCurve->ApproxWithLines( 0.1, 5, PL) ;
- glBegin( GL_LINE_STRIP) ;
- for ( bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
- glVertex3f( (GLfloat)ptP.x, (GLfloat)ptP.y, (GLfloat)ptP.z) ;
- }
- glEnd() ;
- }
+ // lo recupero
+ IGeoObj* pGeoObj = pIter->GetGeoObj() ;
+ if ( pGeoObj == nullptr)
+ return false ;
+ // lo disegno
+ if ( ! DrawGeoObj( pGeoObj))
+ return false ;
}
+ // se gruppo
else if ( nGdbType == GDB_GROUP) {
+ // lo disegno
if ( ! DrawGroup( pIter->GetId()))
return false ;
}
+ // passo al successivo
bNext = pIter->GoToNext() ;
}
// se necessario, ripristino lo stack delle matrici
@@ -106,3 +127,75 @@ Scene::DrawGroup( int nId)
return true ;
}
+
+//----------------------------------------------------------------------------
+bool
+Scene::DrawGeoObj( IGeoObj* pGeoObj)
+{
+ // se non esiste grafica associata, la creo
+ if ( pGeoObj->GetObjGraphics() == nullptr) {
+ ObjEGrGraphics* pGraphics = CreateObjEGrGraphics( m_bNewWay) ;
+ if ( pGraphics == nullptr)
+ return false ;
+ pGraphics->SetScene( this) ;
+ pGeoObj->SetObjGraphics( pGraphics) ;
+ }
+ // leggo il tipo di oggetto geometrico
+ int nGeoType = pGeoObj->GetType() ;
+ // se curva
+ if ( ( nGeoType & GEO_CURVE) != 0) {
+ // recupero la curva
+ const ICurve* pCurve = GetCurve( pGeoObj) ;
+ if ( pCurve == nullptr)
+ return false ;
+ // se la grafica associata non è valida la ricalcolo
+ ObjEGrGraphics* pGraphics = GetObjEGrGraphics( pGeoObj) ;
+ if ( ! pGraphics->IsValid()) {
+ PolyLine PL ;
+ pCurve->ApproxWithLines( 0.1, 5, PL) ;
+ pGraphics->AddPolyLine( PL) ;
+ }
+ // visualizzo la grafica associata
+ pGraphics->Draw() ;
+ }
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+Scene::DeleteObjGraphicsGroup( int nId)
+{
+ // creo un iteratore
+ PtrOwner pIter( CreateGdbIterator()) ;
+ if ( ! ::IsValid( pIter))
+ return false ;
+ // scandisco il gruppo
+ pIter->SetGDB( m_pGeomDB) ;
+ bool bNext = pIter->GoToFirstInGroup( nId) ;
+ while ( bNext) {
+ // leggo il tipo di nodo
+ int nGdbType = pIter->GetGdbType() ;
+ // se oggetto geometrico
+ if ( nGdbType == GDB_GEO) {
+ // lo recupero
+ IGeoObj* pGeoObj = pIter->GetGeoObj() ;
+ if ( pGeoObj == nullptr)
+ return false ;
+ // ne cancello l'eventuale parte grafica
+ ObjEGrGraphics* pGraph = GetObjEGrGraphics( pGeoObj) ;
+ if ( pGraph != nullptr && pGraph->GetScene() == this)
+ pGeoObj->SetObjGraphics( nullptr) ;
+ }
+ // se gruppo
+ else if ( nGdbType == GDB_GROUP) {
+ // ripeto sugli oggetti dello stesso
+ if ( ! DeleteObjGraphicsGroup( pIter->GetId()))
+ return false ;
+ }
+ // passo al successivo
+ bNext = pIter->GoToNext() ;
+ }
+
+ return true ;
+}