X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolStructureSetManager.cxx;h=ac53fb53c3060f7be98ee27c4b2b3e9437d3d29f;hb=fe61abeb6e452e5f54bef60a287aa104e4e02d70;hp=0b0d661da1b9f1ccf9a212aec8559a94911782c5;hpb=e6add2e56013846bcf4368013c4aaf4eb36991ec;p=clitk.git 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); } //------------------------------------------------------------------------------