[vtkusers] Changing slice number in vtkImagePlaneWIdget

Kompalli Suryaprakash neosurya at yahoo.com
Sun Nov 25 12:52:32 EST 2007


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



More information about the vtkusers mailing list