Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
__version__ = 0
# The `Outline` filter which can either be an instance of
# `OutlineFilter` or `OutlineCornerFilter`. The `ObjectBase` class
# is the superclass of both the `OutlineFilter` and the
# `OutlineCornerFilter`.
outline_filter = Property(Instance(tvtk.ObjectBase,
allow_none=False), record=True)
# Enum to set the outline type.
outline_mode = Enum('full', 'cornered',
desc='if outline mode is "full" or "cornered"')
actor = Instance(Actor, allow_none=False, record=True)
input_info = PipelineInfo(datasets=['any'],
attribute_types=['any'],
attributes=['any'])
# An outline source, optionally used to choose the bounds of the
# outline.
outline_source = Instance(tvtk.OutlineSource, ())
bounds = DelegatesTo('outline_source',
desc="the bounds of the outline: xmin, xmax, ymin, ymax")
manual_bounds = Bool(
desc="whether the bounds are automatically inferred from "
"the data source")
# Create the UI for the traits.
class GreedyTerrainDecimation(FilterBase):
""" Performs a triangulation of image data after simplifying it. """
# The version of this class. Used for persistence.
__version__ = 0
# The actual TVTK filter that this class manages.
filter = Instance(tvtk.GreedyTerrainDecimation, args=(),
allow_none=False, record=True)
input_info = PipelineInfo(datasets=['any'],
attribute_types=['any'],
attributes=['any'])
output_info = PipelineInfo(datasets=['poly_data'],
attribute_types=['any'],
attributes=['any'])
cutter = Instance(Cutter, allow_none=False, record=True)
# The WarpVectorCutPlane component that warps the data.
warp_vector = Instance(WarpVector, allow_none=False, record=True)
# Specify if vector normals are to be computed to make a smoother surface.
compute_normals = Bool(False, desc='if normals are to be computed '\
'to make the warped surface smoother')
# The component that computes the normals.
normals = Instance(PolyDataNormals, record=True)
# The Actor component.
actor = Instance(Actor, allow_none=False, record=True)
input_info = PipelineInfo(datasets=['any'],
attribute_types=['any'],
attributes=['vectors'])
########################################
# View related traits.
_warp_group = Group(Item(name='filter',
style='custom',
editor=\
InstanceEditor(view=
View(Item('scale_factor')))),
show_labels=False)
view = View(Group(Item(name='implicit_plane', style='custom'),
label='ImplicitPlane',
show_labels=False),
######################################################################
# `VRMLImporter` class.
######################################################################
class VRMLImporter(Source):
__version__ = 0
# The file name.
file_name = Str('', enter_set=True, auto_set=False,
desc='the VRML file name')
# The VRML importer.
reader = Instance(tvtk.VRMLImporter, args=(), allow_none=False,
record=True)
output_info = PipelineInfo(datasets=['none'])
###############
# Private traits.
# Our file path used for persistence
_file_path = Instance(FilePath, args=())
# Our View.
view = View(Item(name='file_name', editor=FileEditor()))
######################################################################
# `object` interface
######################################################################
def __get_pure_state__(self):
d = super(VRMLImporter, self).__get_pure_state__()
# These traits are dynamically created.
# The (optional) components used by this module. NOTE: This is
# not pickled. It is the developers responsibility to setup the
# components when the component traits are set in the handler.
components = List(record=False)
# The icon
icon = Str('module.ico')
# The human-readable type for this object
type = Str(' module')
# Information about what this object can consume.
input_info = PipelineInfo(datasets=['any'])
# Information about what this object can produce.
output_info = PipelineInfo(datasets=['none'])
######################################################################
# `object` interface.
######################################################################
def __init__(self, **traits):
super(Module, self).__init__(**traits)
# Let the module setup its pipeline.
self.setup_pipeline()
def __get_pure_state__(self):
d = super(Module, self).__get_pure_state__()
for x in ('module_manager', 'components'):
d.pop(x, None)
return d
from mayavi.filters.collection import Collection
from mayavi.core.pipeline_info import PipelineInfo
################################################################################
# `CutPlane` class.
################################################################################
class CutPlane(Collection):
"""
This class represents a cut plane that can be used to slice through
any dataset. It also provides a 3D widget interface to position and
move the slice interactively.
"""
# The version of this class. Used for persistence.
__version__ = 0
input_info = PipelineInfo(datasets=['any'],
attribute_types=['any'],
attributes=['any'])
output_info = PipelineInfo(datasets=['poly_data'],
attribute_types=['any'],
attributes=['any'])
######################################################################
# `Filter` interface.
######################################################################
def setup_pipeline(self):
"""Creates the pipeline."""
ip = ImplicitPlane()
cut = Cutter(cut_function=ip.plane)
self.filters = [ip, cut]
class ExtractVectorComponents(FilterBase):
""" This wraps the TVTK ExtractVectorComponents filter and allows
one to select any of the three components of an input vector data
attribute."""
# The version of this class. Used for persistence.
__version__ = 0
# The actual TVTK filter that this class manages.
filter = Instance(tvtk.ExtractVectorComponents, args=(), allow_none=False)
# The Vector Component to be extracted
component = Enum('x-component', 'y-component', 'z-component',
desc='component of the vector to be extracted')
input_info = PipelineInfo(datasets=['any'],
attribute_types=['any'],
attributes=['vectors'])
output_info = PipelineInfo(datasets=['any'],
attribute_types=['any'],
attributes=['any'])
view = View(Group(Item(name='component')),
resizable=True
)
######################################################################
# `Filter` interface.
######################################################################
def update_pipeline(self):
# Do nothing if there is no input.
# The actors generated by this object that will be rendered on the
# scene. Changing this list while the actors are renderered *is*
# safe and will do the right thing.
actors = List(record=False)
# The optional list of actors belonging to this object. These
# will be added to the scene at an appropriate time. Changing
# this list while the widgets are renderered *is* safe and will do
# the right thing.
widgets = List(record=False)
# Information about what this object can consume.
input_info = Instance(PipelineInfo)
# Information about what this object can produce.
output_info = Instance(PipelineInfo)
########################################
# Events.
# This event is fired when the pipeline has changed.
pipeline_changed = Event(record=False)
# This event is fired when the data alone changes but the pipeline
# outputs are the same.
data_changed = Event(record=False)
##################################################
# Private traits.
##################################################
# Identifies if `actors` and `widgets` are added to the `scene` or
# not.
######################################################################
# `PolyDataNormals` class.
######################################################################
class PolyDataNormals(PolyDataFilterBase):
"""Computes normals from input data. This gives meshes a smoother
appearance. This should work for any input dataset.
"""
# The version of this class. Used for persistence.
__version__ = 0
# The actual TVTK filter that this class manages.
filter = Instance(tvtk.PolyDataNormals, args=(), allow_none=False, record=True)
input_info = PipelineInfo(datasets=['poly_data'],
attribute_types=['any'],
attributes=['any'])
output_info = PipelineInfo(datasets=['poly_data'],
attribute_types=['any'],
attributes=['any'])
__version__ = 0
# The implicit plane widget used to place the implicit function.
implicit_plane = Instance(ImplicitPlane, allow_none=False,
record=True)
# The cutter. Takes a cut of the data on the implicit plane.
cutter = Instance(Cutter, allow_none=False, record=True)
# The Glyph component.
glyph = Instance(Glyph, allow_none=False, record=True)
# The Glyph component.
actor = Instance(Actor, allow_none=False, record=True)
input_info = PipelineInfo(datasets=['any'],
attribute_types=['any'],
attributes=['vectors'])
########################################
# View related traits.
view = View(Group(Item(name='implicit_plane', style='custom'),
label='ImplicitPlane',
show_labels=False),
Group(Item(name='glyph', style='custom', resizable=True),
label='Glyph',
show_labels=False),
Group(Item(name='actor', style='custom'),
label='Actor',
show_labels=False),
)