From: dsarrut Date: Mon, 19 Apr 2010 07:19:22 +0000 (+0000) Subject: - add future structure set manager X-Git-Tag: v1.2.0~710 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e94da8e1a76e3c9bf5301ce46e72074ba01cd1c1;p=clitk.git - add future structure set manager --- diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 723c003..18347c2 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -110,11 +110,12 @@ SET(vv_SRCS vvToolSimpleInputSelectorWidget.cxx vvToolInputSelectorWidget.cxx vvImageContour.cxx + vvBinaryImageOverlayActor.cxx vvToolImageArithm.cxx vvToolConvert.cxx - # vvToolStructureSetManager.cxx -# vvStructureSetActor.cxx -# vvROIActor.cxx + vvToolStructureSetManager.cxx + vvStructureSetActor.cxx + vvROIActor.cxx vvToolResample.cxx ) @@ -147,9 +148,9 @@ QT4_WRAP_CPP(vv_SRCS vvToolCropImage.h vvToolImageArithm.h vvToolConvert.h - # vvToolStructureSetManager.h - # vvStructureSetActor.h -# vvROIActor.h + vvToolStructureSetManager.h + vvStructureSetActor.h + vvROIActor.h vvToolResample.h ) @@ -177,7 +178,7 @@ QT4_WRAP_UI(vv_UI_CXX qt_ui/vvToolCropImage.ui qt_ui/vvToolBinarize.ui qt_ui/vvToolImageArithm.ui - # qt_ui/vvToolStructureSetManager.ui + qt_ui/vvToolStructureSetManager.ui qt_ui/vvToolResample.ui ) diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx new file mode 100644 index 0000000..f54b743 --- /dev/null +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -0,0 +1,282 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + ======================================================================-====*/ + +#include "vvBinaryImageOverlayActor.h" +#include "vvImage.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//------------------------------------------------------------------------------ +vvBinaryImageOverlayActor::vvBinaryImageOverlayActor() { + mTSlice = -1; + mSlice = 0; + mColor.resize(3); + mAlpha = 0.6; + mImage = 0; + mSlicer = 0; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor() { + for (unsigned int i = 0; i < mSlicer->GetImage()->GetVTKImages().size(); i++) { + mSlicer->GetRenderer()->RemoveActor(mImageActorList[i]); + } + mImageActorList.clear(); + mMapperList.clear(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::setColor(double r, double g, double b) { + mColor[0] = r; + mColor[1] = g; + mColor[2] = b; +} +//------------------------------------------------------------------------------ + + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::setSlicer(vvSlicer * slicer) { + mSlicer = slicer; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::initialize() { + if (!mSlicer) { + std::cerr << "ERROR. Please use setSlicer before setSlicer in vvBinaryImageOverlayActor." << std::endl; + exit(0); + } + + if (!mImage) { + std::cerr << "ERROR. Please use setImage before setSlicer in vvBinaryImageOverlayActor." << std::endl; + exit(0); + } + // Create an actor for each time slice + for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) { + DD(numImage); + vtkImageMapToRGBA * mOverlayMapper = vtkImageMapToRGBA::New(); + mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!! + vtkLookupTable * lut = vtkLookupTable::New(); + DD(lut->IsOpaque ()); + lut->SetRange(0,1); + lut->SetNumberOfTableValues(2); + lut->SetTableValue(0, 0, 0, 0, 0.0); // BG + lut->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG + DD(mColor[0]); + mOverlayMapper->SetLookupTable(lut); + + vtkImageActor * mOverlayActor = vtkImageActor::New(); + mOverlayActor->SetInput(mOverlayMapper->GetOutput()); + mOverlayActor->SetPickable(0); + mOverlayActor->SetVisibility(true); + //mOverlayActor->SetOpacity(1.0); + + mMapperList.push_back(mOverlayMapper); + mImageActorList.push_back(mOverlayActor); + mSlicer->GetRenderer()->AddActor(mOverlayActor); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image) { + mImage = image; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::hideActors() { + if (!mSlicer) return; + mSlice = mSlicer->GetSlice(); + for(unsigned int i=0; iVisibilityOff(); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::showActors() { + if (!mSlicer) return; + mSlice = mSlicer->GetSlice(); + mTSlice = mSlicer->GetTSlice(); + // for(unsigned int i=0; iVisibilityOn(); + update(0, mSlice); + //} +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::update(int slicer, int slice) { + // DD("update"); + // DD(slicer); + // DD(slice); + if (!mSlicer) return; + // DD(mSlicer->GetSlice()); + // DD(mSlicer->GetTSlice()); + + if (mPreviousSlice == mSlicer->GetSlice()) { + if (mPreviousTSlice == mSlicer->GetTSlice()) { + DD("=========== NOTHING"); + return; // Nothing to do + } + } + + // Get current slice + mSlice = mSlicer->GetSlice(); + mTSlice = mSlicer->GetTSlice(); + + // Update extent + // DD("Update extent"); + + /* +1 - get extent +2 - orientation +3 - compute new extent : ComputeImageDisplayedExtent +4 - ClipDisplayedExtent +5 - actor SetDisplayExtent + +==> à mettre dans slicer. + ==> fct (image input, image à overl) + */ + int * imageExtent = mSlicer->GetExtent(); + int orientation = mSlicer->GetOrientation(); + int maskExtent[6]; + ComputeExtent(orientation, mSlice, imageExtent, maskExtent); + //ComputeExtent(imageExtent, maskExtent, mSlicer->GetImage()->GetFirstVTKImageData(), mImage->GetFirstVTKImageData()); + ComputeExtent(maskExtent, maskExtent, mSlicer->GetImage()->GetFirstVTKImageData(), mImage->GetFirstVTKImageData()); + // std::cout << "maskExtent = " << maskExtent[0] << " " << maskExtent[1] << " " << maskExtent[2] << " " + // << maskExtent[3] << " " << maskExtent[4] << " " << maskExtent[5] << std::endl; + mSlicer->ClipDisplayedExtent(maskExtent, mMapperList[mTSlice]->GetInput()->GetWholeExtent()); + // std::cout << "maskExtent = " << maskExtent[0] << " " << maskExtent[1] << " " << maskExtent[2] << " " + // << maskExtent[3] << " " << maskExtent[4] << " " << maskExtent[5] << std::endl; + SetDisplayExtentAndCameraPosition(orientation, mSlice, maskExtent, mImageActorList[mTSlice], 0.0); + + // TOO SLOW ? + //mSlicer->Render(); + + // + mPreviousTSlice = mSlicer->GetTSlice(); + mPreviousSlice = mSlicer->GetSlice(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::ComputeExtent(int orientation, + int slice, + int * inExtent, + int * outExtent) { + // std::cout << "InExtent = " << inExtent[0] << " " << inExtent[1] << " " << inExtent[2] << " " + // << inExtent[3] << " " << inExtent[4] << " " << inExtent[5] << std::endl; + // DD(orientation); + switch (orientation) { + case vtkImageViewer2::SLICE_ORIENTATION_XY: + for(int i=0; i<4; i++) outExtent[i] = inExtent[i]; + outExtent[4] = outExtent[5] = slice; + break; + case vtkImageViewer2::SLICE_ORIENTATION_XZ: + for(int i=0; i<2; i++) outExtent[i] = inExtent[i]; + for(int i=4; i<6; i++) outExtent[i] = inExtent[i]; + outExtent[2] = outExtent[3] = slice; + break; + case vtkImageViewer2::SLICE_ORIENTATION_YZ: + for(int i=2; i<6; i++) outExtent[i] = inExtent[i]; + outExtent[0] = outExtent[1] = slice; + break; + } + // std::cout << "OutExtent = " << outExtent[0] << " " << outExtent[1] << " " << outExtent[2] << " " + // << outExtent[3] << " " << outExtent[4] << " " << outExtent[5] << std::endl; +} +//------------------------------------------------------------------------------ + + +//---------------------------------------------------------------------------- +void vvBinaryImageOverlayActor::ComputeExtent(int * inExtent, int * outExtent, vtkImageData * image, vtkImageData * overlay) +{ + outExtent[0] = (( image->GetOrigin()[0] + inExtent[0]*image->GetSpacing()[0] ) - overlay->GetOrigin()[0]) / + overlay->GetSpacing()[0]; + outExtent[1] = (( image->GetOrigin()[0] + inExtent[1]*image->GetSpacing()[0] ) - overlay->GetOrigin()[0]) / + overlay->GetSpacing()[0]; + outExtent[2] = (( image->GetOrigin()[1] + inExtent[2]*image->GetSpacing()[1] ) - overlay->GetOrigin()[1]) / + overlay->GetSpacing()[1]; + outExtent[3] = (( image->GetOrigin()[1] + inExtent[3]*image->GetSpacing()[1] ) - overlay->GetOrigin()[1]) / + overlay->GetSpacing()[1]; + outExtent[4] = (( image->GetOrigin()[2] + inExtent[4]*image->GetSpacing()[2] ) - overlay->GetOrigin()[2]) / + overlay->GetSpacing()[2]; + outExtent[5] = (( image->GetOrigin()[2] + inExtent[5]*image->GetSpacing()[2] ) - overlay->GetOrigin()[2]) / + overlay->GetSpacing()[2]; +} +//---------------------------------------------------------------------------- + + +//------------------------------------------------------------------------------ +void vvBinaryImageOverlayActor::SetDisplayExtentAndCameraPosition(int orientation, + int slice, + int * extent, + vtkImageActor * actor, + double position) { + // DD("SetDisplayExtentAndCameraPosition"); + //DD(orientation); + //DD(slice); + actor->SetDisplayExtent(extent); + + + if (orientation == vtkImageViewer2::SLICE_ORIENTATION_XY) { + if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) + actor->SetPosition(0,0, position); + else + actor->SetPosition(0,0, -position); + } + if (orientation == vtkImageViewer2::SLICE_ORIENTATION_XZ) { + if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) + actor->SetPosition(0,position,0); + else + actor->SetPosition(0,-position,0); + } + if (orientation == vtkImageViewer2::SLICE_ORIENTATION_YZ) { + if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) + actor->SetPosition(position,0, 0); + else + actor->SetPosition(-position,0, 0); + } + +} +//------------------------------------------------------------------------------ + + + + diff --git a/vv/vvBinaryImageOverlayActor.h b/vv/vvBinaryImageOverlayActor.h new file mode 100644 index 0000000..e4e3be9 --- /dev/null +++ b/vv/vvBinaryImageOverlayActor.h @@ -0,0 +1,78 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ +#ifndef VVBINARYIMAGEOVERLAYACTOR_H +#define VVBINARYIMAGEOVERLAYACTOR_H + +#include "clitkCommon.h" +#include "vvSlicer.h" + +class vtkImageClip; +class vtkMarchingSquares; +class vtkActor; +class vvImage; +class vtkImageMapToRGBA; +class vtkImageActor; + +//------------------------------------------------------------------------------ +class vvBinaryImageOverlayActor +{ + // Q_OBJECT + public: + vvBinaryImageOverlayActor(); + ~vvBinaryImageOverlayActor(); + + void setSlicer(vvSlicer * slicer); + void update(int slicer, int slice); + void hideActors(); + void showActors(); + void setColor(double r, double g, double b); + void setImage(vvImage::Pointer image); + void initialize(); + + protected: + vvSlicer * mSlicer; + int mSlice; + int mTSlice; + int mPreviousTSlice; + int mPreviousSlice; + vvImage::Pointer mImage; + std::vector mColor; + double mAlpha; + + std::vector mMapperList; + std::vector mImageActorList; + + void ComputeExtent(int orientation, + int slice, + int * inExtent, + int * outExtent); + void ComputeExtent(int * inExtent, + int * outExtent, + vtkImageData * image, + vtkImageData * overlay); + void SetDisplayExtentAndCameraPosition(int orientation, + int slice, + int * extent, + vtkImageActor * actor, + double position); + +}; // end class vvBinaryImageOverlayActor +//------------------------------------------------------------------------------ + +#endif + diff --git a/vv/vvDefaultLut.h b/vv/vvDefaultLut.h new file mode 100644 index 0000000..66532b6 --- /dev/null +++ b/vv/vvDefaultLut.h @@ -0,0 +1,256 @@ + mDefaultLUTColor->SetTableValue(0, 1.0, 0.0, 0.0); + mDefaultLUTColor->SetTableValue(1, 0.0, 1.0, 0.0); + mDefaultLUTColor->SetTableValue(2, 1.0, 0.0, 1.0); +mDefaultLUTColor->SetTableValue(3, 0.499653, 0.392081, 0.0603868); +mDefaultLUTColor->SetTableValue(4, 0.325654, 0.937002, 0.579147); +mDefaultLUTColor->SetTableValue(5, 0.102058, 0.258154, 0.746147); +mDefaultLUTColor->SetTableValue(6, 0.320134, 0.35002, 0.227738); +mDefaultLUTColor->SetTableValue(7, 0.788268, 0.229445, 0.835595); +mDefaultLUTColor->SetTableValue(8, 0.822671, 0.291356, 0.235651); +mDefaultLUTColor->SetTableValue(9, 0.557618, 0.234778, 0.855559); +mDefaultLUTColor->SetTableValue(10, 0.2383, 0.0315673, 0.578753); +mDefaultLUTColor->SetTableValue(11, 0.175414, 0.780366, 0.236857); +mDefaultLUTColor->SetTableValue(12, 0.612912, 0.664528, 0.141837); +mDefaultLUTColor->SetTableValue(13, 0.845952, 0.164181, 0.533919); +mDefaultLUTColor->SetTableValue(14, 0.906339, 0.489835, 0.470921); +mDefaultLUTColor->SetTableValue(15, 0.485486, 0.591893, 0.729074); +mDefaultLUTColor->SetTableValue(16, 0.231633, 0.912027, 0.0790941); +mDefaultLUTColor->SetTableValue(17, 0.459371, 0.700296, 0.308539); +mDefaultLUTColor->SetTableValue(18, 0.294966, 0.522966, 0.599895); +mDefaultLUTColor->SetTableValue(19, 0.530617, 0.0805838, 0.834673); +mDefaultLUTColor->SetTableValue(20, 0.386176, 0.318884, 0.866241); +mDefaultLUTColor->SetTableValue(21, 0.964929, 0.494298, 0.646606); +mDefaultLUTColor->SetTableValue(22, 0.201786, 0.10721, 0.311134); +mDefaultLUTColor->SetTableValue(23, 0.343623, 0.953162, 0.475315); +mDefaultLUTColor->SetTableValue(24, 0.877542, 0.859501, 0.96515); +mDefaultLUTColor->SetTableValue(25, 0.348463, 0.344987, 0.557043); +mDefaultLUTColor->SetTableValue(26, 0.0775373, 0.57662, 0.46907); +mDefaultLUTColor->SetTableValue(27, 0.156631, 0.0359909, 0.169366); +mDefaultLUTColor->SetTableValue(28, 0.46517, 0.330957, 0.692332); +mDefaultLUTColor->SetTableValue(29, 0.0650656, 0.861574, 0.772916); +mDefaultLUTColor->SetTableValue(30, 0.899739, 0.24775, 0.0918); +mDefaultLUTColor->SetTableValue(31, 0.76598, 0.212679, 0.586098); +mDefaultLUTColor->SetTableValue(32, 0.412586, 0.414465, 0.693307); +mDefaultLUTColor->SetTableValue(33, 0.72372, 0.758088, 0.646469); +mDefaultLUTColor->SetTableValue(34, 0.199036, 0.63563, 0.505971); +mDefaultLUTColor->SetTableValue(35, 0.164186, 0.984093, 0.850958); +mDefaultLUTColor->SetTableValue(36, 0.721229, 0.0616299, 0.427578); +mDefaultLUTColor->SetTableValue(37, 0.190299, 0.218261, 0.463569); +mDefaultLUTColor->SetTableValue(38, 0.359665, 0.683432, 0.794526); +mDefaultLUTColor->SetTableValue(39, 0.0519966, 0.748497, 0.6561); +mDefaultLUTColor->SetTableValue(40, 0.824912, 0.648236, 0.90385); +mDefaultLUTColor->SetTableValue(41, 0.916713, 0.414216, 0.116529); +mDefaultLUTColor->SetTableValue(42, 0.50281, 0.826802, 0.530994); +mDefaultLUTColor->SetTableValue(43, 0.196118, 0.550522, 0.289082); +mDefaultLUTColor->SetTableValue(44, 0.842587, 0.749558, 0.924712); +mDefaultLUTColor->SetTableValue(45, 0.348558, 0.913743, 0.908805); +mDefaultLUTColor->SetTableValue(46, 0.199515, 0.634972, 0.970434); +mDefaultLUTColor->SetTableValue(47, 0.627093, 0.825271, 0.188696); +mDefaultLUTColor->SetTableValue(48, 0.090662, 0.184935, 0.872127); +mDefaultLUTColor->SetTableValue(49, 0.885188, 0.236932, 0.620624); +mDefaultLUTColor->SetTableValue(50, 0.541288, 0.0618445, 0.268861); +mDefaultLUTColor->SetTableValue(51, 0.445138, 0.978557, 0.683077); +mDefaultLUTColor->SetTableValue(52, 0.561667, 0.481367, 0.509878); +mDefaultLUTColor->SetTableValue(53, 0.0926612, 0.677485, 0.0604006); +mDefaultLUTColor->SetTableValue(54, 0.381743, 0.520072, 0.809958); +mDefaultLUTColor->SetTableValue(55, 0.306455, 0.86863, 0.723702); +mDefaultLUTColor->SetTableValue(56, 0.21526, 0.068145, 0.358674); +mDefaultLUTColor->SetTableValue(57, 0.185694, 0.695238, 0.183944); +mDefaultLUTColor->SetTableValue(58, 0.37439, 0.7859, 0.36888); +mDefaultLUTColor->SetTableValue(59, 0.246517, 0.671088, 0.605812); +mDefaultLUTColor->SetTableValue(60, 0.867141, 0.212375, 0.667656); +mDefaultLUTColor->SetTableValue(61, 0.136002, 0.657513, 0.646213); +mDefaultLUTColor->SetTableValue(62, 0.819079, 0.21918, 0.127581); +mDefaultLUTColor->SetTableValue(63, 0.328957, 0.311841, 0.805065); +mDefaultLUTColor->SetTableValue(64, 0.389358, 0.693585, 0.325137); +mDefaultLUTColor->SetTableValue(65, 0.199316, 3.98755e-05, 0.193767); +mDefaultLUTColor->SetTableValue(66, 0.923018, 0.2153, 0.261912); +mDefaultLUTColor->SetTableValue(67, 0.281691, 0.400994, 0.95715); +mDefaultLUTColor->SetTableValue(68, 0.465636, 0.775383, 0.743051); +mDefaultLUTColor->SetTableValue(69, 0.834515, 0.0219005, 0.414139); +mDefaultLUTColor->SetTableValue(70, 0.440327, 0.889042, 0.626514); +mDefaultLUTColor->SetTableValue(71, 0.107984, 0.0250438, 0.284027); +mDefaultLUTColor->SetTableValue(72, 0.754197, 0.844122, 0.503207); +mDefaultLUTColor->SetTableValue(73, 0.881777, 0.173079, 0.815049); +mDefaultLUTColor->SetTableValue(74, 0.686843, 0.562437, 0.508633); +mDefaultLUTColor->SetTableValue(75, 0.0119802, 0.761753, 0.508673); +mDefaultLUTColor->SetTableValue(76, 0.205747, 0.68477, 0.723973); +mDefaultLUTColor->SetTableValue(77, 0.467659, 0.966462, 0.124967); +mDefaultLUTColor->SetTableValue(78, 0.42481, 0.432097, 0.90035); +mDefaultLUTColor->SetTableValue(79, 0.16786, 0.266613, 0.92225); +mDefaultLUTColor->SetTableValue(80, 0.581999, 0.70694, 0.811292); +mDefaultLUTColor->SetTableValue(81, 0.208513, 0.814924, 0.836336); +mDefaultLUTColor->SetTableValue(82, 0.49254, 0.56912, 0.680458); +mDefaultLUTColor->SetTableValue(83, 0.995747, 0.450898, 0.853538); +mDefaultLUTColor->SetTableValue(84, 0.810796, 0.13774, 0.415975); +mDefaultLUTColor->SetTableValue(85, 0.319429, 0.149721, 0.177728); +mDefaultLUTColor->SetTableValue(86, 0.828103, 0.355468, 0.862498); +mDefaultLUTColor->SetTableValue(87, 0.552075, 0.823127, 0.828959); +mDefaultLUTColor->SetTableValue(88, 0.677042, 0.247937, 0.261057); +mDefaultLUTColor->SetTableValue(89, 0.577392, 0.415797, 0.527669); +mDefaultLUTColor->SetTableValue(90, 0.499642, 0.997796, 0.234609); +mDefaultLUTColor->SetTableValue(91, 0.310935, 0.206309, 0.0495329); +mDefaultLUTColor->SetTableValue(92, 0.147271, 0.698849, 0.618653); +mDefaultLUTColor->SetTableValue(93, 0.827729, 0.694596, 0.0695508); +mDefaultLUTColor->SetTableValue(94, 0.681267, 0.505392, 0.207291); +mDefaultLUTColor->SetTableValue(95, 0.0972417, 0.824821, 0.357012); +mDefaultLUTColor->SetTableValue(96, 0.274969, 0.652924, 0.712479); +mDefaultLUTColor->SetTableValue(97, 0.137467, 0.205, 0.535607); +mDefaultLUTColor->SetTableValue(98, 0.966426, 0.882041, 0.783543); +mDefaultLUTColor->SetTableValue(99, 0.227483, 0.459433, 0.19934); +mDefaultLUTColor->SetTableValue(100, 0.755152, 0.959076, 0.197136); +mDefaultLUTColor->SetTableValue(101, 0.989762, 0.27001, 0.403445); +mDefaultLUTColor->SetTableValue(102, 0.0392947, 0.417281, 0.102294); +mDefaultLUTColor->SetTableValue(103, 0.657948, 0.24501, 0.79689); +mDefaultLUTColor->SetTableValue(104, 0.727499, 0.926277, 0.302282); +mDefaultLUTColor->SetTableValue(105, 0.93479, 0.0235187, 0.127104); +mDefaultLUTColor->SetTableValue(106, 0.291801, 0.298488, 0.780028); +mDefaultLUTColor->SetTableValue(107, 0.00428069, 0.435955, 0.985027); +mDefaultLUTColor->SetTableValue(108, 0.539887, 0.402381, 0.867069); +mDefaultLUTColor->SetTableValue(109, 0.323431, 0.629864, 0.326502); +mDefaultLUTColor->SetTableValue(110, 0.522771, 0.385017, 0.285578); +mDefaultLUTColor->SetTableValue(111, 0.719907, 0.374779, 0.555588); +mDefaultLUTColor->SetTableValue(112, 0.123353, 0.414073, 0.972869); +mDefaultLUTColor->SetTableValue(113, 0.225646, 0.0720214, 0.217879); +mDefaultLUTColor->SetTableValue(114, 0.0225363, 0.79952, 0.144156); +mDefaultLUTColor->SetTableValue(115, 0.324818, 0.73431, 0.167675); +mDefaultLUTColor->SetTableValue(116, 0.451922, 0.0261111, 0.466162); +mDefaultLUTColor->SetTableValue(117, 0.23195, 0.0303918, 0.902117); +mDefaultLUTColor->SetTableValue(118, 0.216977, 0.570279, 0.304499); +mDefaultLUTColor->SetTableValue(119, 0.0840454, 0.89371, 0.934363); +mDefaultLUTColor->SetTableValue(120, 0.410547, 0.416481, 0.31938); +mDefaultLUTColor->SetTableValue(121, 0.696125, 0.136388, 0.694159); +mDefaultLUTColor->SetTableValue(122, 0.251713, 0.259741, 0.108232); +mDefaultLUTColor->SetTableValue(123, 0.224582, 0.485387, 0.180254); +mDefaultLUTColor->SetTableValue(124, 0.442461, 0.507923, 0.979774); +mDefaultLUTColor->SetTableValue(125, 0.586616, 0.832742, 0.714084); +mDefaultLUTColor->SetTableValue(126, 0.754291, 0.284663, 0.740195); +mDefaultLUTColor->SetTableValue(127, 0.220453, 0.516613, 0.770586); +mDefaultLUTColor->SetTableValue(128, 0.122571, 0.73359, 0.340865); +mDefaultLUTColor->SetTableValue(129, 0.427069, 0.817635, 0.234575); +mDefaultLUTColor->SetTableValue(130, 0.361432, 0.228182, 0.651056); +mDefaultLUTColor->SetTableValue(131, 0.680812, 0.924307, 0.787444); +mDefaultLUTColor->SetTableValue(132, 0.374971, 0.17602, 0.0471842); +mDefaultLUTColor->SetTableValue(133, 0.483203, 0.400602, 0.532571); +mDefaultLUTColor->SetTableValue(134, 0.663457, 0.843063, 0.0404943); +mDefaultLUTColor->SetTableValue(135, 0.643231, 0.429679, 0.873236); +mDefaultLUTColor->SetTableValue(136, 0.357314, 0.18397, 0.157899); +mDefaultLUTColor->SetTableValue(137, 0.0975087, 0.404424, 0.674512); +mDefaultLUTColor->SetTableValue(138, 0.868095, 0.526994, 0.408102); +mDefaultLUTColor->SetTableValue(139, 0.208961, 0.954063, 0.225737); +mDefaultLUTColor->SetTableValue(140, 0.443536, 0.315496, 0.45392); +mDefaultLUTColor->SetTableValue(141, 0.0945911, 0.996308, 0.378227); +mDefaultLUTColor->SetTableValue(142, 0.882035, 0.371279, 0.554248); +mDefaultLUTColor->SetTableValue(143, 0.929219, 0.854482, 0.95485); +mDefaultLUTColor->SetTableValue(144, 0.46179, 0.517939, 0.797913); +mDefaultLUTColor->SetTableValue(145, 0.502284, 0.16117, 0.227592); +mDefaultLUTColor->SetTableValue(146, 0.37552, 0.518484, 0.411562); +mDefaultLUTColor->SetTableValue(147, 0.53342, 0.615992, 0.815986); +mDefaultLUTColor->SetTableValue(148, 0.207932, 0.484088, 0.34298); +mDefaultLUTColor->SetTableValue(149, 0.616034, 0.693048, 0.297043); +mDefaultLUTColor->SetTableValue(150, 0.841772, 0.136584, 0.612539); +mDefaultLUTColor->SetTableValue(151, 0.295691, 0.231175, 0.608846); +mDefaultLUTColor->SetTableValue(152, 0.673919, 0.11321, 0.980125); +mDefaultLUTColor->SetTableValue(153, 0.228166, 0.0424285, 0.834607); +mDefaultLUTColor->SetTableValue(154, 0.183016, 0.504219, 0.352546); +mDefaultLUTColor->SetTableValue(155, 0.980929, 0.00650296, 0.513716); +mDefaultLUTColor->SetTableValue(156, 0.20852, 0.382023, 0.0321993); +mDefaultLUTColor->SetTableValue(157, 0.620083, 0.915443, 0.648192); +mDefaultLUTColor->SetTableValue(158, 0.436068, 0.123375, 0.132279); +mDefaultLUTColor->SetTableValue(159, 0.779048, 0.739409, 0.825327); +mDefaultLUTColor->SetTableValue(160, 0.0760911, 0.581181, 0.961911); +mDefaultLUTColor->SetTableValue(161, 0.68863, 0.876872, 0.193086); +mDefaultLUTColor->SetTableValue(162, 0.297476, 0.550791, 0.306296); +mDefaultLUTColor->SetTableValue(163, 0.277601, 0.778957, 0.348724); +mDefaultLUTColor->SetTableValue(164, 0.112209, 0.961973, 0.852943); +mDefaultLUTColor->SetTableValue(165, 0.464755, 0.942902, 0.859446); +mDefaultLUTColor->SetTableValue(166, 0.97847, 0.151422, 0.241469); +mDefaultLUTColor->SetTableValue(167, 0.0106697, 0.771505, 0.156912); +mDefaultLUTColor->SetTableValue(168, 0.658861, 0.207573, 0.280287); +mDefaultLUTColor->SetTableValue(169, 0.791141, 0.986621, 0.0196963); +mDefaultLUTColor->SetTableValue(170, 0.616468, 0.0627118, 0.600877); +mDefaultLUTColor->SetTableValue(171, 0.578379, 0.751342, 0.477749); +mDefaultLUTColor->SetTableValue(172, 0.771465, 0.0488178, 0.0285402); +mDefaultLUTColor->SetTableValue(173, 0.077761, 0.326419, 0.807497); +mDefaultLUTColor->SetTableValue(174, 0.426485, 0.438628, 0.76947); +mDefaultLUTColor->SetTableValue(175, 0.279428, 0.903383, 0.712372); +mDefaultLUTColor->SetTableValue(176, 0.138873, 0.881853, 0.863794); +mDefaultLUTColor->SetTableValue(177, 0.380342, 0.892523, 0.635298); +mDefaultLUTColor->SetTableValue(178, 0.537254, 0.551384, 0.842871); +mDefaultLUTColor->SetTableValue(179, 0.817541, 0.342525, 0.829492); +mDefaultLUTColor->SetTableValue(180, 0.837237, 0.958993, 0.892203); +mDefaultLUTColor->SetTableValue(181, 0.438114, 0.537373, 0.643545); +mDefaultLUTColor->SetTableValue(182, 0.915864, 0.308838, 0.692363); +mDefaultLUTColor->SetTableValue(183, 0.944404, 0.386599, 0.018782); +mDefaultLUTColor->SetTableValue(184, 0.751901, 0.813084, 0.45741); +mDefaultLUTColor->SetTableValue(185, 0.521371, 0.0925119, 0.360792); +mDefaultLUTColor->SetTableValue(186, 0.233743, 0.231385, 0.242645); +mDefaultLUTColor->SetTableValue(187, 0.0975361, 0.611727, 0.135168); +mDefaultLUTColor->SetTableValue(188, 0.732834, 0.148981, 0.686552); +mDefaultLUTColor->SetTableValue(189, 0.575705, 0.966522, 0.0290767); +mDefaultLUTColor->SetTableValue(190, 0.405196, 0.803759, 0.98807); +mDefaultLUTColor->SetTableValue(191, 0.2974, 0.241874, 0.525443); +mDefaultLUTColor->SetTableValue(192, 0.940945, 0.157738, 0.834281); +mDefaultLUTColor->SetTableValue(193, 0.633307, 0.102141, 0.22088); +mDefaultLUTColor->SetTableValue(194, 0.652089, 0.854043, 0.0339641); +mDefaultLUTColor->SetTableValue(195, 0.109499, 0.375414, 0.126476); +mDefaultLUTColor->SetTableValue(196, 0.470291, 0.609156, 0.357861); +mDefaultLUTColor->SetTableValue(197, 0.712937, 0.706692, 0.969588); +mDefaultLUTColor->SetTableValue(198, 0.848104, 0.439526, 0.11857); +mDefaultLUTColor->SetTableValue(199, 0.534656, 0.0152312, 0.0850919); +mDefaultLUTColor->SetTableValue(200, 0.563733, 0.420428, 0.888851); +mDefaultLUTColor->SetTableValue(201, 0.551803, 0.717827, 0.130725); +mDefaultLUTColor->SetTableValue(202, 0.0772452, 0.658772, 0.288463); +mDefaultLUTColor->SetTableValue(203, 0.911526, 0.29208, 0.390604); +mDefaultLUTColor->SetTableValue(204, 0.132406, 0.944169, 0.244647); +mDefaultLUTColor->SetTableValue(205, 0.16637, 0.0536683, 0.62006); +mDefaultLUTColor->SetTableValue(206, 0.292846, 0.52396, 0.229216); +mDefaultLUTColor->SetTableValue(207, 0.650707, 0.236896, 0.935908); +mDefaultLUTColor->SetTableValue(208, 0.620296, 0.0850006, 0.375435); +mDefaultLUTColor->SetTableValue(209, 0.738865, 0.619657, 0.390666); +mDefaultLUTColor->SetTableValue(210, 0.823957, 0.183389, 0.811093); +mDefaultLUTColor->SetTableValue(211, 0.712809, 0.735192, 0.528921); +mDefaultLUTColor->SetTableValue(212, 0.843534, 0.812437, 0.187693); +mDefaultLUTColor->SetTableValue(213, 0.131996, 0.723963, 0.479773); +mDefaultLUTColor->SetTableValue(214, 0.5226, 0.856369, 0.423942); +mDefaultLUTColor->SetTableValue(215, 0.767247, 0.022739, 0.47761); +mDefaultLUTColor->SetTableValue(216, 0.387307, 0.315585, 0.00156981); +mDefaultLUTColor->SetTableValue(217, 0.616523, 0.966292, 0.238466); +mDefaultLUTColor->SetTableValue(218, 0.552431, 0.586588, 0.323467); +mDefaultLUTColor->SetTableValue(219, 0.927866, 0.325453, 0.943124); +mDefaultLUTColor->SetTableValue(220, 0.318531, 0.14941, 0.126513); +mDefaultLUTColor->SetTableValue(221, 0.129625, 0.862219, 0.861705); +mDefaultLUTColor->SetTableValue(222, 0.658546, 0.705752, 0.674142); +mDefaultLUTColor->SetTableValue(223, 0.846239, 0.837748, 0.398105); +mDefaultLUTColor->SetTableValue(224, 0.326011, 0.360348, 0.254475); +mDefaultLUTColor->SetTableValue(225, 0.749953, 0.127595, 0.277214); +mDefaultLUTColor->SetTableValue(226, 0.227563, 0.514902, 0.592799); +mDefaultLUTColor->SetTableValue(227, 0.229133, 0.131425, 0.559091); +mDefaultLUTColor->SetTableValue(228, 0.467599, 0.683856, 0.145678); +mDefaultLUTColor->SetTableValue(229, 0.791066, 0.611721, 0.471131); +mDefaultLUTColor->SetTableValue(230, 0.73419, 0.930253, 0.620541); +mDefaultLUTColor->SetTableValue(231, 0.860703, 0.0598778, 0.48276); +mDefaultLUTColor->SetTableValue(232, 0.722408, 0.718424, 0.188513); +mDefaultLUTColor->SetTableValue(233, 0.39655, 0.564662, 0.0262609); +mDefaultLUTColor->SetTableValue(234, 0.794655, 0.890674, 0.386609); +mDefaultLUTColor->SetTableValue(235, 0.0491299, 0.640627, 0.514204); +mDefaultLUTColor->SetTableValue(236, 0.326343, 0.86819, 0.029106); +mDefaultLUTColor->SetTableValue(237, 0.919142, 0.0973235, 0.160531); +mDefaultLUTColor->SetTableValue(238, 0.478233, 0.564923, 0.844386); +mDefaultLUTColor->SetTableValue(239, 0.623911, 0.355989, 0.456108); +mDefaultLUTColor->SetTableValue(240, 0.0950421, 0.0901784, 0.386361); +mDefaultLUTColor->SetTableValue(241, 0.715584, 0.950881, 0.446238); +mDefaultLUTColor->SetTableValue(242, 0.198344, 0.673289, 0.164662); +mDefaultLUTColor->SetTableValue(243, 0.386856, 0.0698384, 0.729324); +mDefaultLUTColor->SetTableValue(244, 0.413117, 0.864494, 0.619998); +mDefaultLUTColor->SetTableValue(245, 0.799727, 0.913624, 0.260625); +mDefaultLUTColor->SetTableValue(246, 0.313931, 0.239967, 0.128815); +mDefaultLUTColor->SetTableValue(247, 0.343037, 0.159109, 0.226139); +mDefaultLUTColor->SetTableValue(248, 0.503568, 0.637342, 0.791061); +mDefaultLUTColor->SetTableValue(249, 0.347954, 0.261252, 0.14705); +mDefaultLUTColor->SetTableValue(250, 0.804062, 0.356295, 0.237229); +mDefaultLUTColor->SetTableValue(251, 0.190422, 0.0718781, 0.18811); +mDefaultLUTColor->SetTableValue(252, 0.636661, 0.270222, 0.861398); +mDefaultLUTColor->SetTableValue(253, 0.801322, 0.657078, 0.931237); +mDefaultLUTColor->SetTableValue(254, 0.530647, 0.0701955, 0.79573); +mDefaultLUTColor->SetTableValue(255, 0.150645, 0.869922, 0.709354); diff --git a/vv/vvROIActor.cxx b/vv/vvROIActor.cxx new file mode 100644 index 0000000..f4db30b --- /dev/null +++ b/vv/vvROIActor.cxx @@ -0,0 +1,124 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + ======================================================================-====*/ + +#include "vvROIActor.h" +#include "vvImageContour.h" +#include "vvSlicerManager.h" +#include "vvBinaryImageOverlayActor.h" +#include +#include +#include +#include +#include +#include +#include +#include + +//------------------------------------------------------------------------------ +vvROIActor::vvROIActor() { + mImageContour.clear(); + mOverlayActors.clear(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvROIActor::~vvROIActor() { +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::SetROI(const clitk::DicomRT_ROI * s) { + mROI = s; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::SetSlicerManager(vvSlicerManager * s) { + mSlicerManager = s; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::Initialize() { + if (mROI->GetImage()) { + mImageContour.clear(); + mOverlayActors.clear(); + DD(mSlicerManager->NumberOfSlicers()); + for(int i=0;iNumberOfSlicers(); i++) { + mImageContour.push_back(new vvImageContour); + mImageContour[i]->setSlicer(mSlicerManager->GetSlicer(i)); + mImageContour[i]->setImage(mROI->GetImage()); + // mImageContour[i]->setColor(1.0, 0.0, 0.0); + mImageContour[i]->setColor(mROI->GetDisplayColor()[0], + mROI->GetDisplayColor()[1], + mROI->GetDisplayColor()[2]); + mImageContour[i]->setPreserveMemoryModeEnabled(false); + + mOverlayActors.push_back(new vvBinaryImageOverlayActor); + mOverlayActors[i]->setImage(mROI->GetImage()); + mOverlayActors[i]->setColor(mROI->GetDisplayColor()[0], + mROI->GetDisplayColor()[1], + mROI->GetDisplayColor()[2]); + mOverlayActors[i]->setSlicer(mSlicerManager->GetSlicer(i)); + mOverlayActors[i]->initialize(); + } + + connect(mSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int))); + //connect(mSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int))); + connect(mSlicerManager, SIGNAL(AVerticalSliderHasChanged(int, int)), SLOT(UpdateSlice(int, int))); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::Update() { + DD("vvROIActor::Update"); + for(int i=0; iNumberOfSlicers(); i++) { + UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice()); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvROIActor::UpdateSlice(int slicer, int slices) { + // DD("UpdateSlice"); + // DD(slicer); + // DD(slices); + if (!mROI->GetImage()) return; + + if (!mSlicerManager) { + std::cerr << "Error. No mSlicerManager ?" << std::endl; + exit(0); + } + + // CONTOUR HERE + // mImageContour[slicer]->update(1.0); + + + mOverlayActors[slicer]->update(slicer, slices); + + // TOO SLOW !!!!! + // mSlicerManager->GetSlicer(slicer)->Render(); +} +//------------------------------------------------------------------------------ diff --git a/vv/vvROIActor.h b/vv/vvROIActor.h new file mode 100644 index 0000000..016a103 --- /dev/null +++ b/vv/vvROIActor.h @@ -0,0 +1,55 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +#ifndef VVROIACTOR_H +#define VVROIACTOR_H + +#include "clitkDicomRT_ROI.h" +#include + +class vvSlicerManager; +class vvImageContour; +class vvBinaryImageOverlayActor; +class vtkActor; + +//------------------------------------------------------------------------------ +class vvROIActor: public QObject { + Q_OBJECT + public: + vvROIActor(); + ~vvROIActor(); + + void SetROI(const clitk::DicomRT_ROI * r); + void SetSlicerManager(vvSlicerManager * s); + void Update(); + void Initialize(); + +public slots: + void UpdateSlice(int slicer, int slices); + + protected: + const clitk::DicomRT_ROI * mROI; + vvSlicerManager * mSlicerManager; + std::vector mImageContour; + std::vector mOverlayActors; + +}; // end class vvROIActor +//------------------------------------------------------------------------------ + +#endif + diff --git a/vv/vvStructureSetActor.cxx b/vv/vvStructureSetActor.cxx new file mode 100644 index 0000000..6473a7d --- /dev/null +++ b/vv/vvStructureSetActor.cxx @@ -0,0 +1,73 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +#include "vvStructureSetActor.h" +#include "vvROIActor.h" + +//------------------------------------------------------------------------------ +vvStructureSetActor::vvStructureSetActor() { + +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvStructureSetActor::~vvStructureSetActor() { +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvStructureSetActor::SetStructureSet(clitk::DicomRT_StructureSet * s) { + mStructureSet = s; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvStructureSetActor::SetSlicerManager(vvSlicerManager * s) { + mSlicerManager = s; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvStructureSetActor::CreateNewROIActor(int n) { + DD("AddROIActor"); + DD(n); + + // Check + const clitk::DicomRT_ROI * roi = mStructureSet->GetROI(n); + if (roi == NULL) { + std::cerr << "Error. No ROI number " << n << std::endl; + exit(0); + } + + // Add ROI Actors + vvROIActor * actor = new vvROIActor; + mROIActors.push_back(actor); + actor->SetROI(roi); + actor->SetSlicerManager(mSlicerManager); + actor->Initialize(); + // + + actor->Update(); +} +//------------------------------------------------------------------------------ + + diff --git a/vv/vvStructureSetActor.h b/vv/vvStructureSetActor.h new file mode 100644 index 0000000..91c1058 --- /dev/null +++ b/vv/vvStructureSetActor.h @@ -0,0 +1,48 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +#ifndef VVSTRUCTURESETACTOR_H +#define VVSTRUCTURESETACTOR_H + +#include "clitkDicomRT_StructureSet.h" +#include + +class vvSlicerManager; +class vvROIActor; + +//------------------------------------------------------------------------------ +class vvStructureSetActor: public QObject { + Q_OBJECT + public: + vvStructureSetActor(); + ~vvStructureSetActor(); + + void SetStructureSet(clitk::DicomRT_StructureSet * s); + void SetSlicerManager(vvSlicerManager * s); + void CreateNewROIActor(int n); + + protected: + clitk::DicomRT_StructureSet * mStructureSet; + vvSlicerManager * mSlicerManager; + std::vector mROIActors; + +}; // end class vvStructureSetActor +//------------------------------------------------------------------------------ + +#endif + diff --git a/vv/vvToolStructureSetManager.cxx b/vv/vvToolStructureSetManager.cxx new file mode 100644 index 0000000..0b0d661 --- /dev/null +++ b/vv/vvToolStructureSetManager.cxx @@ -0,0 +1,278 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +#include "vvToolStructureSetManager.h" +#include "vvImageReader.h" +#include "vvStructureSetActor.h" +#include "vvSlicer.h" +#include +#include +#include +#include + +//------------------------------------------------------------------------------ +// Create the tool and automagically (I like this word) insert it in +// the main window menu. +ADD_TOOL(vvToolStructureSetManager); +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent, Qt::WindowFlags f) + :vvToolWidgetBase(parent, f), + vvToolBase(parent), + Ui::vvToolStructureSetManager() { + // Setup the UI + Ui_vvToolStructureSetManager::setupUi(mToolWidget); + mTree->clear(); + mCurrentStructureSet = NULL; + + mDefaultLUTColor = vtkLookupTable::New(); + for(unsigned int i=0; iGetNumberOfTableValues(); i++) { + double r = (rand()/(RAND_MAX+1.0)); + double v = (rand()/(RAND_MAX+1.0)); + double b = (rand()/(RAND_MAX+1.0)); + mDefaultLUTColor->SetTableValue(i, r, v, b); + // std::cout << "mDefaultLUTColor->SetTableValue(" << i << ", " << r << ", " << v << ", " << b << ");" << std::endl; + } + #include "vvDefaultLut.h" + + // Add input selector + AddInputSelector("Select image"); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolStructureSetManager::~vvToolStructureSetManager() { + DD("vvToolStructureSetManager DESTRUCTOR"); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::Initialize() { + SetToolName("StructureSetManager"); + SetToolMenuName("StructureSet"); + SetToolIconFilename(":/common/icons/ducky.png"); + SetToolTip("Display Structure Set."); + SetToolExperimental(true); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) { + // Hide the input selector + QList s; + s.push_back(0); + s.push_back(1); + splitter->setSizes(s); + // Connect open menus + connect(mOpenComboBox, SIGNAL(activated(int)), this, SLOT(open(int))); + DD(mCurrentImage->GetNumberOfDimensions()); + + // To trigger the Render ?? + // connect(m,SIGNAL(releasemouse()),this,SLOT(Render())); + + // connect(m, SIGNAL(UpdateSlice(int, int)), SLOT(UpdateSlice(int, int))); + connect(m, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int))); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::LeftButtonReleaseEvent(int slicer) { + DD("vvToolStructureSetManager::UpdateSlice"); + //DD(slicer); + //DD(view); + //DD(slices); + for(int i=0; iNumberOfSlicers(); i++) { + if (i != slicer); + mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render(); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::open(int type) { + DD(type); + switch (type) { + case 0: openBinaryImage(); return; // Open binary image; + case 1: DD("TODO"); return; // Open DICOM RT + case 2: DD("TODO"); return; // Open mesh + default: std::cerr << "Error ????" << std::endl; exit(0); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::addRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTreeWidgetItem * ww) { + QTreeWidgetItem * w = new QTreeWidgetItem(ww); + w->setText(0, QString("%1").arg(roi->GetROINumber())); + w->setText(1, QString("%1").arg(roi->GetName().c_str())); + QBrush brush(QColor(roi->GetDisplayColor()[0]*255, roi->GetDisplayColor()[1]*255, roi->GetDisplayColor()[2]*255)); + brush.setStyle(Qt::SolidPattern); + for(int i=0; icolumnCount (); i++) { + w->setBackground(i, brush); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::addStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) { + // Main row item + QTreeWidgetItem * ss = new QTreeWidgetItem(mTree); + // ss->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate); + ss->setText(0, QString("S%1").arg(index)); + ss->setText(1, QString("%1").arg(s->GetLabel().c_str())); + + // Insert ROI + const std::vector & rois = s->GetListOfROI(); + for(unsigned int i=0; iSetStructureSet(mStructureSet); + mStructureSetActor->SetSlicerManager(mCurrentSlicerManager); + + // Insert in lists and get index + mStructureSetsList.push_back(mStructureSet); + mStructureSetActorsList.push_back(mStructureSetActor); + int index = mStructureSetsList.size()-1; + + // Return index + return index; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::openBinaryImage() { + DD("openBinaryImage"); + // Select current StructureSet (or create) + int index; + if (mCurrentStructureSet == NULL) { + if (mStructureSetsList.size() == 0) { // Create a default SS + clitk::DicomRT_StructureSet * mStructureSet = new clitk::DicomRT_StructureSet; + index = addStructureSet(mStructureSet); + DD(index); + } + else { // Get first SS + index = 0; + } + // TODO -> SET THIS SS AS CURRENT + mCurrentStructureSet = mStructureSetsList[index]; + mCurrentStructureSetActor = mStructureSetActorsList[index]; + } + else { + index = mCurrentStructureSetIndex; + } + DD(mCurrentStructureSet->GetName()); + + // Open images + QString Extensions = "Images files ( *.mhd *.hdr *.his)"; + Extensions += ";;All Files (*)"; + QStringList filename = + QFileDialog::getOpenFileNames(this,tr("Open binary image"), + mMainWindowBase->GetInputPathName(),Extensions); + if (filename.size() == 0) return; + + for(int i=0; i filenames; + filenames.push_back(filename[i].toStdString()); + mReader->SetInputFilenames(filenames); + mReader->Update(IMAGE); + QApplication::restoreOverrideCursor(); + + if (mReader->GetLastError().size() != 0) { + std::cerr << "Error while reading " << filename[i].toStdString() << std::endl; + QString error = "Cannot open file \n"; + error += mReader->GetLastError().c_str(); + QMessageBox::information(this,tr("Reading problem"),error); + delete mReader; + return; + } + vvImage::Pointer binaryImage = mReader->GetOutput(); + // delete mReader; + + // Check Dimension + int dim = mCurrentImage->GetNumberOfDimensions(); + DD(dim); + int bin_dim = binaryImage->GetNumberOfDimensions(); + DD(bin_dim); + if (dim < bin_dim) { ////////// TO CHANGE FOR 3D/4D + std::ostringstream os; + os << "Error. Loaded binary image is " << bin_dim + << "D while selected image is " << dim << "D" << std::endl; + QMessageBox::information(this,tr("Reading problem"),os.str().c_str()); + return; + } + + // Add a new roi to the structure + int n = mCurrentStructureSet->AddBinaryImageAsNewROI(binaryImage, filename[i].toStdString()); + DD(n); + + // Change color NEED DEFAULT COLOR LIST + DD(mDefaultLUTColor->GetNumberOfTableValues ()); + if (nGetNumberOfTableValues ()) { + double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ()); + DD(color[0]); + DD(color[1]); + DD(color[2]); + mCurrentStructureSet->GetROI(n)->SetDisplayColor(color[0], color[1], color[2]); + } + + // Add a new roi actor + mCurrentStructureSetActor->CreateNewROIActor(n); + } + + // Update the TreeWidget + addStructureSetInTreeWidget(index, mCurrentStructureSet); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::apply() { + close(); +} +//------------------------------------------------------------------------------ diff --git a/vv/vvToolStructureSetManager.h b/vv/vvToolStructureSetManager.h new file mode 100644 index 0000000..e46bf5c --- /dev/null +++ b/vv/vvToolStructureSetManager.h @@ -0,0 +1,69 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +#ifndef VVTOOLSTRUCTURESETMANAGER_H +#define VVTOOLSTRUCTURESETMANAGER_H + +#include +#include "vvToolBase.h" +#include "vvToolWidgetBase.h" +#include "clitkDicomRT_StructureSet.h" +#include "ui_vvToolStructureSetManager.h" + +class vvStructureSetActor; + +//------------------------------------------------------------------------------ +class vvToolStructureSetManager: + public vvToolWidgetBase, + public vvToolBase, + private Ui::vvToolStructureSetManager +{ + Q_OBJECT + public: + vvToolStructureSetManager(vvMainWindowBase* parent=0, Qt::WindowFlags f=0); + ~vvToolStructureSetManager(); + + static void Initialize(); + virtual void InputIsSelected(vvSlicerManager *m); + + int addStructureSet(clitk::DicomRT_StructureSet * mStructureSet); + void addStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s); + void addRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTreeWidgetItem * w); + +public slots: + virtual void apply(); + void open(int type); + void LeftButtonReleaseEvent(int slicer); + + protected: + Ui::vvToolStructureSetManager ui; + void openBinaryImage(); + clitk::DicomRT_StructureSet * mCurrentStructureSet; + vvStructureSetActor * mCurrentStructureSetActor; + int mCurrentStructureSetIndex; + vtkLookupTable * mDefaultLUTColor; + + std::vector mStructureSetsList; + std::vector mStructureSetActorsList; + std::map mStructureSetItemsList; + +}; // end class vvToolStructureSetManager +//------------------------------------------------------------------------------ + +#endif +