~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to examples/demo/vtk_example.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
from numpy import linspace
3
 
from scipy.special import jn
4
 
 
5
 
from tvtk.api import tvtk
6
 
from mayavi import mlab
7
 
from enable.vtk_backend.vtk_window import EnableVTKWindow
8
 
from chaco.api import ArrayPlotData, Plot, OverlayPlotContainer
9
 
from chaco.tools.api import PanTool, ZoomTool, MoveTool
10
 
 
11
 
def main():
12
 
    # Create some x-y data series to plot
13
 
    x = linspace(-2.0, 10.0, 100)
14
 
    pd = ArrayPlotData(index = x)
15
 
    for i in range(5):
16
 
        pd.set_data("y" + str(i), jn(i,x))
17
 
 
18
 
    # Create some line plots of some of the data
19
 
    plot = Plot(pd, bgcolor="none", padding=30, border_visible=True,
20
 
                 overlay_border=True, use_backbuffer=False)
21
 
    plot.legend.visible = True
22
 
    plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="auto")
23
 
    plot.plot(("index", "y3"), name="j_3", color="auto")
24
 
    plot.tools.append(PanTool(plot))
25
 
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
26
 
    plot.overlays.append(zoom)
27
 
 
28
 
    # Create the mlab test mesh and get references to various parts of the
29
 
    # VTK pipeline
30
 
    f = mlab.figure(size=(600,500))
31
 
    m = mlab.test_mesh()
32
 
    scene = mlab.gcf().scene
33
 
    render_window = scene.render_window
34
 
    renderer = scene.renderer
35
 
    rwi = scene.interactor
36
 
 
37
 
    plot.resizable = ""
38
 
    plot.bounds = [200,200]
39
 
    plot.padding = 25
40
 
    plot.outer_position = [30,30]
41
 
    plot.tools.append(MoveTool(component=plot,drag_button="right"))
42
 
 
43
 
    container = OverlayPlotContainer(bgcolor = "transparent",
44
 
                    fit_window = True)
45
 
    container.add(plot)
46
 
 
47
 
    # Create the Enable Window
48
 
    window = EnableVTKWindow(rwi, renderer,
49
 
            component=container,
50
 
            #istyle_class = tvtk.InteractorStyleSwitch,
51
 
            #istyle_class = tvtk.InteractorStyle,
52
 
            istyle_class = tvtk.InteractorStyleTrackballCamera,
53
 
            bgcolor = "transparent",
54
 
            event_passthrough = True,
55
 
            )
56
 
 
57
 
    mlab.show()
58
 
    return window, render_window
59
 
 
60
 
if __name__=="__main__":
61
 
    main()
62