Commit 96ce074a authored by Mathieu Westphal's avatar Mathieu Westphal Committed by Kitware Robot

Merge topic 'ImprovePythonPropertiesSupport'

d54a67e7 Improve python support for domain based property
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Utkarsh Ayachit's avatarUtkarsh Ayachit <utkarsh.ayachit@kitware.com>
Acked-by: Michael Migliore's avatarMichael Migliore <michael.migliore@kitware.com>
Merge-request: !3262
parents f297c557 d54a67e7
Pipeline #148099 failed with stage
in 0 seconds
# Improve python properties support
Improving Python Properties support by returning the property instead of the value for domain based properties.
Which allows to do the following:
rep = GetDisplayProperties()
rep.Representation.Available
['3D Glyphs', 'Feature Edges', 'Outline', 'Point Gaussian', 'Points', 'Slice', 'Surface', 'Surface With Edges', 'Volume', 'Wireframe']
......@@ -351,11 +351,17 @@ class Proxy(object):
"""Returns a scalar for properties with 1 elements, the property
itself for vectors."""
p = self.GetProperty(name)
if isinstance(p, VectorProperty):
if paraview.compatibility.GetVersion() <= 4.1 and name == "ColorArrayName":
# Return ColorArrayName as just the array name for backwards compatibility.
return p[1]
elif p.GetNumberOfElements() == 1 and not p.GetRepeatable():
if isinstance(p, VectorProperty) and paraview.compatibility.GetVersion() <= 4.1 and name == "ColorArrayName":
# Return ColorArrayName as just the array name for backwards compatibility.
return p[1]
if isinstance(p, EnumerationProperty) or \
isinstance(p, ArraySelectionProperty) or \
isinstance(p, StringListProperty) or \
isinstance(p, ArrayListProperty):
# with domain based property, return the property to provide access to Available method
return p
elif isinstance(p, VectorProperty):
if p.GetNumberOfElements() == 1 and not p.GetRepeatable():
if p.SMProperty.IsA("vtkSMStringVectorProperty") or not p.GetArgumentIsArray():
return p[0]
elif isinstance(p, InputProperty):
......@@ -659,6 +665,16 @@ class Property(object):
self.SMProperty = smproperty
self.Proxy = proxy
def __eq__(self, other):
"Returns true if the properties or properties values are the same."
return ((self is None and other is None) or
(self is not None and other is not None and self.__repr__() == other.__repr__()))
if sys.version_info < (3,):
def __ne__(self, other):
"Returns true if the properties or properties values are not the same."
return not self.__eq__(other)
def __repr__(self):
"""Returns a string representation containing property name
and value"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment