I have a Traits and Mayavi script that presents an mlab scene and several traits editors. The editors affect what data is shown in a surface
, quiver3d
and legend (Scalar LUT Manager) by calling my drawing method. Each change triggers a clear figure and re-draw.
Learning from the Mlab interactive dialog example the plot3d
* uses mlab_source.set
to change the data without clearing the figure and re-drawing. In update_plot():
if self.plot is None:
self.plot = self.scene.mlab.plot3d(x, y, z, t, tube_radius=0.025, colormap='Spectral')
else:
self.plot.mlab_source.set(x=x, y=y, z=z, scalars=t)
What my surface
and quiver3d
calls return are mayavi.modules.surface.Surface
and mayavi.modules.vectors.Vectors
objects respectively. Surface and LUTManager report no mlab_source: AttributeError: 'Surface'/'LUTManager' object has no attribute 'mlab_source'
. Quiver3d reports an mayavi.tools.sources.MGlyphSource
1) How can I change the data/source in my surface
and scalar LUTManager
?
2) How do I correctly change the quiver’s data/source?
When I attempt to change the values of the quiver I get a TraitError: Cannot set the undefined 'u' attribute of a 'Vectors' object.
This puzzles me because I used the six-value initializer.
if self.quiver is None:
self.quiver = self.scene.mlab.quiver3d(xyz[:,0], xyz[:,1], xyz[:,2],
velocity[:,0], velocity[:,1], velocity[:,2],
figure=self.scene.mayavi_scene, scale_factor = self.scale)
else:
self.quiver.mlab_source.set(x = xyz[:,0], y = xyz[:,1], z = xyz[:,2],
u = velocity[:,0], v = velocity[:,1], w = velocity[:,2])
In the example the plot3d
returns a mayavi.modules.surface.Surface
and its mlab_source
object is a mayavi.tools.sources.MLineSource
. Searching the docs for MLineSource is fruitless but externally yields Enthought Tool Suite 3.2 results. Are the Tool Suite docs current?
*self.plot, self.surface and self.quiver are declared as variable = Instance(PipelineBase)
. PipelineBase
is imported from mayavi.core.api
.