1 /*=========================================================================
4 Module: $RCSfile: bbvtkImagePlanes.cxx,v $
6 Date: $Date: 2008/04/18 12:59:52 $
7 Version: $Revision: 1.2 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
26 #include "bbvtkImagePlanes.h"
27 #include "bbvtkPackage.h"
28 #include "vtkCellPicker.h"
29 #include "vtkProperty.h"
31 #include "bbstdCast.h"
34 //====================================================================
35 BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
36 bbtk::AtomicBlackBox);
37 //====================================================================
40 using namespace bbstd;
43 //====================================================================
44 // Add the specialized adaptors to the package
45 typedef vtkImagePlaneWidget* I;
46 typedef vtkInteractorObserver* O;
48 BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(vtk,Cast,I,O);
58 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes)
59 BBTK_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
65 void ImagePlanes::bbUserConstructor()
70 void ImagePlanes::bbUserCopyConstructor()
75 void ImagePlanes::Init()
78 // The shared picker enables us to use 3 planes at one time
79 // and gets the picking order right
80 vtkCellPicker* picker = vtkCellPicker::New();
81 picker->SetTolerance(0.005);
83 // The 3 image plane widgets are used to probe the dataset.
84 planeWidgetX = vtkImagePlaneWidget::New();
85 planeWidgetX->DisplayTextOn();
86 planeWidgetX->SetPicker(picker);
87 planeWidgetX->SetKeyPressActivationValue('x');
88 vtkProperty* prop1 = planeWidgetX->GetPlaneProperty();
89 prop1->SetColor(1, 0, 0);
91 planeWidgetY = vtkImagePlaneWidget::New();
92 planeWidgetY->DisplayTextOn();
93 planeWidgetY->SetPicker(picker);
94 planeWidgetY->SetKeyPressActivationValue('y');
95 vtkProperty* prop2 = planeWidgetY->GetPlaneProperty();
96 prop2->SetColor(1, 1, 0);
97 planeWidgetY->SetLookupTable(planeWidgetX->GetLookupTable());
99 // for the z-slice, turn off texture interpolation:
100 // interpolation is now nearest neighbour, to demonstrate
101 // cross-hair cursor snapping to pixel centers
102 planeWidgetZ = vtkImagePlaneWidget::New();
103 planeWidgetZ->DisplayTextOn();
104 planeWidgetZ->SetPicker(picker);
105 planeWidgetZ->SetKeyPressActivationValue('z');
106 vtkProperty* prop3 = planeWidgetZ->GetPlaneProperty();
107 prop3->SetColor(0, 0, 1);
108 planeWidgetZ->SetLookupTable(planeWidgetX->GetLookupTable());
110 bbSetOutputPlaneX(planeWidgetX);
111 bbSetOutputPlaneY(planeWidgetY);
112 bbSetOutputPlaneZ(planeWidgetZ);
115 //---------------------------------------------------------------------
117 void ImagePlanes::Process()
119 if (bbGetInputIn()!=0)
121 int xMin, xMax, yMin, yMax, zMin, zMax;
122 bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
124 planeWidgetX->SetInput(bbGetInputIn());
125 planeWidgetX->SetPlaneOrientationToXAxes();
126 planeWidgetX->SetSlicePosition((xMax+xMin)/2.);
128 planeWidgetY->SetInput(bbGetInputIn());
129 planeWidgetY->SetPlaneOrientationToYAxes();
130 planeWidgetY->SetSlicePosition((yMax+yMin)/2.);
132 planeWidgetZ->SetInput(bbGetInputIn());
133 planeWidgetZ->SetPlaneOrientationToZAxes();
134 planeWidgetZ->SetSlicePosition((zMax+zMin)/2.);
136 planeWidgetZ->SetWindowLevel(512,256);