Back to index

salome-paravis  6.5.0
paravis.py
Go to the documentation of this file.
00001 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 #  File   : paravis.py
00020 #  Module : PARAVIS
00021 #
00022 
00023 import os, new
00024 
00025 import PARAVIS
00026 import SALOME
00027 import SALOME_Session_idl
00028 import SALOMEDS
00029 import SALOME_ModuleCatalog
00030 from omniORB import CORBA
00031 from time import sleep
00032 from salome import *
00033 
00034 myORB = None
00035 myNamingService = None
00036 myLifeCycleCORBA = None
00037 myNamingService = None
00038 myLocalStudyManager = None
00039 myLocalStudy = None
00040 myLocalParavis = None
00041 myDelay = None
00042 mySession = None
00043 
00044 ## Initialization of paravis server
00045 def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
00046     global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
00047     global mySession, myDelay
00048     myDelay = theDelay
00049     myORB = theORB
00050     myNamingService = theNamingService
00051     myLifeCycleCORBA = theLifeCycleCORBA
00052     myLocalStudyManager = theStudyManager
00053     while mySession == None:
00054         mySession = myNamingService.Resolve("/Kernel/Session")
00055     mySession = mySession._narrow(SALOME.Session)
00056     mySession.GetInterface()
00057     myDelay = theDelay
00058     sleep(myDelay)
00059     myLocalParavis = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "PARAVIS")
00060     myLocalStudy = theStudy
00061     myLocalParavis.SetCurrentStudy(myLocalStudy)
00062     myLocalParavis.ActivateModule()
00063     return myLocalParavis
00064 
00065 
00066 def ImportFile(theFileName):
00067     "Import a file of any format supported by ParaView"
00068     myParavis.ImportFile(theFileName)
00069 
00070 
00071 def createFunction(theName):
00072     "Create function - constructor of Paravis object"
00073     def MyFunction():
00074         return myParavis.CreateClass(theName)
00075     return MyFunction
00076 
00077 
00078 def createConstructors():
00079     "Create constructor functions according to list of extracted classes"
00080     g = globals()
00081     aClassNames = myParavis.GetClassesList();
00082     for aName in aClassNames:
00083         g[aName] = createFunction(aName)
00084 
00085 ## Initialize of a PARAVIS interface  
00086 myParavis = Initialize(orb, naming_service,lcc,myStudyManager,myStudy, 2)
00087 
00088 ## Initialize constructor functions
00089 createConstructors()
00090 
00091 ## Initialize Paravis static objects
00092 vtkSMObject = vtkSMObject()
00093 vtkProcessModule = vtkProcessModule()
00094 vtkPVPythonModule = vtkPVPythonModule()
00095 vtkSMProxyManager = vtkSMProxyManager()
00096 
00097