[vtkusers] Changing slice number in vtkImagePlaneWIdget

Mark Wyszomierski markww at gmail.com
Sun Nov 25 12:55:58 EST 2007


You can do something like add a mouse wheel listener and advance the
slice position when the wheel is moved by the user, etc. I have an
example here:

http://devsample.org/index.php?option=com_content&task=view&id=51&Itemid=27

Mark

On Nov 25, 2007 12:52 PM, Kompalli Suryaprakash <neosurya at yahoo.com> wrote:
> Hi All,
>      I need to change the slice number in
> ImagePlaneWidget using UI. Is there a default UI
> control built into vtkRenderWindowInteractor to  do
> this, or do we have to write something else to enable
> such interaction?
>
> The code where I initialize the interactor and the
> imageplanewidget pipeline is:
>
> // Create a renderer, render window, and render window
> interactor to
> // display the results.
> vtkRenderer* renderer = vtkRenderer::New();
> vtkRenderWindow* renWin = vtkRenderWindow::New();
> vtkRenderWindowInteractor* iren =
> vtkRenderWindowInteractor::New();
>
> renWin->SetSize(500, 500);
> renWin->AddRenderer(renderer);
> iren->SetRenderWindow(renWin);
>
> // use cell picker for interacting with the image
> orthogonal views.
> //
> vtkCellPicker * picker = vtkCellPicker::New();
> picker->SetTolerance(0.005);
>
> //assign default props to the ipw's texture plane
> actor
> vtkProperty * ipwProp = vtkProperty::New();
>
> // Create 3 orthogonal view using the ImagePlaneWidget
> //
> vtkImagePlaneWidget * xImagePlaneWidget =
> vtkImagePlaneWidget::New();
> vtkImagePlaneWidget * yImagePlaneWidget =
> vtkImagePlaneWidget::New();
> vtkImagePlaneWidget * zImagePlaneWidget =
> vtkImagePlaneWidget::New();
>
> // The 3 image plane widgets are used to probe the
> dataset.
> //
> xImagePlaneWidget->DisplayTextOn();
> xImagePlaneWidget->SetInput(vtkImporter1->GetOutput());
> xImagePlaneWidget->SetPlaneOrientationToXAxes();
> xImagePlaneWidget->SetSliceIndex(size[0]/2);
> xImagePlaneWidget->SetPicker(picker);
> xImagePlaneWidget->RestrictPlaneToVolumeOn();
> xImagePlaneWidget->SetKeyPressActivationValue('x');
> xImagePlaneWidget->GetPlaneProperty()->SetColor(1, 0,
> 0);
> xImagePlaneWidget->SetTexturePlaneProperty(ipwProp);
> xImagePlaneWidget->SetResliceInterpolateToNearestNeighbour();
>
> yImagePlaneWidget->DisplayTextOn();
> yImagePlaneWidget->SetInput(vtkImporter1->GetOutput());
> yImagePlaneWidget->SetPlaneOrientationToYAxes();
> yImagePlaneWidget->SetSliceIndex(size[1]/2);
> yImagePlaneWidget->SetPicker(picker);
> yImagePlaneWidget->RestrictPlaneToVolumeOn();
> yImagePlaneWidget->SetKeyPressActivationValue('y');
> yImagePlaneWidget->GetPlaneProperty()->SetColor(1, 1,
> 0);
> yImagePlaneWidget->SetTexturePlaneProperty(ipwProp);
> yImagePlaneWidget->SetLookupTable(xImagePlaneWidget->GetLookupTable());
>
> zImagePlaneWidget->DisplayTextOn();
> zImagePlaneWidget->SetInput(vtkImporter1->GetOutput());
> zImagePlaneWidget->SetPlaneOrientationToZAxes();
> //zImagePlaneWidget->SetSliceIndex(58);
> zImagePlaneWidget->SetSliceIndex(size[2]/2);
> zImagePlaneWidget->SetPicker(picker);
> zImagePlaneWidget->SetKeyPressActivationValue('z');
> zImagePlaneWidget->GetPlaneProperty()->SetColor(0, 0,
> 1);
> zImagePlaneWidget->SetTexturePlaneProperty(ipwProp);
> zImagePlaneWidget->SetLookupTable(xImagePlaneWidget->GetLookupTable());
> //zImagePlaneWidget->SetInteraction(1);
>
> xImagePlaneWidget->SetInteractor(iren );
> xImagePlaneWidget->On();
>
> yImagePlaneWidget->SetInteractor(iren );
> yImagePlaneWidget->On();
>
> zImagePlaneWidget->SetInteractor(iren );
> zImagePlaneWidget->On();
>
>
>
> Thanks,
> Surya
>
> http://buffalo.aidindia.org
>
>
>      ____________________________________________________________________________________
> Be a better sports nut!  Let your teams follow you
> with Yahoo Mobile. Try it now.  http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list