vtk Motion Callback

Sean Spicer spicer at bme.stanford.edu
Wed Nov 10 17:25:14 EST 1999


Jim, David, Others,

What I really need is to be able to do define a C++ function which gets
called on every motion event (like an XMotionEvent) and which depends on
the position of the mouse...so in pseudo code:

void myButton2Callback(void *arg)
{
  vtkRenderWindowInteractor *iren = (vtkRenderWindowInteractor *) arg;

  int position[2];

  iren -> GetEventPosition(position)

  // This function modifies rendering parameters
  // such that the scene needs to be updated
  DoSomethingWithThePosition(position);

}


void main(void)
{
  ... Initialize Vtk and all that jazz ...

  vtkInteractorStyleTrackball *aStyle;

  aStyle = (vtkInteractorStyleTrackball *)iren->GetInteractorStyle();
  aStyle -> SetTrackballModeToTrackball();
  aStyle -> SetMiddleButtonMotionMethod(myButton2Callback, (void *)iren);

  ... Get the window interactor started ...

  iren -> Start();

}

I don't see how one can do this with a Timer, mainly because every time
the timer is triggered, you have to figure out which button is down, and
react accordingly.  This would foul up the trackball.  Better to override
the default behavior for one of the buttons (or simply switch to a new
interactor with modified callbacks)  

I could do this by descending a class off of vtkInteractorStyleTrackball,
but that would be an inelegant solution.

Providing the Motion override functions would be elegant.

Let me know what you think,

sean

ps -- I work entirely in C/C++, so the tcl and python solutions 
      don't apply.

___________________________________________________________________________
Sean Spicer 	     	          Stanford University Medical Center  
Biomechanical Engineering         Division of Vascular Surgery, Suite H3642
Cardiovascular Biomechanics Lab   Stanford CA, 94305 
                                  Telephone...650.723.1695
  			          Fax.........650.723.8762

            http://solvedeath.stanford.edu/~spicer
 





-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list