2 > # Copyright (C) 2010-2014 CEA/DEN, EDF R&D
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.
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.
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
18 > # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 < #==============================================================================
27 < # Copyright (c) Kitware, Inc.
28 < # All rights reserved.
29 < # See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
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.
35 < #==============================================================================
38 < paraview.compatibility.major = 3
39 < paraview.compatibility.minor = 5
40 < import servermanager
44 < def enableMultiServer():
45 < servermanager.enableMultiServer()
47 > servermanager = paravisSM
49 < def switchActiveConnection(newActiveConnection=None, ns=None):
52 < _remove_functions(ns)
53 < servermanager.switchActiveConnection(newActiveConnection)
56 < def Disconnect(ns=None, force=True):
57 < if servermanager.ActiveConnection and (force or servermanager.MultiServerConnections == None):
59 < _remove_functions(ns)
60 < _remove_functions(globals())
61 < servermanager.ProxyManager().DisableStateUpdateNotification()
64 > if servermanager.ActiveConnection:
66 < servermanager.Disconnect()
68 > servermanager.Disconnect()
70 < Disconnect(globals(), False)
71 < connection = servermanager.Connect(ds_host, ds_port, rs_host, rs_port)
74 > session = servermanager.Connect(ds_host, ds_port, rs_host, rs_port)
76 < servermanager.ProxyManager().DisableStateUpdateNotification()
77 < servermanager.ProxyManager().UpdateFromRemote()
78 < tk = servermanager.ProxyManager().GetProxy("timekeeper", "TimeKeeper")
80 < tk = servermanager.misc.TimeKeeper()
81 < servermanager.ProxyManager().RegisterProxy("timekeeper", "TimeKeeper", tk)
83 < scene = servermanager.ProxyManager().GetProxy("animation", "AnimationScene")
85 < scene = AnimationScene()
86 < scene.TimeKeeper = tk
88 < servermanager.ProxyManager().EnableStateUpdateNotification()
89 < servermanager.ProxyManager().TriggerStateUpdate()
93 > tk = servermanager.misc.TimeKeeper()
94 > servermanager.ProxyManager().RegisterProxy("timekeeper", "tk", tk)
95 > scene = AnimationScene()
96 > scene.TimeKeeper = tk
99 < Disconnect(globals(), False)
100 < connection = servermanager.ReverseConnect(port)
103 > session = servermanager.ReverseConnect(port)
106 < servermanager.ProxyManager().DisableStateUpdateNotification()
107 < servermanager.ProxyManager().UpdateFromRemote()
108 < tk = servermanager.ProxyManager().GetProxy("timekeeper", "TimeKeeper")
110 < tk = servermanager.misc.TimeKeeper()
111 < servermanager.ProxyManager().RegisterProxy("timekeeper", "TimeKeeper", tk)
113 < scene = servermanager.ProxyManager().GetProxy("animation", "AnimationScene")
115 < scene = AnimationScene()
116 < scene.TimeKeeper = tk
118 < servermanager.ProxyManager().EnableStateUpdateNotification()
119 < servermanager.ProxyManager().TriggerStateUpdate()
123 > tk = servermanager.misc.TimeKeeper()
124 > servermanager.ProxyManager().RegisterProxy("timekeeper", "tk", tk)
125 > scene = AnimationScene()
126 > scene.TimeKeeper = tk
133 > reader_factor = servermanager.ProxyManager().GetReaderFactory()
134 > if reader_factor.GetNumberOfRegisteredPrototypes() == 0:
135 > reader_factor.RegisterPrototypes("sources")
137 < reader_factor = servermanager.vtkSMProxyManager.GetProxyManager().GetReaderFactory()
138 < if reader_factor.GetNumberOfRegisteredPrototypes() == 0:
139 < reader_factor.RegisterPrototypes(session, "sources")
141 < msg = "File not readable: %s " % first_file
142 < raise RuntimeError, msg
144 > raise RuntimeError, "File not readable: %s " % first_file
146 < msg = "File not readable. No reader found for '%s' " % first_file
147 < raise RuntimeError, msg
149 > raise RuntimeError, "File not readable. No reader found for '%s' " % first_file
151 < session = servermanager.ActiveConnection.Session
152 < writer_factory = servermanager.vtkSMProxyManager.GetProxyManager().GetWriterFactory()
154 > writer_factory = servermanager.ProxyManager().GetWriterFactory()
156 < writer_factory.RegisterPrototypes(session, "writers")
158 > writer_factory.RegisterPrototypes("writers")
160 < if proxy == GetActiveSource():
163 > if proxy.IsSame(GetActiveSource()):
165 < if rep.Input == proxy:
168 > if rep.Input.IsSame(proxy):
170 < if proxy == GetActiveView():
173 > if proxy.IsSame(GetActiveView()):
175 < activeModule = servermanager.ActiveConnection.Modules
176 < for m in [activeModule.filters, activeModule.sources,
177 < activeModule.writers, activeModule.animation]:
179 > for m in [servermanager.filters, servermanager.sources,
180 > servermanager.writers, servermanager.animation]:
182 < #print "add %s function" % key
184 < def _remove_functions(g):
186 < if servermanager.ActiveConnection:
187 < list = [m for m in dir(servermanager.ActiveConnection.Modules) if m[0] != '_']
190 < dt = servermanager.ActiveConnection.Modules.__dict__[m].__dict__
191 < for key in dt.keys():
193 < if not isinstance(cl, str) and g.has_key(key):
195 < #print "remove %s function" % key
198 < if cue.AnimatedProxy == proxy and\
200 > if cue.AnimatedProxy.IsSame(proxy) and\
202 < if index == None or index == cue.AnimatedElement:
204 > if index == None or index.IsSame(cue.AnimatedElement): ##index == cue.AnimatedElement:
206 < if cue.AnimatedProxy == view and\
208 > if cue.AnimatedProxy.IsSame(view) and\
210 < if cue.GetXMLName() == "TimeAnimationCue" and cue.AnimatedProxy == tk\
212 > if cue.GetXMLName() == "TimeAnimationCue" and cue.AnimatedProxy.IsSame(tk)\
214 < if not servermanager.ActiveConnection:
215 < raise RuntimeError, "Cannot load a plugin without a session."
216 < plm = servermanager.vtkSMProxyManager.GetProxyManager().GetPluginManager()
218 > plm = servermanager.ProxyManager().GetSession().GetPluginManager()
220 < session = servermanager.ActiveConnection.Session
221 < info = plm.GetRemoteInformation(session)
223 > info = plm.GetRemoteInformation()
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")
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.
235 < view = GetActiveView()
237 < raise RuntimeError, "No active view was found."
238 < layouts = GetLayouts()
239 < for layout in layouts.values():
240 < if layout.GetViewLocation(view) != -1:
244 < def __get_selection_model(self, name, session=None):
246 > def __get_selection_model(self, name):
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)
252 > pxm = servermanager.ProxyManager()
254 < active_view_model = self.__get_selection_model("ActiveView")
256 > active_view_model = self.__get_selection_model("ActiveView")
258 < active_view_model = self.__get_selection_model("ActiveView", view.GetSession())
260 < active_view_model = self.__get_selection_model("ActiveView")
262 < active_sources_model = self.__get_selection_model("ActiveSources")
264 > active_sources_model = self.__get_selection_model("ActiveSources")
266 < active_sources_model = self.__get_selection_model("ActiveSources", source.GetSession())
268 < active_sources_model = self.__get_selection_model("ActiveSources")
271 > print paravisSM.myParavis.GetTrace()
273 > def SaveTrace(fileName):
274 > paravisSM.myParavis.SaveTrace(fileName)
277 > _add_functions(globals())
281 < _add_functions(globals())
283 < active_objects = ActiveObjects()
285 > def ImportFile(theFileName):
286 > paravisSM.ImportFile(theFileName)
288 < def _switchToActiveConnectionCallback(caller, event):
290 < session = servermanager.vtkSMProxyManager.GetProxyManager().GetActiveSession()
291 < if session and ((not servermanager.ActiveConnection) or session != servermanager.ActiveConnection.Session):
292 < switchActiveConnection(servermanager.GetConnectionFromSession(session))
294 < class ActiveSessionObserver:
295 < def __init__(self):
296 < self.ObserverTag = servermanager.vtkSMProxyManager.GetProxyManager().AddObserver(9753, _switchToActiveConnectionCallback)
300 < servermanager.vtkSMProxyManager.GetProxyManager().RemoveObserver(self.ObserverTag)
302 < active_session_observer = ActiveSessionObserver()
304 > active_objects = ActiveObjects()
305 > active_objects.view = GetRenderView()