10
10
# Copyright (c) 2007, Enthought, Inc.
11
11
# License: BSD Style.
13
from enthought.traits.api import Trait, CArray, Instance, CFloat, Enum, \
14
Any, false, TraitTuple, Range
13
from enthought.traits.api import Trait, CArray, Instance, CFloat, \
14
Any, false, TraitTuple, Range, Bool
15
15
from pipe_base import PipeFactory, make_function
16
16
import enthought.mayavi.modules.api as modules
17
17
from enthought.tvtk.api import tvtk
19
19
from enthought.mayavi.core.lut_manager import lut_mode_list
22
__all__ = [ 'vectors', 'glyph', 'streamline', 'volume', 'surface',
23
'isosurface', 'contoursurface', 'image', 'imageplanewidget',
24
'scalarcutplane', 'contourgridplane', 'customgridplane', 'gridplane',
25
'hyperstreamline', 'sliceunstructuredgrid', 'structuredgridoutline',
26
'tensorglyph', 'vectorcutplane', 'warpvectorcutplane',
22
29
##############################################################################
23
30
# Abstract module classes
24
31
##############################################################################
33
40
def _color_changed(self):
35
42
self._target.actor.property.color = self.color
36
if hasattr(self._target.actor.mapper, "scalarvisibility"):
43
if hasattr(self._target.actor.mapper, "scalar_visibility"):
37
44
self._target.actor.mapper.scalar_visibility = False
38
45
if hasattr(self._target, "property"):
39
46
self._target.property.color = self.color
49
help="""The overall opacity of the vtk object.""")
51
def _opacity_changed(self):
53
self._target.actor.property.opacity = self.opacity
54
except AttributeError:
56
self._target.property.opacity = self.opacity
57
except AttributeError:
42
60
##############################################################################
43
61
class DataModuleFactory(ModuleFactory):
267
298
self._contours_changed()
270
isosurface = make_function(IsoSurfaceFactory)
301
contoursurface = make_function(ContourSurfaceFactory)
303
##############################################################################
304
class ImageActorFactory(DataModuleFactory):
305
"""Applies the ImageActor mayavi module to the given VTK data object."""
306
_target = Instance(modules.ImageActor, ())
308
interpolate = Bool(True, adapts='actor.interpolate',
309
desc="""if the pixels in the image are to be
310
interpolated or not.""")
312
opacity = Range(0.0, 1.0, 1.0, adapts='actor.opacity',
313
desc="""the opacity of the image.""")
316
image = make_function(ImageActorFactory)
319
##############################################################################
320
class ImagePlaneWidgetFactory(DataModuleFactory):
321
"""Applies the ImagePlaneWidget mayavi module to the given VTK data
323
_target = Instance(modules.ImagePlaneWidget, ())
326
imageplanewidget = make_function(ImagePlaneWidgetFactory)
329
##############################################################################
330
class ScalarCutPlaneFactory(DataModuleFactory):
331
"""Applies the ScalarCutImagePlane mayavi module to the given VTK data
333
_target = Instance(modules.ScalarCutPlane, ())
336
scalarcutplane = make_function(ScalarCutPlaneFactory)
339
##############################################################################
340
class ContourGridPlaneFactory(ContourModuleFactory):
341
"""Applies the ContourGridPlane mayavi module to the given VTK data
343
_target = Instance(modules.ContourGridPlane, ())
345
contourgridplane = make_function(ContourGridPlaneFactory)
348
##############################################################################
349
class CustomGridPlaneFactory(ContourModuleFactory):
350
"""Applies the CustomGridPlane mayavi module to the given VTK data
352
_target = Instance(modules.CustomGridPlane, ())
354
customgridplane = make_function(CustomGridPlaneFactory)
357
##############################################################################
358
class GridPlaneFactory(DataModuleFactory):
359
"""Applies the GridPlane mayavi module to the given VTK data object."""
360
_target = Instance(modules.GridPlane, ())
362
gridplane = make_function(GridPlaneFactory)
365
##############################################################################
366
class HyperStreamlineFactory(DataModuleFactory):
367
"""Applies the HyperStreamline mayavi module to the given VTK data
369
_target = Instance(modules.HyperStreamline, ())
371
hyperstreamline = make_function(HyperStreamlineFactory)
374
##############################################################################
375
class SliceUnstructuredGridFactory(DataModuleFactory):
376
"""Applies the SliceUnstructuredGrid mayavi module to the given VTK data
378
_target = Instance(modules.SliceUnstructuredGrid, ())
380
sliceunstructuredgrid = make_function(SliceUnstructuredGridFactory)
383
##############################################################################
384
class StructuredGridOutlineFactory(DataModuleFactory):
385
"""Applies the StructuredGridOutline mayavi module to the given VTK data
387
_target = Instance(modules.StructuredGridOutline, ())
389
structuredgridoutline = make_function(StructuredGridOutlineFactory)
392
##############################################################################
393
class TensorGlyphFactory(DataModuleFactory):
394
"""Applies the TensorGlyph mayavi module to the given VTK data object."""
395
_target = Instance(modules.TensorGlyph, ())
397
tensorglyph = make_function(TensorGlyphFactory)
400
##############################################################################
401
class VectorCutPlaneFactory(DataModuleFactory):
402
"""Applies the VectorCutPlane mayavi module to the given VTK data object."""
403
_target = Instance(modules.VectorCutPlane, ())
405
vectorcutplane = make_function(VectorCutPlaneFactory)
408
##############################################################################
409
class WarpVectorCutPlaneFactory(DataModuleFactory):
410
"""Applies the WarpVectorCutPlane mayavi module to the given VTK data
412
_target = Instance(modules.WarpVectorCutPlane, ())
414
warpvectorcutplane = make_function(WarpVectorCutPlaneFactory)