[vtkusers] mouseWheelEvent issue

Wei Lu learza2008 at gmail.com
Tue Aug 18 12:54:12 EDT 2009


Hi vtkusers,

My goal is to find the camera position when wheeling the mouse.
I have tried to follow the example in VTK/Example/ImageProcessing/ 
ImageSlicing. Intuitively, I think the only thing I need to do is  
adding a "mouseWheelEvent" in the example, so my code looks like this:

class vtkImageInteractionCallback : public vtkCommand
{
   ...

   virtual void Execute(vtkObject *, unsigned long event, void *)
   {
     ...

     else if (event == vtkCommand::MouseWheelForwardEvent ||  
vtkCommand::MouseWheelBackwardEvent)
       {
         double cPos[3] // camera position
         interactor->GetRenderWindow()->GetRenderers()- 
 >GetFirstRenderer()->GetActiveCamera()->GetPosition(cPos);
         std::cout << "camera position: " << cPos[0] << " " << cPos[1]  
<< " " << cPos[2] << "\n";
       }
     ...

   }
}

int main (int argc, char **argv)
{
   ...

   imageStyle->AddObserver(vtkCommand::MouseWheelForwardEvent,  
callback);
   imageStyle->AddObserver(vtkCommand::MouseWheelBackwardEvent,  
callback);
   ...

}

Now the problem is that the mouseWheelEvent behaves like been disabled  
when I add mouseWheel observers for the callback... Does anyone know  
where the issue is? Thanks in advance.


Wei Lu
Master Candidate
Image Analysis Lab, Dept. Psychiatry
Dept. Electrical and Computer Engineering
University of Iowa

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090818/bf5838cc/attachment.htm>


More information about the vtkusers mailing list