def main(): from basic_move import Box from enable.api import Container container = Container() box = Box(bounds=[30, 30], position=[20, 20], padding=5) container.add(box) # Create the mlab test mesh and get references to various parts of the # VTK pipeline m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor # Create the Enable Window window = EnableVTKWindow( rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, istyle_class=tvtk.InteractorStyle, resizable="v", bounds=[100, 100], padding_top=20, padding_bottom=20, padding_left=20, ) #rwi.render() #rwi.start() mlab.show() return window, render_window
def main(): # Create some x-y data series to plot x = linspace(-2.0, 10.0, 100) pd = ArrayPlotData(index=x) for i in range(5): pd.set_data("y" + str(i), jn(i, x)) # Create some line plots of some of the data plot = Plot( pd, bgcolor="none", padding=30, border_visible=True, overlay_border=True, use_backbuffer=False) plot.legend.visible = True plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="auto") plot.plot(("index", "y3"), name="j_3", color="auto") plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Create the mlab test mesh and get references to various parts of the # VTK pipeline f = mlab.figure(size=(600, 500)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor plot.resizable = "" plot.bounds = [200, 200] plot.padding = 25 plot.bgcolor = "lightgray" plot.outer_position = [30, 30] plot.tools.append(MoveTool(component=plot, drag_button="right")) container = OverlayPlotContainer(bgcolor="transparent", fit_window=True) container.add(plot) # Create the Enable Window window = EnableVTKWindow( rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, #istyle_class = tvtk.InteractorStyle, istyle_class=tvtk.InteractorStyleTrackballCamera, bgcolor="transparent", event_passthrough=True, ) mlab.show() return window, render_window
def start_vtk(component): f = mlab.figure(size=(700, 500)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor window = EnableVTKWindow( rwi, renderer, component=component, istyle_class=tvtk.InteractorStyleTrackballCamera, bgcolor="transparent", event_passthrough=True, ) mlab.show()
def main(): from tvtk.api import tvtk from mayavi import mlab from enable.vtk_backend.vtk_window import EnableVTKWindow f = mlab.figure(size=(900, 850)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor # Create the plot timer_controller = TimerController() plots = create_plot_component(timer_controller) specplot, timeplot, spectrogram = plots for i, p in enumerate(plots): p.resizable = "" p.bgcolor = "transparent" p.bounds = [200, 200] p.outer_x = 0 p.outer_y = i * 250 p.tools.append(MoveTool(p, drag_button="right")) p.tools.append(PanTool(p)) p.tools.append(ZoomTool(p)) spectrogram.tools[-1].tool_mode = "range" spectrogram.tools[-1].axis = "value" spectrogram.tools[-2].constrain = True spectrogram.tools[-2].constrain_direction = "y" container = OverlayPlotContainer(bgcolor="transparent", fit_window=True) container.add(*plots) container.timer_callback = timer_controller.on_timer window = EnableVTKWindow( rwi, renderer, component=container, istyle_class=tvtk.InteractorStyleTrackballCamera, bgcolor="transparent", event_passthrough=True, ) mlab.show()
def __init__(self, **kw): super(MLabChacoPlot, self).__init__(**kw) self.prices = get_data() x = self.prices['Date'] pd = ArrayPlotData(index = x) pd.set_data("y", self.prices["Crude Supply"]) # Create some line plots of some of the data plot = Plot(pd, bgcolor="none", padding=30, border_visible=True, overlay_border=True, use_backbuffer=False) #plot.legend.visible = True plot.plot(("index", "y"), name="Crude Price", color=(.3, .3, .8, .8)) #plot.tools.append(PanTool(plot)) plot.tools.append(PanTool(plot, constrain=True, drag_button="right", constrain_direction="x")) range_plt = plot.plots['Crude Price'][0] range_selection = RangeSelection(range_plt, left_button_selects=True) range_selection.on_trait_change(self.update_interval, 'selection') range_plt.tools.append(range_selection) range_plt.overlays.append(RangeSelectionOverlay(range_plt)) zoom = ZoomTool(component=plot, tool_mode="range", always_on=False, axis="index", max_zoom_out_factor=1.0,) plot.overlays.append(zoom) # Set the plot's bottom axis to use the Scales ticking system scale_sys = CalendarScaleSystem(fill_ratio=0.4, default_numlabels=5, default_numticks=10,) tick_gen = ScalesTickGenerator(scale=scale_sys) bottom_axis = ScalesPlotAxis(plot, orientation="bottom", tick_generator=tick_gen, label_color="white", line_color="white") # Hack to remove default axis - FIXME: how do I *replace* an axis? del(plot.underlays[-2]) plot.overlays.append(bottom_axis) # Create the mlab test mesh and get references to various parts of the # VTK pipeline f = mlab.figure(size=(700,500)) self.m = mlab.points3d(self.prices['Gasoline Supply'], self.prices['Jet Fuel Supply'], self.prices['Distillate Supply'], self.prices['Crude Supply']) # Add another glyph module to render the full set of points g2 = Glyph() g2.glyph.glyph_source.glyph_source.glyph_type = "circle" g2.glyph.glyph_source.glyph_source.filled = True g2.actor.property.opacity = 0.75 self.m.module_manager.source.add_module(g2) # Set a bunch of properties on the scene to make things look right self.m.module_manager.scalar_lut_manager.lut_mode = 'PuBuGn' self.m.glyph.mask_points.random_mode = False self.m.glyph.mask_points.on_ratio = 1 self.m.scene.isometric_view() self.m.scene.background = (.9, 0.95, 1.0) scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor plot.resizable = "" plot.bounds = [600,120] plot.padding = 25 plot.bgcolor = "white" plot.outer_position = [30,30] plot.tools.append(MoveTool(component=plot,drag_button="right")) container = OverlayPlotContainer(bgcolor = "transparent", fit_window = True) container.add(plot) # Create the Enable Window window = EnableVTKWindow(rwi, renderer, component=container, istyle_class = tvtk.InteractorStyleTrackballCamera, bgcolor = "transparent", event_passthrough = True, ) mlab.show()