Esempio n. 1
0
    def addmodules(self, idx, addTextIndexer):
        #add Outline module
        o = Outline()
        mayavi.add_module(o)
        #add OrientationAxes module
        oa = OrientationAxes()
        mayavi.add_module(oa)
        """
        #add IsoSurface module if requested
        i = IsoSurface()
        mayavi.add_module(i)
        """

        #add Surface module if requested
        s = Surface()
        s.enable_contours = True
        s.actor.property.opacity = 0.5
        mayavi.add_module(s)

        #add Text module if requested
        t1 = Text()
        t1.text = self.title
        t1.actor.scaled_text = False
        t1.actor.text_property.font_size = 18
        mayavi.add_module(t1)
        t1.width = 1.0 * t1.actor.mapper.get_width(
            t1.scene.renderer) / t1.scene.renderer.size[0]
        height = 1.0 * t1.actor.mapper.get_height(
            t1.scene.renderer) / t1.scene.renderer.size[1]
        t1.x_position = 0.5 - t1.width / 2
        t1.y_position = 1 - height

        if (addTextIndexer):
            #add default Text module for indicating scene index
            self.sceneTextCount = Text()
            self.sceneTextCount.text = "0"
            mayavi.add_module(self.sceneTextCount)
            self.sceneTextCount.actor.scaled_text = False
            self.sceneTextCount.actor.text_property.font_size = 24
            self.sceneTextCount.x_position = .95
            self.sceneTextCount.y_position = .05
        savename = filename

        ##
        scene1 = engine.new_scene()
        scene1.scene.off_screen_rendering = True

        jesse_mat_lab_coord_source1 = engine.open(filename, scene1)

        ##
        from enthought.mayavi.modules.iso_surface import IsoSurface
        iso_surface1 = IsoSurface()
        engine.add_filter(iso_surface1, jesse_mat_lab_coord_source1)
        iso_surface1.contour.contours[0:1] = [0.5]

        ##Orientation axes
        orientation_axes = OrientationAxes()
        engine.add_module(orientation_axes, obj=None)
        orientation_axes.text_property.shadow_offset = array([1, -1])
        orientation_axes.text_property.font_family = 'times'
        orientation_axes.text_property.shadow_offset = array([1, -1])
        orientation_axes.text_property.font_size = 15
        orientation_axes.axes.axis_labels = False
        ##

        if os.path.isdir(dir + '/pics/') == False:
            os.mkdir(dir + '/pics/')

        filename = dir + '/pics/AMP-'

        ##
        module_manager1 = engine.scenes[1].children[0].children[0]
Esempio n. 3
0
# Note: VTK \> 5.0 must be installed in order to use this module.
#
# Nothing special here, as the Outline module, you can set the labels
# color:
#
# <codecell>

from enthought.mayavi.modules.orientation_axes import OrientationAxes

# <markdowncell>

# and
#
# <codecell>

oa = OrientationAxes()
script.add_module(oa)
oa.text_property.color = fg_color

# <markdowncell>

# ![](files/MayaVi(2f)ScriptingMayavi2(2f)BasicModules_attachments/basic_orientationaxes.png
#
# Text module
# ===========
#
# You can use this module to display a title for your rendering window.
#
# You need a text (a string), and you have to set up its position in the
# window (coordinates go from 0 to 1 in x and y) with the x\_position and
# y\_position parameters.
Esempio n. 4
0
    def run(self):
        """This is executed once the application GUI has started.
        *Make sure all other MayaVi specific imports are made here!*
        """
        # Various imports to do different things.
        from enthought.mayavi.sources.vtk_file_reader import VTKFileReader
        from enthought.mayavi.modules.outline import Outline
        from enthought.mayavi.modules.axes import Axes
        from enthought.mayavi.modules.grid_plane import GridPlane
        from enthought.mayavi.modules.image_plane_widget import ImagePlaneWidget
        from enthought.mayavi.modules.text import Text

        script = self.script
        # Create a new scene.
        script.new_scene()

        # Read a VTK (old style) data file.
        r = VTKFileReader()
        r.initialize(
            join(get_data_dir(dirname(abspath(__file__))), 'heart.vtk'))
        script.add_source(r)

        # Put up some text.
        t = Text(text='MayaVi rules!',
                 x_position=0.2,
                 y_position=0.9,
                 width=0.8)
        t.property.color = 1, 1, 0  # Bright yellow, yeah!
        script.add_module(t)

        # Create an outline for the data.
        o = Outline()
        script.add_module(o)

        # Create an axes for the data.
        a = Axes()
        script.add_module(a)

        # Create an orientation axes for the scene.  This only works with
        # VTK-4.5 and above which is why we have the try block.
        try:
            from enthought.mayavi.modules.orientation_axes import OrientationAxes
        except ImportError:
            pass
        else:
            a = OrientationAxes()
            a.marker.set_viewport(0.0, 0.8, 0.2, 1.0)
            script.add_module(a)

        # Create three simple grid plane modules.
        # First normal to 'x' axis.
        gp = GridPlane()
        script.add_module(gp)
        # Second normal to 'y' axis.
        gp = GridPlane()
        gp.grid_plane.axis = 'y'
        script.add_module(gp)
        # Third normal to 'z' axis.
        gp = GridPlane()
        script.add_module(gp)
        gp.grid_plane.axis = 'z'

        # Create one ImagePlaneWidget.
        ipw = ImagePlaneWidget()
        script.add_module(ipw)
        # Set the position to the middle of the data.
        ipw.ipw.slice_position = 16