[vtkusers] how to interact two renderers
Antonin Perrot-Audet
antonin07130 at gmail.com
Mon May 17 00:43:07 EDT 2010
Here is the solution I found to synchronize the camera of two renderers.
If someone has a better idea, feel free to help.
Here is a tutorial about how to setup callbacks with vtk:
http://www.itk.org/Wiki/VTK/Tutorials/Callbacks
Here is my solution : it synchronize in one direction the interaction of
a user on one renderwindow and forces another renderer to render:
when the camera move in the first rendere, the second rendere is
forced to render by the callback.
You may set two callback of the same type if you want to be able to
interact on both windows and always force the other one to render.
I created a class just for synchronization in this class I write the
callback function :
in Myclass.h
static void synchronizeCameras( vtkObject* caller, long unsigned int
eventId, void* clientData, void* callData );
in Myclass.cxx :
void
Myclass::
synchronizeCameras( vtkObject* caller, long unsigned int eventId, void*
clientData, void* callData )
{
QGoComparer* p_otherViewer
= static_cast< QGoComparer* >(clientData);
p_otherViewer->Render();
}
I also add a callback object :
in Myclass.h :
vtkCallbackCommand* m_vtkCallBackCamSync;
that I declare and initilalize when creating an instance of Myclass :
in Myclass.cxx :
Myclass::Myclass(vtkimageviewer * firstViewer, vtkimageviewer * otherViewer)
{
m_vtkCallBackCamSync = vtkCallbackCommand::New();
m_vtkCallBackCamSync->SetCallback(Myclass::synchronizeCameras );
m_vtkCallBackCamSync->SetClientData( firstViewer );
firstViewer-> [...] ->GetCamera->AddObserver(
vtkCommand::ModifiedEvent,
Myclass::m_vtkCallBackCamSync );
}
regards
--
Antonin Perrot-Audet
Electrical Engineering& Computer Sciences, INSA Lyon
M2 GEGP Signal& Image Processing, INSA Lyon, UCBL, Centrale Lyon
More information about the vtkusers
mailing list