From ae007f05cd4209cca83ffdaf547758fdcc0217f5 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 15 Aug 2005 11:14:50 +0000 Subject: [PATCH] To improve Viewer memory management --- src/VISUGUI/VisuGUI_Module.cxx | 19 ++++++++++++------- src/VISUGUI/VisuGUI_Module.h | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 830df45f..a581b04d 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -59,18 +59,22 @@ namespace VISU SalomeApp_VTKSelector* mySelector; public: - Viewer(SalomeApp_Application* theApp, TViewerMap& theViewerMap) + Viewer(VisuGUI_Module* theModule, TViewerMap& theViewerMap) { - myViewManager = new SVTK_ViewManager( theApp->activeStudy(), theApp->desktop() ); + SalomeApp_Application* anApp = theModule->getApp(); + myViewManager = new SVTK_ViewManager( anApp->activeStudy(), anApp->desktop() ); SVTK_Viewer* aViewer = (SVTK_Viewer*)myViewManager->getViewModel(); - mySelector = new SalomeApp_VTKSelector( aViewer, theApp->selectionMgr() ); - theApp->addViewManager( myViewManager ); - theViewerMap.insert(TViewerMap::value_type(myViewManager,PViewer(this))); + mySelector = new SalomeApp_VTKSelector( aViewer, anApp->selectionMgr() ); + anApp->addViewManager( myViewManager ); + theViewerMap.insert(TViewerMap::value_type(myViewManager,PViewer(this))); + QObject::connect( myViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + theModule, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); + //aViewer->setBackgroundColor( Qt::darkGreen ); myViewManager->createViewWindow(); } - + virtual ~Viewer() { @@ -130,6 +134,7 @@ VisuGUI_Module createAction( GAUSS_NEW_VIEWER, tr("MEN_NEW_VIEWER"), QIconSet(), tr("MEN_NEW_VIEWER"), "", 0, this, false, this, SLOT(onCreateViewManager())); + createMenu( GAUSS_NEW_VIEWER, aMenuId, 10 ); // new viewer } @@ -165,7 +170,7 @@ void VisuGUI_Module ::onCreateViewManager() { - new Viewer(getApp(),myViewerMap); + new Viewer(this,myViewerMap); } diff --git a/src/VISUGUI/VisuGUI_Module.h b/src/VISUGUI/VisuGUI_Module.h index 9eb309b0..ab76990b 100644 --- a/src/VISUGUI/VisuGUI_Module.h +++ b/src/VISUGUI/VisuGUI_Module.h @@ -50,6 +50,8 @@ class VisuGUI_Module: public VisuGUI { Q_OBJECT; + friend class VISU::Viewer; + public: VisuGUI_Module(); -- 2.39.2