]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
PAL11954 - "Point view" viewer must be activated on PostPro loading
authorasl <asl@opencascade.com>
Wed, 12 Apr 2006 09:40:33 +0000 (09:40 +0000)
committerasl <asl@opencascade.com>
Wed, 12 Apr 2006 09:40:33 +0000 (09:40 +0000)
src/VISUGUI/VisuGUI_Module.cxx
src/VISUGUI/VisuGUI_Module.h

index 2cdff7b2a770fb9914c793cdd475906313e6717c..647feba5c1e7342f65ad09e0fc12de4e3cbfe6a7 100644 (file)
@@ -121,61 +121,27 @@ using namespace VISU;
 
 namespace VISU
 {
-  //---------------------------------------------------------------
-  class Viewer
-  {
-    VVTK_ViewManager* myViewManager;
-    LightApp_VTKSelector* mySelector;
-  public:
-
-    Viewer(VisuGUI_Module* theModule, TViewerMap& theViewerMap)
-    {
-      SalomeApp_Application* anApp = theModule->getApp();
-      myViewManager = new VVTK_ViewManager( anApp->activeStudy(), anApp->desktop() );
-      VVTK_Viewer* aViewer = (VVTK_Viewer*)myViewManager->getViewModel();
-      mySelector = new LightApp_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();
-    }
-    
-    VVTK_ViewManager* getViewManager() 
-    {
-      return myViewManager;
-    }
-
-    virtual
-    ~Viewer()
-    {
-    }
-  };
-
-
   //---------------------------------------------------------------
   typedef void (SUIT_ViewWindow::* TViewVisibility)();
   void
-  SetViewVisibility(const TViewerMap& theViewerMap, 
+  SetViewVisibility(SalomeApp_Application* app,
                    TViewVisibility theViewVisibility)
   {
-    TViewerMap::const_iterator anIter = theViewerMap.begin();
-    for(; anIter != theViewerMap.end(); anIter++){
-      if(SUIT_ViewManager* aViewManager = anIter->first){
+    ViewManagerList l;
+    app->viewManagers( VVTK_Viewer::Type(), l );
+    ViewManagerList::const_iterator anIt = l.begin(), aLast = l.end();
+    for( ; anIt!=aLast; anIt++ )
+      if( SUIT_ViewManager* aViewManager = *anIt )
+      {
        QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
        int aSize = aViews.size();
-       for(int anId = 0; anId < aSize; anId++){
-         if(SUIT_ViewWindow* aView = aViews[anId]){
+       for(int anId = 0; anId < aSize; anId++)
+       {
+         if(SUIT_ViewWindow* aView = aViews[anId])
            (aView->* theViewVisibility)();
-         }
        }
       }
-    }
   }
-
 }
 
 //---------------------------------------------------------------
@@ -342,7 +308,7 @@ activateModule( SUIT_Study* theStudy )
 {
   VisuGUI::activateModule( theStudy );
 
-  SetViewVisibility(myViewerMap,&SUIT_ViewWindow::show);
+  SetViewVisibility(getApp(),&SUIT_ViewWindow::show);
 
   return true;
 }
@@ -355,7 +321,7 @@ deactivateModule( SUIT_Study* theStudy )
 {
   VisuGUI::deactivateModule( theStudy );
 
-  SetViewVisibility(myViewerMap,&SUIT_ViewWindow::hide);
+  SetViewVisibility(getApp(),&SUIT_ViewWindow::hide);
 
   return true;
 }
@@ -366,17 +332,16 @@ SUIT_ViewManager*
 VisuGUI_Module::
 onCreateViewManager()
 {
-  Viewer* aViewer = new Viewer( this, myViewerMap );
-  return aViewer->getViewManager();
-}
+  SalomeApp_Application* anApp = getApp();
+  VVTK_ViewManager* aViewManager = new VVTK_ViewManager( anApp->activeStudy(), anApp->desktop() );
+  VVTK_Viewer* aViewer = (VVTK_Viewer*)aViewManager->getViewModel();
+  new LightApp_VTKSelector( aViewer, anApp->selectionMgr() );
+  anApp->addViewManager( aViewManager );
+     
+  //aViewer->setBackgroundColor( Qt::darkGreen );
+  aViewManager->createViewWindow();
 
-
-//---------------------------------------------------------------
-void
-VisuGUI_Module::
-onLastViewClosed(SUIT_ViewManager* theViewManager)
-{
-  myViewerMap.erase(theViewManager);
+  return aViewer->getViewManager();
 }
 
 
index d0c371b48dc187e960a27839bc865741874a23e4..af02c8b7b450aad01572ed0e77853eac5ba91553 100644 (file)
@@ -38,22 +38,12 @@ class SVTK_ViewWindow;
 
 #include "MED_SharedPtr.hxx"
 
-namespace VISU
-{
-  class Viewer;
-  typedef MED::SharedPtr<Viewer> PViewer;
-  
-  typedef std::map<SUIT_ViewManager*,PViewer> TViewerMap;
-}
-
 //! This class inherits base VisuGUI.
 /*! Used to display, erase end edit presentations in the VVTK viewer. */
 class VisuGUI_Module: public VisuGUI
 {
   Q_OBJECT;
 
-  friend class VISU::Viewer;
-
 public:
   VisuGUI_Module();
 
@@ -136,9 +126,6 @@ protected slots:
   SUIT_ViewManager*
   onCreateViewManager();
 
-  void
-  onLastViewClosed(SUIT_ViewManager*);
-
   void
   OnCreateGaussPoints();
 
@@ -169,7 +156,6 @@ protected slots:
   OnRestoreConfiguration();
 
 protected:
-  VISU::TViewerMap myViewerMap;
   _PTR(SObject) myConfigSObject;
 
   void setProperty( SVTK_ViewWindow*, const QString& );  // set a property (speed_increment, etc ) for SVTK ViewWindow