]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxPython/demo/wxVTKRenderWindow.py
updated wxMVCTree, VTK, and the demo
[wxWidgets.git] / utils / wxPython / demo / wxVTKRenderWindow.py
diff --git a/utils/wxPython/demo/wxVTKRenderWindow.py b/utils/wxPython/demo/wxVTKRenderWindow.py
new file mode 100644 (file)
index 0000000..eed4fd2
--- /dev/null
@@ -0,0 +1,60 @@
+
+from wxPython.wx  import *
+try:
+    from wxPython.lib import vtk
+    haveVTK = true
+except ImportError:
+    haveVTK = false
+
+#----------------------------------------------------------------------
+
+def runTest(frame, nb, log):
+    if haveVTK:
+        win = vtk.wxVTKRenderWindow(nb, -1)
+
+        # Get the render window
+        renWin = win.GetRenderWindow()
+
+        # Next, do the VTK stuff
+        ren = vtk.vtkRenderer()
+        renWin.AddRenderer(ren)
+        cone = vtk.vtkConeSource()
+        cone.SetResolution(80)
+        coneMapper = vtk.vtkPolyDataMapper()
+        coneMapper.SetInput(cone.GetOutput())
+        coneActor = vtk.vtkActor()
+        coneActor.SetMapper(coneMapper)
+        ren.AddActor(coneActor)
+        coneMapper.GetLookupTable().Build()
+
+        # Create a scalar bar
+        scalarBar = vtk.vtkScalarBarActor()
+        scalarBar.SetLookupTable(coneMapper.GetLookupTable())
+        scalarBar.SetTitle("Temperature")
+        scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
+        scalarBar.GetPositionCoordinate().SetValue(0.1, 0.01)
+        scalarBar.SetOrientationToHorizontal()
+        scalarBar.SetWidth(0.8)
+        scalarBar.SetHeight(0.17)
+        ren.AddActor2D(scalarBar)
+
+        return win
+
+
+    else:
+        wxMessageBox("Unable to import VTK, which is a required component "
+                     "of this demo.  You need to download and install the "
+                     "Python extension module for VTK from http://www.kitware.com/",
+                     "Import Error")
+        return None
+
+#----------------------------------------------------------------------
+
+
+overview = """\
+wxVTKRenderWindow is a wrapper around the vtkRenderWindow from the
+VTK Visualization Toolkit.  The VTK Python extensions are required,
+they can be obtained from http://www.kitware.com/ where you can also
+find some nifty pictures and stuff.
+
+"""