[vtkusers] VtkSphereWidget unable to handle the right or left click...

David Doria daviddoria+vtk at gmail.com
Thu Mar 4 08:46:08 EST 2010


On Thu, Mar 4, 2010 at 6:29 AM, Adeline Joliet <adeline_joli at hotmail.com>wrote:

>  Hi vtk users,
>
>
> I need some help with the vtkSphereWidget. I managed to use it but now I
> need to detect when the Left Button is released (or pressed whatever)
> SO i did something like that:
>
>
> sphereCallback = vtkSphereCallback::New();
>
> sphereCallback->m_myClass= this;
>
>   m_lineWidget->GetSphereSource
> ()->AddObserver(vtkCommand::LeftButtonReleaseEvent,sphereCallback);
>
>
>
> where vtkSPhereCallBack is
>
>
> class vtkSphereCallback : public vtkCommand
> {
>       public:
>       static vtkSphereCallback *New()
>     {
>        return new vtkSphereCallback;
>     }
>
>     virtual void Execute(vtkObject *caller, unsigned long, void*)
>    {
>     }
>
>
> }
>   vtkSphereCallback():m_myClass(0){}
>   MyClass * m_myClass;
>
> };
>
>
>
>
>
> But It doesn't work... the callback is not called when I release the the
> left button on the sphere... BUT if if put vtkCommand::InteractionEvent
> instead of vtkCommand::LeftButtonReleaseEvent in this case it works .. !
> the callback is called... but now it will be called for everything.. but
> still not for the mouse click unclick...
> Even if I put " if (vtkCommand::LeftButtonReleaseEvent) {} " in the Execute
> function...
>
>
>
>
> Does someone has any Idea why ?,
>
>
> Regards,
> Adeline
>
>
I believe it is because that event is simply not handled by the widget. If
you look here:
http://www.vtk.org/doc/nightly/html/classvtkSphereWidget.html#_details

You will see InteractionEvent, but not LeftButton*

I tried to subclass the sphere widget and catch the event:
http://www.vtk.org/Wiki/VTK/Examples/Widgets/SphereWidgetEvents

but it didn't work. Anyone know why?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100304/02f1ca99/attachment.htm>


More information about the vtkusers mailing list