Salome HOME
Multi server mode for PARAVIS. This allow to integrate modules using local visualizat...
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 24 Aug 2017 09:20:14 +0000 (11:20 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 28 Aug 2017 12:13:55 +0000 (14:13 +0200)
src/PVViewer/CMakeLists.txt
src/PVViewer/PVViewer_Core.cxx
src/PVViewer/PVViewer_InitSingleton.cxx [new file with mode: 0644]
src/PVViewer/PVViewer_InitSingleton.h [new file with mode: 0644]
src/PVViewer/PVViewer_ViewManager.cxx
src/PVViewer/PVViewer_ViewWindow.cxx

index 623550d735a9179f8485dc4f3aa548cf81349d26..05910b4817670a6f541dfbf6e15f66b6eaa35626 100644 (file)
@@ -61,6 +61,7 @@ SET(_moc_HEADERS
   PVViewer_ViewWindow.h
   PVViewer_Behaviors.h
   PVViewer_GUIElements.h
+  PVViewer_InitSingleton.h
 )
 
 # header files / no moc processing
@@ -96,6 +97,7 @@ SET(_other_SOURCES
   PVViewer_Behaviors.cxx
   PVViewer_GUIElements.cxx
   PVViewer_Core.cxx
+  PVViewer_InitSingleton.cxx
   )
   
 # sources / to compile
index 8f9abaafc193d6f6ffddc06ee47182c3900d3c3e..993d6b2491b6bde69bd47655a74e2e79cfe0e5c9 100644 (file)
@@ -65,7 +65,7 @@ bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop, LogWindow * logWindo
       char** argv = 0;
       QString aOptions = getenv("PARAVIEW_OPTIONS");
       QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
-      argv = new char*[aOptList.size() + 1];
+      argv = new char*[aOptList.size() + 2];
       QStringList args = QApplication::arguments();
       argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis");
       argc++;
@@ -74,6 +74,7 @@ bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop, LogWindow * logWindo
         argv[argc] = strdup( aStr.toLatin1().constData() );
         argc++;
       }
+      argv[argc++] = strdup("--multi-servers");
       MyCoreApp = new pqPVApplicationCore (argc, argv);
       if (MyCoreApp->getOptions()->GetHelpSelected() ||
           MyCoreApp->getOptions()->GetUnknownArgument() ||
diff --git a/src/PVViewer/PVViewer_InitSingleton.cxx b/src/PVViewer/PVViewer_InitSingleton.cxx
new file mode 100644 (file)
index 0000000..538e0d0
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2017  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony GEAY (EDF R&D)
+
+#include "PVViewer_InitSingleton.h"
+#include "PVViewer_Core.h"
+#include "PVViewer_ViewManager.h"
+
+bool PVViewer_InitSingleton::IS_INIT=false;
+
+void PVViewer_InitSingleton::Init(QMainWindow *aDesktop, LogWindow *logWindow)
+{
+  if(IS_INIT)
+    return ;
+  PVViewer_Core::ParaviewInitApp(aDesktop,logWindow);
+  // Finish ParaView set up: behaviors, connection and configurations.
+  const QString configPath(PVViewer_ViewManager::GetPVConfigPath());
+  PVViewer_Core::ParaviewInitBehaviors(true,aDesktop);
+  PVViewer_ViewManager::ConnectToExternalPVServer(aDesktop);
+  PVViewer_Core::ParaviewLoadConfigurations(configPath);
+  IS_INIT=true;
+}
diff --git a/src/PVViewer/PVViewer_InitSingleton.h b/src/PVViewer/PVViewer_InitSingleton.h
new file mode 100644 (file)
index 0000000..93eba85
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright (C) 2017  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony GEAY (EDF R&D)
+
+#ifndef __PVVIEWER_INITSINGLETON_H__
+#define __PVVIEWER_INITSINGLETON_H__
+
+#include "PVViewer.h"
+
+class QMainWindow;
+class LogWindow;
+
+/**
+ * This class deals with initialization of SALOME_Session to make it a PV based application.
+ * The initialization must be done only once.
+ * It allows multi initializator ParaView visu modules other than PARAVIS.
+ */
+class PVVIEWER_EXPORT PVViewer_InitSingleton
+{
+public:
+  static void Init(QMainWindow *aDesktop, LogWindow *logWindow);
+private:
+  static bool IS_INIT;
+};
+
+#endif /* SRC_PVVIEWER_PVVIEWER_CORE_H_ */
index 9c0f6004c815104dc602256030f5c24be3090fb2..42a7947994b759a822a56cd4d918a45f633b0276 100644 (file)
@@ -23,6 +23,7 @@
 #include "PVViewer_ViewModel.h"
 #include "PVViewer_GUIElements.h"
 #include "PVViewer_Core.h"
+#include "PVViewer_InitSingleton.h"
 #include "PVServer_ServiceWrapper.h"
 
 #include <utilities.h>
@@ -49,7 +50,7 @@ PVViewer_ViewManager::PVViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* des
   setTitle( tr( "PARAVIEW_VIEW_TITLE" ) );
 
   // Initialize minimal paraview stuff (if not already done)
-  PVViewer_Core::ParaviewInitApp(desk, logWindow);
+  PVViewer_InitSingleton::Init(desk, logWindow);
 
   connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
            this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
index f26f9a74517891ed78cbbb2d6c37b1833398aad5..f2c7f9221c048da06bdcdf2fc62057efec6d88ec 100644 (file)
@@ -59,13 +59,6 @@ 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.
-    const QString configPath(PVViewer_ViewManager::GetPVConfigPath());
-    PVViewer_Core::ParaviewInitBehaviors(true, theDesktop);
-    PVViewer_ViewManager::ConnectToExternalPVServer(theDesktop);
-    PVViewer_Core::ParaviewLoadConfigurations(configPath);
-
     // Hide toolbars
     PVViewer_GUIElements * pvge = PVViewer_GUIElements::GetInstance(myDesktop);
     pvge->setToolBarVisible(false);