]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To customize GAUSS Viewer
authorapo <apo@opencascade.com>
Mon, 15 Aug 2005 10:58:24 +0000 (10:58 +0000)
committerapo <apo@opencascade.com>
Mon, 15 Aug 2005 10:58:24 +0000 (10:58 +0000)
Segmentation task

src/VISUGUI/Makefile.in
src/VISUGUI/VISUM_msg_en.po [new file with mode: 0644]
src/VISUGUI/VisuGUI_Module.cxx
src/VISUGUI/VisuGUI_Module.h

index 8760101439d8f87eaa59c8a0d7ad1d4d34ceecec..ed3d27921a32ffa3a474e48beba2eb4b0cf17033 100644 (file)
@@ -40,7 +40,7 @@ EXPORT_HEADERS= \
 
 # .po files to transform in .qm
 PO_FILES = \
-          VISU_msg_en.po VISU_images.po
+          VISU_msg_en.po VISU_images.po VISUM_msg_en.po
 
 # Libraries targets
 LIB = libVISU.la
diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po
new file mode 100644 (file)
index 0000000..a4c4a6c
--- /dev/null
@@ -0,0 +1,13 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2002-02-22 16:56:46 CET\n"
+"PO-Revision-Date: 2005-06-27 12:38+0400\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+msgid "VisuGUI_Module::MEN_GAUSS"
+msgstr "Gauss"
+
+msgid "VisuGUI_Module::MEN_NEW_VIEWER"
+msgstr "New Viewer"
index 10252c3bf36aef7dda8149103fe2d9a13ef8ea07..830df45f4ecd7855a693943802c228dae2d162c0 100644 (file)
 #include "SUIT_Study.h"
 #include "SUIT_Desktop.h"
 
+#include "CAM_Module.h"
+
 #include "SalomeApp_Application.h"
+#include "SalomeApp_SelectionMgr.h"
 #include "SalomeApp_VTKSelector.h"
-#include "CAM_Module.h"
 
 #include "SVTK_ViewManager.h"
 #include "SVTK_ViewModel.h"
 
-//using namespace VISU;
-
 #ifdef _DEBUG_
 static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
 
-VisuGUI_Module::VisuGUI_Module() : VisuGUI()
+#define GAUSS_NEW_VIEWER         5100
+
+using namespace VISU;
+
+namespace VISU
+{
+  //---------------------------------------------------------------
+  class Viewer
+  {
+    SVTK_ViewManager* myViewManager;
+    SalomeApp_VTKSelector* mySelector;
+  public:
+
+    Viewer(SalomeApp_Application* theApp, TViewerMap& theViewerMap)
+    {
+      myViewManager = new SVTK_ViewManager( theApp->activeStudy(), theApp->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)));
+
+      //aViewer->setBackgroundColor( Qt::darkGreen );
+      myViewManager->createViewWindow();
+    }
+
+    virtual
+    ~Viewer()
+    {
+    }
+  };
+
+
+  //---------------------------------------------------------------
+  typedef void (SUIT_ViewWindow::* TViewVisibility)();
+  void
+  SetViewVisibility(const TViewerMap& theViewerMap, 
+                   TViewVisibility theViewVisibility)
+  {
+    TViewerMap::const_iterator anIter = theViewerMap.begin();
+    for(; anIter != theViewerMap.end(); anIter++){
+      if(SUIT_ViewManager* aViewManager = anIter->first){
+       QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+       int aSize = aViews.size();
+       for(int anId = 0; anId < aSize; anId++){
+         if(SUIT_ViewWindow* aView = aViews[anId]){
+           (aView->* theViewVisibility)();
+         }
+       }
+      }
+    }
+  }
+
+}
+
+//---------------------------------------------------------------
+VisuGUI_Module
+::VisuGUI_Module() : 
+  VisuGUI()
 {
 }
 
 
