# List of targets in this project we want to make visible to the rest of the world.
# They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
IF(NOT SALOME_LIGHT_ONLY)
- SET(_${PROJECT_NAME}_exposed_targets SalomeIDLPARAVIS PARAVIS)
+ SET(_${PROJECT_NAME}_exposed_targets SalomeIDLPVServer PARAVIS)
# Add all targets to the build-tree export set
EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
)
ELSE()
SET(SalomeIDLPARAVIS_IDLSOURCES
- ${CMAKE_CURRENT_SOURCE_DIR}/no_wrap/PARAVIS_Gen.idl
+ ${CMAKE_CURRENT_SOURCE_DIR}/no_wrap/PVSERVER_Gen.idl
)
SET(_idl_include_dirs
${CMAKE_CURRENT_SOURCE_DIR}/no_wrap
${KERNEL_SalomeIDLKernel}
)
-OMNIORB_ADD_MODULE(SalomeIDLPARAVIS "${SalomeIDLPARAVIS_IDLSOURCES}" "${_idl_include_dirs}" "${_idl_link_flags}")
-INSTALL(TARGETS SalomeIDLPARAVIS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+OMNIORB_ADD_MODULE(SalomeIDLPVServer "${SalomeIDLPARAVIS_IDLSOURCES}" "${_idl_include_dirs}" "${_idl_link_flags}")
+INSTALL(TARGETS SalomeIDLPVServer EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+++ /dev/null
-// Copyright (C) 2010-2014 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 : Adrien Bruneton (CEA)
-
-
-#ifndef __PARAVIS_GEN__
-#define __PARAVIS_GEN__
-
-#include "SALOME_Exception.idl"
-#include "SALOME_Component.idl"
-#include "SALOMEDS.idl"
-#include "SALOME_Exception.idl"
-
-/*!
- The main package of interfaces of the module %PARAVIS.
-*/
-module PARAVIS_ORB {
-
- /*!
- * \brief The main interface class for PARAVIS server.
- * Instantiation of this class has to be done before access to any other PARAVIS interfaces
- */
- interface PARAVIS_Gen : Engines::EngineComponent, SALOMEDS::Driver
- {
-
- /*!
- * \brief Returns IOR of the current object.
- */
- string GetIOR();
-
- /*! If a pvserver is already started, returns its current URL, regardless of the provided
- * parameters.
- * If not, start a pvserver on the machine hosting the PARAVIS engine and on the given port.
- * If port <= 0, a free port is automatically detected, starting from the usual 11111 pvserver port.
- */
- string FindOrStartPVServer(in long port);
-
- /*! Tries to stop the PVserver currently running (send KILL).
- * @return false if no server was running, true otherwise.
- */
- boolean StopPVServer();
-
- /*! Gets the last trace string pushed by the GUI onto the engine.
- */
- string GetPythonTraceString();
-
- /*! HACK!! For now ParaView's trace mechanism is implemented in such away that asking the trace
- * outside the GUI provides an incomplete script. Hence the GUI regularly pushes to the engine
- * the latest status of the trace which is then returned by GetPythonTraceString().
- */
- void PutPythonTraceStringToEngine(in string trace);
-
- /*! Indicates if the GUI process is already connected to the pvserver.
- * This avoids multiple attempts to connect from a single thread (makes ParaView crash). */
- void SetGUIConnected(in boolean isConnected);
-
- boolean GetGUIConnected();
-
- };
-
-};
-
-#endif
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2010-2014 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 : Adrien Bruneton (CEA)
+
+
+#ifndef __PVSERVER_GEN__
+#define __PVSERVER_GEN__
+
+#include "SALOME_Exception.idl"
+#include "SALOME_Component.idl"
+#include "SALOMEDS.idl"
+#include "SALOME_Exception.idl"
+
+/*!
+ The main package of interfaces of the module %PARAVIS.
+*/
+module PVSERVER_ORB {
+
+ /*!
+ * \brief The main interface class for PARAVIS server.
+ * Instantiation of this class has to be done before access to any other PARAVIS interfaces
+ */
+ interface PVSERVER_Gen : Engines::EngineComponent, SALOMEDS::Driver
+ {
+
+ /*!
+ * \brief Returns IOR of the current object.
+ */
+ string GetIOR();
+
+ /*! If a pvserver is already started, returns its current URL, regardless of the provided
+ * parameters.
+ * If not, start a pvserver on the machine hosting the PARAVIS engine and on the given port.
+ * If port <= 0, a free port is automatically detected, starting from the usual 11111 pvserver port.
+ */
+ string FindOrStartPVServer(in long port);
+
+ /*! Tries to stop the PVserver currently running (send KILL).
+ * @return false if no server was running, true otherwise.
+ */
+ boolean StopPVServer();
+
+ /*! Gets the last trace string pushed by the GUI onto the engine.
+ */
+ string GetPythonTraceString();
+
+ /*! HACK!! For now ParaView's trace mechanism is implemented in such away that asking the trace
+ * outside the GUI provides an incomplete script. Hence the GUI regularly pushes to the engine
+ * the latest status of the trace which is then returned by GetPythonTraceString().
+ */
+ void PutPythonTraceStringToEngine(in string trace);
+
+ /*! Indicates if the GUI process is already connected to the pvserver.
+ * This avoids multiple attempts to connect from a single thread (makes ParaView crash). */
+ void SetGUIConnected(in boolean isConnected);
+
+ boolean GetGUIConnected();
+
+ };
+
+};
+
+#endif
\ No newline at end of file
<type-list></type-list>
<component-list>
<component>
- <component-name>PARAVIS</component-name>
+ <component-name>PVSERVER</component-name>
<component-username>ParaView</component-username>
<component-type>PARAVIS</component-type>
<component-author>vsv</component-author>
<component-version>@SALOMEPARAVIS_VERSION@</component-version>
- <component-comment>ParaView module</component-comment>
+ <component-comment>PVServer control service</component-comment>
<component-multistudy>1</component-multistudy>
<component-impltype>1</component-impltype>
<component-icone>pqAppIcon22.png</component-icone>
<constraint></constraint>
<component-interface-list>
- <component-interface-name>PARAVIS_Gen</component-interface-name>
+ <component-interface-name>PVSERVER_Gen</component-interface-name>
<component-interface-comment>unknown</component-interface-comment>
<component-service-list>
<component-service>
INSTALL(FILES PARAVIS_Engine_i.hh DESTINATION ${SALOME_INSTALL_HEADERS})
ELSE()
- CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/no_wrap/PARAVIS.py.in ${CMAKE_CURRENT_BINARY_DIR}/PARAVIS.py @ONLY)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/no_wrap/PVSERVER.py.in ${CMAKE_CURRENT_BINARY_DIR}/PVSERVER.py @ONLY)
SET(_bin_SCRIPTS
- ${CMAKE_CURRENT_BINARY_DIR}/PARAVIS.py
- no_wrap/PARAVIS_utils.py
+ ${CMAKE_CURRENT_BINARY_DIR}/PVSERVER.py
+ no_wrap/PVSERVER_utils.py
)
# --- rules ---
+++ /dev/null
-# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-#
-# 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 : Adrien Bruneton (CEA)
-#
-
-import PARAVIS_ORB__POA
-import SALOME_ComponentPy
-import SALOME_DriverPy
-import SALOMEDS
-import SALOME
-import PARAVIS_utils
-import subprocess as subp
-import socket
-from time import sleep
-import os
-#from SALOME_utilities import MESSAGE
-
-def MESSAGE(m):
- pass
- #os.system("echo \"%s\" >> /tmp/paravis_log.txt" % m)
-
-class PARAVIS_Impl:
- """ The core implementation (non CORBA, or Study related).
- See the IDL for the documentation.
- """
- MAX_PVSERVER_PORT_TRIES = 10
- PARAVIEW_ROOT_DIR = "@PARAVIEW_ROOT_DIR@"
- PVSERVER_DEFAULT_PORT = 11111
-
- def __init__(self):
- self.pvserverPort = -1
- self.pvserverPop = None # Popen object from subprocess module
- self.lastTrace = ""
- self.isGUIConnected = False # whether there is an active connection from the GUI.
-
- """
- Private. Identify a free port to launch the PVServer.
- """
- def __getFreePort(self, startPort):
- cnt = 0
- currPort = startPort
- while cnt < self.MAX_PVSERVER_PORT_TRIES:
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.bind(('', currPort))
- s.close()
- return currPort
- except socket.error as e:
- cnt += 1
- currPort += 1
- pass
- raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,
- "[PARAVIS] maximum number of tries to retrieve a free port for the PVServer",
- "PARAVIS.py", 0))
-
- def FindOrStartPVServer( self, port ):
- MESSAGE("[PARAVIS] FindOrStartPVServer ...")
- host = "localhost"
- alive = True
- if self.pvserverPop is None:
- alive = False
- else:
- # Poll active server to check if still alive
- self.pvserverPop.poll()
- if not self.pvserverPop.returncode is None: # server terminated
- alive = False
-
- if alive:
- return "cs://%s:%d" % (host, self.pvserverPort)
-
- # (else) Server not alive, start it:
- pvServerPath = os.path.join(self.PARAVIEW_ROOT_DIR, 'bin', 'pvserver')
- opt = []
- if port <= 0:
- port = self.__getFreePort(self.PVSERVER_DEFAULT_PORT)
- self.pvserverPop = subp.Popen([pvServerPath, "--multi-clients", "--server-port=%d" % port])
- sleep(3) # Give some time to the server to start up to avoid
- # ugly messages on the client side saying that it cannot connect
- # Is PID still alive? If yes, consider that the launch was successful
- self.pvserverPop.poll()
- if self.pvserverPop.returncode is None:
- success = True
- self.pvserverPort = port
- MESSAGE("[PARAVIS] pvserver successfully launched on port %d" % port)
- else:
- raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,
- "[PARAVIS] Unable to start PVServer on port %d!" % port,
- "PARAVIS.py", 0))
- return "cs://%s:%d" % (host, self.pvserverPort)
-
- def StopPVServer( self ):
- MESSAGE("[PARAVIS] Trying to stop PVServer (sending KILL) ...")
- if not self.pvserverPop is None:
- self.pvserverPop.poll()
- if self.pvserverPop.returncode is None:
- # Terminate if still running:
- self.pvserverPop.terminate()
- MESSAGE("[PARAVIS] KILL signal sent.")
- return True
- MESSAGE("[PARAVIS] Nothing to kill.")
- return False
-
- def PutPythonTraceStringToEngine( self, t ):
- self.lastTrace = t
-
- def GetPythonTraceString(self):
- return self.lastTrace
-
- def SetGUIConnected( self, isConnected ):
- self.isGUIConnected = isConnected
-
- def GetGUIConnected( self ):
- return self.isGUIConnected
-
-class PARAVIS(PARAVIS_ORB__POA.PARAVIS_Gen,
- SALOME_ComponentPy.SALOME_ComponentPy_i,
- SALOME_DriverPy.SALOME_DriverPy_i,
- PARAVIS_Impl):
- """
- Construct an instance of PARAVIS module engine.
- The class PARAVIS implements CORBA interface PARAVIS_Gen (see PARAVIS_Gen.idl).
- It is inherited from the classes SALOME_ComponentPy_i (implementation of
- Engines::EngineComponent CORBA interface - SALOME component) and SALOME_DriverPy_i
- (implementation of SALOMEDS::Driver CORBA interface - SALOME module's engine).
- """
- def __init__ ( self, orb, poa, contID, containerName, instanceName,
- interfaceName ):
- SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
- contID, containerName, instanceName, interfaceName, 0)
- SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
- PARAVIS_Impl.__init__(self)
- #
- self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
- #
-
- """ Override base class destroy to make sure we try to kill the pvserver
- before leaving.
- """
- def destroy(self):
- self.StopPVServer()
- # Invokes super():
- SALOME_ComponentPy.destroy(self)
-
- """
- Get version information.
- """
- def getVersion( self ):
- import salome_version
- return salome_version.getVersion("PARAVIS", True)
-
- def GetIOR(self):
- return PARAVIS_utils.getEngineIOR()
-
- """
- Create object.
- """
- def createObject( self, study, name ):
- MESSAGE("createObject()")
- self._createdNew = True # used for getModifiedData method
- builder = study.NewBuilder()
- father = findOrCreateComponent( study )
- object = builder.NewObject( father )
- attr = builder.FindOrCreateAttribute( object, "AttributeName" )
- attr.SetValue( name )
- attr = builder.FindOrCreateAttribute( object, "AttributeLocalID" )
- attr.SetValue( PARAVIS_utils.objectID() )
- pass
-
- """
- Dump module data to the Python script.
- """
- def DumpPython( self, study, isPublished, isMultiFile ):
- MESSAGE("dumpPython()")
- abuffer = self.GetPythonTraceString().split("\n")
- if isMultiFile:
- abuffer = [ " " + s for s in abuffer ]
- abuffer[0:0] = [ "def RebuildData( theStudy ):" ]
- abuffer += [ " pass" ]
- abuffer += [ "\0" ]
- return ("\n".join( abuffer ), 1)
-
- """
- Import file to restore module data
- """
- def importData(self, studyId, dataContainer, options):
- MESSAGE("importData()")
- # get study by Id
- obj = self._naming_service.Resolve("myStudyManager")
- myStudyManager = obj._narrow(SALOMEDS.StudyManager)
- study = myStudyManager.GetStudyByID(studyId)
- # create all objects from the imported stream
- stream = dataContainer.get()
- for objname in stream.split("\n"):
- if len(objname) != 0:
- self.createObject(study, objname)
- self._createdNew = False # to store the modification of the study information later
- return ["objects"] # identifier what is in this file
-
- def getModifiedData(self, studyId):
- MESSAGE("getModifiedData()")
- if self._createdNew:
- # get study by Id
- obj = self._naming_service.Resolve("myStudyManager")
- myStudyManager = obj._narrow(SALOMEDS.StudyManager)
- study = myStudyManager.GetStudyByID(studyId)
- # iterate all objects to get their names and store this information in stream
- stream=""
- father = study.FindComponent( moduleName() )
- if father:
- iter = study.NewChildIterator( father )
- while iter.More():
- name = iter.Value().GetName()
- stream += name + "\n"
- iter.Next()
- # store stream to the temporary file to send it in DataContainer
- dataContainer = SALOME_DataContainerPy_i(stream, "", "objects", False, True)
- aVar = dataContainer._this()
- return [aVar]
- return []
+++ /dev/null
-# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# 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
-#
-
-# ---
-# File : PARAVIS_utils.py
-# Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-# ---
-#
-__all__ = [
- "moduleID",
- "objectID",
- "unknownID",
- "moduleName",
- "modulePixmap",
- "verbose",
- "getORB",
- "getNS",
- "getLCC",
- "getStudyManager",
- "getEngine",
- "getEngineIOR",
- "findOrCreateComponent",
- "getObjectID",
- ]
-
-from omniORB import CORBA
-from SALOME_NamingServicePy import SALOME_NamingServicePy_i
-from LifeCycleCORBA import LifeCycleCORBA
-import SALOMEDS
-import SALOMEDS_Attributes_idl
-import PARAVIS_ORB
-import os
-
-###
-# Get PARAVIS module's ID
-###
-def moduleID():
- MODULE_ID = 1000
- return MODULE_ID
-
-###
-# Get PARAVIS object's ID
-###
-def objectID():
- OBJECT_ID = 1010
- return OBJECT_ID
-
-###
-# Get unknown ID
-###
-def unknownID():
- FOREIGN_ID = -1
- return FOREIGN_ID
-
-###
-# Get PARAVIS module's name
-###
-def moduleName():
- return "PARAVIS"
-
-###
-# Get module's pixmap name
-###
-def modulePixmap():
- return "PARAVIS_small.png"
-
-###
-# Get verbose level
-###
-__verbose__ = None
-def verbose():
- global __verbose__
- if __verbose__ is None:
- try:
- __verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) )
- except:
- __verbose__ = 0
- pass
- pass
- return __verbose__
-
-###
-# Get ORB reference
-###
-__orb__ = None
-def getORB():
- global __orb__
- if __orb__ is None:
- __orb__ = CORBA.ORB_init( [''], CORBA.ORB_ID )
- pass
- return __orb__
-
-###
-# Get naming service instance
-###
-__naming_service__ = None
-def getNS():
- global __naming_service__
- if __naming_service__ is None:
- __naming_service__ = SALOME_NamingServicePy_i( getORB() )
- pass
- return __naming_service__
-
-##
-# Get life cycle CORBA instance
-##
-__lcc__ = None
-def getLCC():
- global __lcc__
- if __lcc__ is None:
- __lcc__ = LifeCycleCORBA( getORB() )
- pass
- return __lcc__
-
-##
-# Get study manager
-###
-__study_manager__ = None
-def getStudyManager():
- global __study_manager__
- if __study_manager__ is None:
- obj = getNS().Resolve( '/myStudyManager' )
- __study_manager__ = obj._narrow( SALOMEDS.StudyManager )
- pass
- return __study_manager__
-
-###
-# Get PARAVIS engine
-###
-__engine__ = None
-def getEngine():
- global __engine__
- if __engine__ is None:
- __engine__ = getLCC().FindOrLoadComponent( "FactoryServer", moduleName() )
- pass
- return __engine__
-
-###
-# Get PARAVIS engine IOR
-###
-def getEngineIOR():
- IOR = ""
- if getORB() and getEngine():
- IOR = getORB().object_to_string( getEngine() )
- pass
- return IOR
-
-###
-# Find or create PARAVIS component object in a study
-###
-def findOrCreateComponent( study ):
- father = study.FindComponent( moduleName() )
- if father is None:
- builder = study.NewBuilder()
- father = builder.NewComponent( moduleName() )
- attr = builder.FindOrCreateAttribute( father, "AttributeName" )
- attr.SetValue( moduleName() )
- attr = builder.FindOrCreateAttribute( father, "AttributePixMap" )
- attr.SetPixMap( modulePixmap() )
- attr = builder.FindOrCreateAttribute( father, "AttributeLocalID" )
- attr.SetValue( moduleID() )
- try:
- builder.DefineComponentInstance( father, getEngine() )
- pass
- except:
- pass
- pass
- return father
-
-###
-# Get object's ID
-###
-def getObjectID( study, entry ):
- ID = unknownID()
- if study and entry:
- sobj = study.FindObjectID( entry )
- if sobj is not None:
- test, anAttr = sobj.FindAttribute( "AttributeLocalID" )
- if test: ID = anAttr._narrow( SALOMEDS.AttributeLocalID ).Value()
- pass
- pass
- return ID
-
--- /dev/null
+# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# 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 : Adrien Bruneton (CEA)
+#
+
+import PVSERVER_ORB__POA
+import SALOME_ComponentPy
+import SALOME_DriverPy
+import SALOMEDS
+import SALOME
+import PVSERVER_utils
+import subprocess as subp
+import socket
+from time import sleep
+import os
+#from SALOME_utilities import MESSAGE
+
+def MESSAGE(m):
+ pass
+ #os.system("echo \"%s\" >> /tmp/paravis_log.txt" % m)
+
+class PVSERVER_Impl:
+ """ The core implementation (non CORBA, or Study related).
+ See the IDL for the documentation.
+ """
+ MAX_PVSERVER_PORT_TRIES = 10
+ PARAVIEW_ROOT_DIR = "@PARAVIEW_ROOT_DIR@"
+ PVSERVER_DEFAULT_PORT = 11111
+
+ def __init__(self):
+ self.pvserverPort = -1
+ self.pvserverPop = None # Popen object from subprocess module
+ self.lastTrace = ""
+ self.isGUIConnected = False # whether there is an active connection from the GUI.
+
+ """
+ Private. Identify a free port to launch the PVServer.
+ """
+ def __getFreePort(self, startPort):
+ cnt = 0
+ currPort = startPort
+ while cnt < self.MAX_PVSERVER_PORT_TRIES:
+ try:
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind(('', currPort))
+ s.close()
+ return currPort
+ except socket.error as e:
+ cnt += 1
+ currPort += 1
+ pass
+ raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,
+ "[PVSERVER] maximum number of tries to retrieve a free port for the PVServer",
+ "PVSERVER.py", 0))
+
+ def FindOrStartPVServer( self, port ):
+ MESSAGE("[PVSERVER] FindOrStartPVServer ...")
+ host = "localhost"
+ alive = True
+ if self.pvserverPop is None:
+ alive = False
+ else:
+ # Poll active server to check if still alive
+ self.pvserverPop.poll()
+ if not self.pvserverPop.returncode is None: # server terminated
+ alive = False
+
+ if alive:
+ return "cs://%s:%d" % (host, self.pvserverPort)
+
+ # (else) Server not alive, start it:
+ pvServerPath = os.path.join(self.PARAVIEW_ROOT_DIR, 'bin', 'pvserver')
+ opt = []
+ if port <= 0:
+ port = self.__getFreePort(self.PVSERVER_DEFAULT_PORT)
+ self.pvserverPop = subp.Popen([pvServerPath, "--multi-clients", "--server-port=%d" % port])
+ sleep(3) # Give some time to the server to start up to avoid
+ # ugly messages on the client side saying that it cannot connect
+ # Is PID still alive? If yes, consider that the launch was successful
+ self.pvserverPop.poll()
+ if self.pvserverPop.returncode is None:
+ success = True
+ self.pvserverPort = port
+ MESSAGE("[PVSERVER] pvserver successfully launched on port %d" % port)
+ else:
+ raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,
+ "[PVSERVER] Unable to start PVServer on port %d!" % port,
+ "PVSERVER.py", 0))
+ return "cs://%s:%d" % (host, self.pvserverPort)
+
+ def StopPVServer( self ):
+ MESSAGE("[PVSERVER] Trying to stop PVServer (sending KILL) ...")
+ if not self.pvserverPop is None:
+ self.pvserverPop.poll()
+ if self.pvserverPop.returncode is None:
+ # Terminate if still running:
+ self.pvserverPop.terminate()
+ MESSAGE("[PVSERVER] KILL signal sent.")
+ return True
+ MESSAGE("[PVSERVER] Nothing to kill.")
+ return False
+
+ def PutPythonTraceStringToEngine( self, t ):
+ self.lastTrace = t
+
+ def GetPythonTraceString(self):
+ return self.lastTrace
+
+ def SetGUIConnected( self, isConnected ):
+ self.isGUIConnected = isConnected
+
+ def GetGUIConnected( self ):
+ return self.isGUIConnected
+
+class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen,
+ SALOME_ComponentPy.SALOME_ComponentPy_i,
+ SALOME_DriverPy.SALOME_DriverPy_i,
+ PVSERVER_Impl):
+ """
+ Construct an instance of PVSERVER module engine.
+ The class PVSERVER implements CORBA interface PVSERVER_Gen (see PVSERVER_Gen.idl).
+ It is inherited from the classes SALOME_ComponentPy_i (implementation of
+ Engines::EngineComponent CORBA interface - SALOME component) and SALOME_DriverPy_i
+ (implementation of SALOMEDS::Driver CORBA interface - SALOME module's engine).
+ """
+ def __init__ ( self, orb, poa, contID, containerName, instanceName,
+ interfaceName ):
+ SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
+ contID, containerName, instanceName, interfaceName, 0)
+ SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
+ PVSERVER_Impl.__init__(self)
+ #
+ self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
+ #
+
+ """ Override base class destroy to make sure we try to kill the pvserver
+ before leaving.
+ """
+ def destroy(self):
+ self.StopPVServer()
+ # Invokes super():
+ SALOME_ComponentPy.destroy(self)
+
+ """
+ Get version information.
+ """
+ def getVersion( self ):
+ import salome_version
+ return salome_version.getVersion("PVSERVER", True)
+
+ def GetIOR(self):
+ return PVSERVER_utils.getEngineIOR()
+
+ """
+ Create object.
+ """
+ def createObject( self, study, name ):
+ MESSAGE("createObject()")
+ self._createdNew = True # used for getModifiedData method
+ builder = study.NewBuilder()
+ father = findOrCreateComponent( study )
+ object = builder.NewObject( father )
+ attr = builder.FindOrCreateAttribute( object, "AttributeName" )
+ attr.SetValue( name )
+ attr = builder.FindOrCreateAttribute( object, "AttributeLocalID" )
+ attr.SetValue( PVSERVER_utils.objectID() )
+ pass
+
+ """
+ Dump module data to the Python script.
+ """
+ def DumpPython( self, study, isPublished, isMultiFile ):
+ MESSAGE("dumpPython()")
+ abuffer = self.GetPythonTraceString().split("\n")
+ if isMultiFile:
+ abuffer = [ " " + s for s in abuffer ]
+ abuffer[0:0] = [ "def RebuildData( theStudy ):" ]
+ abuffer += [ " pass" ]
+ abuffer += [ "\0" ]
+ return ("\n".join( abuffer ), 1)
+
+ """
+ Import file to restore module data
+ """
+ def importData(self, studyId, dataContainer, options):
+ MESSAGE("importData()")
+ # get study by Id
+ obj = self._naming_service.Resolve("myStudyManager")
+ myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+ study = myStudyManager.GetStudyByID(studyId)
+ # create all objects from the imported stream
+ stream = dataContainer.get()
+ for objname in stream.split("\n"):
+ if len(objname) != 0:
+ self.createObject(study, objname)
+ self._createdNew = False # to store the modification of the study information later
+ return ["objects"] # identifier what is in this file
+
+ def getModifiedData(self, studyId):
+ MESSAGE("getModifiedData()")
+ if self._createdNew:
+ # get study by Id
+ obj = self._naming_service.Resolve("myStudyManager")
+ myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+ study = myStudyManager.GetStudyByID(studyId)
+ # iterate all objects to get their names and store this information in stream
+ stream=""
+ father = study.FindComponent( moduleName() )
+ if father:
+ iter = study.NewChildIterator( father )
+ while iter.More():
+ name = iter.Value().GetName()
+ stream += name + "\n"
+ iter.Next()
+ # store stream to the temporary file to send it in DataContainer
+ dataContainer = SALOME_DataContainerPy_i(stream, "", "objects", False, True)
+ aVar = dataContainer._this()
+ return [aVar]
+ return []
--- /dev/null
+# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+
+# ---
+# File : PVSERVER_utils.py
+# Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+# ---
+#
+__all__ = [
+ "moduleID",
+ "objectID",
+ "unknownID",
+ "moduleName",
+ "modulePixmap",
+ "verbose",
+ "getORB",
+ "getNS",
+ "getLCC",
+ "getStudyManager",
+ "getEngine",
+ "getEngineIOR",
+ "findOrCreateComponent",
+ "getObjectID",
+ ]
+
+from omniORB import CORBA
+from SALOME_NamingServicePy import SALOME_NamingServicePy_i
+from LifeCycleCORBA import LifeCycleCORBA
+import SALOMEDS
+import SALOMEDS_Attributes_idl
+import PVSERVER_ORB
+import os
+
+###
+# Get PVSERVER module's ID
+###
+def moduleID():
+ MODULE_ID = 1000
+ return MODULE_ID
+
+###
+# Get PVSERVER object's ID
+###
+def objectID():
+ OBJECT_ID = 1010
+ return OBJECT_ID
+
+###
+# Get unknown ID
+###
+def unknownID():
+ FOREIGN_ID = -1
+ return FOREIGN_ID
+
+###
+# Get PVSERVER module's name
+###
+def moduleName():
+ return "PVSERVER"
+
+###
+# Get module's pixmap name
+###
+def modulePixmap():
+ return "PVSERVER_small.png"
+
+###
+# Get verbose level
+###
+__verbose__ = None
+def verbose():
+ global __verbose__
+ if __verbose__ is None:
+ try:
+ __verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) )
+ except:
+ __verbose__ = 0
+ pass
+ pass
+ return __verbose__
+
+###
+# Get ORB reference
+###
+__orb__ = None
+def getORB():
+ global __orb__
+ if __orb__ is None:
+ __orb__ = CORBA.ORB_init( [''], CORBA.ORB_ID )
+ pass
+ return __orb__
+
+###
+# Get naming service instance
+###
+__naming_service__ = None
+def getNS():
+ global __naming_service__
+ if __naming_service__ is None:
+ __naming_service__ = SALOME_NamingServicePy_i( getORB() )
+ pass
+ return __naming_service__
+
+##
+# Get life cycle CORBA instance
+##
+__lcc__ = None
+def getLCC():
+ global __lcc__
+ if __lcc__ is None:
+ __lcc__ = LifeCycleCORBA( getORB() )
+ pass
+ return __lcc__
+
+##
+# Get study manager
+###
+__study_manager__ = None
+def getStudyManager():
+ global __study_manager__
+ if __study_manager__ is None:
+ obj = getNS().Resolve( '/myStudyManager' )
+ __study_manager__ = obj._narrow( SALOMEDS.StudyManager )
+ pass
+ return __study_manager__
+
+###
+# Get PVSERVER engine
+###
+__engine__ = None
+def getEngine():
+ global __engine__
+ if __engine__ is None:
+ __engine__ = getLCC().FindOrLoadComponent( "FactoryServer", moduleName() )
+ pass
+ return __engine__
+
+###
+# Get PVSERVER engine IOR
+###
+def getEngineIOR():
+ IOR = ""
+ if getORB() and getEngine():
+ IOR = getORB().object_to_string( getEngine() )
+ pass
+ return IOR
+
+###
+# Find or create PVSERVER component object in a study
+###
+def findOrCreateComponent( study ):
+ father = study.FindComponent( moduleName() )
+ if father is None:
+ builder = study.NewBuilder()
+ father = builder.NewComponent( moduleName() )
+ attr = builder.FindOrCreateAttribute( father, "AttributeName" )
+ attr.SetValue( moduleName() )
+ attr = builder.FindOrCreateAttribute( father, "AttributePixMap" )
+ attr.SetPixMap( modulePixmap() )
+ attr = builder.FindOrCreateAttribute( father, "AttributeLocalID" )
+ attr.SetValue( moduleID() )
+ try:
+ builder.DefineComponentInstance( father, getEngine() )
+ pass
+ except:
+ pass
+ pass
+ return father
+
+###
+# Get object's ID
+###
+def getObjectID( study, entry ):
+ ID = unknownID()
+ if study and entry:
+ sobj = study.FindObjectID( entry )
+ if sobj is not None:
+ test, anAttr = sobj.FindAttribute( "AttributeLocalID" )
+ if test: ID = anAttr._narrow( SALOMEDS.AttributeLocalID ).Value()
+ pass
+ pass
+ return ID
+
${MED_SalomeIDLMED}
${_PARAVIEW_APP_COMPO_LIB}
${GUI_PVViewer}
- SalomeIDLPARAVIS
+ SalomeIDLPVServer
)
# --- headers ---
#include <vtkPython.h> // Python first
#include "PVGUI_Module.h"
-#ifdef PARAVIS_WITH_FULL_CORBA
-# include "PARAVIS_Gen_i.hh"
-#endif
+//#ifdef PARAVIS_WITH_FULL_CORBA
+//# include "PARAVIS_Gen_i.hh"
+//#endif
#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
#include CORBA_SERVER_HEADER(SALOMEDS)
//----------------------------------------------------------------------------
PVGUI_Module* ParavisModule = 0;
-PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Module::MyEngine;
+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
SALOME module wrapping ParaView GUI.
*/
-//_PTR(SComponent)
-//ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
-//{
-// _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("PARAVIS");
-// if (!aSComponent) {
-// _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
-// aStudyBuilder->NewCommand();
-// int aLocked = theStudyDocument->GetProperties()->IsLocked();
-// if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
-// aSComponent = aStudyBuilder->NewComponent("PARAVIS");
-// _PTR(GenericAttribute) anAttr =
-// aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
-// _PTR(AttributeName) aName (anAttr);
-//
-// ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
-// CORBA::ORB_var anORB = init( qApp->argc(), qApp->argv() );
-//
-// SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
-// 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" );
-// if (!Comp->_is_nil()) {
-// aName->SetValue(Comp->componentusername());
-// }
-//
-// anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
-// _PTR(AttributePixMap) aPixmap (anAttr);
-// aPixmap->SetPixMap( "pqAppIcon16.png" );
-//
-// // Create Attribute parameters for future using
-// anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeParameter");
-//
-// aStudyBuilder->DefineComponentInstance(aSComponent, PVGUI_Module::GetCPPEngine()->GetIOR());
-// if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
-// aStudyBuilder->CommitCommand();
-// }
-// return aSComponent;
-//}
+_PTR(SComponent)
+ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
+{
+ _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("PVSERVER");
+ _PTR(GenericAttribute) anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
+ _PTR(AttributeName) aName (anAttr);
+
+ ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
+ CORBA::ORB_var anORB = init( qApp->argc(), qApp->argv() );
+
+ SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
+ 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( "PVSERVER" );
+ if (!Comp->_is_nil()) {
+ aName->SetValue(Comp->componentusername());
+ }
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
+ _PTR(AttributePixMap) aPixmap (anAttr);
+ aPixmap->SetPixMap( "pqAppIcon16.png" );
+
+ // Create Attribute parameters for future using
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeParameter");
+
+ aStudyBuilder->DefineComponentInstance(aSComponent, PVGUI_Module::GetCPPEngine()->GetIOR());
+ if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
+ aStudyBuilder->CommitCommand();
+ }
+ return aSComponent;
+}
/*!
Clean up function; used to stop ParaView progress events when
return PVViewer_EngineWrapper::GetInstance();
}
+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.
if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId);
- //ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this));
+ ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this));
return isDone;
}
*/
QString PVGUI_Module::engineIOR() const
{
-// CORBA::String_var anIOR = GetCPPEngine()->GetIOR();
-// return QString(anIOR.in());
- return QString("");
+ CORBA::String_var anIOR = GetCPPEngine()->GetIOR();
+ return QString(anIOR.in());
}
/*!
#define PVGUI_Module_H
#include <SalomeApp_Module.h>
-#include "SALOMEconfig.h"
-#include CORBA_SERVER_HEADER(SALOMEDS)
-#include CORBA_SERVER_HEADER(PARAVIS_Gen)
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(PVSERVER_Gen)
#include <ostream>
#include <vtkType.h>
virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
inline static PVViewer_EngineWrapper * GetEngine();
+ inline static PVSERVER_ORB::PVSERVER_Gen_var GetCPPEngine(); // to be removed once light!
inline static pqPVApplicationCore * GetPVApplication();
virtual CAM_DataModel* createDataModel();
PVViewer_GUIElements * myGuiElements;
- static PARAVIS_ORB::PARAVIS_Gen_var MyEngine;
+ static PVSERVER_ORB::PVSERVER_Gen_var MyEngine;
+
};
#endif // PVGUI_Module_H
# Use another set of Python files redirecting the API directly
# to the original ParaView modules.
LIST(APPEND _PYFILES_TO_INSTALL
- no_wrap/paravis.py
+ no_wrap/pvserver.py
no_wrap/pvsimple.py
no_wrap/presentations.py
no_wrap/paravisSM.py
+++ /dev/null
-# Copyright (C) 2010-2014 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
-#
-# File : paravis.py
-# Module : PARAVIS
-#
-
-import PARAVIS_utils
-
-## Initialize PARAVIS interface
-myParavisEngine = PARAVIS_utils.getEngine()
--- /dev/null
+# Copyright (C) 2010-2014 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
+#
+# File : paravis.py
+# Module : PARAVIS
+#
+
+import PVSERVER_utils
+
+## Initialize PARAVIS interface
+myParavisEngine = PVSERVER_utils.getEngine()
ShowParaviewView()
import paraview
-import paravis
+import pvserver
from paraview import simple
def SalomeConnectToPVServer():