Attributes
- DOING_UPDATE
This is just a dummy integer (MUST be > 1) that indicates that we are updating the traits and there is no need to change the underlying VTK object.
DOING_UPDATE = 10
Method summary
- __getinitargs__(self)
- __getstate__(self)
- __init__(self, klass, obj = None, update = True, **traits)
- __setstate__(self, dict)
- __str__(self)
- class_trait_view_elements(cls)
- setup_observers(self)
- teardown_observers(self)
- update_traits(self, obj = None, event = None)
Methods
- __getinitargs__(self)
This is merely a placeholder so that subclasses can override this if needed. This is called by __setstate__ because traits.HasTrait is a newstyle class.
- __getstate__(self)
Support for primitive pickling. Only the basic state is pickled.
- __init__(self, klass, obj = None, update = True, **traits)
Object initialization.
Parameters
klass: vtkObjectBase
A VTK class to wrap. If obj is passed, its class must be the same as klass or a subclass of it.
obj: vtkObjectBase (default: None)
An optional VTK object. If passed the passed object is wrapped. This defaults to None where a new VTK instance of class, klass is created.
update: bool (default: True)
If True (default), the traits of the class are automatically updated based on the state of the wrapped VTK object. If False, no updation is performed. This is particularly useful when the object is being unpickled.
traits: dict
A dictionary having the names of the traits as its keys. This allows a user to set the traits of the object while creating the object.
- __setstate__(self, dict)
Support for primitive pickling. Only the basic state is pickled.
- __str__(self)
Return a nice string representation of the object.
This merely returns the result of str on the underlying VTK object.
- class_trait_view_elements(cls)
Returns the ViewElements object associated with the class.
The returned object can be used to access all the view elements associated with the class.
Overridden here to search through a particular directory for substitute views to use for this tvtk object. The view should be declared in a file named <class name>_view. We execute this file and replace any currently defined view elements with view elements declared in this file (that have the same name).
- setup_observers(self)
Add an observer for the ModifiedEvent so the traits are kept up-to-date with the wrapped VTK object and do it in a way that avoids reference cycles.
- teardown_observers(self)
Remove the observer for the Modified event.
- update_traits(self, obj = None, event = None)
Updates all the 'updateable' traits of the object.
The method works by getting the current value from the wrapped VTK object. self._updateable_traits_ stores a tuple of tuples containing the trait name followed by the name of the get method to use on the wrapped VTK object.
The obj and event parameters may be ignored and are not used in the function. They exist only for compatibility with the VTK observer callback functions.