Slicer3:Python:ScriptedActor

From Slicer Wiki
Revision as of 18:15, 7 May 2009 by Pieper (talk | contribs) (New page: After a conversation with Gordon Kindlmann, I (Steve Pieper) decided to try an experiment... == Question == Can python be used to tie non-VTK-aware OpenGL C++ code into VTK? == Answer =...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < Slicer3:Python:ScriptedActor

After a conversation with Gordon Kindlmann, I (Steve Pieper) decided to try an experiment...

Question

Can python be used to tie non-VTK-aware OpenGL C++ code into VTK?

Answer

I checked in some code to make this possible. The C++ class, vtkOpenGLScriptedActor, allows you to specify a script that should be executed inside the VTK render process. This calls out to python, where arbitrary code can be run (something like a callback).

The example script shows how to draw some simple OpenGL shapes in the same window with a VTK managed sphere. The example relies on having PyOpenGL installed in Slicer's python.

The result is shown in the image to the right.

VtkOpenGLScriptedActor.png