How to use the mayavi.mlab.outline function in mayavi

To help you get started, we’ve selected a few mayavi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MusculoskeletalAtlasProject / mapclient / tests / test_resources / updater_test / mayaviviewerstep-master / mapclientplugins / mayaviviewerstep / viewerobjects / mayaviviewergiasscan.py View on Github external
def draw(self, scene):
        scene.disable_render = True
        
        try:
            I = self.scan.I
        except AttributeError:
            print 'scan is None:', self.name

        ISrc = mlab.pipeline.scalar_field(I, colormap=self.renderArgs['colormap'])
        slicerWidget = scene.mlab.pipeline.image_plane_widget(ISrc,
                                                            plane_orientation=self._slicePlane,
                                                            slice_index=0,
                                                            **self.renderArgs
                                                            )
        mlab.outline()
        self.sceneObject = MayaviViewerGiasScanSceneObject(self.name, slicerWidget, ISrc)
        scene.disable_render = False

        return self.sceneObject
github xinglunju / tdviz / TDViz3.py View on Github external
ra0 = self.extent[1]; dec0 = self.extent[3]
        c = SkyCoord(ra=ra0*u.degree, dec=dec0*u.degree, frame='icrs')
        RA_ll = str(int(c.ra.hms.h))+'h'+str(int(c.ra.hms.m))+'m'+str(round(c.ra.hms.s,1))+'s'
        mlab.text3d(self.xrang,-10,self.zrang+5,RA_ll,scale=fontsize,orient_to_camera=True,color=tcolor)
        DEC_ll = str(int(c.dec.dms.d))+'d'+str(int(abs(c.dec.dms.m)))+'m'+str(round(abs(c.dec.dms.s),1))+'s'
        mlab.text3d(-40,self.yrang,self.zrang+5,DEC_ll,scale=fontsize,orient_to_camera=True,color=tcolor)
        # V axis
        if self.extent[5] > self.extent[4]:
            v0 = self.extent[4]; v1 = self.extent[5]
        else:
            v0 = self.extent[5]; v1 = self.extent[4]
        mlab.text3d(-10,-10,self.zrang,str(round(v0,1)),scale=fontsize,orient_to_camera=True,color=tcolor)
        mlab.text3d(-10,-10,0,str(round(v1,1)),scale=fontsize,orient_to_camera=True,color=tcolor)
        
        mlab.axes(self.field, ranges=self.extent, x_axis_visibility=False, y_axis_visibility=False, z_axis_visibility=False)
        mlab.outline()
github amaggi / waveloc / PyProgs / double_diff.py View on Github external
z_ph = [-elt for elt in z]

    # Initial hypocentral parameters
    xini, yini, zini, zini_ph, to_ini = coord_cluster(cluster[i], locs)

    mlab.figure(i, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0), size=(1000, 900))
    mlab.clf()
    # yellow : initial locations
    mlab.points3d(xini, yini, zini_ph, color=(1, 1, 0), scale_factor=0.2)
    mlab.points3d(xsta, ysta, zsta, color=(1, 0, 0), scale_factor=0.05,
                  mode='cube')
    # cyan : new locations
    mlab.points3d(x, y, z_ph, color=(0, 1, 1), scale_factor=0.2)
    mlab.axes(extent=area, color=(0, 0, 0))  # axe des z positif vers le haut
    mlab.outline(extent=area, color=(0, 0, 0))
    mlab.title("cluster=%s,  threshold=%s,  nbmin=%s" % (i, threshold, nbmin),
               height=0.1, size=0.35, color=(0, 0, 0))

    if len(cluster[i]) < 20:
        for ind_I in range(len(cluster[i])):
            for ind_J in range(ind_I+1, len(cluster[i])):
                ev_I = cluster[i][ind_I]-1
                ev_J = cluster[i][ind_J]-1
                W_IJ = nbsta[ev_I, ev_J]
                if W_IJ >= nbmin:
                    mlab.points3d(xini[ind_J], yini[ind_J], zini_ph[ind_J],
                                  scale_factor=0.1, color=(0, 0, 0))
                    mlab.points3d(xini[ind_I], yini[ind_I], zini_ph[ind_I],
                                  scale_factor=0.1, color=(0, 0, 0))
                    d = (xini[ind_J]-xini[ind_I], yini[ind_J]-yini[ind_I],
                         zini_ph[ind_J]-zini_ph[ind_I])
