[vtkusers] Legacy interactor code

Kernel Blaha kernelblaha at gmail.com
Mon Aug 24 15:12:16 EDT 2009


Hi,

I'm a relative new user of VTK and I've inherited some code which works  
fine with VTK 4.2.
I've now upgraded to 5.4 and have gotten stuck.

On compiling (in MS Visual Studio 2008) I get the following error:

'SetTimerMethod' : is not a member of 'vtkInteractorStyleUser'

The offending bit of code is the following:

DWORD WINAPI OnRunning(LPVOID){
	int i;
	// interact with data
	renderer = vtkRenderer::New(); 		// create renderer
	renderer->SetBackground(1,1,1);	// set background to white
	renWin = vtkRenderWindow::New();		// create window
	renWin->AddRenderer(renderer);				// attach renderer to window
	renWin->SetSize(700,700);					// set size of window
	iren = vtkRenderWindowInteractor::New(); 	// create interactor  (for  
mouse interaction)
	iren->SetRenderWindow(renWin);			// attach interactor to main window
     	vtkInteractorStyleUser  *myint= vtkInteractorStyleUser::New();	// my  
settings for interaction
	myint->SetInteractor(iren);				// attach my interactor settings to  
windows interactor
     	myint->SetTimerMethod(&animation,NULL);	//	set timer method to use  
animation function


	axes = vtkAxes::New(); // add axes
	axes->SetScaleFactor(1.0);	// scale factor of axes
	vtkPolyDataMapper *axesMapper = vtkPolyDataMapper::New(); // create axes  
DataMapper (points to be drawn)
	axesMapper->SetInput(axes->GetOutput());	//give the data mapper some date  
(about the axes)
	vtkActor *axesActor = vtkActor::New();		//axes actor, the actual thing to  
pass to the renderer
	axesActor->SetMapper(axesMapper);			// pass the mapper to the actor

	camera = vtkCamera::New();
	camera->SetPosition(0.55,-1.75,-0.5);
	camera->SetFocalPoint(0.55,0,0.5);
	camera->Roll(180);

	renderer->SetActiveCamera(camera);
	renderer->ResetCamera();
//	renderer->AddActor(axesActor ); // actually send axes Actor to the  
renderer.
	for(i=0;i<=vtknet_nnodes;i++)
		renderer->AddActor(nodesActor[i]); // actually send the points to the  
renderer
	
	renWin->Render();				// Render in Window

	myint->StartAnimate();			//Start animation using interactor and renderer
	iren->Start();
	return 0;
}


The above calls the animation function below, which uses mutex to stop  
multiple access of cylx, cyly, cylz in another thread.


void animation(void *)
{
	int i;
	int scale=60;
	char str[20];

	WaitForSingleObject(m_mutex, INFINITE);
		
	for(i=0;i<vtknet_ncyls;i++)
	{

		nodesActor[trans2i[i]]->SetScale(1,cyly[i]*(float)scale,1);
		nodesActor[trans2i[i]]->SetPosition(cylx[i],-cyly[i]/((float)2000/scale),cylz[i]);  
//cyly[i]*(float)scale/2
		nodesActor[trans2i[i]]->GetProperty()->SetColor(cylcolour[i]);

	}

	vtknet_ncyls_old=vtknet_ncyls;

	ReleaseMutex(m_mutex);
	Sleep(1);

}


I've had a look through (some of) the online resources and found that this  
is an obsolete way of doing things.

Would anyone be kind enough to point me in the right direction as to how  
it should be done now?
Any help would be greatly appreciated!!
Thanks in advance
Leon


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



More information about the vtkusers mailing list