[vtkusers] Changing interactors at runtime

Leonardo M. Ramé l.rame at griensu.com
Mon Oct 25 14:47:51 EDT 2010


I'm using QVTKWidget containing a vtkImageViewer2 and vtkInteractorStyleImage 
as default interactor, but I'm adding an option to my app, that let the user 
select some actors with using the interactor vtkInteractorStyleRubberBand2D. 
After the user end using the rubber band, the app should switch back to the
vtkInteractorStyleImage, and I can't get the desired results.

To create the rubberband interactor I'm using a subclass I copied from
here: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/RubberBand2D

When the user chooses the option "select" this code is executed:

  m_rubberBand = MyRubberBand::New();
  this->GetInteractor()->SetInteractorStyle(m_rubberBand);

After using the rubberband, on the mouseReleaseEvent of QVTKWidget,
I'm executing this, to go back to vtkInteractorStyleImage:

  this->GetInteractor()->SetInteractorStyle(vtkInteractorStyleImage::New());

The vtkInteractorStyleImage style should do window/level when the user
drags the mouse using the left button, this stops working after changing
the interactor.

How shoul I change the interactor at run-time?

-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com



More information about the vtkusers mailing list