/*========================================================================= Program: bbtk Module: $RCSfile: bbvtkImagePlanes.cxx,v $ Language: C++ Date: $Date: 2008/06/25 08:21:31 $ Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** * \file * \brief */ #ifdef _USE_VTK_ #include "bbvtkImagePlanes.h" #include "bbvtkPackage.h" #include "vtkCellPicker.h" #include "vtkProperty.h" #include "bbstdCast.h" namespace bbstd { //==================================================================== BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast, bbtk::AtomicBlackBox); //==================================================================== } using namespace bbstd; namespace bbvtk { //==================================================================== // Add the specialized adaptors to the package typedef vtkImagePlaneWidget* I; typedef vtkInteractorObserver* O; BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(vtk,Cast,I,O); } namespace bbvtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes) BBTK_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox); void ImagePlanes::bbUserConstructor() { Init(); bbSetInputIn(0); std::vector vect; vect.push_back(512); vect.push_back(256); bbSetInputWindowLevel (vect); } void ImagePlanes::bbUserCopyConstructor() { Init(); } void ImagePlanes::Init() { // The shared picker enables us to use 3 planes at one time // and gets the picking order right vtkCellPicker* picker = vtkCellPicker::New(); picker->SetTolerance(0.005); // The 3 image plane widgets are used to probe the dataset. planeWidgetX = vtkImagePlaneWidget::New(); planeWidgetX->DisplayTextOn(); planeWidgetX->SetPicker(picker); planeWidgetX->SetKeyPressActivationValue('x'); vtkProperty* prop1 = planeWidgetX->GetPlaneProperty(); prop1->SetColor(1, 0, 0); planeWidgetY = vtkImagePlaneWidget::New(); planeWidgetY->DisplayTextOn(); planeWidgetY->SetPicker(picker); planeWidgetY->SetKeyPressActivationValue('y'); vtkProperty* prop2 = planeWidgetY->GetPlaneProperty(); prop2->SetColor(1, 1, 0); planeWidgetY->SetLookupTable(planeWidgetX->GetLookupTable()); // for the z-slice, turn off texture interpolation: // interpolation is now nearest neighbour, to demonstrate // cross-hair cursor snapping to pixel centers planeWidgetZ = vtkImagePlaneWidget::New(); planeWidgetZ->DisplayTextOn(); planeWidgetZ->SetPicker(picker); planeWidgetZ->SetKeyPressActivationValue('z'); vtkProperty* prop3 = planeWidgetZ->GetPlaneProperty(); prop3->SetColor(0, 0, 1); planeWidgetZ->SetLookupTable(planeWidgetX->GetLookupTable()); bbSetOutputPlaneX(planeWidgetX); bbSetOutputPlaneY(planeWidgetY); bbSetOutputPlaneZ(planeWidgetZ); picker->UnRegister(NULL); } //--------------------------------------------------------------------- void ImagePlanes::bbUserDestructor() { planeWidgetX->Delete(); planeWidgetY->Delete(); planeWidgetZ->Delete(); } //--------------------------------------------------------------------- void ImagePlanes::Process() { if (bbGetInputIn()!=0) { int xMin, xMax, yMin, yMax, zMin, zMax; bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax); planeWidgetX->SetInput(bbGetInputIn()); planeWidgetX->SetPlaneOrientationToXAxes(); planeWidgetX->SetSlicePosition((xMax+xMin)/2.); planeWidgetY->SetInput(bbGetInputIn()); planeWidgetY->SetPlaneOrientationToYAxes(); planeWidgetY->SetSlicePosition((yMax+yMin)/2.); planeWidgetZ->SetInput(bbGetInputIn()); planeWidgetZ->SetPlaneOrientationToZAxes(); planeWidgetZ->SetSlicePosition((zMax+zMin)/2.); // planeWidgetZ->SetWindowLevel(512,256); planeWidgetZ->SetWindowLevel(bbGetInputWindowLevel()[0],bbGetInputWindowLevel()[1]); } } }//namespace bbtk #endif // _USE_VTK_