[vtkusers] ImagePlaneWidget Mouse Event Handling Problem

David Doria daviddoria+vtk at gmail.com
Tue Jan 19 09:52:59 EST 2010


On Tue, Jan 19, 2010 at 9:33 AM, circass <circass at gmail.com> wrote:
>
> Hi my friends,
> i m trying to get mouse input from my imageviewer2 which uses three
> imageplanewidgets for sagital axial and coronal views of a volume(Dicom
> Volume).
>
> I want to handle the middlebuttonpressed and released events of
> ImageplaneWidget but i coudnt succeed whatever i tried.
>
> I wrote a class vtkImageInteractionCallback3D : public vtkCommand that
> includes an Execute method, and there are those lines in that method:
>
>                if (event == vtkCommand::MiddleButtonPressEvent)
>                {
>                        this->Slicing = 1;
>                }
>                else if (event == vtkCommand::MiddleButtonReleaseEvent)
>                {
>                        this->Slicing = 0;
>                }
>                else if (event == vtkCommand::MouseMoveEvent)
>                {
>                        if (this->Slicing)
>                        {
>                                i_viewer1->SetInput(i_planeWidget1->GetResliceOutput());
>                                i_viewer1->Render();
>                                i_viewer2->SetInput(i_planeWidget2->GetResliceOutput());
>                                i_viewer2->Render();
>                                i_viewer3->SetInput(i_planeWidget3->GetResliceOutput());
>                                i_viewer3->Render();
>                        }
>                        else
>                        {
>                                vtkInteractorStyle *style = vtkInteractorStyle::SafeDownCast(
>                                interactor->GetInteractorStyle());
>                                if (style)
>                                {
>                                        style->OnMouseMove();
>                                }
>                        }
>                }
>
>
> i add that callback to my interactor but the problem is, i cant get mouse
> inputs when i clicked on imagePlaneWidget, i m getting mouse inputs anywhere
> else.
>
> I searched for that but found nothing.
> I hope someone can help me.
> Thanx.

I don't know if it works with the image viewer, but I usually subclass
the interactor style I'm using:
http://www.cmake.org/Wiki/VTK/Examples/Interaction/MouseEvents

rather than vtkCommand.

My $.02,

David



More information about the vtkusers mailing list