[vtkusers] vtkInteractorStyleImage and vtkImageActor

David Doria daviddoria at gmail.com
Thu May 30 07:49:28 EDT 2013


On Wed, May 29, 2013 at 1:39 PM, Jay Li <chyumm at yahoo.com> wrote:
> Dear All,
>
> I wonder if I can access the a vtkImageActor object from
> vtkInteractorStyleImage::WindowLevel().
>
> I used the sample code in QuickViewDemo to interact ITK with VTK. Basically
> an image was read in ITK then using the itk::ImageToVTKImageFilter connector
> to construct an vtkImageData object. The vtkImageData object was then passed
> to a vtkImageActor object "actor" (actor->SetInput(connector->GetOutput());
> ) An vtkInteractorStyleImage object "style" was passed in the interactor
> (interactor->SetInteractorStyle(style);)
>
> I want to capture the mouse movement then change the slice number to display
> another 2D grey level image. (Please correct me if I'm wrong here) I was
> thinking maybe I could reassign an input to the vtkImageActor actor object
> when the movement is captured in vtkInteractorStyleImage::WindowLevel(),
> then render the new view. I wonder if there's a way I can access
> vtkImageActor from vtkInteractorStyleImage. Thanks.
>
> Regards,
> Jay


First, I'd recommend using the newer vtkImageSlice* classes:
http://www.vtkedge.org/Wiki/VTK/Examples/Cxx/Images/ImageSliceMapper
http://www.vtkedge.org/Wiki/VTK/Examples/Cxx/Images/ImageSlice

Second, you'd need to subclass the interactor style so that you can
give it a pointer to the slice. Here is an example of how to subclass
an interactor style:
http://www.vtkedge.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEvents

You'd just add a member variable that is a pointer to the slice, and
then re-implement which every "action" function you want to get the
desired behavior at the appropriate time.

Good luck,

David



More information about the vtkusers mailing list