github CellProfiler / CellProfiler-Analyst / cpa / timelapsetool.py View on Github external
self.lineage_temporal_scaling = dt
            
            # Try to scale the nodes in a reasonable way
            # To inspect, see pts.glyph.glpyh.scale_factor 
            node_scale_factor = 0.5*dt
            pts = mlab.points3d(xyts[:,0], xyts[:,1], xyts[:,2], xyts[:,3],
                                scale_factor = 0.0,
                                scale_mode = 'none',
                                colormap = selected_colormap,
                                figure = self.trajectory_scene.mayavi_scene) 
            pts.glyph.color_mode = 'color_by_scalar'
            pts.mlab_source.dataset.lines = np.array(G.edges())
            self.trajectory_node_collection = pts    
    
            # Add outline to be used later when selecting points
            self.trajectory_selection_outline = mlab.outline(line_width = 3,
                                                             figure = self.trajectory_scene.mayavi_scene)
            self.trajectory_selection_outline.outline_mode = 'cornered'
            self.trajectory_selection_outline.bounds = (-node_scale_factor,node_scale_factor,
                                                        -node_scale_factor,node_scale_factor,
                                                        -node_scale_factor,node_scale_factor)
            self.trajectory_selection_outline.actor.actor.visibility = 0
            
            # Add 2 more points to be used later when selecting points
            self.trajectory_point_selection_outline = []
            for i in range(2):
                ol = mlab.points3d(0,0,0,
                                   extent = [-node_scale_factor,node_scale_factor,
                                             -node_scale_factor,node_scale_factor,
                                             -node_scale_factor,node_scale_factor],
                                   color = (1,0,1),
                                   figure = self.trajectory_scene.mayavi_scene)
github tomoncle / PythonStudy / data_analysis / study_mlab / mlab_3d.py View on Github external
import numpy as np
    # create data
    x, y = np.ogrid[-2:2:20j, -2:2:20j]
    z = x * np.exp(- x ** 2 - y ** 2)

    # view it
    from mayavi import mlab

    # 绘制一个三维空间中的曲面
    pl = mlab.surf(x, y, z, warp_scale="auto")

    # 在三维空间中添加坐标轴
    mlab.axes(xlabel='x', ylabel='y', zlabel='z')

    # 在三维空间中添加曲面区域的外框
    mlab.outline(pl)

    mlab.show()
github espressomd / espresso / src / python / espressomd / visualization.py View on Github external
def __init__(self, system):
		"""Constructor.
		**Arguments**

		:system: instance of espressomd.System
		"""
		self.system = system

		# objects drawn
		self.points = mlab.quiver3d([],[],[], [],[],[], scalars=[], mode="sphere", scale_factor=1, name="Particles")
		self.points.glyph.color_mode = 'color_by_scalar'
		self.points.glyph.glyph_source.glyph_source.center = [0, 0, 0]
		self.box = mlab.outline(extent=(0,0,0,0,0,0), color=(1,1,1), name="Box")
		self.arrows = mlab.quiver3d([],[],[], [],[],[], scalars=[], mode="2ddash", scale_factor=1, name="Bonds")
		self.arrows.glyph.color_mode = 'color_by_scalar'

		# state
		self.data = None
		self.last_N = 1
		self.last_Nbonds = 1
		self.last_boxl = [0,0,0]
		self.running = False
		self.last_T = None

		# GUI window
		self.gui = GUI()
		self.timers = [Timer(100, self._draw)]
github CellProfiler / CellProfiler-Analyst / cpa / timevisual.py View on Github external
pts.mlab_source.dataset.lines = np.array(G.edges())
        self.node_collection = pts    

        # Add object label text
        self.text_collection = [mlab.text3d(self.directed_graph.node[i[-1]]["x"],
                                            self.directed_graph.node[i[-1]]["y"],
                                            self.directed_graph.node[i[-1]]["t"]*t_scaling,
                                            str(i[-1][0]),
                                            line_width = 20,
                                            scale = 10,
                                            name = str(i[-1][0]),
                                            figure = self.mayavi_view.scene.mayavi_scene) 
                                for i in self.connected_nodes]
        
        # Add outline to be used later when selecting points
        self.selection_outline = mlab.outline(line_width=3)
        self.selection_outline.outline_mode = 'cornered'
        
        # Using axes doesn't work until the scene is avilable: 
        # http://docs.enthought.com/mayavi/mayavi/building_applications.html#making-the-visualization-live
        #mlab.axes()
        self.mayavi_view.scene.reset_zoom()
        
        # An trajectory picker object is created to trigger an event when a trajectory is picked.       
        # TODO: Figure out how to re-activate picker on scene refresh
        #  E.g., (not identical problem) http://www.mail-archive.com/mayavi-users@lists.sourceforge.net/msg00583.html
        self.trajectory_picker = self.mayavi_view.scene.mayavi_scene.on_mouse_pick(self.on_pick_one_trajectory)
        
        # Figure decorations
        # Orientation axes
        mlab.orientation_axes(zlabel = "t", figure = self.mayavi_view.scene.mayavi_scene, line_width = 5)
        # Colormap
