[vtkusers] Mouse button release event is still broken in VTK 6.0.0 !

Mengda Wu wumengda at gmail.com
Sat Dec 7 11:41:58 EST 2013


Yes. Subclass of InteractorStyle has no problem getting both left button
down and up events.

However, my question was why the render window interactor only "eats" left
button up, but not the left button down event. Should the render window
interactor also invokes the button up observers if possible, or just remove
invoking the button down observers? This will make sure up and down are
handled together or otherwise strange behaviors may occur.

Thanks,
Mengda


On Fri, Dec 6, 2013 at 6:40 AM, David Cole <dlrdave at aol.com> wrote:

> Hi Mengda,
>
> This is not really "broken" -- it's more "by design," but with an
> unfortunately non-obvious way to do what you want.
>
> If, instead of adding your observers to the render window interactor, you
> add them to the interactor's current style, you will see that the events
> are indeed invoked. But by default, the interactor style "eats" the left
> button up event such that the render window interactor never sees it. You
> can change this behavior by creating your own custom interactor style if
> you want to override it. (Or use one of the many other different types of
> interactor style available in VTK.)
>
> I added your code to this example...
>
>     http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/
> ObserverMemberFunction
>
> ...and then put this code just before the call to "Start":
>
>    ...
>     vtkInteractorObserver *currentStyle = renderWindowInteractor->
> GetInteractorStyle();
>     std::cout << "currentStyle class name: " <<
> currentStyle->GetClassName() << std::endl;
>
>     vtkInteractorStyleSwitch *iss = vtkInteractorStyleSwitch::
> SafeDownCast(currentStyle);
>    vtkInteractorObserver *actualStyle = iss->GetCurrentStyle();
>     std::cout << "actualStyle class name: " << actualStyle->GetClassName()
> << std::endl;
>
>
>     vtkSmartPointer<CRRotateCallBack> crk = vtkSmartPointer<
> CRRotateCallBack>::New();
>     actualStyle->AddObserver(vtkCommand::LeftButtonPressEvent, crk,
> 10.0f);
>    //actualStyle->AddObserver(vtkCommand::MouseMoveEvent, crk, 10.0f);
>     actualStyle->AddObserver(vtkCommand::LeftButtonReleaseEvent, crk,
> 10.0f);
>
>    renderWindowInteractor->Start();
>    ...
>
>
> One more change: I changed the beginning of your Execute callback to
> expect a different type of caller object:
>
>     vtkInteractorObserver *iobs = vtkInteractorObserver::
> SafeDownCast(caller);
>    if( !iobs )
>    {
>      return;
>    }
>
>
> The output looks like this when I run it and click in the window:
>
>    currentStyle class name: vtkInteractorStyleSwitch
>    actualStyle class name: vtkInteractorStyleJoystickCamera
>    LeftButtonPressEvent
>    LeftButtonReleaseEvent
>
>
> HTH,
> David C.
>
>
>
> -----Original Message-----
> From: Mengda Wu <wumengda at gmail.com>
> To: vtkusers <vtkusers at vtk.org>
> Cc: clinton <clinton at elemtech.com>; EvilMax <maxim.privalov at gmail.com>
> Sent: Sun, Dec 1, 2013 9:19 pm
> Subject: [vtkusers] Mouse button release event is still broken in VTK
> 6.0.0 !
>
>
>
> Hi all,
>
>
>    I found this series is very relevant to my issue.
>
>
>
>    I am also trying to catch the LeftButtonReleaseEvent event in VTK
> 6.0.0. I believe it is still broken. Basically, I added observers of
> LeftButtonPressEvent, MouseMoveEvent, and LeftButtonReleaseEvent to
> RenderWindowInteractor. Only LeftButtonPressEvent and  MouseMoveEvent got
> tracked in the C++ callback function. No LeftButtonReleaseEvent was
> observed.
>
>
> What I did was:
>
>
> vtkSmartPointer<CRRotateCallBack> crk = vtkSmartPointer<
> CRRotateCallBack>::New();
>      this->ui->view1->GetInteractor()->AddObserver(
> vtkCommand::LeftButtonPress
> Event, crk, 10.0f);  this->ui->view1->GetInteractor()->AddObserver(
> vtkCommand::MouseMoveEvent,
>  crk, 10.0f);        this->ui->view1->GetInteractor()->AddObserver(
> vtkCommand::LeftButtonRelea
> seEvent, crk, 10.0f);
>
> class CRRotateCallBack : public vtkCommand
> {
> public:
>     static CRRotateCallBack *New() {return new CRRotateCallBack;}
>
>     virtual void Execute(vtkObject *caller, unsigned long eventId, void*)
>     {
>         vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::
> SafeDownCast(caller);
>         if( !iren ) return;
>
>         if( eventId == vtkCommand::LeftButtonPressEvent )
>         {
>             std::cout << "LeftButtonPressEvent" << std::endl;
>         }
>         else if( eventId == vtkCommand::MouseMoveEvent )
>         {
>             std::cout << "MouseMoveEvent " << std::endl;
>         }
>         else if( eventId == vtkCommand::LeftButtonReleaseEvent )    //for
> some reason, this left mouse release event never gets here
>         {
>             std::cout << "LeftButtonReleaseEvent " << std::endl;
>         }
>     }
> };
>
>
> Thanks,
>
> Mengda
>
>
>
>
>
>
> On Mon, Oct 31, 2011 at 4:25 PM, Sebastien Jourdain <
> sebastien.jourdain at kitware.com> wrote:
>
> Hi Max,
>
> I get that but when I was monitoring the event that was happening on a
> C++ observer, I've noticed the following order.
>
> LeftButtonPressEvent
> StartInteractionEvent
> ModifiedEvent
> EndInteractionEvent
> RenderEvent
>
> So despite the fact that ReleaseEvent is not properly propagated (even
> in the C++ layer), I was wondering if you could rely on the
> EndInteractionEvent while we fix this bug ? Because, this event seems
> to map at the release time...
>
> Does it make sense ?
>
> At lease let me know if this could fix your issue temporarily...
>
> Thanks,
>
> Seb
>
> PS: If I get more time, I will track down the reason why the
> ReleaseEvent get digested...
>
>
>
> On Mon, Oct 31, 2011 at 4:16 PM, EvilMax <maxim.privalov at gmail.com> wrote:
>
>> Hi, Sebastien!
>>
>> I need to implement dragging of an actors, so I really need to track
>>
> mouse
>
>> button release event.
>>
>> --
>> View this message in context:
>>
> http://vtk.1045678.n5.nabble.com/Mouse-button-release-is-
> still-broken-in-5-8-0-tp4949887p4953458.html
>
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>>
> http://www.kitware.com/opensource/opensource.html
>
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>>
> http://www.vtk.org/Wiki/VTK_FAQ
>
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>  _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131207/e72a1ab9/attachment.htm>


More information about the vtkusers mailing list