]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
First demonstration of the use of a ParaView window outside PARAVIS.
authorabn <adrien.bruneton@cea.fr>
Wed, 17 Sep 2014 15:12:26 +0000 (17:12 +0200)
committerabn <adrien.bruneton@cea.fr>
Wed, 17 Sep 2014 15:12:26 +0000 (17:12 +0200)
SalomePARAVISConfig.cmake.in
src/PVGUI/PVGUI_Module.cxx
src/PVGUI/view/PVViewer_Behaviors.cxx
src/PVGUI/view/PVViewer_Behaviors.h
src/PVGUI/view/PVViewer_ViewManager.cxx
src/PVGUI/view/PVViewer_ViewManager.h
src/PVGUI/view/PVViewer_ViewModel.h
src/PVGUI/view/PVViewer_ViewWindow.cxx
src/PVGUI/view/PVViewer_ViewWindow.h

index 823e29a382d79025759a77877c113f4f0d53bdf8..07fe64e2325940bb6c559af84104464729ffe56f 100644 (file)
@@ -30,7 +30,7 @@
 # Load the dependencies for the libraries of @PROJECT_NAME@ 
 # (contains definitions for IMPORTED targets). This is only 
 # imported if we are not built as a subproject (in this case targets are already there)
-IF(NOT TARGET Event AND NOT @PROJECT_NAME@_BINARY_DIR)
+IF(NOT TARGET PARAVIS AND NOT @PROJECT_NAME@_BINARY_DIR)
   INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE_LOCAL@/@PROJECT_NAME@Targets.cmake")
 ENDIF()   
 
@@ -132,3 +132,5 @@ ENDIF()
 SET(PARAVIS_SalomeIDLPARAVIS SalomeIDLPARAVIS)
 SET(PARAVIS_PARAVIS PARAVIS)
 SET(PARAVIS_PARAVISEngine PARAVISEngine)
+SET(PARAVIS_PVViewer PVViewer)
+
index 97679fdf4a6d9fc04cd5cc5860c5b2d9f0ad8438..d4f7cc9a1766d93b2c715e43b8daaa6c35b29535 100644 (file)
@@ -340,7 +340,8 @@ void PVGUI_Module::initialize( CAM_Application* app )
 
   setupDockWidgets();
 
-  // Behaviors and connection must be instanciated *after* widgets are in place:
+  // Behaviors and connection must be instanciated *after* widgets are in place
+  // In PARAVIS module we do not wait for PVViewer_ViewWindow to be instanciated to have this:
   PVViewer_ViewManager::ParaviewInitBehaviors(true, aDesktop);
   PVViewer_ViewManager::ConnectToExternalPVServer(aDesktop);
 
@@ -378,16 +379,7 @@ void PVGUI_Module::initialize( CAM_Application* app )
 //      }
 //    }
 
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
-  if (!aPath.isNull()) {
-      pqPVApplicationCore * pvApp = GetPVApplication();
-      pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
-      pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
-      pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
-      pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
-  }
-
+  PVViewer_ViewManager::ParaviewLoadConfigurations();
   updateObjBrowser();
 
   // Find created toolbars
@@ -534,6 +526,7 @@ void PVGUI_Module::showView( bool toShow )
   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 );
@@ -611,7 +604,8 @@ bool PVGUI_Module::activateModule( SUIT_Study* study )
   bool isDone = SalomeApp_Module::activateModule( study );
   if ( !isDone ) return false;
 
