Salome HOME
add MEDReader tests
[modules/paravis.git] / src / PVGUI / PVGUI_Module.cxx
index f1f9b836a1365d582f84f4c483eb046c385e17d5..d134e80a86ce0c10eb5a675017fa1eb50618169d 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
@@ -20,6 +20,8 @@
 //
 // File   : PVGUI_Module.cxx
 
+#define PARAVIS_MODULE_NAME "PARAVIS"
+
 #include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
 #ifdef HAVE_FINITE
 #undef HAVE_FINITE            // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
 #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 "PVViewer_ViewModel.h"
 #include "PVGUI_Tools.h"
 #include "PVGUI_ParaViewSettingsPane.h"
+#include "PVViewer_GUIElements.h"
+#include "PVViewer_EngineWrapper.h"
+#include "PVGUI_DataModel.h"
 
 // SALOME Includes
+#include <utilities.h>
 #include <SUIT_DataBrowser.h>
 #include <SUIT_Desktop.h>
 #include <SUIT_MessageBox.h>
@@ -54,7 +56,8 @@
 
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_NameDlg.h>
-#include <SalomeApp_Application.h>
+#include <LightApp_Application.h>
+#include <SalomeApp_Application.h>  // should ultimately be a LightApp only
 #include <SalomeApp_Study.h>
 #include <SALOME_ListIO.hxx>
 #include <SALOMEDS_Tool.hxx>
 
 #include <pqApplicationCore.h>
 #include <pqPVApplicationCore.h>
-#include <pqActiveView.h>
 #include <pqObjectBuilder.h>
 #include <pqOptions.h>
 #include <pqSettings.h>
 #include <pqScalarBarVisibilityReaction.h>
 #include <pqServerResource.h>
 #include <pqServerConnectReaction.h>
-
-// TO REMOVE:
-#include <PyInterp_Interp.h>
-
+#include <pqPluginManager.h>
+#include <pqVCRToolbar.h>
+#include <pqAnimationScene.h>
+#include <pqServerManagerModel.h>
+#include <pqAnimationTimeToolbar.h>
 
 //----------------------------------------------------------------------------
 PVGUI_Module* ParavisModule = 0;
+PVSERVER_ORB::PVSERVER_Gen_var PVGUI_Module::MyEngine;
 
 /*!
   \mainpage
+  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.
 
-  <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. 
-  
-
-  <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)
 */
 
 /*!
@@ -203,13 +157,13 @@ PVGUI_Module* ParavisModule = 0;
 _PTR(SComponent)
 ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
 {
-  _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("PARAVIS");
+  _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("PVSERVER");
   if (!aSComponent) {
     _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
     aStudyBuilder->NewCommand();
     int aLocked = theStudyDocument->GetProperties()->IsLocked();
     if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
-    aSComponent = aStudyBuilder->NewComponent("PARAVIS");
+    aSComponent = aStudyBuilder->NewComponent("PVSERVER");
     _PTR(GenericAttribute) anAttr =
       aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
     _PTR(AttributeName) aName (anAttr);
@@ -221,7 +175,7 @@ ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
     CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
     SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
       SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
-    SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "PARAVIS" );
+    SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "PVSERVER" );
     if (!Comp->_is_nil()) {
       aName->SetValue(Comp->componentusername());
     }
@@ -233,7 +187,7 @@ ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
     // Create Attribute parameters for future using
     anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeParameter");
 
-    aStudyBuilder->DefineComponentInstance(aSComponent, PVGUI_Module::GetEngine()->GetIOR());
+    aStudyBuilder->DefineComponentInstance(aSComponent, PVGUI_Module::GetCPPEngine()->GetIOR());
     if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
     aStudyBuilder->CommitCommand();
   }
@@ -241,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()
@@ -256,7 +212,7 @@ void paravisCleanUp()
   \brief Constructor. Sets the default name for the module.
 */
 PVGUI_Module::PVGUI_Module()
-  : SalomeApp_Module( "PARAVIS" ),
+    : SalomeApp_Module( PARAVIS_MODULE_NAME ),
     mySelectionControlsTb( -1 ),
     mySourcesMenuId( -1 ),
     myFiltersMenuId( -1 ),
@@ -267,7 +223,8 @@ PVGUI_Module::PVGUI_Module()
     myTraceWindow(0),
     myStateCounter(0),
     myInitTimer(0),
-    myPushTraceTimer(0)
+    myPushTraceTimer(0),
+    myGuiElements(0)
 {
 #ifdef HAS_PV_DOC
   Q_INIT_RESOURCE( PVGUI );
@@ -300,11 +257,46 @@ PVGUI_Module::~PVGUI_Module()
     delete myInitTimer;
 }
 
-PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Module::GetEngine()
+/*!
+ * \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_ViewManager::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)
+  if ( CORBA::is_nil( MyEngine ) ) {
+      Engines::EngineComponent_var comp =
+          SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "PVSERVER" );
+      MyEngine = PVSERVER_ORB::PVSERVER_Gen::_narrow( comp );
+ }
+  return MyEngine;
+}
+
+/*!
+  \brief Create data model.
+  \return module specific data model
+*/
+CAM_DataModel* PVGUI_Module::createDataModel()
+{
+  return new PVGUI_DataModel( this );
+}
+
+/*!
+ * \brief Get the ParaView application singleton.
+ */
 pqPVApplicationCore * PVGUI_Module::GetPVApplication()
 {
   return PVViewer_ViewManager::GetPVApplication();
@@ -316,11 +308,9 @@ pqPVApplicationCore * PVGUI_Module::GetPVApplication()
 */
 void PVGUI_Module::initialize( CAM_Application* app )
 {
-  SalomeApp_Module::initialize( app );
+  LightApp_Module::initialize( app );
 
-  // Create ParaViS actions
   createActions();
-  // Create ParaViS menus
   createMenus();
 
   // Uncomment to debug ParaView initialization
@@ -332,26 +322,28 @@ void PVGUI_Module::initialize( CAM_Application* app )
   }
   */
 
-  SalomeApp_Application* anApp = getApp();
+  LightApp_Application* anApp = getApp();
   SUIT_Desktop* aDesktop = anApp->desktop();
 
-  // Initialize ParaView client and associated behaviors
-  // and connect to externally launched pvserver
-  PVViewer_ViewManager::ParaviewInitApp(aDesktop);
-
   // Remember current state of desktop toolbars
   QList<QToolBar*> foreignToolbars = aDesktop->findChildren<QToolBar*>();
 
-  setupDockWidgets();
+  // Initialize ParaView client and associated behaviors
+  // and connect to externally launched pvserver
+  PVViewer_ViewManager::ParaviewInitApp(aDesktop, anApp->logWindow());
+  myGuiElements = PVViewer_GUIElements::GetInstance(aDesktop);
 
-  // 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);
+  // [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.
+  // Reference points are: ParaViewMainWindow.cxx and branded_paraview_initializer.cxx.in
+  setupDockWidgets();
 
   pvCreateActions();
-  pvCreateToolBars();
   pvCreateMenus();
+  pvCreateToolBars();
+
+  PVViewer_ViewManager::ParaviewInitBehaviors(true, aDesktop);
 
   QList<QDockWidget*> activeDocks = aDesktop->findChildren<QDockWidget*>();
   QList<QMenu*> activeMenus = aDesktop->findChildren<QMenu*>();
@@ -383,15 +375,30 @@ void PVGUI_Module::initialize( CAM_Application* app )
 //      }
 //    }
 
-  PVViewer_ViewManager::ParaviewLoadConfigurations();
+  // Connect after toolbar creation, etc ... as some activations of the toolbars is triggered
+  // by the ServerConnection event:
+  PVViewer_ViewManager::ParaviewLoadConfigurations(true);
+  PVViewer_ViewManager::ConnectToExternalPVServer(aDesktop);
   updateObjBrowser();
 
   // 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);
@@ -402,7 +409,7 @@ void PVGUI_Module::initialize( CAM_Application* app )
   updateMacros();
  
   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
-  bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
+  bool isStop = aResourceMgr->booleanValue( PARAVIS_MODULE_NAME, "stop_trace", false );
   if(!isStop)
     {
       // Start a timer to schedule asap:
@@ -436,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() {
@@ -454,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()
 {
@@ -482,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();
@@ -512,11 +534,11 @@ void PVGUI_Module::windows( QMap<int, int>& m ) const
 */
 void PVGUI_Module::showView( bool toShow )
 {
-  SalomeApp_Application* anApp = getApp();
+  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() );
+    viewMgr = new PVViewer_ViewManager( anApp->activeStudy(), anApp->desktop(), anApp->logWindow() );
     anApp->addViewManager( viewMgr );
     connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
              anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) );
@@ -567,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)
@@ -600,15 +625,23 @@ bool PVGUI_Module::activateModule( SUIT_Study* study )
 
   storeCommonWindowsState();
 
-  bool isDone = SalomeApp_Module::activateModule( study );
+  bool isDone = LightApp_Module::activateModule( study );
   if ( !isDone ) return false;
 
-  showView( true );  // this will also trigger the connection to the server
-                     // and the instanciation of the relevant PV behaviors
+  showView( true );
   if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
   if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
-  if ( myFiltersMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
-  if ( myFiltersMenuId != -1 ) menuMgr()->show(myToolbarsMenuId);
+  if ( myMacrosMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
+  if ( myToolbarsMenuId != -1 ) menuMgr()->show(myToolbarsMenuId);
+
+  // Update the various menus with the content pre-loaded in myGuiElements
+//  QMenu* srcMenu = menuMgr()->findMenu( mySourcesMenuId );
+//  myGuiElements->updateSourcesMenu(srcMenu);
+//  QMenu* filtMenu = menuMgr()->findMenu( myFiltersMenuId );
+//  myGuiElements->updateFiltersMenu(filtMenu);
+//  QMenu* macMenu = menuMgr()->findMenu( myMacrosMenuId );
+//  myGuiElements->updateMacrosMenu(macMenu);
+
   setMenuShown( true );
   setToolShown( true );
 
@@ -694,7 +727,7 @@ bool PVGUI_Module::deactivateModule( SUIT_Study* study )
 
   restoreCommonWindowsState();
   
-  return SalomeApp_Module::deactivateModule( study );
+  return LightApp_Module::deactivateModule( study );
 }
 
 
@@ -742,7 +775,7 @@ void PVGUI_Module::studyClosed(SUIT_Study* study)
 {
   clearParaviewState();
 
-  SalomeApp_Module::studyClosed(study);
+  LightApp_Module::studyClosed(study);
 }
 
 /*!
@@ -754,9 +787,9 @@ void PVGUI_Module::onModelOpened()
   if(!studyDS) {
     return;
   }
-  
-  _PTR(SComponent) paravisComp = 
-    studyDS->FindComponent(GetEngine()->ComponentDataType());
+
+  _PTR(SComponent) paravisComp =
+    studyDS->FindComponent(PARAVIS_MODULE_NAME);
   if(!paravisComp) {
     return;
   }
@@ -776,11 +809,11 @@ void PVGUI_Module::onModelOpened()
 }
 
 /*!
-  \brief Returns IOR of current engine
+\brief Returns IOR of current engine
 */
 QString PVGUI_Module::engineIOR() const
 {
-  CORBA::String_var anIOR = GetEngine()->GetIOR();
+  CORBA::String_var anIOR = GetCPPEngine()->GetIOR();
   return QString(anIOR.in());
 }
 
@@ -795,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())
  */
@@ -819,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
@@ -865,7 +906,6 @@ void PVGUI_Module::executeScript(const char *script)
   \brief Returns trace string
 */
 static const QString MYReplaceStr("paraview.simple");
-static const QString MYReplaceImportStr("except: from pvsimple import *");
 QString PVGUI_Module::getTraceString()
 {
   vtkSMTrace *tracer = vtkSMTrace::GetActiveTracer();
@@ -873,6 +913,12 @@ QString PVGUI_Module::getTraceString()
     return QString("");
 
   QString traceString(tracer->GetCurrentTrace());
+  std::stringstream nl; nl << std::endl; // surely there is some Qt trick to do that in a portable way??
+  QString end_line(nl.str().c_str());
+  // 'import pvsimple' is necessary to fix the first call to DisableFirstRenderCamera in the paraview trace
+  // 'ShowParaviewView()' ensure there is an opened viewing window (otherwise SEGFAULT!)
+  traceString = "import pvsimple" + end_line +
+                "pvsimple.ShowParaviewView()" + end_line + traceString;
 
   // Replace import "paraview.simple" by "pvsimple"
   if ((!traceString.isNull()) && traceString.length() != 0) {
@@ -881,11 +927,6 @@ QString PVGUI_Module::getTraceString()
       traceString = traceString.replace(aPos, MYReplaceStr.length(), "pvsimple");
       aPos = traceString.indexOf(MYReplaceStr, aPos);
     }
-    int aImportPos = traceString.indexOf(MYReplaceImportStr);
-    if(aImportPos != -1)
-      {
-      traceString = traceString.replace(aImportPos, MYReplaceImportStr.length(), "except:\n  import pvsimple\n  from pvsimple import *");
-      }
   }
 
   return traceString;
@@ -945,24 +986,27 @@ pqServer* PVGUI_Module::getActiveServer()
 
 
 /*!
-  \brief Creates PARAVIS preference pane 
+  \brief Creates PARAVIS preferences panel.
 */
 void PVGUI_Module::createPreferences()
 {
   // Paraview settings tab
   int aParaViewSettingsTab = addPreference( tr( "TIT_PVIEWSETTINGS" ) );
-  int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, "PARAVIS", "");
-  setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane()));
+
+  setPreferenceProperty(aParaViewSettingsTab, "stretch", false );
+  int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, PARAVIS_MODULE_NAME, "");
+
+  setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane(0, getApp())));
 
   // Paravis settings tab
   int aParaVisSettingsTab = addPreference( tr( "TIT_PVISSETTINGS" ) );
