[vtkusers] Disabling middle mouse button for vtkImageTracerWidget

Jim Peterson jimcp at cox.net
Mon Nov 22 20:28:40 EST 2010


David Doria wrote:
> I want to disallow the connected line segment mode that can be entered
> using the middle mouse button. I tried to derive a class and implement
> empty OnMiddleButtonDown and OnMiddleButtonUp functions:
>
> class vtkSimpleImageTracerWidget : public vtkImageTracerWidget
> {
> public:
>   static vtkSimpleImageTracerWidget* New();
>   vtkTypeMacro(vtkSimpleImageTracerWidget, vtkImageTracerWidget);
>
>   void OnMiddleButtonDown(){}
>   void OnMiddleButtonUp(){}
> };
>
> but the line segment functionality still works!
>
> I see this in vtkImageTracerWidget:
>
> void vtkImageTracerWidget::ProcessEvents(vtkObject* vtkNotUsed(object), ... )
> {
>   vtkImageTracerWidget* self = reinterpret_cast<vtkImageTracerWidget
> *>( clientdata );
>
>   switch ( event )
>     {
>     ...
>     case vtkCommand::MiddleButtonPressEvent:
>       self->OnMiddleButtonDown();
> }
>
> Shouldn't this call to OnMiddleButtonDown() now call my new empty
> function and effectively disable this functionality?
>
> Thanks,
>
> David
>   
David,
I think except for this line with overrides the pointer type for "self" 
and  keeps the functionality in vtkImageTracerWidget...

  vtkImageTracerWidget* self = reinterpret_cast<vtkImageTracerWidget

It looks to me like ProcessEvents() is the callback function used for all of the callback operations, and the way ProcessEvents() is coded it defeats sub classing. 
Hope that helps, 

*>( clientdata );

 



More information about the vtkusers mailing list