-  showView( true );
+  showView( true );  // this will also trigger the connection to the server
+                     // and the instanciation of the relevant PV behaviors
   if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
   if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
   if ( myFiltersMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
index 417cd65c09a2f0b579e23aa4b37d8522980bf8d8..5ff809ffb57611339ce11d53c3c36328711c1024 100644 (file)
@@ -50,7 +50,9 @@
 #include <pqFixPathsInStateFilesBehavior.h>
 #include <pqApplyBehavior.h>
 
-bool PVViewer_Behaviors::hasMinimalInstanciated = false;
+#include <pqPropertiesPanel.h>
+
+int PVViewer_Behaviors::BehaviorLoadingLevel = 0;
 
 PVViewer_Behaviors::PVViewer_Behaviors(SUIT_Desktop * parent)
   : QObject(static_cast<QObject *>(parent))
@@ -63,27 +65,33 @@ PVViewer_Behaviors::PVViewer_Behaviors(SUIT_Desktop * parent)
  */
 void PVViewer_Behaviors::instanciateMinimalBehaviors(SUIT_Desktop * desk)
 {
-  hasMinimalInstanciated = true;
-
-  // Register ParaView interfaces.
-  pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
-
-  // Register standard types of property widgets.
-  pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
-  // Register standard types of view-frame actions.
-  pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm));
-
-  // Load plugins distributed with application.
-  pqApplicationCore::instance()->loadDistributedPlugins();
-
-  new pqDefaultViewBehavior(this);  // shows a 3D view as soon as a server connection is made
-  new pqAlwaysConnectedBehavior(this);  // client always connected to a server
-  new pqAutoLoadPluginXMLBehavior(this);  // auto load plugins
-  new pqVerifyRequiredPluginBehavior(this);
-  new pqPluginSettingsBehavior(this);
-  new pqFixPathsInStateFilesBehavior(this);
-  new pqCrashRecoveryBehavior(this);
-  new pqCommandLineOptionsBehavior(this);
+  if (BehaviorLoadingLevel < 1)
+    {
+      // Register ParaView interfaces.
+      pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
+
+      // Register standard types of property widgets.
+      pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
+      // Register standard types of view-frame actions.
+      pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm));
+
+      // Load plugins distributed with application.
+      pqApplicationCore::instance()->loadDistributedPlugins();
+
+      new pqDefaultViewBehavior(this);  // shows a 3D view as soon as a server connection is made
+      new pqAlwaysConnectedBehavior(this);  // client always connected to a server
+      new pqAutoLoadPluginXMLBehavior(this);  // auto load plugins
+      new pqVerifyRequiredPluginBehavior(this);
+      new pqPluginSettingsBehavior(this);
+      new pqFixPathsInStateFilesBehavior(this);
+      new pqCrashRecoveryBehavior(this);
+      new pqCommandLineOptionsBehavior(this);
+
+      // Create a hidden pqPropertiesPanel()
+      hiddenProp = new pqPropertiesPanel(desk);
+
+      BehaviorLoadingLevel = 1;
+    }
 }
 
 /**! Instanciate usual ParaView behaviors.
@@ -97,24 +105,34 @@ void PVViewer_Behaviors::instanciateAllBehaviors(SUIT_Desktop * desk)
   // exclude using of pqQtMessageHandlerBehaviour
 
   // Define application behaviors.
-  if (!hasMinimalInstanciated)
+  if (BehaviorLoadingLevel < 1)
     instanciateMinimalBehaviors(desk);
-  //new pqQtMessageHandlerBehavior(this);   // THIS ONE TO EXCLUDE !! see comment above
-  new pqDataTimeStepBehavior(this);
-  new pqSpreadSheetVisibilityBehavior(this);
-  new pqPipelineContextMenuBehavior(this);
-  new pqUndoRedoBehavior(this);
-  new pqPluginDockWidgetsBehavior(desk);
-  new pqPluginActionGroupBehavior(desk);
-  new pqPersistentMainWindowStateBehavior(desk);
-  new pqObjectPickingBehavior(desk);
-  new pqCollaborationBehavior(this);
-  new pqViewStreamingBehavior(this);
-
-  pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
-  foreach (pqPropertiesPanel* ppanel, desk->findChildren<pqPropertiesPanel*>())
+
+  if (BehaviorLoadingLevel < 2)
     {
-    applyBehavior->registerPanel(ppanel);
+      //new pqQtMessageHandlerBehavior(this);   // THIS ONE TO EXCLUDE !! see comment above
+      new pqDataTimeStepBehavior(this);
+      new pqSpreadSheetVisibilityBehavior(this);
+      new pqPipelineContextMenuBehavior(this);
+      new pqUndoRedoBehavior(this);
+      new pqPluginDockWidgetsBehavior(desk);
+      new pqPluginActionGroupBehavior(desk);
+      new pqPersistentMainWindowStateBehavior(desk);
+      new pqObjectPickingBehavior(desk);
+      new pqCollaborationBehavior(this);
+      new pqViewStreamingBehavior(this);
+
+      pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
+      foreach (pqPropertiesPanel* ppanel, desk->findChildren<pqPropertiesPanel*>())
+      {
+        applyBehavior->registerPanel(ppanel);
+      }
+      BehaviorLoadingLevel = 2;
     }
+}
 
+void PVViewer_Behaviors::onEmulateApply()
+{
+  if (hiddenProp)
+    hiddenProp->apply();
 }
index 6e99c26c1fbc7d0d89774b01269ba92b933545dc..f9858cb39aab811ad86c03fb970bcea33a86718f 100644 (file)
@@ -26,6 +26,7 @@
 
 class SalomeApp_Module;
 class SUIT_Desktop;
+class pqPropertiesPanel;
 
 /**!
  * PARAVIS behaviors - mimic what is done in
@@ -45,8 +46,13 @@ public:
 
   virtual ~PVViewer_Behaviors() {}
 
+public slots:
+  void onEmulateApply();
+
 private:
-  static bool hasMinimalInstanciated;
+  static int BehaviorLoadingLevel;
+
+  pqPropertiesPanel * hiddenProp;
 };
 
 #endif /* PVGUIBEHAVIORS_H_ */
