class SceneWithBrowser(SplitPanel): """ Provides an Scene along with an embedded PyCrust Python shell. In the shell, 'scene' and 's' are bound to the Scene.""" # The ratio of the size of the left/top pane to the right/bottom pane. ratio = Float(0.3) # The direction in which the panel is split. direction = Str("vertical") # The `Scene` instance into which VTK renders. scene = Instance(Scene) # The `PythonShell` instance. browser = Instance(PipelineBrowser) ########################################################################### # `IWidget` interface. ########################################################################### def destroy(self): if self.scene is not None: self.scene.close() super(SceneWithBrowser, self).destroy() ########################################################################### # Protected 'SplitPanel' interface. ########################################################################### def _create_lhs(self, parent): """ Creates the left hand side or top depending on the style. """ self._create_scene(parent) self.browser = PipelineBrowser(self.scene) self.browser.show(parent=parent) return self.browser.ui.control def _create_rhs(self, parent): """ Creates the right hand side or bottom depending on the style. 's' and 'scene' are bound to the Scene instance.""" self._create_scene(parent) self.scene.renderer.background = 0.5, 0.5, 0.5 return self.scene.control ########################################################################### # Private 'SceneWithBrowser' interface. ########################################################################### def _create_scene(self, parent): """ Make sure that the scene has been created. """ if self.scene is None: self.scene = DecoratedScene(parent)
class SceneWithBrowser(SplitPanel): """ Provides an Scene along with an embedded PyCrust Python shell. In the shell, 'scene' and 's' are bound to the Scene.""" # The ratio of the size of the left/top pane to the right/bottom pane. ratio = Float(0.3) # The direction in which the panel is split. direction = Str('vertical') # The `Scene` instance into which VTK renders. scene = Instance(Scene) # The `PythonShell` instance. browser = Instance(PipelineBrowser) ########################################################################### # `IWidget` interface. ########################################################################### def destroy(self): if self.scene is not None: self.scene.close() super(SceneWithBrowser, self).destroy() ########################################################################### # Protected 'SplitPanel' interface. ########################################################################### def _create_lhs(self, parent): """ Creates the left hand side or top depending on the style. """ self._create_scene(parent) self.browser = PipelineBrowser(self.scene) self.browser.show(parent=parent) return self.browser.ui.control def _create_rhs(self, parent): """ Creates the right hand side or bottom depending on the style. 's' and 'scene' are bound to the Scene instance.""" self._create_scene(parent) self.scene.renderer.background = 0.5, 0.5, 0.5 return self.scene.control ########################################################################### # Private 'SceneWithBrowser' interface. ########################################################################### def _create_scene(self, parent): """ Make sure that the scene has been created. """ if self.scene is None: self.scene = DecoratedScene(parent)
connect_ = tvtk.PolyDataConnectivityFilter(extraction_mode=4) connect = mlab.pipeline.user_defined(smooth, filter=connect_) # Compute normals for shading the surface compute_normals = mlab.pipeline.poly_data_normals(connect) compute_normals.filter.feature_angle = 80 surf = mlab.pipeline.surface(compute_normals, color=(0.9, 0.72, 0.62)) #---------------------------------------------------------------------- # Display a cut plane of the raw data ipw = mlab.pipeline.image_plane_widget(src, colormap='bone', plane_orientation='z_axes', slice_index=55) mlab.view(-165, 32, 350, [143, 133, 73]) mlab.roll(180) fig.scene.disable_render = False #---------------------------------------------------------------------- # To make the link between the Mayavi pipeline and the much more # complex VTK pipeline, we display both: mlab.show_pipeline(rich_view=False) from enthought.tvtk.pipeline.browser import PipelineBrowser browser = PipelineBrowser(fig.scene) browser.show() mlab.show()
def _edit_pipeline_fired(self): from enthought.tvtk.pipeline.browser import PipelineBrowser pb = PipelineBrowser(self.scene) pb.show()
# -*- coding: utf-8 -*- import numpy as np from enthought.mayavi import mlab x, y = np.ogrid[-2:2:20j, -2:2:20j] z = x * np.exp(-x**2 - y**2) face = mlab.surf(x, y, z, warp_scale=2) mlab.axes(xlabel='x', ylabel='y', zlabel='z') mlab.outline(face) from enthought.tvtk.pipeline.browser import PipelineBrowser b = PipelineBrowser() b.root_object = [mlab.gcf().scene.render_window] b.show() mlab.show() mscene = mlab.gcf() tscene = mscene.scene rw = tscene.render_window a1 = rw.renderers[0].view_props[0]
class BrowserView(View): """ The TVTK pipeline browser view. """ #### 'IWorkbenchPart' interface ########################################### # The part's name (displayed to the user). name = 'TVTK Pipeline Browser' #### 'IView' interface #################################################### # The position of the view relative to the item specified in the # 'relative_to' trait. position = 'left' #### 'BrowserView' interface ############################################## # The pipeline browser instance that we are a view of. browser = Instance('enthought.tvtk.pipeline.browser.PipelineBrowser') # The scene manager. scene_manager = Instance( 'enthought.tvtk.plugins.scene.i_scene_manager.ISceneManager') ########################################################################### # 'IWorkbenchPart' interface. ########################################################################### def create_control(self, parent): """ Create the toolkit-specific control that represents the view. """ from enthought.tvtk.pipeline.browser import PipelineBrowser self.browser = PipelineBrowser() self.browser.show(parent=parent) return self.browser.ui.control ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ @on_trait_change('scene_manager:scenes_items') def _on_scenes_changed(self, event): """ Dynamic trait change handler. This is called when scenes are added/removed from the scene manager, it is used to add and remove objects from the pipeline. """ # Scenes that were removed. map(self._remove_scene, event.removed) # Scenes that were added. map(self._add_scene, event.added) return #### Methods ############################################################## def _add_scene(self, scene): """ Add the specified scene to the pipeline browser. """ self.browser.renwins.append(scene) self.browser.root_object.append(scene.render_window) return def _remove_scene(self, scene): """ Remove the specified scene from the pipeline browser. """ if scene in self.browser.renwins: self.browser.renwins.remove(scene) self.browser.root_object.remove(scene.render_window) return
# -*- coding: utf-8 -*- import numpy as np from enthought.mayavi import mlab x, y = np.ogrid[-2:2:20j, -2:2:20j] z = x * np.exp( - x**2 - y**2) face = mlab.surf(x, y, z, warp_scale=2) mlab.axes(xlabel='x', ylabel='y', zlabel='z') mlab.outline(face) from enthought.tvtk.pipeline.browser import PipelineBrowser b = PipelineBrowser() b.root_object = [mlab.gcf().scene.render_window] b.show() mlab.show() mscene = mlab.gcf() tscene = mscene.scene rw = tscene.render_window a1 = rw.renderers[0].view_props[0]
class BrowserView(View): """ The TVTK pipeline browser view. """ #### 'IWorkbenchPart' interface ########################################### # The part's name (displayed to the user). name = 'TVTK Pipeline Browser' #### 'IView' interface #################################################### # The position of the view relative to the item specified in the # 'relative_to' trait. position = 'left' #### 'BrowserView' interface ############################################## # The pipeline browser instance that we are a view of. browser = Instance('enthought.tvtk.pipeline.browser.PipelineBrowser') # The scene manager. scene_manager = Instance( 'enthought.tvtk.plugins.scene.i_scene_manager.ISceneManager' ) ########################################################################### # 'IWorkbenchPart' interface. ########################################################################### def create_control(self, parent): """ Create the toolkit-specific control that represents the view. """ from enthought.tvtk.pipeline.browser import PipelineBrowser self.browser = PipelineBrowser() self.browser.show(parent=parent) return self.browser.ui.control ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ @on_trait_change('scene_manager:scenes_items') def _on_scenes_changed(self, event): """ Dynamic trait change handler. This is called when scenes are added/removed from the scene manager, it is used to add and remove objects from the pipeline. """ # Scenes that were removed. map(self._remove_scene, event.removed) # Scenes that were added. map(self._add_scene, event.added) return #### Methods ############################################################## def _add_scene(self, scene): """ Add the specified scene to the pipeline browser. """ self.browser.renwins.append(scene) self.browser.root_object.append(scene.render_window) return def _remove_scene(self, scene): """ Remove the specified scene from the pipeline browser. """ if scene in self.browser.renwins: self.browser.renwins.remove(scene) self.browser.root_object.remove(scene.render_window) return