-  addPreference( tr( "PREF_STOP_TRACE" ), aParaVisSettingsTab, LightApp_Preferences::Bool, "PARAVIS", "stop_trace");
+  addPreference( tr( "PREF_STOP_TRACE" ), aParaVisSettingsTab, LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "stop_trace");
 
-  addPreference( tr( "PREF_NO_EXT_PVSERVER" ), aParaVisSettingsTab, LightApp_Preferences::Bool, "PARAVIS", "no_ext_pv_server");
+  addPreference( tr( "PREF_NO_EXT_PVSERVER" ), aParaVisSettingsTab, LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "no_ext_pv_server");
 
   int aSaveType = addPreference(tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab,
                                 LightApp_Preferences::Selector,
-                                "PARAVIS", "savestate_type");
+                                PARAVIS_MODULE_NAME, "savestate_type");
   QList<QVariant> aIndices;
   QStringList aStrings;
   aIndices<<0<<1<<2;
@@ -978,8 +1022,8 @@ void PVGUI_Module::createPreferences()
 */
 void PVGUI_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
 {
-  SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
-  
+  LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
+
   // Check if we are in Object Browser
   SUIT_DataBrowser* ob = getApp()->objectBrowser();
   bool isOBClient = (ob && theClient == ob->popupClientType());
@@ -993,22 +1037,22 @@ void PVGUI_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QS
   aSelectionMgr->selectedObjects(aListIO);
   if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
     QString entry = QString(aListIO.First()->getEntry());
-    
+
     // Get active study
-    SalomeApp_Study* activeStudy = 
+    SalomeApp_Study* activeStudy =
       dynamic_cast<SalomeApp_Study*>(getApp()->activeStudy());
     if(!activeStudy) {
       return;
     }
 
-    // Get SALOMEDS client study 
+    // Get SALOMEDS client study
     _PTR(Study) studyDS = activeStudy->studyDS();
     if(!studyDS) {
       return;
     }
 
-    QString paravisDataType(GetEngine()->ComponentDataType());
-    if(activeStudy && activeStudy->isComponent(entry) && 
+    QString paravisDataType(PARAVIS_MODULE_NAME);
+    if(activeStudy && activeStudy->isComponent(entry) &&
        activeStudy->componentDataType(entry) == paravisDataType) {
       // ParaViS module object
       theMenu->addSeparator();
@@ -1016,12 +1060,12 @@ void PVGUI_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QS
     }
     else {
       // Try to get state object
-      _PTR(SObject) stateSObj = 
+      _PTR(SObject) stateSObj =
           studyDS->FindObjectID(entry.toLatin1().constData());
       if (!stateSObj) {
           return;
       }
-      
+
       // Check local id
       _PTR(GenericAttribute) anAttr;
       if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
@@ -1029,7 +1073,7 @@ void PVGUI_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QS
       }
 
       _PTR(AttributeLocalID) anID(anAttr);
-      
+
       if (anID->Value() == PVSTATEID) {
         // Paraview state object
         theMenu->addSeparator();
@@ -1067,14 +1111,6 @@ void PVGUI_Module::onRestartTrace()
   startTrace();
 }
 
-/*!
-  \brief Show ParaView view.
-*/
-void PVGUI_Module::onNewParaViewWindow()
-{
-  showView(true);
-}
-
 /*!
   \brief Save state under the module root object.
 */
@@ -1087,9 +1123,9 @@ void PVGUI_Module::onSaveMultiState()
   if(!studyDS) {
     return;
   }
-  
+
   _PTR(SComponent) paravisComp = 
-    studyDS->FindComponent(GetEngine()->ComponentDataType());
+      studyDS->FindComponent(PARAVIS_MODULE_NAME);
   if(!paravisComp) {
     return;
   }
@@ -1253,9 +1289,12 @@ 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...");
+  //MESSAGE("onPushTraceTimer(): Pushing trace to engine...");
   GetEngine()->PutPythonTraceStringToEngine(getTraceString().toStdString().c_str());
 }