[vtkusers] Disabling middle mouse button for vtkImageTracerWidget

Dean Inglis dean.inglis at camris.ca
Tue Nov 23 09:29:37 EST 2010


doh!  Im an idiot.  You cant override non-virtual methods!  You would
have to make the original methods in vtkImageTracerWidget virtual to 
override in
your subclass.  What should really be done is to modify vtkImageTracerWidget
to disable certain types of interaction, perhaps the easiest would be with
bool ivars like MiddleMouseAction, rather than forcing users to subclass.

Dean

----- Original Message ----- 
From: "David Doria" <daviddoria at gmail.com>
To: "Dean Inglis" <dean.inglis at camris.ca>
Cc: "vtkusers archive" <vtkusers at vtk.org>
Sent: Tuesday, November 23, 2010 8:55 AM
Subject: Re: [vtkusers] Disabling middle mouse button for 
vtkImageTracerWidget


>> David,
>>
>> vtkImageTracerWidget is written in the old style of widgets (inherit from
>> vtk3DWidget)
>> and so ProcessEvents has this method signature common to most/all(?)
>> vtk3DWidget subclasses.
>> You could subclass the widget's AddObservers method or set the widget's
>> interactor,
>> and after the SetEnabled call, you could remove the command from the
>> interactor with
>> RemoveObservers.
>>
>> Dean
>
> Hmm, even with this:
>
> void vtkSimpleImageTracerWidget::AddObservers(void)
> {
>  // Listen for the following events
>  vtkRenderWindowInteractor *i = this->Interactor;
>  if (i)
>    {
>    i->AddObserver(vtkCommand::MouseMoveEvent, this->EventCallbackCommand,
>                   this->Priority);
>    i->AddObserver(vtkCommand::LeftButtonPressEvent,
>                   this->EventCallbackCommand, this->Priority);
>    i->AddObserver(vtkCommand::LeftButtonReleaseEvent,
>                   this->EventCallbackCommand, this->Priority);
>    i->AddObserver(vtkCommand::RightButtonPressEvent,
>                   this->EventCallbackCommand, this->Priority);
>    i->AddObserver(vtkCommand::RightButtonReleaseEvent,
>                   this->EventCallbackCommand, this->Priority);
>    }
> }
>
> it still keeps the middle click line segment functionality.
>
> I also tried:
>
> void MyInteractorStyle::InitializeTracer()
> {
> ...
>  this->Tracer->On();
>
>  this->Interactor->RemoveObserver(vtkCommand::MiddleButtonPressEvent);
>  this->Interactor->RemoveObserver(vtkCommand::MiddleButtonReleaseEvent);
> ...
> }
>
> and the line segments STILL appear!
>
> David 




More information about the vtkusers mailing list