Salome HOME
Merge from BR_PARAVIS_DEV 29Dec09
[modules/paravis.git] / src / PV_SWIG / paravis.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 #  VISU VISU_SWIG : binding of C++ implementation and Python
23 #  File   : paravis.py
24 #  Module : PARAVIS
25 #
26
27 import os, new
28
29 import PARAVIS
30 import SALOME
31 import SALOME_Session_idl
32 import SALOMEDS
33 import SALOME_ModuleCatalog
34 from omniORB import CORBA
35 from time import sleep
36 from salome import *
37
38 myORB = None
39 myNamingService = None
40 myLifeCycleCORBA = None
41 myNamingService = None
42 myLocalStudyManager = None
43 myLocalStudy = None
44 myLocalParavis = None
45 myDelay = None
46 mySession = None
47
48 ## Initialization of paravis server
49 def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
50     global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
51     global mySession, myDelay
52     myDelay = theDelay
53     myORB = theORB
54     myNamingService = theNamingService
55     myLifeCycleCORBA = theLifeCycleCORBA
56     myLocalStudyManager = theStudyManager
57     while mySession == None:
58         mySession = myNamingService.Resolve("/Kernel/Session")
59     mySession = mySession._narrow(SALOME.Session)
60     mySession.GetInterface()
61     myDelay = theDelay
62     sleep(myDelay)
63     myLocalParavis = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "PARAVIS")
64     myLocalStudy = theStudy
65     myLocalParavis.ActivateModule()
66     return myLocalParavis
67
68
69 def ImportFile(theFileName):
70     "Import a file of any format supported by ParaView"
71     myParavis.ImportFile(theFileName)
72
73
74 def createFunction(theName):
75     "Create function - constructor of Paravis object"
76     def MyFunction():
77         return myParavis.CreateClass(theName)
78     return MyFunction
79
80
81 def createConstructors():
82     "Create constructor functions according to list of extracted classes"
83     g = globals()
84     aClassNames = myParavis.GetClassesList();
85     for aName in aClassNames:
86         g[aName] = createFunction(aName)
87
88 ## Initialize of a PARAVIS interface  
89 myParavis = Initialize(orb, naming_service,lcc,myStudyManager,myStudy, 2)
90
91 ## Initialize constructor functions
92 createConstructors()
93
94 ## Initialize Paravis static objects
95 vtkSMObject = vtkSMObject()
96 vtkProcessModule = vtkProcessModule()
97 vtkPVPythonModule = vtkPVPythonModule()
98 vtkSMProxyManager = vtkSMProxyManager()
99
100