VTK Renderers and Windows
Renderers and Windows represent the end of the VTK pipeline,
which users actually see on the screen. In practice there is not
generally a lot to do with renderers and windows, with a few notable
exceptions:
- All actors must be added to a rendering window before they
can appear on the screen. Therefore the renderer is usually created
first thing in a VTK program, even though it is the end of the
data flow pipeline. Then each actor can be added to the renderer
as that particular pipeline section is completed.
- VTK components do not normally generate their output until
requested to do so. Normally this is accomplished by requesting
that the rendering window render its results. This will cause
the renderer to issue an update( ) request to all if its inputs,
which will in turn issue update( ) requests to all of their inputs,
and so on back down the pipeline to the sources. If any parameters
in the pipeline change, ( e.g. in response to user input through
the user interface ), then the renderer window must be requested
to re-render before the effects of the parameter adjustment can
be seen.
- Interactors, which allow users to grab and rotate the rendered
data, are typically added along with the renderers and windows.
Typical code snippets for renderers and windows are shown here.
These could come from almost any VTK program, such as the volume viewer example, or the weather display example:
- Renderer Window and Interactor initial setup:
# Create the RenderWindow, Renderer, and Interactor
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# set the background and size.
ren1 SetBackground 0.8 0.8 0.8
renWin SetSize 720 720
- Adding an actor to the renderer:
ren1 AddActor tempActor
- Requesting the renderer to re-render the scene after a parameter
change:
proc adjustDay { value } {
global day
set day [ expr $value - 1 ]
tempGeometry SetExtent 0 100 0 100 $day $day
windExtractor SetVOI 0 100 0 100 $day $day
precipExtractor SetVOI 0 100 0 100 $day $day
humidityExtractor SetVOI 0 100 0 100 $day $day
renWin Render
}