X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolStructureSetManager.cxx;h=a169c087cfcea1538a77329cbb0410cb4b9c7ce4;hb=d1dc57c5af88ff53c75904b1dd55722f9631a21e;hp=fd09b11f2fc9c74b97af0167da47bd379acd5fa7;hpb=d8b45274cd67177427f3480f2ce4e9345d83612f;p=clitk.git diff --git a/vv/vvToolStructureSetManager.cxx b/vv/vvToolStructureSetManager.cxx index fd09b11..a169c08 100644 --- a/vv/vvToolStructureSetManager.cxx +++ b/vv/vvToolStructureSetManager.cxx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ + ===========================================================================**/ // vv #include "vvToolStructureSetManager.h" @@ -116,11 +116,11 @@ vvToolStructureSetManager::~vvToolStructureSetManager() //------------------------------------------------------------------------------ // STATIC void vvToolStructureSetManager::Initialize() { - SetToolName("ROIManager"); + SetToolName("ROIManager_OLD"); SetToolMenuName("Display ROI (binary image)"); SetToolIconFilename(":/common/icons/tool-roi.png"); SetToolTip("Display ROI from a binary image."); - SetToolExperimental(false); + SetToolExperimental(true); } //------------------------------------------------------------------------------ @@ -137,6 +137,7 @@ void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) if (mCurrentImage->GetNumberOfDimensions() != 3) { QMessageBox::information(this,tr("Sorry only 3D yet"), tr("Sorry only 3D yet")); close(); + return; } // Hide selector HideInputSelector(); // splitter @@ -158,6 +159,7 @@ void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool))); connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor())); connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int))); + connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int))); connect(mReloadButton, SIGNAL(clicked()), this, SLOT(ReloadCurrentROI())); connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int))); connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool))); @@ -187,6 +189,8 @@ void vvToolStructureSetManager::AddRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTr QTreeWidgetItem * w = mTreeWidgetList.back().data(); w->setText(0, QString("%1").arg(roi->GetROINumber())); w->setText(1, QString("%1").arg(roi->GetName().c_str())); + vvROIActor * actor = mStructureSetActorsList[0]->GetROIActor(roi->GetROINumber()); + w->setText(3, QString("%1").arg(actor->GetDepth())); QBrush brush(QColor(roi->GetDisplayColor()[0]*255, roi->GetDisplayColor()[1]*255, roi->GetDisplayColor()[2]*255)); brush.setStyle(Qt::SolidPattern); w->setBackground(2, brush); @@ -201,11 +205,19 @@ void vvToolStructureSetManager::AddRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTr //------------------------------------------------------------------------------ void vvToolStructureSetManager::UpdateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) { // Insert ROI + /* const std::vector & rois = s->GetListOfROI(); for(unsigned int i=0; iGetROIs().begin(); iter != s->GetROIs().end(); iter++) { + clitk::DicomRT_ROI::Pointer roi = iter->second; + if (mMapROIToTreeWidget.find(roi) == mMapROIToTreeWidget.end()) + AddRoiInTreeWidget(roi, mTree); // replace mTree with ss if several SS + } } //------------------------------------------------------------------------------ @@ -247,7 +259,7 @@ void vvToolStructureSetManager::OpenBinaryImage() mCurrentStructureSetActor = mStructureSetActorsList[index].data(); mCurrentStructureSetIndex = index; // Open images - QString Extensions = "Images files ( *.mhd *.hdr *.his)"; + QString Extensions = "Images files ( *.mha *.mhd *.hdr *.his)"; Extensions += ";;All Files (*)"; QStringList filename = QFileDialog::getOpenFileNames(this,tr("Open binary image"), @@ -261,7 +273,7 @@ void vvToolStructureSetManager::OpenBinaryImage() std::vector filenames; filenames.push_back(filename[i].toStdString()); reader->SetInputFilenames(filenames); - reader->Update(IMAGE); + reader->Update(vvImageReader::IMAGE); QApplication::restoreOverrideCursor(); if (reader->GetLastError().size() != 0) { @@ -333,14 +345,14 @@ void vvToolStructureSetManager::AddImage(vvImage * binaryImage, std::string file int n = mCurrentStructureSet->AddBinaryImageAsNewROI(binaryImage, filename); mLoadedROIIndex.push_back(n); if (m_modeBG) - mCurrentStructureSet->GetROI(n)->SetBackgroundValueLabelImage(BG); + mCurrentStructureSet->GetROIFromROINumber(n)->SetBackgroundValueLabelImage(BG); else - mCurrentStructureSet->GetROI(n)->SetForegroundValueLabelImage(BG); + mCurrentStructureSet->GetROIFromROINumber(n)->SetForegroundValueLabelImage(BG); // Change color if (nGetNumberOfTableValues ()) { double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ()); - mCurrentStructureSet->GetROI(n)->SetDisplayColor(color[0], color[1], color[2]); + mCurrentStructureSet->GetROIFromROINumber(n)->SetDisplayColor(color[0], color[1], color[2]); } // Add a new roi actor @@ -432,24 +444,40 @@ void vvToolStructureSetManager::SelectedItemChangedInTree() { mCurrentROI = roi; mCurrentROIActor = actor; + // Warning -> avoid unuseful Render here by disconnect slider // Update GUI + disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree())); + disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool))); + disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int))); + disconnect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor())); + disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool))); + disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor())); + disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int))); + disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int))); + mGroupBoxROI->setEnabled(true); mROInameLabel->setText(roi->GetName().c_str()); mCheckBoxShow->setChecked(actor->IsVisible()); mContourCheckBoxShow->setChecked(actor->IsContourVisible()); mContourWidthSpinBox->setValue(actor->GetContourWidth()); - - // Warning -> avoir unuseful Render here by disconnect slider - disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), - this, SLOT(OpacityChanged(int))); + mDepthSpinBox->setValue(actor->GetDepth()); + w->setText(3, QString("%1").arg(actor->GetDepth())); mOpacitySlider->setValue((int)lrint(actor->GetOpacity()*100)); mOpacitySpinBox->setValue((int)lrint(actor->GetOpacity()*100)); - connect(mOpacitySlider, SIGNAL(valueChanged(int)), - this, SLOT(OpacityChanged(int))); - actor->Update(); + connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree())); + connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool))); + connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int))); + connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor())); + connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool))); + connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor())); + connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int))); + connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int))); + + // is this needed ? + // actor->Update(); // Final rendering - mCurrentSlicerManager->Render(); + // mCurrentSlicerManager->Render(); } //------------------------------------------------------------------------------ @@ -588,12 +616,24 @@ void vvToolStructureSetManager::ChangeContourWidth(int n) { //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvToolStructureSetManager::ChangeDepth(int n) { + mCurrentROIActor->SetDepth(n); + mCurrentROIActor->UpdateImage(); + mCurrentSlicerManager->Render(); + QList l = mTree->selectedItems(); + QTreeWidgetItem * w = l[0]; + w->setText(3, QString("%1").arg(mCurrentROIActor->GetDepth())); +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvToolStructureSetManager::ReloadCurrentROI() { // Reload image vvImageReader::Pointer reader = vvImageReader::New(); reader->SetInputFilename(mCurrentROI->GetFilename()); - reader->Update(IMAGE); + reader->Update(vvImageReader::IMAGE); if (reader->GetLastError() != "") { QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), reader->GetLastError().c_str()); return;