github enthought / mayavi / docs / source / mayavi / auto / adjust_cropping_extents.py View on Github external
self.filter.extent = (self.x_min, self.x_max,
                                  self.y_min, self.y_max,
                                  self.z_min, self.z_max)

    view = View('x_min', 'x_max', 'y_min', 'y_max', 'z_min', 'z_max',
                title='Edit extent', resizable=True)


################################################################################
# Now build the visualization using mlab
from mayavi import mlab
fig = mlab.figure(1, bgcolor=(1, 1, 1))

# Create unconnected points
pts = mlab.pipeline.scalar_scatter(x, y, z, s)
mlab.outline(pts)

# Use a geometry_filter to filter with a bounding box
geometry_filter = mlab.pipeline.user_defined(pts,
                                   filter='GeometryFilter')
geometry_filter.filter.extent_clipping = True
# Connect our dialog to the filter
extent_dialog = ExtentDialog(
            data_x_min=0, data_x_max=1,
            data_y_min=0, data_y_max=1,
            data_z_min=0, data_z_max=1,
            filter=geometry_filter.filter)
# We need to use 'edit_traits' and not 'configure_traits()' as we do
# not want to start the GUI event loop (the call to mlab.show())
# at the end of the script will do it.
extent_dialog.edit_traits()
github xinglunju / tdviz / TDViz.py View on Github external
ra0 = self.extent[1]; dec0 = self.extent[3]
		c = SkyCoord(ra=ra0*u.degree, dec=dec0*u.degree, frame='icrs')
		RA_ll = str(int(c.ra.hms.h))+'h'+str(int(c.ra.hms.m))+'m'+str(round(c.ra.hms.s,1))+'s'
		mlab.text3d(self.xrang,-10,self.zrang+5,RA_ll,scale=fontsize,orient_to_camera=True,color=tcolor)
		DEC_ll = str(int(c.dec.dms.d))+'d'+str(int(abs(c.dec.dms.m)))+'m'+str(round(abs(c.dec.dms.s),1))+'s'
		mlab.text3d(-40,self.yrang,self.zrang+5,DEC_ll,scale=fontsize,orient_to_camera=True,color=tcolor)
		# V axis
		if self.extent[5] > self.extent[4]:
			v0 = self.extent[4]; v1 = self.extent[5]
		else:
			v0 = self.extent[5]; v1 = self.extent[4]
		mlab.text3d(-10,-10,self.zrang,str(round(v0,1)),scale=fontsize,orient_to_camera=True,color=tcolor)
		mlab.text3d(-10,-10,0,str(round(v1,1)),scale=fontsize,orient_to_camera=True,color=tcolor)

		mlab.axes(self.field, ranges=self.extent, x_axis_visibility=False, y_axis_visibility=False, z_axis_visibility=False)
		mlab.outline()
github PytLab / VASPy / vaspy / electro.py View on Github external
self.__logger.info("Mayavi is not installed on your device.")
            return
        #do 2d interpolation
        #get slice object
        s = np.s_[0:ndim0:1, 0:ndim1:1]
        x, y = np.ogrid[s]
        mx, my = np.mgrid[s]
        #use cubic 2d interpolation
        interpfunc = interp2d(x, y, z, kind='cubic')
        newx = np.linspace(0, ndim0, 600)
        newy = np.linspace(0, ndim1, 600)
        newz = interpfunc(newx, newy)
        #mlab
        face = mlab.surf(newx, newy, newz, warp_scale=2)
        mlab.axes(xlabel='x', ylabel='y', zlabel='z')
        mlab.outline(face)
        #save or show
        if show_mode == 'show':
            mlab.show()
        elif show_mode == 'save':
            mlab.savefig('mlab_contour3d.png')
        else:
            raise ValueError('Unrecognized show mode parameter : ' +
                             show_mode)

        return