1 /*=========================================================================
4 Module: $RCSfile: bbvtkImagePlanes.cxx,v $
6 Date: $Date: 2008/06/25 08:21:31 $
7 Version: $Revision: 1.4 $
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 =========================================================================*/
24 #include "bbvtkImagePlanes.h"
25 #include "bbvtkPackage.h"
26 #include "vtkCellPicker.h"
27 #include "vtkProperty.h"
29 #include "bbstdCast.h"
32 //====================================================================
33 BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
34 bbtk::AtomicBlackBox);
35 //====================================================================
38 using namespace bbstd;
41 //====================================================================
42 // Add the specialized adaptors to the package
43 typedef vtkImagePlaneWidget* I;
44 typedef vtkInteractorObserver* O;
46 BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(vtk,Cast,I,O);
54 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes)
55 BBTK_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
57 void ImagePlanes::bbUserConstructor()
61 std::vector<double> vect;
64 bbSetInputWindowLevel (vect);
67 void ImagePlanes::bbUserCopyConstructor()
72 void ImagePlanes::Init()
75 // The shared picker enables us to use 3 planes at one time
76 // and gets the picking order right
77 vtkCellPicker* picker = vtkCellPicker::New();
78 picker->SetTolerance(0.005);
80 // The 3 image plane widgets are used to probe the dataset.
81 planeWidgetX = vtkImagePlaneWidget::New();
82 planeWidgetX->DisplayTextOn();
83 planeWidgetX->SetPicker(picker);
84 planeWidgetX->SetKeyPressActivationValue('x');
85 vtkProperty* prop1 = planeWidgetX->GetPlaneProperty();
86 prop1->SetColor(1, 0, 0);
88 planeWidgetY = vtkImagePlaneWidget::New();
89 planeWidgetY->DisplayTextOn();
90 planeWidgetY->SetPicker(picker);
91 planeWidgetY->SetKeyPressActivationValue('y');
92 vtkProperty* prop2 = planeWidgetY->GetPlaneProperty();
93 prop2->SetColor(1, 1, 0);
94 planeWidgetY->SetLookupTable(planeWidgetX->GetLookupTable());
96 // for the z-slice, turn off texture interpolation:
97 // interpolation is now nearest neighbour, to demonstrate
98 // cross-hair cursor snapping to pixel centers
99 planeWidgetZ = vtkImagePlaneWidget::New();
100 planeWidgetZ->DisplayTextOn();
101 planeWidgetZ->SetPicker(picker);
102 planeWidgetZ->SetKeyPressActivationValue('z');
103 vtkProperty* prop3 = planeWidgetZ->GetPlaneProperty();
104 prop3->SetColor(0, 0, 1);
105 planeWidgetZ->SetLookupTable(planeWidgetX->GetLookupTable());
107 bbSetOutputPlaneX(planeWidgetX);
108 bbSetOutputPlaneY(planeWidgetY);
109 bbSetOutputPlaneZ(planeWidgetZ);
111 picker->UnRegister(NULL);
114 //---------------------------------------------------------------------
115 void ImagePlanes::bbUserDestructor()
117 planeWidgetX->Delete();
118 planeWidgetY->Delete();
119 planeWidgetZ->Delete();
122 //---------------------------------------------------------------------
123 void ImagePlanes::Process()
125 if (bbGetInputIn()!=0)
127 int xMin, xMax, yMin, yMax, zMin, zMax;
128 bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
130 planeWidgetX->SetInput(bbGetInputIn());
131 planeWidgetX->SetPlaneOrientationToXAxes();
132 planeWidgetX->SetSlicePosition((xMax+xMin)/2.);
134 planeWidgetY->SetInput(bbGetInputIn());
135 planeWidgetY->SetPlaneOrientationToYAxes();
136 planeWidgetY->SetSlicePosition((yMax+yMin)/2.);
138 planeWidgetZ->SetInput(bbGetInputIn());
139 planeWidgetZ->SetPlaneOrientationToZAxes();
140 planeWidgetZ->SetSlicePosition((zMax+zMin)/2.);
142 // planeWidgetZ->SetWindowLevel(512,256);
144 planeWidgetZ->SetWindowLevel(bbGetInputWindowLevel()[0],bbGetInputWindowLevel()[1]);