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 < #==============================================================================
25 < # Module: servermanager.py
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 < #==============================================================================
36 < import paraview, re, os, os.path, new, sys, vtk
38 < if not paraview.compatibility.minor:
39 < paraview.compatibility.major = 3
40 < if not paraview.compatibility.major:
41 < paraview.compatibility.minor = 5
43 < from vtkPVClientServerCorePython import *
44 < from vtkPVServerImplementationPython import *
45 < from vtkPVServerManagerPython import *
46 < from vtkPVCommonPython import *
50 > import re, os, new, sys
51 > from paravis import *
55 < if paraview.compatibility.GetVersion() >= 3.5 and \
56 < smproperty.IsA("vtkSMStringVectorProperty"):
58 > if smproperty.IsA("vtkSMStringVectorProperty"):
60 < return self.SMProxy == other.SMProxy
61 < return self.SMProxy == other
63 > ## VSV using IsSame instead ==
64 > return self.SMProxy.IsSame(other.SMProxy)
65 > return self.SMProxy.IsSame(other)
67 < if not c.HasObserver("ModifiedEvent"):
68 < self.ObserverTag =c.AddObserver("ModifiedEvent", \
69 < _makeUpdateCameraMethod(weakref.ref(self)))
72 > # VSV: Observers are not supported
73 > ## if not c.HasObserver("ModifiedEvent"):
74 > ## self.ObserverTag =c.AddObserver("ModifiedEvent", _makeUpdateCameraMethod(weakref.ref(self)))
75 > ## self.Observed = c
77 < if paraview.compatibility.GetVersion() >= 3.5:
78 < def FileNameChanged(self):
79 < "Called when the filename changes. Selects all variables."
80 < SourceProxy.FileNameChanged(self)
81 < self.SelectAllVariables()
83 < def SelectAllVariables(self):
84 < "Select all available variables for reading."
85 < for prop in ('PointVariables', 'EdgeVariables', 'FaceVariables',
86 < 'ElementVariables', 'GlobalVariables'):
87 < f = getattr(self, prop)
90 < def DeselectAllVariables(self):
91 < "Deselects all variables."
92 < for prop in ('PointVariables', 'EdgeVariables', 'FaceVariables',
93 < 'ElementVariables', 'GlobalVariables'):
94 < f = getattr(self, prop)
97 > def FileNameChanged(self):
98 > "Called when the filename changes. Selects all variables."
99 > SourceProxy.FileNameChanged(self)
100 > self.SelectAllVariables()
102 > def SelectAllVariables(self):
103 > "Select all available variables for reading."
104 > for prop in ('PointVariables', 'EdgeVariables', 'FaceVariables',
105 > 'ElementVariables', 'GlobalVariables'):
106 > f = getattr(self, prop)
109 > def DeselectAllVariables(self):
110 > "Deselects all variables."
111 > for prop in ('PointVariables', 'EdgeVariables', 'FaceVariables',
112 > 'ElementVariables', 'GlobalVariables'):
113 > f = getattr(self, prop)
119 > if proxy.IsSame(px):
121 < if paraview.compatibility.GetVersion() <= 3.4:
122 < def Range(self, component=0):
123 < return self.GetRange(component)
126 < aProxy = self.SMProxyManager.NewProxy(group, name)
128 > aProxy = self.SMProxyManager.NewProxy(group, name, "NULL")
130 > # VTN: Observers are not supported
132 < self.DefinitionObserverTag = self.Session.GetProxyDefinitionManager().AddObserver(2000, _update_definitions)
134 > ## self.DefinitionObserverTag = self.Session.GetProxyDefinitionManager().AddObserver(2000, _update_definitions)
136 < self.CustomDefinitionObserverTag = self.Session.GetProxyDefinitionManager().AddObserver(2001, _update_definitions)
138 > ## self.CustomDefinitionObserverTag = self.Session.GetProxyDefinitionManager().AddObserver(2001, _update_definitions)
140 < try: isRep = rep.Input == aProxy
143 > try: isRep = rep.Input.IsSame(aProxy)
145 < """Turn on/off printing of progress (by default, it is on). You can
146 < always turn progress off and add your own observer to the process
147 < module to handle progress in a custom way. See _printProgress for
148 < an example event observer."""
149 < global progressObserverTag
151 < # If value is true and progress printing is currently off...
152 < if value and not GetProgressPrintingIsEnabled():
154 < raise RuntimeError("Printing progress in the GUI is not supported.")
155 < progressObserverTag = vtkProcessModule.GetProcessModule().AddObserver(\
156 < "ProgressEvent", _printProgress)
158 < # If value is false and progress printing is currently on...
159 < elif GetProgressPrintingIsEnabled():
160 < vtkProcessModule.GetProcessModule().RemoveObserver(progressObserverTag)
161 < progressObserverTag = None
163 > """Is not supported because of not supported observers"""
166 < if paraview.compatibility.GetVersion() >= 3.5:
167 < if smproxy.GetXMLLabel():
168 < xmlName = smproxy.GetXMLLabel()
170 > if smproxy.GetXMLLabel():
171 > xmlName = smproxy.GetXMLLabel()
173 < if paraview.compatibility.GetVersion() >= 3.5:
174 < return self.GetPropertyValue(propName)
176 < return self.GetProperty(propName)
178 > return self.GetPropertyValue(propName)
180 < return paraview.make_name_valid(name)
182 > """Make a string into a valid Python variable name."""
186 > valid_chars = "_%s%s" % (string.ascii_letters, string.digits)
187 > name = str().join([c for c in name if c in valid_chars])
188 > if not name[0].isalpha():
192 < if paraview.compatibility.GetVersion() >= 3.5 and\
193 < proto.GetXMLLabel():
195 > if proto.GetXMLLabel():
197 < if paraview.compatibility.GetVersion() >= 3.5:
198 < if (prop.GetInformationOnly() and propName != "TimestepValues" ) \
199 < or prop.GetIsInternal():
202 > if (prop.GetInformationOnly() and propName != "TimestepValues" ) \
203 > or prop.GetIsInternal():
206 < if paraview.compatibility.GetVersion() >= 3.5:
207 < names = [iter.PropertyLabel]
209 > names = [iter.PropertyLabel]
211 < if paraview.compatibility.GetVersion() <= 3.4:
212 < ss = sources.SphereSource(Radius=2, ThetaResolution=32)
213 < shr = filters.ShrinkFilter(Input=OutputPort(ss,0))
214 < cs = sources.ConeSource()
215 < app = filters.Append()
217 < ss = sources.Sphere(Radius=2, ThetaResolution=32)
218 < shr = filters.Shrink(Input=OutputPort(ss,0))
219 < cs = sources.Cone()
220 < app = filters.AppendDatasets()
222 > ss = sources.Sphere(Radius=2, ThetaResolution=32)
223 > shr = filters.Shrink(Input=OutputPort(ss,0))
224 > cs = sources.Cone()
225 > app = filters.AppendDatasets()
227 < if paraview.compatibility.GetVersion() <= 3.4:
228 < arraySelection = reader.PointResultArrayStatus
230 < arraySelection = reader.PointVariables
232 > arraySelection = reader.PointVariables
234 < if paraview.compatibility.GetVersion() <= 3.4:
235 < print "Range:", ai.Range(j)
237 < print "Range:", ai.GetRange(j)
239 > print "Range:", ai.GetRange(j)
241 < if paraview.compatibility.GetVersion() <= 3.4:
242 < source = sources.RTAnalyticSource()
244 < source = sources.Wavelet()
246 > source = sources.Wavelet()
248 < if paraview.compatibility.GetVersion() <= 3.4:
249 < probe = filters.Probe(Input=source)
251 < line = sources.LineSource(Resolution=60)
253 < probe = filters.ResampleWithDataset(Input=source)
255 < line = sources.Line(Resolution=60)
257 > probe = filters.ResampleWithDataset(Input=source)
259 > line = sources.Line(Resolution=60)
261 < if paraview.compatibility.GetVersion() <= 3.4:
262 < sphere = sources.SphereSource()
264 < sphere = sources.Sphere()
266 > sphere = sources.Sphere()
269 < if paraview.options.batch:
270 < pvoptions = vtkPVOptions();
271 < pvoptions.SetProcessType(0x40)
272 < if paraview.options.symmetric:
273 < pvoptions.SetSymmetricMPIMode(True)
275 > # pvoptions = None Not applicable for SALOME Python console
276 > # if paraview.options.batch:
277 > # pvoptions = vtkPVOptions();
278 > # pvoptions.SetProcessType(0x40)
279 > # if paraview.options.symmetric:
280 > # pvoptions.SetSymmetricMPIMode(True)
283 < if not paraview.fromFilter:
285 > ## VSV fromFilter is alwais False for SALOME because it can't be changed from ParaView code
286 > #if not paraview.fromFilter:
288 < connection.AttachDefinitionUpdater()
291 > # global _defUpdater
292 > # _defUpdater = __DefinitionUpdater()
293 > connection.AttachDefinitionUpdater()
296 > # Definitions for working in SALOME GUI mode
297 > #aParams = myParavis.GetConnectionParameters()
298 > #ActiveConnection = Connect()
299 > ##Connection(aParams[0])
300 > #ActiveConnection.SetHost(aParams[1], aParams[2], aParams[3], aParams[4], aParams[5])
301 > #ToggleProgressPrinting()