]>
Commit | Line | Data |
---|---|---|
e395c057 RD |
1 | |
2 | from wxPython.wx import * | |
3 | try: | |
4 | from wxPython.lib import vtk | |
5 | haveVTK = true | |
6 | except ImportError: | |
7 | haveVTK = false | |
8 | ||
9 | #---------------------------------------------------------------------- | |
10 | ||
11 | def runTest(frame, nb, log): | |
12 | if haveVTK: | |
54b96882 RD |
13 | f = wxFrame(frame, -1, "wxVTKRenderWindow", size=(450, 300)) |
14 | win = vtk.wxVTKRenderWindow(f, -1) | |
e395c057 RD |
15 | |
16 | # Get the render window | |
17 | renWin = win.GetRenderWindow() | |
18 | ||
19 | # Next, do the VTK stuff | |
20 | ren = vtk.vtkRenderer() | |
21 | renWin.AddRenderer(ren) | |
22 | cone = vtk.vtkConeSource() | |
23 | cone.SetResolution(80) | |
24 | coneMapper = vtk.vtkPolyDataMapper() | |
25 | coneMapper.SetInput(cone.GetOutput()) | |
26 | coneActor = vtk.vtkActor() | |
27 | coneActor.SetMapper(coneMapper) | |
28 | ren.AddActor(coneActor) | |
29 | coneMapper.GetLookupTable().Build() | |
30 | ||
31 | # Create a scalar bar | |
32 | scalarBar = vtk.vtkScalarBarActor() | |
33 | scalarBar.SetLookupTable(coneMapper.GetLookupTable()) | |
34 | scalarBar.SetTitle("Temperature") | |
35 | scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport() | |
36 | scalarBar.GetPositionCoordinate().SetValue(0.1, 0.01) | |
37 | scalarBar.SetOrientationToHorizontal() | |
38 | scalarBar.SetWidth(0.8) | |
39 | scalarBar.SetHeight(0.17) | |
40 | ren.AddActor2D(scalarBar) | |
41 | ||
54b96882 RD |
42 | f.Show(true) |
43 | frame.otherWin = f | |
44 | return None | |
e395c057 RD |
45 | |
46 | ||
47 | else: | |
8e425133 RD |
48 | wxMessageBox("Unable to import VTK, which is a required component\n" |
49 | "of this demo. You need to download and install the\n" | |
e395c057 RD |
50 | "Python extension module for VTK from http://www.kitware.com/", |
51 | "Import Error") | |
52 | return None | |
53 | ||
54 | #---------------------------------------------------------------------- | |
55 | ||
56 | ||
57 | overview = """\ | |
58 | wxVTKRenderWindow is a wrapper around the vtkRenderWindow from the | |
59 | VTK Visualization Toolkit. The VTK Python extensions are required, | |
60 | they can be obtained from http://www.kitware.com/ where you can also | |
61 | find some nifty pictures and stuff. | |
62 | ||
63 | """ |