]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Explicitely create a PVViewer
authorCédric Aguerre <cedric.aguerre@edf.fr>
Tue, 7 Apr 2015 12:47:08 +0000 (14:47 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 8 Apr 2015 15:14:33 +0000 (17:14 +0200)
src/MEDOP/gui/MEDOPModule.cxx
src/MEDOP/gui/MEDOPModule.hxx

index de8acdabd264b8d964afe5730b500a36624c85e6..de984bb5c15b1b9853dd37795e78a05037449e80 100644 (file)
 
 #include "MEDOPFactoryClient.hxx"
 
+#include <LightApp_Application.h>
+#include "PVViewer_ViewManager.h"
+#include "PVViewer_ViewWindow.h"
+#include "PVViewer_ViewModel.h"
+#include "SUIT_ViewManager.h"
+
 MEDOPModule::MEDOPModule() :
   StandardApp_Module()
 {
@@ -82,9 +88,35 @@ void MEDOPModule::createModuleWidgets() {
     _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent *)));
 }
 
+/*!
+  \brief Shows (toShow = true) or hides ParaView view window
+*/
+void MEDOPModule::showView( bool toShow )
+{
+  LightApp_Application* anApp = getApp();
+  PVViewer_ViewManager* viewMgr =
+    dynamic_cast<PVViewer_ViewManager*>( anApp->getViewManager( PVViewer_Viewer::Type(), false ) );
+  if ( !viewMgr ) {
+    viewMgr = new PVViewer_ViewManager( anApp->activeStudy(), anApp->desktop(), anApp->logWindow() );
+    anApp->addViewManager( viewMgr );
+    connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+             anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) );
+  }
+
+  PVViewer_ViewWindow* pvWnd = dynamic_cast<PVViewer_ViewWindow*>( viewMgr->getActiveView() );
+  if ( !pvWnd ) {
+    pvWnd = dynamic_cast<PVViewer_ViewWindow*>( viewMgr->createViewWindow() );
+    // this also connects to the pvserver and instantiates relevant PV behaviors
+  }
+
+  pvWnd->setShown( toShow );
+  if ( toShow ) pvWnd->setFocus();
+}
+
 bool MEDOPModule::activateModule( SUIT_Study* theStudy )
 {
   bool bOk = StandardApp_Module::activateModule( theStudy );
+  showView(true);
   _workspaceController->showDockWidgets(true);
   this->setDockLayout(StandardApp_Module::DOCKLAYOUT_LEFT_VLARGE);
   return bOk;
@@ -93,6 +125,7 @@ bool MEDOPModule::deactivateModule( SUIT_Study* theStudy )
 {
   _workspaceController->showDockWidgets(false);
   this->unsetDockLayout();
+  showView(false);
   return StandardApp_Module::deactivateModule( theStudy );
 }
 
index 6d9c7ad3eb0b9e7ef4654912ae8b3cfa76eb61c6..f38f4cb70ce1af7a6521f713924156de7edfcd09 100644 (file)
@@ -55,6 +55,10 @@ protected:
   virtual bool activateModule( SUIT_Study* theStudy );
   virtual bool deactivateModule( SUIT_Study* theStudy );
 
+ private:
+  //! Shows or hides ParaView view window
+  void showView(bool);
+
 private:
   DatasourceController * _datasourceController;
   WorkspaceController *  _workspaceController;