with an external pvserver (this still has to be launched manually for now).
#include <pqScalarBarVisibilityReaction.h>
#include <pqStandardPropertyWidgetInterface.h>
#include <pqViewStreamingBehavior.h>
+#include <pqServerResource.h>
+#include <pqServerConnectReaction.h>
#include <PARAVIS_version.h>
connect(&pqActiveObjects::instance(),
SIGNAL(representationChanged(pqRepresentation*)),
this, SLOT(onRepresentationChanged(pqRepresentation*)));
+
+ // Try to connect to the external PVServer
+ QString serverUrlEnv = getenv("PARAVIS_PVSERVER_URL");
+ const char * serverUrl = "cs://localhost";
+ if (!serverUrlEnv.isEmpty())
+ serverUrl = serverUrlEnv.toStdString().c_str();
+ std::cout << "** Trying to connect to the external PVServer '" << serverUrl << "' ..." << std::endl;
+
+ if (!pqServerConnectReaction::connectToServer(pqServerResource(serverUrl)))
+ {
+ std::cerr << "** Could not connect to the requested server \""
+ << serverUrl << "\". Creating default builtin connection.\n" << std::endl;
+ }
+ else
+ std::cout << "** Connected!" << std::endl;
+
}
void PVGUI_Module::onStartProgress()
import SALOME_ModuleCatalog
from omniORB import CORBA
from time import sleep
-from salome import *
-
-myORB = None
-myNamingService = None
-myLifeCycleCORBA = None
-myNamingService = None
-myLocalStudyManager = None
-myLocalStudy = None
-myLocalParavis = None
-myDelay = None
-mySession = None
+import salome
## Initialization of paravis server
-def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
- global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
- global mySession, myDelay
- myDelay = theDelay
- myORB = theORB
- myNamingService = theNamingService
- myLifeCycleCORBA = theLifeCycleCORBA
- myLocalStudyManager = theStudyManager
+def Initialize(theDelay) :
+ mySession = None
while mySession == None:
- mySession = myNamingService.Resolve("/Kernel/Session")
+ mySession = salome.naming_service.Resolve("/Kernel/Session")
mySession = mySession._narrow(SALOME.Session)
mySession.GetInterface()
- myDelay = theDelay
- sleep(myDelay)
- myLocalParavis = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "PARAVIS")
- myLocalStudy = theStudy
+ sleep(theDelay)
+ myLocalParavis = salome.lcc.FindOrLoadComponent("FactoryServer", "PARAVIS")
+ myLocalStudy = salome.myStudy
myLocalParavis.SetCurrentStudy(myLocalStudy)
- myLocalParavis.ActivateModule()
+ myLocalParavis.ActivateModule() ## TO BE DISCUSSED!
return myLocalParavis
+def StartOrRetrievePVServerURL():
+ """ To be completed!!! Should invoke IDL methods from 'PARAVIS' module"""
+ return "localhost"
-def ImportFile(theFileName):
- "Import a file of any format supported by ParaView"
- myParavis.ImportFile(theFileName)
+# def ImportFile(theFileName):
+# "Import a file of any format supported by ParaView"
+# myParavis.ImportFile(theFileName)
## Initialize PARAVIS interface
-myParavis = Initialize(orb, naming_service,lcc,myStudyManager,myStudy, 2)
-
-## Initialize Paravis static objects
-#vtkSMObject = vtkSMObject()
-#vtkProcessModule = vtkProcessModule()
-#vtkPVPythonModule = vtkPVPythonModule()
-#vtkSMProxyManager = vtkSMProxyManager()
+myParavisEngine = Initialize(2)
'servermanager' module of ParaView.
"""
-from paraview import servermanager
-from paravis import *
+from paraview.servermanager import *
-for name in dir(servermanager):
- if name != "__file__":
- globals()[name] = getattr(servermanager, name)
-del servermanager
-
-InitFromGUI()
+# for name in dir(servermanager):
+# if name != "__file__":
+# globals()[name] = getattr(servermanager, name)
+# del servermanager
+#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-r""" This module is a direct forward to the initial
-'simple' module of ParaView.
+r""" This module is a direct forward to the initial 'simple' module of ParaView.
+On top of that it also establishes a connection to a valid PVServer whose address
+is provided by the PARAVIS engine.
"""
-from paraview import simple
+from paraview.simple import *
+import paravis ## Triggers the "FindOrLoadCompo(PARAVIS)"
-for name in dir(simple):
- if name != "__file__":
- globals()[name] = getattr(simple, name)
-del simple
+def SalomeConnectToPVServer():
+ print "Connecting to PVServer ..."
+ try:
+ server_url = paravis.StartOrRetrievePVServerURL()
+ Connect(server_url)
+ except Exception as e:
+ print "*******************************************"
+ print "*******************************************"
+ print "Could not connect to a running PVServer!"
+ print "*******************************************"
+ print "*******************************************"
+ raise e
+ print "Connected!"
-print "Connecting to PVServer ..."
-try:
- # TODO: this should be improved (retrieval from the engine)
- Connect('localhost')
-except Exception as e:
- print "*******************************************"
- print "*******************************************"
- print "Could not connect to PVServer on localhost!"
- print "*******************************************"
- print "*******************************************"
- raise e
+# Automatically connect to the right PVServer:
+SalomeConnectToPVServer()