Reputation: 1346
I have a simple question: why the following code:
int p[2] = {0, 0};
vtkRenderWindow->GetInteractor()->GetMousePosition(&p[0], &p[1]);
TRACE("Mouse position: %d.%d\n", p[0], p[1]);
gave me always Mouse position: 0.0 ?
It means a lot for me if I solve this problem !!! Could you help me a little bit, please ?
Upvotes: 2
Views: 1627
Reputation: 1611
Generally the event position of the interactor is always updated on events like MouseMove, MouseWheelForward, etc.
So if you create your own interactor style and handle the MouseWheelForwardEvt, then you get the current position of the mouse cursor within the renderer by querying the event position.
Additionally you should make sure, the the RenderWindow has the focus, when you scroll the MouseWheel otherwise the event is not recognized.
A good example for your own interactor style can be found here VTK MouseEvents
Based on the example in the link, your MouseWheelForwardEvt could look like this (assuming vtkInteractorStyleTrackballCamera
is used).
virtual void OnMouseWheelForwardEvt()
{
myInteractor->GetEventPosition(x,y);
//do more stuff
//forward the event
vtkInteractorStyleTrackballCamera::OnMouseWheelForwardEvt();
}
Upvotes: 2