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