Salome HOME
Merge akl/tests_update: update tests
[modules/paravis.git] / src / PV_SWIG / VTKWrapping / simple.diff
1 0a1,19
2 > # Copyright (C) 2010-2014  CEA/DEN, EDF R&D
3 > #
4 > # This library is free software; you can redistribute it and/or
5 > # modify it under the terms of the GNU Lesser General Public
6 > # License as published by the Free Software Foundation; either
7 > # version 2.1 of the License, or (at your option) any later version.
8 > #
9 > # This library is distributed in the hope that it will be useful,
10 > # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 > # Lesser General Public License for more details.
13 > #
14 > # You should have received a copy of the GNU Lesser General Public
15 > # License along with this library; if not, write to the Free Software
16 > # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 > #
18 > # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 > #
20
21 21,34d39
22 < #==============================================================================
23 < #
24 < #  Program:   ParaView
25 < #  Module:    simple.py
26 < #
27 < #  Copyright (c) Kitware, Inc.
28 < #  All rights reserved.
29 < #  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
30 < #
31 < #     This software is distributed WITHOUT ANY WARRANTY; without even
32 < #     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
33 < #     PURPOSE.  See the above copyright notice for more information.
34 < #
35 < #==============================================================================
36 36,39c41
37 < import paraview
38 < paraview.compatibility.major = 3
39 < paraview.compatibility.minor = 5
40 < import servermanager
41 ---
42 > import paravisSM
43 41,42c43
44 < def enableMultiServer():
45 <     servermanager.enableMultiServer()
46 ---
47 > servermanager = paravisSM
48 44,56c45,46
49 < def switchActiveConnection(newActiveConnection=None, ns=None):
50 <     if not ns:
51 <        ns = globals()
52 <     _remove_functions(ns)
53 <     servermanager.switchActiveConnection(newActiveConnection)
54 <     _add_functions(ns)
55
56 < def Disconnect(ns=None, force=True):
57 <     if servermanager.ActiveConnection and (force or servermanager.MultiServerConnections == None):
58 <         if ns:
59 <            _remove_functions(ns)
60 <         _remove_functions(globals())
61 <         servermanager.ProxyManager().DisableStateUpdateNotification()
62 ---
63 > def _disconnect():
64 >     if servermanager.ActiveConnection:
65 61d50
66 <         servermanager.Disconnect()
67 62a52
68 >         servermanager.Disconnect()
69 69,70c59,60
70 <     Disconnect(globals(), False)
71 <     connection = servermanager.Connect(ds_host, ds_port, rs_host, rs_port)
72 ---
73 >     _disconnect()
74 >     session = servermanager.Connect(ds_host, ds_port, rs_host, rs_port)
75 73,88c63,67
76 <     servermanager.ProxyManager().DisableStateUpdateNotification()
77 <     servermanager.ProxyManager().UpdateFromRemote()
78 <     tk = servermanager.ProxyManager().GetProxy("timekeeper", "TimeKeeper")
79 <     if not tk:
80 <        tk = servermanager.misc.TimeKeeper()
81 <        servermanager.ProxyManager().RegisterProxy("timekeeper", "TimeKeeper", tk)
82
83 <     scene = servermanager.ProxyManager().GetProxy("animation", "AnimationScene")
84 <     if not scene:
85 <        scene = AnimationScene()
86 <        scene.TimeKeeper = tk
87
88 <     servermanager.ProxyManager().EnableStateUpdateNotification()
89 <     servermanager.ProxyManager().TriggerStateUpdate()
90
91 <     return connection
92 ---
93 >     tk =  servermanager.misc.TimeKeeper()
94 >     servermanager.ProxyManager().RegisterProxy("timekeeper", "tk", tk)
95 >     scene = AnimationScene()
96 >     scene.TimeKeeper = tk
97 >     return session
98 93,94c72,73
99 <     Disconnect(globals(), False)
100 <     connection = servermanager.ReverseConnect(port)
101 ---
102 >     _disconnect()
103 >     session = servermanager.ReverseConnect(port)
104 96,112c75,79
105
106 <     servermanager.ProxyManager().DisableStateUpdateNotification()
107 <     servermanager.ProxyManager().UpdateFromRemote()
108 <     tk = servermanager.ProxyManager().GetProxy("timekeeper", "TimeKeeper")
109 <     if not tk:
110 <        tk = servermanager.misc.TimeKeeper()
111 <        servermanager.ProxyManager().RegisterProxy("timekeeper", "TimeKeeper", tk)
112
113 <     scene = servermanager.ProxyManager().GetProxy("animation", "AnimationScene")
114 <     if not scene:
115 <        scene = AnimationScene()
116 <        scene.TimeKeeper = tk
117
118 <     servermanager.ProxyManager().EnableStateUpdateNotification()
119 <     servermanager.ProxyManager().TriggerStateUpdate()
120
121 <     return connection
122 ---
123 >     tk =  servermanager.misc.TimeKeeper()
124 >     servermanager.ProxyManager().RegisterProxy("timekeeper", "tk", tk)
125 >     scene = AnimationScene()
126 >     scene.TimeKeeper = tk
127 >     return session
128 121c88
129
130 ---
131 >     
132 161a129,131
133 >     reader_factor = servermanager.ProxyManager().GetReaderFactory()
134 >     if  reader_factor.GetNumberOfRegisteredPrototypes() == 0:
135 >       reader_factor.RegisterPrototypes("sources")
136 163,165d132
137 <     reader_factor = servermanager.vtkSMProxyManager.GetProxyManager().GetReaderFactory()
138 <     if reader_factor.GetNumberOfRegisteredPrototypes() == 0:
139 <       reader_factor.RegisterPrototypes(session, "sources")
140 170,171c137
141 <         msg = "File not readable: %s " % first_file
142 <         raise RuntimeError, msg
143 ---
144 >         raise RuntimeError, "File not readable: %s " % first_file
145 173,174c139
146 <         msg = "File not readable. No reader found for '%s' " % first_file
147 <         raise RuntimeError, msg
148 ---
149 >         raise RuntimeError, "File not readable. No reader found for '%s' " % first_file
150 192,193c157
151 <     session = servermanager.ActiveConnection.Session
152 <     writer_factory = servermanager.vtkSMProxyManager.GetProxyManager().GetWriterFactory()
153 ---
154 >     writer_factory = servermanager.ProxyManager().GetWriterFactory()
155 195c159
156 <         writer_factory.RegisterPrototypes(session, "writers")
157 ---
158 >         writer_factory.RegisterPrototypes("writers")
159 441c405,406
160 <         if proxy == GetActiveSource():
161 ---
162 >         #VSV:==
163 >         if proxy.IsSame(GetActiveSource()):
164 449c414,415
165 <             if rep.Input == proxy:
166 ---
167 >             #VSV:==
168 >             if rep.Input.IsSame(proxy):
169 453c419,420
170 <         if proxy == GetActiveView():
171 ---
172 >         ##VSV:==
173 >         if proxy.IsSame(GetActiveView()):
174 691,693c658,659
175 <     activeModule = servermanager.ActiveConnection.Modules
176 <     for m in [activeModule.filters, activeModule.sources,
177 <               activeModule.writers, activeModule.animation]:
178 ---
179 >     for m in [servermanager.filters, servermanager.sources,
180 >               servermanager.writers, servermanager.animation]:
181 699d664
182 <                     #print "add %s function" % key
183 703,715d667
184 < def _remove_functions(g):
185 <     list = []
186 <     if servermanager.ActiveConnection:
187 <        list = [m for m in dir(servermanager.ActiveConnection.Modules) if m[0] != '_']
188
189 <     for m in list:
190 <         dt = servermanager.ActiveConnection.Modules.__dict__[m].__dict__
191 <         for key in dt.keys():
192 <             cl = dt[key]
193 <             if not isinstance(cl, str) and g.has_key(key):
194 <                 g.pop(key)
195 <                 #print "remove %s function" % key
196
197 844c796
198 <             if cue.AnimatedProxy == proxy and\
199 ---
200 >             if cue.AnimatedProxy.IsSame(proxy) and\
201 846c798
202 <                 if index == None or index == cue.AnimatedElement:
203 ---
204 >                 if index == None or index.IsSame(cue.AnimatedElement): ##index == cue.AnimatedElement:
205 870c822
206 <         if cue.AnimatedProxy == view and\
207 ---
208 >         if cue.AnimatedProxy.IsSame(view) and\
209 887c839
210 <         if cue.GetXMLName() == "TimeAnimationCue" and cue.AnimatedProxy == tk\
211 ---
212 >         if cue.GetXMLName() == "TimeAnimationCue" and cue.AnimatedProxy.IsSame(tk)\
213 929,931c881
214 <     if not servermanager.ActiveConnection:
215 <         raise RuntimeError, "Cannot load a plugin without a session."
216 <     plm = servermanager.vtkSMProxyManager.GetProxyManager().GetPluginManager()
217 ---
218 >     plm = servermanager.ProxyManager().GetSession().GetPluginManager()
219 933,934c883
220 <         session = servermanager.ActiveConnection.Session
221 <         info = plm.GetRemoteInformation(session)
222 ---
223 >         info = plm.GetRemoteInformation()
224 942,959d890
225 < def GetLayouts():
226 <     """Returns the layout proxies on the active session.
227 <     Layout proxies are used to place views in a grid."""
228 <     return servermanager.ProxyManager().GetProxiesInGroup("layouts")
229
230 < def GetLayout(view=None):
231 <     """Return the layout containing the give view, if any.
232 <     If no view is specified, active view is used.
233 <     """
234 <     if not view:
235 <         view = GetActiveView()
236 <     if not view:
237 <         raise RuntimeError, "No active view was found."
238 <     layouts = GetLayouts()
239 <     for layout in layouts.values():
240 <         if layout.GetViewLocation(view) != -1:
241 <             return layout
242 <     return None
243 966c897
244 <     def __get_selection_model(self, name, session=None):
245 ---
246 >     def __get_selection_model(self, name):
247 968,970c899
248 <         if session and session != servermanager.ActiveConnection.Session:
249 <             raise RuntimeError, "Try to set an active object with invalid active connection."
250 <         pxm = servermanager.ProxyManager(session)
251 ---
252 >         pxm = servermanager.ProxyManager()
253 979c908
254 <         active_view_model = self.__get_selection_model("ActiveView")
255 ---
256 >         active_view_model = self.__get_selection_model("ActiveView") 
257 981d909
258 <             active_view_model = self.__get_selection_model("ActiveView", view.GetSession())
259 984d911
260 <             active_view_model = self.__get_selection_model("ActiveView")
261 994c921
262 <         active_sources_model = self.__get_selection_model("ActiveSources")
263 ---
264 >         active_sources_model = self.__get_selection_model("ActiveSources") 
265 997d923
266 <             active_sources_model = self.__get_selection_model("ActiveSources", source.GetSession())
267 1000d925
268 <             active_sources_model = self.__get_selection_model("ActiveSources")
269 1107a1033,1041
270 > def PrintTrace():
271 >     print paravisSM.myParavis.GetTrace()
272
273 > def SaveTrace(fileName):
274 >     paravisSM.myParavis.SaveTrace(fileName)
275
276
277 > _add_functions(globals())
278
279 1110,1111d1043
280 < else:
281 <     _add_functions(globals())
282 1113c1045,1046
283 < active_objects = ActiveObjects()
284 ---
285 > def ImportFile(theFileName):
286 >     paravisSM.ImportFile(theFileName)
287 1115,1129c1048,1049
288 < def _switchToActiveConnectionCallback(caller, event):
289 <    if servermanager:
290 <       session = servermanager.vtkSMProxyManager.GetProxyManager().GetActiveSession()
291 <       if session and ((not servermanager.ActiveConnection) or session != servermanager.ActiveConnection.Session):
292 <          switchActiveConnection(servermanager.GetConnectionFromSession(session))
293
294 < class ActiveSessionObserver:
295 <     def __init__(self):
296 <         self.ObserverTag = servermanager.vtkSMProxyManager.GetProxyManager().AddObserver(9753, _switchToActiveConnectionCallback)
297
298 <     def __del__(self):
299 <         if servermanager:
300 <             servermanager.vtkSMProxyManager.GetProxyManager().RemoveObserver(self.ObserverTag)
301
302 < active_session_observer = ActiveSessionObserver()
303 ---
304 > active_objects = ActiveObjects()
305 > active_objects.view = GetRenderView()