[vtkusers] How do I limit how often a window is rendered?

richn richnchinees at gmail.com
Thu Oct 6 12:09:34 EDT 2011


Hello,

I have a .NET application, which has a system state (lets call it system), a
VTK-window (call it simulation), which displays the system and should react
to any changes made to the system, and a Windows Form with some controls
controling the system. So I have 2 GUI windows in total. The system is and
should remain independant of both GUIs.
I am looking for an efficient method to control when and how often the
simulation is rendered. 

What I am doing right now:

	// Setting up the simulation window:
	vtkRenderWindow* renderWindow = vtkRenderWindow::New();
	
	vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
	renderWindow->AddRenderer(renderer);
	
	vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor 
		=	vtkSmartPointer<vtkRenderWindowInteractor>::New();
	vtkSmartPointer<vtkInteractorStyleTrackballCamera>
interactorStyleTrackballCamera
		= vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
	renderWindowInteractor->SetRenderWindow(renderWindow);
	renderWindowInteractor->SetInteractorStyle(interactorStyleTrackballCamera);

	renderWindowInteractor->Start();
	renderer->SetBackground(.3, .6, .3);
	renderWindow -> Render();
	
When the system state changes, a systemChangedEvent is fired which is caught
by the simulation. The change affects the position of one actor and I do
this:

	actor->SetUserMatrix(newPosition);
	actor->Modified();

I can call renderWindow->Render() after this, but potentially very many
systemChangedEvents are fired and I don't want the simulation to render
itself every time as this whould take too long.
If I don't call RenderWindow->Render(), then the simulation is also updated,
but only after some sort of interaction with the RenderWindow like clicking
into it. 

I am fairly new to VTK, so forgive me in case this is a pretty dumb
question... But I feel like there must be something in VTK to solve this.
Can VTK do anything like "render whenever something is modified, but not
more than XX frames per second"? Or should I create a thread "by hand", that
periodically calls renderWindow->Render()?

Thank you for any input!
richn


--
View this message in context: http://vtk.1045678.n5.nabble.com/How-do-I-limit-how-often-a-window-is-rendered-tp4876870p4876870.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list