-VisuGUI_Module::~VisuGUI_Module()
+//---------------------------------------------------------------
+VisuGUI_Module
+::~VisuGUI_Module()
 {
 }
 
+
+//---------------------------------------------------------------
 void
-VisuGUI_Module::
-initialize( CAM_Application* theApp )
+VisuGUI_Module
+::initialize( CAM_Application* theApp )
 {
   VisuGUI::initialize( theApp );
 
-  myViewManager = new SVTK_ViewManager( getApp()->activeStudy(), getApp()->desktop() );
-  SVTK_Viewer* aViewer = new SVTK_Viewer();
-  myViewManager->setViewModel( aViewer );
-
-  myViewManager->createViewWindow();
-  myViewManager->getActiveView()->hide();
-
-  //aViewer->setBackgroundColor( Qt::darkGreen );
-
-  new SalomeApp_VTKSelector( aViewer, ( SUIT_SelectionMgr* )getApp()->selectionMgr() );
+  onCreateViewManager();
 
-  theApp->addViewManager( myViewManager );
+  // Add menus
+  int aMenuId;
+  aMenuId = createMenu( tr( "MEN_GAUSS" ), -1, -1, 30 );
+  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
 }
 
+
+//---------------------------------------------------------------
 bool
-VisuGUI_Module::
-activateModule( SUIT_Study* theStudy )
+VisuGUI_Module
+::activateModule( SUIT_Study* theStudy )
 {
   VisuGUI::activateModule( theStudy );
 
-  myViewManager->getActiveView()->show();
+  SetViewVisibility(myViewerMap,&SUIT_ViewWindow::show);
 
   return true;
 }
 
+
+//---------------------------------------------------------------
 bool
-VisuGUI_Module::
-deactivateModule( SUIT_Study* theStudy )
+VisuGUI_Module
+::deactivateModule( SUIT_Study* theStudy )
 {
   VisuGUI::deactivateModule( theStudy );
 
-  myViewManager->getActiveView()->hide();
+  SetViewVisibility(myViewerMap,&SUIT_ViewWindow::hide);
 
   return true;
 }
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module
+::onCreateViewManager()
+{
+  new Viewer(getApp(),myViewerMap);
+}
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module
+::onLastViewClosed(SUIT_ViewManager* theViewManager)
+{
+  myViewerMap.erase(theViewManager);
+}
+
index 02df162243a4e9c69872df72a065c6596b9fc31e..9eb309b086889eb9216caeeafb077505df9d0f0a 100644 (file)
 #define VisuGUI_Module_HeaderFile
 
 #include "VisuGUI.h"
+#include "STD_Application.h"
 
+class SUIT_ViewManager;
 class SVTK_ViewManager;
 
+#include "MED_SharedPtr.hxx"
+
+namespace VISU
+{
+  class Viewer;
+  typedef MED::SharedPtr<Viewer> PViewer;
+  
+  typedef std::map<SUIT_ViewManager*,PViewer> TViewerMap;
+}
+
+
 class VisuGUI_Module: public VisuGUI
 {
-  Q_OBJECT
+  Q_OBJECT;
 
 public:
   VisuGUI_Module();
-  virtual ~VisuGUI_Module();
 
-  virtual void initialize( CAM_Application* );
+  virtual
+  ~VisuGUI_Module();
+
+  virtual
+  void
+  initialize( CAM_Application* );
 
 public slots:
-  virtual bool deactivateModule( SUIT_Study* );
-  virtual bool activateModule( SUIT_Study* );
+  virtual 
+  bool
+  deactivateModule( SUIT_Study* );
+
+  virtual 
+  bool
+  activateModule( SUIT_Study* );
+
+protected slots:
+  void
+  onCreateViewManager();
+
+  void
+  onLastViewClosed(SUIT_ViewManager*);
 
 protected:
-  SVTK_ViewManager* myViewManager;
+  VISU::TViewerMap myViewerMap;
 };
 
 #endif