vtk Motion Callback
David Gobbi
dgobbi at irus.rri.on.ca
Wed Nov 10 17:41:47 EST 1999
Hi Sean,
In C++, the best approach might be to create your own
vtkInteractorStyle class and override the appropriate
methods.
There used to be a SetTimerMethod in vtkRenderWindowInteractor,
but it was axed when the vtkInteractorStyle class was
created.
- David
--David Gobbi, MSc dgobbi at irus.rri.on.ca
Advanced Imaging Research Group
Robarts Research Institute, University of Western Ontario
On Wed, 10 Nov 1999, Sean Spicer wrote:
>
> 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