index b187ca44741d88f7ef59748e19b4214abfbe4e93..ae6442106b28b6fb4bcf32ad20f8de0608198d2e 100644 (file)
 #include <SUIT_MessageBox.h>
 #include <SUIT_Desktop.h>
 #include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
 #include <PyInterp_Interp.h>
 #include <PyConsole_Interp.h>
 #include <PyConsole_Console.h>
 
 #include <QApplication>
 #include <QStringList>
+#include <QDir>
 #include <string>
 
 #include <pqOptions.h>
@@ -48,7 +50,8 @@
 //---------- Static init -----------------
 pqPVApplicationCore* PVViewer_ViewManager::MyCoreApp = 0;
 PARAVIS_ORB::PARAVIS_Gen_var PVViewer_ViewManager::MyEngine;
-
+bool PVViewer_ViewManager::ConfigLoaded = false;
+PVViewer_Behaviors * PVViewer_ViewManager::ParaviewBehaviors = NULL;
 
 /*!
   Constructor
@@ -58,6 +61,10 @@ PVViewer_ViewManager::PVViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* des
 {
   MESSAGE("PARAVIS - view manager created ...")
   setTitle( tr( "PARAVIEW_VIEW_TITLE" ) );
+  // Initialize minimal paraview stuff (if not already done)
+  ParaviewInitApp(desk);
+
+  connect(this, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*)));
 }
 
 pqPVApplicationCore * PVViewer_ViewManager::GetPVApplication()
@@ -124,11 +131,29 @@ bool PVViewer_ViewManager::ParaviewInitApp(SUIT_Desktop * aDesktop)
 
 void PVViewer_ViewManager::ParaviewInitBehaviors(bool fullSetup, SUIT_Desktop* aDesktop)
 {
-  PVViewer_Behaviors * behav = new PVViewer_Behaviors(aDesktop);
+  if (!ParaviewBehaviors)
+      ParaviewBehaviors = new PVViewer_Behaviors(aDesktop);
+
   if(fullSetup)
-    behav->instanciateAllBehaviors(aDesktop);
+    ParaviewBehaviors->instanciateAllBehaviors(aDesktop);
   else
-    behav->instanciateMinimalBehaviors(aDesktop);
+    ParaviewBehaviors->instanciateMinimalBehaviors(aDesktop);
+}
+
+void PVViewer_ViewManager::ParaviewLoadConfigurations()
+{
+  if (!ConfigLoaded)
+    {
+      SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+      QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
+      if (!aPath.isNull()) {
+          MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
+          MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
+          MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
+          MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
+      }
+      ConfigLoaded = true;
+    }
 }
 
 void PVViewer_ViewManager::ParaviewCleanup()
@@ -144,9 +169,11 @@ void PVViewer_ViewManager::ParaviewCleanup()
   pqApplicationCore::instance()->settings()->sync();
 
   pqPVApplicationCore * app = GetPVApplication();
+  // [ABN] : TODO review this, this triggers an ugly crash (Python thread state mix-up)
+  // at SALOME's exit.
   // Schedule destruction of PVApplication singleton:
-  if (app)
-    app->deleteLater();
+//  if (app)
+//    app->deleteLater();
 }
 
 PARAVIS_ORB::PARAVIS_Gen_var PVViewer_ViewManager::GetEngine()
@@ -216,3 +243,10 @@ bool PVViewer_ViewManager::ConnectToExternalPVServer(SUIT_Desktop* aDesktop)
     }
   return true;
 }
+
+void PVViewer_ViewManager::onPVViewCreated(SUIT_ViewWindow* w)
+{
+  PVViewer_ViewWindow * w2 = dynamic_cast<PVViewer_ViewWindow *>(w);
+  Q_ASSERT(w2 != NULL);
+  connect(w2, SIGNAL(applyRequest()), ParaviewBehaviors, SLOT(onEmulateApply()));
+}
index fe3896032e2452cb41216bdbbf1e2adf3e122919..a995156575267ee99dd58be3faae1b43db404cbd 100644 (file)
 
 class SUIT_Desktop;
 class SUIT_Study;
+class SUIT_ViewWindow;
 class pqTabbedMultiViewWidget;
 class pqPVApplicationCore;
+class PVViewer_Behaviors;
+class pqPropertiesPanel;
 
 class PVViewer_ViewManager : public SUIT_ViewManager
 {
@@ -42,17 +45,21 @@ public:
   //! Initialize ParaView if not yet done (once per session)
   static bool   ParaviewInitApp(SUIT_Desktop* aDesktop);
   static void   ParaviewInitBehaviors(bool fullSetup=false, SUIT_Desktop* aDesktop=0);
-
+  static void   ParaviewLoadConfigurations();
   static void   ParaviewCleanup();
 
   //! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not
   //! already up.
   static bool   ConnectToExternalPVServer(SUIT_Desktop* aDesktop);
 
+public slots:
+  void onPVViewCreated(SUIT_ViewWindow*);
+
 private:
   static pqPVApplicationCore* MyCoreApp;
   static PARAVIS_ORB::PARAVIS_Gen_var MyEngine;
-
+  static bool ConfigLoaded;
+  static PVViewer_Behaviors * ParaviewBehaviors;
 };
 
 #endif
index 6463c7acdbc0ebed6693609252eb37d5e03ac9c9..e70f663cb820d30c35649aac4356dda31cd4c90c 100644 (file)
@@ -36,7 +36,6 @@ public:
   virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
   virtual QString getType() const { return Type(); }
   static QString Type() { return "ParaView"; }
-
 };
 
 #endif // !defined(_PVViewer_VIEWMODEL_H)
index 84e37f0ef7300d5b153ef5e1f43743edec7ab5ff..415717a5c29c402978de50ef77a5045bdb156922 100644 (file)
@@ -21,6 +21,7 @@
 //
 
 #include "PVViewer_ViewWindow.h"
+#include "PVViewer_ViewManager.h"
 
 #include <SUIT_ViewManager.h>
 #include <SUIT_ResourceMgr.h>
@@ -38,7 +39,7 @@
 /*!
   \brief Constructor.
   \param theDesktop parent desktop window
-  \param theModel plt2d view model
+  \param theModel view model
 */
 PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Viewer* theModel )
   : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 )
