]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve Viewer memory management
authorapo <apo@opencascade.com>
Mon, 15 Aug 2005 11:14:50 +0000 (11:14 +0000)
committerapo <apo@opencascade.com>
Mon, 15 Aug 2005 11:14:50 +0000 (11:14 +0000)
src/VISUGUI/VisuGUI_Module.cxx
src/VISUGUI/VisuGUI_Module.h

index 830df45f4ecd7855a693943802c228dae2d162c0..a581b04d028eeadcd4b79e4dc84bf46331cbc72c 100644 (file)
@@ -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);
 }
 
 
index 9eb309b086889eb9216caeeafb077505df9d0f0a..ab76990b2e4b5f027d7c79adbaa9b8f99461e052 100644 (file)
@@ -50,6 +50,8 @@ class VisuGUI_Module: public VisuGUI
 {
   Q_OBJECT;
 
+  friend class VISU::Viewer;
+
 public:
   VisuGUI_Module();