New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix "_p_void" values in TVTK with VTK 6.x #370
Changes from 4 commits
32dbd6e
7f5d4d4
d41a95f
6db2ddc
1e4b819
7c8f967
7a30bdd
f03798b
a68b520
07c9f9d
1ea5cce
559c567
117b4d4
10a3838
8f07d82
ad538ef
52cae16
7088434
b619f45
c95e5ab
f88c7c8
286e27c
350c1f6
491f88e
c1e1f46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,10 +199,11 @@ def info(self): | |
|
||
def vtk_color_trait(default, **metadata): | ||
Range = traits.Range | ||
|
||
if default[0] == -1.0: | ||
# Occurs for the vtkTextProperty's color trait. Need to work | ||
# around. | ||
return traits.Trait(default, traits.Tuple(*default), | ||
return traits.Trait(default, | ||
traits.Tuple(Range(0.0, 1.0), | ||
Range(0.0, 1.0), | ||
Range(0.0, 1.0), | ||
|
@@ -212,7 +213,8 @@ def vtk_color_trait(default, **metadata): | |
return traits.Trait(traits.Tuple(Range(0.0, 1.0, default[0]), | ||
Range(0.0, 1.0, default[1]), | ||
Range(0.0, 1.0, default[2])), | ||
editor=RGBColorEditor, **metadata) | ||
editor=RGBColorEditor, | ||
**metadata) | ||
else: | ||
return traits.Trait( | ||
traits.Tuple( | ||
|
@@ -272,6 +274,11 @@ class TVTKBase(traits.HasStrictTraits): | |
# The wrapped VTK object. | ||
_vtk_obj = traits.Trait(None, None, vtk.vtkObjectBase()) | ||
|
||
# Stores the names of the traits whose VTK Get methods may return | ||
# invalid values (e.g. reference to a point) or uninitialised values | ||
# We would try to update but allow it to failure | ||
_allow_update_failure_ = traits.Tuple | ||
|
||
# Stores the names of the traits that need to be updated. | ||
_updateable_traits_ = traits.Tuple | ||
|
||
|
@@ -471,15 +478,28 @@ def update_traits(self, obj=None, event=None): | |
vtk.vtkObject.GlobalWarningDisplayOff() | ||
|
||
for name, getter in self._updateable_traits_: | ||
if name == 'global_warning_display': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about this one ? what makes it special? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is not originally my code, I just moved it out of the try block. So I don't know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. Leave it as is. We can't know everything. |
||
setattr(self, name, warn) | ||
continue | ||
|
||
try: | ||
val = getattr(vtk_obj, getter)() | ||
except (AttributeError, TypeError): | ||
# Some vtk GetMethod accepts more than 1 arguments | ||
# FIXME: If we really want to try harder, we could | ||
# pass an empty array to the Get method, some Get | ||
# method will populate the array as the return | ||
# value (e.g. vtkImageConvolve.GetKernel3x3 and alike) | ||
pass | ||
else: | ||
if name == 'global_warning_display': | ||
setattr(self, name, warn) | ||
else: | ||
try: | ||
setattr(self, name, val) | ||
except traits.TraitError: | ||
if name in self._allow_update_failure_: | ||
pass | ||
else: | ||
raise | ||
|
||
# Reset the warning state. | ||
vtk.vtkObject.SetGlobalWarningDisplay(warn) | ||
self._in_set = 0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,13 +69,12 @@ class or instance. | |
object. Here is an example:: | ||
|
||
>>> import vtk | ||
>>> p = VTKMethodParser() | ||
>>> o = vtk.vtkProperty | ||
>>> print p.get_method_signature(o.GetClassName) | ||
>>> print VTKMethodParser.get_method_signature(o.GetClassName) | ||
[(['string'], None)] | ||
>>> print p.get_method_signature(o.GetColor)[0] | ||
>>> print VTKMethodParser.get_method_signature(o.GetColor)[0] | ||
([('float', 'float', 'float')], None) | ||
>>> print p.get_method_signature(o.GetColor)[1] | ||
>>> print VTKMethodParser.get_method_signature(o.GetColor)[1] | ||
([None], (('float', 'float', 'float'),)) | ||
|
||
The `get_method_signature` is fairly efficient and obtaining the | ||
|
@@ -295,7 +294,8 @@ def get_other_methods(self): | |
""" | ||
return self.other_meths | ||
|
||
def get_method_signature(self, method): | ||
@staticmethod | ||
def get_method_signature(method): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are many occurrence of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave it as is. not top priority. If you want, open a issue tagged refactoring. |
||
"""Returns information on the Python method signature given | ||
the VTK method. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"allow it to fail" :)