Salome HOME
INTPAL 52641: PARAVIS deactivation hides PV viewer.
[modules/paravis.git] / src / PVGUI / PVGUI_Module.cxx
index e97566a1de124236f4e9b7138cac22156ffb2726..39c8b2435203ecb39495b2a29dbb1fb952a2f9d7 100644 (file)
@@ -1,6 +1,6 @@
 // PARAVIS : ParaView wrapper SALOME module
 //
-// Copyright (C) 2010-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2010-2015  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include <vtkPython.h> // Python first
 #include "PVGUI_Module.h"
 
-//#ifdef PARAVIS_WITH_FULL_CORBA
-//# include "PARAVIS_Gen_i.hh"
-//#endif
-
 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
 
 #include <pqApplicationCore.h>
 #include <pqPVApplicationCore.h>
-#include <pqActiveView.h>
 #include <pqObjectBuilder.h>
 #include <pqOptions.h>
 #include <pqSettings.h>
 #include <pqServerResource.h>
 #include <pqServerConnectReaction.h>
 #include <pqPluginManager.h>
-
-//#include <PVViewer_EngineWrapper.h>
-
+#include <pqVCRToolbar.h>
+#include <pqAnimationScene.h>
+#include <pqServerManagerModel.h>
+#include <pqAnimationTimeToolbar.h>
 
 //----------------------------------------------------------------------------
 PVGUI_Module* ParavisModule = 0;
@@ -143,64 +139,13 @@ PVSERVER_ORB::PVSERVER_Gen_var PVGUI_Module::MyEngine;
 
 /*!
   \mainpage
-  TODO TODO update this:
-
-  <h2>Building and installing PARAVIS</h2>
-  As any other SALOME module, PARAVIS requires PARAVIS_ROOT_DIR environment variable to be set to PARAVIS
-  installation directory.
-  Other variables needed for correct detection of ParaView location:
-  \li PVHOME - points at the ParaView installation directory tree
-  \li PVVERSION - number of ParaView version
-
-  It also requires common SALOME environment including GUI_ROOT_DIR and other prerequsites.
-
-
-  PARAVIS module can be launched using the following commands:
-  \li Full SALOME configuration
-  \code
-  runSalome --modules="PARAVIS"
-  \endcode
-
-  <h2>ParaView GUI integration</h2>
-  <h3>ParaView GUI integration overview</h3>
-
-  The main idea is to reuse ParaView GUI internal logic as much as possible, providing a layer 
-  between it and SALOME GUI that hides the following SALOME GUI implementation details from ParaView:
-
-  \li SALOME GUI executable and Qt event loop
-  \li SALOME GUI desktop
-  \li Dock windows areas
-  \li SALOME menu and toolbar managers
-
-  Major part of the integration is implemented in PVGUI_Module class.
-
-  <h3>ParaView client initalization</h3>
-
-  ParaView client initalization is performed when an instance of PVGUI_Module class has been created 
-  and \link PVGUI_Module::initialize() PVGUI_Module::initialize()\endlink method is called by SALOME GUI.
-  The actual client start-up is done in \link PVGUI_Module::pvInit() PVGUI_Module::pvInit()\endlink method. 
-  
+  This is the doxygen documentation of the ParaVis module.
+  If you are looking for general information about the structure of the module, you should
+  take a look at the <a href="../index.html">Sphinx documentation</a> first.
 
-  <h3>Multi-view manager</h3>
-
-  SALOME GUI requires that each kind of view be implemnted with help of (at least) three classes. For ParaView multi-view manager 
-  these are:
-
-  \li PVGUI_ViewManager - view manager class
-  \li PVGUI_Viewer      - view model class
-  \li PVGUI_ViewWindow  - view window class that acts as a parent for %pqViewManager
-
-  Single instances of PVGUI_ViewManager and PVGUI_ViewWindow classes are created by \link PVGUI_Module::showView() 
-  PVGUI_Module::showView()\endlink method upon the first PARAVIS module activation. The same method hides the multi-view manager 
-  when the module is deactivated (the user switches to another module or a study is closed). 
-  A special trick is used to make PVGUI_ViewWindow the parent of %pqViewManager widget. It is created initally by %pqMainWindowCore
-  with the desktop as a parent, so when it is shown PVGUI_ViewWindow instance is passed to its setParent() method. In  
-  \link PVGUI_ViewWindow::~PVGUI_ViewWindow() PVGUI_ViewWindow::~PVGUI_ViewWindow()\endlink the parent is nullified to avoid deletion
-  of %pqViewManager widget that would break %pqMainWindowCore class.
-
-  <h3>ParaView plugins</h3>
-  ParaView server and client plugins are managed by %pqMainWindowCore slots that has full access to PARAVIS menus and toolbars. 
-  As a result they appears automatically in PARAVIS menus and toolbars if loaded successfully.
+  The integration of ParaView into SALOME is split in two parts:
+  \li the PVViewer in the GUI module (folder *src/PVViewer*)
+  \li the ParaVis module itself (the pages you are currently browsing)
 */
 
 /*!
@@ -250,7 +195,9 @@ ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
 }
 
 /*!
-  Clean up function; used to stop ParaView progress events when
+  \brief Clean up function
+
+  Used to stop ParaView progress events when
   exception is caught by global exception handler.
 */
 void paravisCleanUp()
@@ -310,11 +257,23 @@ PVGUI_Module::~PVGUI_Module()
     delete myInitTimer;
 }
 
+/*!
+ * \brief Retrieve the PVSERVER CORBA engine.
+ * This uses the Python wrapper provided
+ * by the PVViewer code in GUI (class PVViewer_EngineWrapper).
+ * \sa GetCPPEngine()
+ */
 PVViewer_EngineWrapper * PVGUI_Module::GetEngine()
 {
   return PVViewer_EngineWrapper::GetInstance();
 }
 
+/*!
+ * \brief Retrieve the PVSERVER CORBA engine.
+ * Uses directly the standard Salome C++ mechanisms
+ * (LifeCycleCorba).
+ * \sa GetEngine()
+ */
 PVSERVER_ORB::PVSERVER_Gen_var PVGUI_Module::GetCPPEngine()
 {
   // initialize PARAVIS module engine (load, if necessary)
@@ -335,6 +294,9 @@ CAM_DataModel* PVGUI_Module::createDataModel()
   return new PVGUI_DataModel( this );
 }
 
+/*!
+ * \brief Get the ParaView application singleton.
+ */
 pqPVApplicationCore * PVGUI_Module::GetPVApplication()
 {
   return PVViewer_ViewManager::GetPVApplication();
@@ -363,14 +325,14 @@ void PVGUI_Module::initialize( CAM_Application* app )
   LightApp_Application* anApp = getApp();
   SUIT_Desktop* aDesktop = anApp->desktop();
 
+  // Remember current state of desktop toolbars
+  QList<QToolBar*> foreignToolbars = aDesktop->findChildren<QToolBar*>();
+
   // Initialize ParaView client and associated behaviors
   // and connect to externally launched pvserver
   PVViewer_ViewManager::ParaviewInitApp(aDesktop, anApp->logWindow());
   myGuiElements = PVViewer_GUIElements::GetInstance(aDesktop);
 
-  // Remember current state of desktop toolbars
-  QList<QToolBar*> foreignToolbars = aDesktop->findChildren<QToolBar*>();
-
   // [ABN]: careful with the order of the GUI element creation, the loading of the configuration
   // and the connection to the server. This order is very sensitive if one wants to make
   // sure all menus, etc ... are correctly populated.
@@ -422,9 +384,21 @@ void PVGUI_Module::initialize( CAM_Application* app )
   // Find created toolbars
   QCoreApplication::processEvents();
 
+  // process PVViewer toolbars (might be added by PVViewer created BEFORE activating ParaVis)
+  QList<QToolBar*> pvToolbars = myGuiElements->getToolbars();
+  foreach(QToolBar* aBar, pvToolbars) {
+    if (!myToolbars.contains(aBar)) {
+      myToolbars[aBar] = true;
+      myToolbarBreaks[aBar] = false;
+      aBar->setVisible(false);
+      aBar->toggleViewAction()->setVisible(false);
+    }
+  }
+
+  // process other toolbars (possibly added by Paraview)
   QList<QToolBar*> allToolbars = aDesktop->findChildren<QToolBar*>();
   foreach(QToolBar* aBar, allToolbars) {
-    if (!foreignToolbars.contains(aBar)) {
+    if (!foreignToolbars.contains(aBar) && !myToolbars.contains(aBar)) {
       myToolbars[aBar] = true;
       myToolbarBreaks[aBar] = false;
       aBar->setVisible(false);
@@ -469,14 +443,26 @@ void PVGUI_Module::initialize( CAM_Application* app )
   }
 }
 
+/*!
+ * \brief Slot called when the progress bar starts.
+ */
 void PVGUI_Module::onStartProgress()
 {
-  QApplication::setOverrideCursor(Qt::WaitCursor);
+  // VSR 19/03/2015, issue 0023025
+  // next line is commented: it is bad idea to show wait cursor on ANY vtk event
+  // moreover, it does not work when running pvserver with --multi-client mode
+  //QApplication::setOverrideCursor(Qt::WaitCursor);
 }
 
+/*!
+ * \brief Slot called when the progress bar is done.
+ */
 void PVGUI_Module::onEndProgress()
 {
-  QApplication::restoreOverrideCursor();
+  // VSR 19/03/2015, issue 0023025
+  // next line is commented: it is bad idea to show wait cursor on ANY vtk event
+  // moreover, it does not work when running pvserver with --multi-client mode
+  //QApplication::restoreOverrideCursor();
 }
 
 void PVGUI_Module::onDataRepresentationUpdated() {
@@ -487,7 +473,7 @@ void PVGUI_Module::onDataRepresentationUpdated() {
 }
 
 /*!
-  \brief Initialisation timer event - trace start up
+  \brief Initialisation timer event - Starts up the Python trace
 */
 void PVGUI_Module::onInitTimer()
 {
@@ -515,6 +501,9 @@ QStringList PVGUI_Module::getEmbeddedMacrosList()
   return aFullPathSourceFiles;
 }
 
+/*!
+  \brief Update the list of embedded macros
+*/
 void PVGUI_Module::updateMacros()
 {
   pqPythonManager* aPythonManager = pqPVApplicationCore::instance()->pythonManager();
@@ -600,6 +589,9 @@ void PVGUI_Module::endWaitCursor()
   QApplication::restoreOverrideCursor();
 }
 
+/*!
+  \brief Handler method for the output of messages.
+*/
 static void ParavisMessageOutput(QtMsgType type, const char *msg)
 {
   switch(type)
@@ -716,7 +708,6 @@ bool PVGUI_Module::deactivateModule( SUIT_Study* study )
   /*if (pqImplementation::helpWindow) {
     pqImplementation::helpWindow->hide();
     }*/
-  showView( false );
   // hide menus
   menuMgr()->hide(myRecentMenuId);
   menuMgr()->hide(mySourcesMenuId);
@@ -781,6 +772,7 @@ void PVGUI_Module::deleteTemporaryFiles()
 */
 void PVGUI_Module::studyClosed(SUIT_Study* study)
 {
+  showView(false);
   clearParaviewState();
 
   LightApp_Module::studyClosed(study);
@@ -836,6 +828,8 @@ void PVGUI_Module::openFile(const char* theName)
 }
 
 /**!
+ * \brief Starts Python trace.
+ *
  * Start trace invoking the newly introduced C++ API (PV 4.2)
  * (inspired from pqTraceReaction::start())
  */
@@ -860,11 +854,17 @@ void PVGUI_Module::startTrace()
     }
 }
 
+/**!
+ * \brief Stops Python trace.
+ */
 void PVGUI_Module::stopTrace()
 {
   vtkSMTrace::StopTrace();
 }
 
+/**!
+ * \brief Execute a Python script.
+ */
 void PVGUI_Module::executeScript(const char *script)
 {
 #ifndef WNT
@@ -986,7 +986,7 @@ pqServer* PVGUI_Module::getActiveServer()
 
 
 /*!
-  \brief Creates PARAVIS preference pane 
+  \brief Creates PARAVIS preferences panel.
 */
 void PVGUI_Module::createPreferences()
 {
@@ -1289,6 +1289,9 @@ void PVGUI_Module::onDelete()
   }
 }
 
+/*!
+ * \brief Slot called everytime the Python trace is pushed onto the CORBA engine.
+ */
 void PVGUI_Module::onPushTraceTimer()
 {
   //MESSAGE("onPushTraceTimer(): Pushing trace to engine...");