From: dsarrut Date: Mon, 26 Apr 2010 09:25:54 +0000 (+0000) Subject: - display binary image as overlay X-Git-Tag: v1.2.0~693 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=fe61abeb6e452e5f54bef60a287aa104e4e02d70;p=clitk.git - display binary image as overlay --- diff --git a/common/clitkDicomRT_ROI.cxx b/common/clitkDicomRT_ROI.cxx index 7aca4be..72f8273 100644 --- a/common/clitkDicomRT_ROI.cxx +++ b/common/clitkDicomRT_ROI.cxx @@ -69,7 +69,6 @@ const std::vector & clitk::DicomRT_ROI::GetDisplayColor() const { } //-------------------------------------------------------------------- - //-------------------------------------------------------------------- void clitk::DicomRT_ROI::Print(std::ostream & os) const { @@ -80,6 +79,20 @@ void clitk::DicomRT_ROI::Print(std::ostream & os) const { //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void clitk::DicomRT_ROI::SetBackgroundValueLabelImage(double bg){ + mBackgroundValue = bg; +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +double clitk::DicomRT_ROI::GetBackgroundValueLabelImage() const { + return mBackgroundValue; +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- void clitk::DicomRT_ROI::Read(std::map & rois, gdcm::SQItem * item) { diff --git a/common/clitkDicomRT_ROI.h b/common/clitkDicomRT_ROI.h index e7aaa28..8ec0404 100644 --- a/common/clitkDicomRT_ROI.h +++ b/common/clitkDicomRT_ROI.h @@ -46,6 +46,9 @@ namespace clitk { void SetDisplayColor(double r, double v, double b); + double GetBackgroundValueLabelImage() const; + void SetBackgroundValueLabelImage(double bg); + protected: void ComputeMesh(); std::string mName; @@ -55,6 +58,7 @@ namespace clitk { vtkPolyData * mMesh; bool mMeshIsUpToDate; vvImage::Pointer mImage; + double mBackgroundValue; }; //-------------------------------------------------------------------- diff --git a/common/clitkImageCommon.cxx b/common/clitkImageCommon.cxx index 45dfa0d..c9085c6 100644 --- a/common/clitkImageCommon.cxx +++ b/common/clitkImageCommon.cxx @@ -129,7 +129,11 @@ void clitk::printImageHeader(itk::ImageIOBase::Pointer header, std::ostream & os << " "; for(unsigned int i=0; i< dim-1; i++) os << inputSpacing[i] << "x"; - os << inputSpacing[dim-1]; + os << inputSpacing[dim-1] + << " "; + for(unsigned int i=0; i< dim-1; i++) + os << inputOrigin[i] << "x"; + os << inputOrigin[dim-1] << " "; } else { os << "Dim = " << dim << "D" << std::endl; diff --git a/common/clitkImageCommon.txx b/common/clitkImageCommon.txx index 547c2c7..e682593 100644 --- a/common/clitkImageCommon.txx +++ b/common/clitkImageCommon.txx @@ -17,16 +17,7 @@ ======================================================================-====*/ #ifndef CLITKIMAGECOMMON_TXX #define CLITKIMAGECOMMON_TXX -/** - ------------------------------------------------- - * @file clitkImageCommon.txx - * @author David Sarrut - * @date 07 Sep 2007 11:34:19 - * - * @brief - * - * - -------------------------------------------------*/ + //-------------------------------------------------------------------- template @@ -101,9 +92,8 @@ typename itk::Image::Pointer NewImage4D(int sx, int sy, int sz, int template typename ImageType::Pointer NewImageLike(const typename ImageType::Pointer input, bool allocate) { typename ImageType::Pointer output = ImageType::New(); - output->SetRegions(input->GetLargestPossibleRegion()); - output->SetOrigin(input->GetOrigin()); - output->SetSpacing(input->GetSpacing()); + output->CopyInformation(input); + output->SetRegions(input->GetLargestPossibleRegion()); if (allocate) output->Allocate(); return output; } diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 18347c2..1094b6c 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -60,7 +60,7 @@ LINK_DIRECTORIES(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ) #========================================================= -OPTION(CLITK_VV_USE_BDCM "Build vv with Dicom selector bdcm" OFF) +# OPTION(CLITK_VV_USE_BDCM "Build vv with Dicom selector bdcm" OFF) SET(vv_SRCS vvInfoPanel.cxx @@ -194,26 +194,26 @@ ENDIF(CMAKE_COMPILER_IS_GNUCC) ENDIF(NOT __APPLE__) #========================================================= -IF (CLITK_VV_USE_BDCM) - FIND_PACKAGE(bdcm) - IF(bdcm_FOUND) - INCLUDE(${bdcm_USE_FILE}) - ELSE(bdcm_FOUND) - MESSAGE(FATAL_ERROR - "Cannot build without BDCM. Please set BDCM_DIR.") - ENDIF(bdcm_FOUND) - #LINK_DIRECTORIES(/home/dsarrut/src/bdcm/build/) - #INCLUDE_DIRECTORIES(/home/dsarrut/src/bdcm/src2/) +# IF (CLITK_VV_USE_BDCM) +# FIND_PACKAGE(bdcm) +# IF(bdcm_FOUND) +# INCLUDE(${bdcm_USE_FILE}) +# ELSE(bdcm_FOUND) +# MESSAGE(FATAL_ERROR +# "Cannot build without BDCM. Please set BDCM_DIR.") +# ENDIF(bdcm_FOUND) +# #LINK_DIRECTORIES(/home/dsarrut/src/bdcm/build/) +# #INCLUDE_DIRECTORIES(/home/dsarrut/src/bdcm/src2/) - FIND_PACKAGE(GDCM) - IF(GDCM_FOUND) - INCLUDE(${GDCM_USE_FILE}) - ELSE(GDCM_FOUND) - MESSAGE(FATAL_ERROR - "Cannot build without GDCM. Please set GDCM_DIR.") - ENDIF(GDCM_FOUND) +# FIND_PACKAGE(GDCM) +# IF(GDCM_FOUND) +# INCLUDE(${GDCM_USE_FILE}) +# ELSE(GDCM_FOUND) +# MESSAGE(FATAL_ERROR +# "Cannot build without GDCM. Please set GDCM_DIR.") +# ENDIF(GDCM_FOUND) -ENDIF (CLITK_VV_USE_BDCM) +# ENDIF (CLITK_VV_USE_BDCM) IF(WIN32) SET(EXE_ICON vvIcon.rc) diff --git a/vv/qt_ui/vvToolStructureSetManager.ui b/vv/qt_ui/vvToolStructureSetManager.ui index a9c7af6..126bf79 100644 --- a/vv/qt_ui/vvToolStructureSetManager.ui +++ b/vv/qt_ui/vvToolStructureSetManager.ui @@ -6,35 +6,124 @@ 0 0 - 601 - 414 + 483 + 519 Form - + - - - 0 - + - - Open binary image - + + + Add Label Image from file + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + Open label image + + + + + + + :/common/icons/fileopen.png:/common/icons/fileopen.png + + + + + + + + + + 0 + 0 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt;">Background value :</span></p></body></html> + + + + + + + + + + - - Open DICOM RT StructureSet - + + + Add DICOM RT contours + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + Open DICOM RT Struct + + + + + + + :/common/icons/fileopen.png:/common/icons/fileopen.png + + + + + - - Open VTK mesh - + + + Qt::Horizontal + + + + 40 + 20 + + + - + @@ -83,16 +172,6 @@ Name - - - Show - - - - - Refresh - - 1 @@ -109,14 +188,6 @@ Default - - - - - - :/common/icons/standardbutton-cancel-16.png - :/common/icons/standardbutton-apply-16.png:/common/icons/standardbutton-cancel-16.png - ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate @@ -132,6 +203,9 @@ 2 + + + @@ -145,11 +219,17 @@ 1 + + + 2 + + + @@ -199,6 +279,74 @@ Current ROI + + + + + + Show + + + false + + + + + + + + + + false + + + color + + + + + + + + + + + + + + :/common/icons/rotateright.png:/common/icons/rotateright.png + + + + + + + + + + + + 0 + 0 + + + + Opacity + + + + + + + Qt::Horizontal + + + + + + + + @@ -248,5 +396,38 @@ - + + + horizontalSlider + valueChanged(int) + spinBox + setValue(int) + + + 344 + 416 + + + 426 + 416 + + + + + spinBox + valueChanged(int) + horizontalSlider + setValue(int) + + + 432 + 421 + + + 351 + 421 + + + + diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx index f54b743..1ea3c6f 100644 --- a/vv/vvBinaryImageOverlayActor.cxx +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -61,7 +61,6 @@ void vvBinaryImageOverlayActor::setColor(double r, double g, double b) { //------------------------------------------------------------------------------ - //------------------------------------------------------------------------------ void vvBinaryImageOverlayActor::setSlicer(vvSlicer * slicer) { mSlicer = slicer; @@ -83,13 +82,17 @@ void vvBinaryImageOverlayActor::initialize() { // Create an actor for each time slice for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) { DD(numImage); + + // how many intensity ? + + 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(mBackgroundValue, 0, 0, 0, 0.0); // BG lut->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG DD(mColor[0]); mOverlayMapper->SetLookupTable(lut); @@ -109,8 +112,9 @@ void vvBinaryImageOverlayActor::initialize() { //------------------------------------------------------------------------------ -void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image) { +void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image, double bg) { mImage = image; + mBackgroundValue = bg; } //------------------------------------------------------------------------------ @@ -141,16 +145,11 @@ void vvBinaryImageOverlayActor::showActors() { //------------------------------------------------------------------------------ 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"); + //DD("=========== NOTHING"); return; // Nothing to do } } @@ -160,18 +159,6 @@ void vvBinaryImageOverlayActor::update(int slicer, int slice) { 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]; @@ -185,10 +172,7 @@ void vvBinaryImageOverlayActor::update(int slicer, int slice) { // << maskExtent[3] << " " << maskExtent[4] << " " << maskExtent[5] << std::endl; SetDisplayExtentAndCameraPosition(orientation, mSlice, maskExtent, mImageActorList[mTSlice], 0.0); - // TOO SLOW ? - //mSlicer->Render(); - - // + // set previous slice mPreviousTSlice = mSlicer->GetTSlice(); mPreviousSlice = mSlicer->GetSlice(); } @@ -249,12 +233,9 @@ void vvBinaryImageOverlayActor::SetDisplayExtentAndCameraPosition(int orientatio int * extent, vtkImageActor * actor, double position) { - // DD("SetDisplayExtentAndCameraPosition"); - //DD(orientation); - //DD(slice); actor->SetDisplayExtent(extent); - + // Set position if (orientation == vtkImageViewer2::SLICE_ORIENTATION_XY) { if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) actor->SetPosition(0,0, position); diff --git a/vv/vvBinaryImageOverlayActor.h b/vv/vvBinaryImageOverlayActor.h index e4e3be9..f33014d 100644 --- a/vv/vvBinaryImageOverlayActor.h +++ b/vv/vvBinaryImageOverlayActor.h @@ -41,7 +41,7 @@ class vvBinaryImageOverlayActor void hideActors(); void showActors(); void setColor(double r, double g, double b); - void setImage(vvImage::Pointer image); + void setImage(vvImage::Pointer image, double bg); void initialize(); protected: @@ -53,6 +53,7 @@ class vvBinaryImageOverlayActor vvImage::Pointer mImage; std::vector mColor; double mAlpha; + double mBackgroundValue; std::vector mMapperList; std::vector mImageActorList; diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 9fa6329..abf38e9 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -2445,8 +2445,8 @@ void vvMainWindow::NOVerticalSliderChanged() { { mSlicerManagers[i]->GetSlicer(0)->SetSlice(value); mSlicerManagers[i]->VerticalSliderHasChanged(0, value); - // mSlicerManagers[i]->UpdateSlice(0); - // <-- DS add this. Not too much update ? YES. + // mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES. + mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } @@ -2462,6 +2462,8 @@ void vvMainWindow::NEVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(1)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(1, value); + mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } @@ -2477,6 +2479,8 @@ void vvMainWindow::SOVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(2)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(2, value); + mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } @@ -2492,6 +2496,8 @@ void vvMainWindow::SEVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(3)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(3, value); + mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } diff --git a/vv/vvROIActor.cxx b/vv/vvROIActor.cxx index f4db30b..f1eb222 100644 --- a/vv/vvROIActor.cxx +++ b/vv/vvROIActor.cxx @@ -23,6 +23,7 @@ #include #include #include +//#include #include #include #include @@ -62,7 +63,6 @@ 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)); @@ -74,7 +74,7 @@ void vvROIActor::Initialize() { mImageContour[i]->setPreserveMemoryModeEnabled(false); mOverlayActors.push_back(new vvBinaryImageOverlayActor); - mOverlayActors[i]->setImage(mROI->GetImage()); + mOverlayActors[i]->setImage(mROI->GetImage(), mROI->GetBackgroundValueLabelImage()); mOverlayActors[i]->setColor(mROI->GetDisplayColor()[0], mROI->GetDisplayColor()[1], mROI->GetDisplayColor()[2]); @@ -92,7 +92,6 @@ void vvROIActor::Initialize() { //------------------------------------------------------------------------------ void vvROIActor::Update() { - DD("vvROIActor::Update"); for(int i=0; iNumberOfSlicers(); i++) { UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice()); } @@ -102,9 +101,6 @@ void vvROIActor::Update() { //------------------------------------------------------------------------------ void vvROIActor::UpdateSlice(int slicer, int slices) { - // DD("UpdateSlice"); - // DD(slicer); - // DD(slices); if (!mROI->GetImage()) return; if (!mSlicerManager) { @@ -115,10 +111,10 @@ void vvROIActor::UpdateSlice(int slicer, int slices) { // CONTOUR HERE // mImageContour[slicer]->update(1.0); - + // Refresh overlays mOverlayActors[slicer]->update(slicer, slices); - // TOO SLOW !!!!! - // mSlicerManager->GetSlicer(slicer)->Render(); + // Do not used the following line : TOO SLOW. + // mSlicerManager->GetSlicer(slicer)->GetRenderWindow()->Render(); } //------------------------------------------------------------------------------ diff --git a/vv/vvStructureSetActor.cxx b/vv/vvStructureSetActor.cxx index 6473a7d..819a653 100644 --- a/vv/vvStructureSetActor.cxx +++ b/vv/vvStructureSetActor.cxx @@ -46,6 +46,17 @@ void vvStructureSetActor::SetSlicerManager(vvSlicerManager * s) { //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +vvROIActor * vvStructureSetActor::GetROIActor(int n) { + if (mMapROIIndex.find(n) == mMapROIIndex.end()) { + std::cerr << "No ROI number " << n << std::endl; + return NULL; + } + return mROIActors[mMapROIIndex[n]]; +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvStructureSetActor::CreateNewROIActor(int n) { DD("AddROIActor"); @@ -64,9 +75,9 @@ void vvStructureSetActor::CreateNewROIActor(int n) { actor->SetROI(roi); actor->SetSlicerManager(mSlicerManager); actor->Initialize(); - // + mMapROIIndex[n] = mROIActors.size()-1; - actor->Update(); + // actor->Update(); } //------------------------------------------------------------------------------ diff --git a/vv/vvStructureSetActor.h b/vv/vvStructureSetActor.h index 91c1058..119169d 100644 --- a/vv/vvStructureSetActor.h +++ b/vv/vvStructureSetActor.h @@ -35,11 +35,13 @@ class vvStructureSetActor: public QObject { void SetStructureSet(clitk::DicomRT_StructureSet * s); void SetSlicerManager(vvSlicerManager * s); void CreateNewROIActor(int n); + vvROIActor* GetROIActor(int n); protected: clitk::DicomRT_StructureSet * mStructureSet; vvSlicerManager * mSlicerManager; std::vector mROIActors; + std::map mMapROIIndex; }; // end class vvStructureSetActor //------------------------------------------------------------------------------ diff --git a/vv/vvToolStructureSetManager.cxx b/vv/vvToolStructureSetManager.cxx index 0b0d661..ac53fb5 100644 --- a/vv/vvToolStructureSetManager.cxx +++ b/vv/vvToolStructureSetManager.cxx @@ -20,6 +20,7 @@ #include "vvImageReader.h" #include "vvStructureSetActor.h" #include "vvSlicer.h" +#include "vvROIActor.h" #include #include #include @@ -83,14 +84,38 @@ void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) { s.push_back(1); splitter->setSizes(s); // Connect open menus - connect(mOpenComboBox, SIGNAL(activated(int)), this, SLOT(open(int))); + // connect(mOpenComboBox, SIGNAL(activated(int)), this, SLOT(open(int))); + + connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(openBinaryImage())); + 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))); + // Seems that the following is not needed to refresh ... + // connect(m, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int))); + + connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(selectedItemChangedInTree())); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::selectedItemChangedInTree() { + DD("selectedItemChangedInTree"); + QList l = mTree->selectedItems(); + DD(l.size()); + QTreeWidgetItem * w = l[0]; + if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) return; // Search for SS (first) + clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w]; + DD(roi->GetName()); + setCurrentSelectedROI(roi); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::setCurrentSelectedROI(clitk::DicomRT_ROI * roi) { + // mCheckBoxShow = // get roi actor .../ + } //------------------------------------------------------------------------------ @@ -132,30 +157,37 @@ void vvToolStructureSetManager::addRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTr for(int i=0; icolumnCount (); i++) { w->setBackground(i, brush); } + mMapROIToTreeWidget[roi] = w; + mMapTreeWidgetToROI[w] = roi; + // Connect ROI TreeWidget + // TODO } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -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())); +void vvToolStructureSetManager::updateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) { + QTreeWidgetItem * ss; + if (mMapStructureSetIndexToTreeWidget.find(index) == mMapStructureSetIndexToTreeWidget.end()) { + // Main row item + 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 in list + mMapStructureSetIndexToTreeWidget[index] = ss; + + // Connect Structure TreeWidget + // TODO + } + else ss = mMapStructureSetIndexToTreeWidget[index]; // Insert ROI const std::vector & rois = s->GetListOfROI(); for(unsigned int i=0; i SET THIS SS AS CURRENT - mCurrentStructureSet = mStructureSetsList[index]; - mCurrentStructureSetActor = mStructureSetActorsList[index]; } else { index = mCurrentStructureSetIndex; } + DD(index); + // TODO -> SET THIS SS AS CURRENT + mCurrentStructureSet = mStructureSetsList[index]; + mCurrentStructureSetActor = mStructureSetActorsList[index]; + mCurrentStructureSetIndex = index; DD(mCurrentStructureSet->GetName()); // Open images @@ -210,6 +245,7 @@ void vvToolStructureSetManager::openBinaryImage() { mMainWindowBase->GetInputPathName(),Extensions); if (filename.size() == 0) return; + std::vector mLoadedROIIndex; for(int i=0; iGetOutput(); - // 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; - } + // 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); + mLoadedROIIndex.push_back(n); + + mCurrentStructureSet->GetROI(n)->SetBackgroundValueLabelImage(mBackgroundValueSpinBox->value()); + + // 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); + } // end loop on n selected filenames - // Add a new roi to the structure - int n = mCurrentStructureSet->AddBinaryImageAsNewROI(binaryImage, filename[i].toStdString()); - DD(n); + // Update the TreeWidget + updateStructureSetInTreeWidget(index, mCurrentStructureSet); - // 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]); + // Render loaded ROIs (the first is sufficient) + for(unsigned int i=0; iGetROIActor(mLoadedROIIndex[i])->Update(); } - - // Add a new roi actor - mCurrentStructureSetActor->CreateNewROIActor(n); + for(int i=0; iNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetSlicer(i)->Render(); } - - // Update the TreeWidget - addStructureSetInTreeWidget(index, mCurrentStructureSet); } //------------------------------------------------------------------------------ diff --git a/vv/vvToolStructureSetManager.h b/vv/vvToolStructureSetManager.h index e46bf5c..0295513 100644 --- a/vv/vvToolStructureSetManager.h +++ b/vv/vvToolStructureSetManager.h @@ -42,25 +42,30 @@ class vvToolStructureSetManager: virtual void InputIsSelected(vvSlicerManager *m); int addStructureSet(clitk::DicomRT_StructureSet * mStructureSet); - void addStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s); + void updateStructureSetInTreeWidget(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); + void openBinaryImage(); + void selectedItemChangedInTree(); protected: Ui::vvToolStructureSetManager ui; - void openBinaryImage(); clitk::DicomRT_StructureSet * mCurrentStructureSet; vvStructureSetActor * mCurrentStructureSetActor; int mCurrentStructureSetIndex; vtkLookupTable * mDefaultLUTColor; - + + void setCurrentSelectedROI(clitk::DicomRT_ROI * roi); + std::vector mStructureSetsList; std::vector mStructureSetActorsList; - std::map mStructureSetItemsList; + std::map mMapStructureSetIndexToTreeWidget; + std::map mMapROIToTreeWidget; + std::map mMapTreeWidgetToROI; }; // end class vvToolStructureSetManager //------------------------------------------------------------------------------