[vtkusers] vtkEventQtSlotConnect
Clinton Stimpson
clinton at elemtech.com
Thu Feb 10 11:46:05 EST 2011
On Thursday, February 10, 2011 07:17:24 am imran khan wrote:
> Hmmm.... that is weird as I can get mouse moves. Please see code below.
>
> vtkEventQtSlotConnect * connections = vtkEventQtSlotConnect::New();
>
> .. connections->Connect(interactorROI,
> vtkCommand::MouseMoveEvent,
> this,
> SLOT(handleMouseMove()));
>
> ..
>
> // The slot
> void myScene::handleMouseMove()
> {
> // get event position
> int event_pos[2];
> interactorROI->GetEventPosition(event_pos);
> qDebug("Move: x=%d : y=%d\n", event_pos[0], event_pos[1]);
> }
>
>
>
> Unfortunately the mouse release of any button is still dysfunctional, which
> is a travesty as this
> is otherwise a very useful class. I wish someone would fix this.
vtkEventQtSlotConnect is functional.
Your problem is the vtkInteractorStyle also processes the mouse and keyboard
events along with your Qt slots that you have added.
When vtkInteractorStyle processes mouse down, it grabs focus of mouse and key
events, so you cannot get any mouse or key events until it releases focus.
For example, vtkInteractorStyleTrackballCamera::OnRightButtonDown calls
this->GrabFocus(this->EventCallbackCommand)
which then calls
this->Interactor->GrabFocus(mouseEvents,keypressEvents)
so only it can get the mouse/key events until it releases focus.
If you instead do this:
connections->Connect(interactorROI->GetInteractorStyle(), ... );
then you won't have this problem. That prevents vtkInteractorStyle from
processing any VTK events that you are observing.
--
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com
More information about the vtkusers
mailing list