From: abn Date: Tue, 26 Aug 2014 08:47:08 +0000 (+0200) Subject: Finished WITHOUT_CORBA implementation: PARAVIS now works by default X-Git-Tag: V7_5_0b1~27^2~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6c884982c96b001ef6987085a9f35018803201c2;p=modules%2Fparavis.git Finished WITHOUT_CORBA implementation: PARAVIS now works by default with an external pvserver (this still has to be launched manually for now). --- diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index caa1fa87..8fb20ea2 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -128,6 +128,8 @@ #include #include #include +#include +#include #include @@ -525,6 +527,22 @@ void PVGUI_Module::initialize( CAM_Application* app ) 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() diff --git a/src/PV_SWIG/paravis.py b/src/PV_SWIG/paravis.py index db3ad315..52f0c47f 100644 --- a/src/PV_SWIG/paravis.py +++ b/src/PV_SWIG/paravis.py @@ -29,50 +29,30 @@ import SALOMEDS 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) diff --git a/src/PV_SWIG/paravisSM.py b/src/PV_SWIG/paravisSM.py index d58f4edd..04775112 100644 --- a/src/PV_SWIG/paravisSM.py +++ b/src/PV_SWIG/paravisSM.py @@ -21,12 +21,10 @@ r""" This module is a direct forward to the initial '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 +# diff --git a/src/PV_SWIG/pvsimple.py b/src/PV_SWIG/pvsimple.py index 48ad9621..73a8aad1 100644 --- a/src/PV_SWIG/pvsimple.py +++ b/src/PV_SWIG/pvsimple.py @@ -17,25 +17,27 @@ # 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()