@@ -50,6 +51,12 @@ PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Vie
     // This is mandatory, see setParent() method in Qt 4 documentation
     myPVMgr->show();
     setCentralWidget( myPVMgr );
+
+    // Finish ParaView set up: behaviors, connection and configurations.
+    // None of this is invoked in PARAVIS module case as it done earlier than View creation:
+    PVViewer_ViewManager::ParaviewInitBehaviors(true, theDesktop);
+    PVViewer_ViewManager::ConnectToExternalPVServer(theDesktop);
+    PVViewer_ViewManager::ParaviewLoadConfigurations();
   } else
     qDebug("No multiViewManager defined");
 }
@@ -96,3 +103,8 @@ pqTabbedMultiViewWidget* PVViewer_ViewWindow::getMultiViewManager() const
 {
   return myPVMgr;
 }
+
+void PVViewer_ViewWindow::onEmulateApply()
+{
+  emit this->applyRequest();
+}
index fb5dd10654d03ccda59da04e48b419a864a1122e..e3ff387ce7092879dffa4eff375dde6b6cd1e198 100644 (file)
@@ -43,6 +43,12 @@ public:
   
   pqTabbedMultiViewWidget*    getMultiViewManager() const;
 
+signals:
+  void applyRequest();
+
+public slots:
+  void onEmulateApply();
+
 private:
   PVViewer_Viewer*     myModel;
   pqTabbedMultiViewWidget*    myPVMgr;