X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolROIManager.cxx;h=c02516f94dde6c9cca9cff898d4543ab1cdfccb7;hb=25964a70b332af11b254f1bf6e1bf9c8d816d7f7;hp=b6784004958c433a88d27756f6476dcbd4d68d24;hpb=152c742cc0002aaec310a800b5016dc3fa6c662f;p=clitk.git diff --git a/vv/vvToolROIManager.cxx b/vv/vvToolROIManager.cxx index b678400..c02516f 100644 --- a/vv/vvToolROIManager.cxx +++ b/vv/vvToolROIManager.cxx @@ -104,9 +104,9 @@ vvToolROIManager::~vvToolROIManager() // STATIC void vvToolROIManager::Initialize() { SetToolName("ROIManager"); - SetToolMenuName("Display ROI (binary image)"); + SetToolMenuName("Open ROI (binary image or RT-STRUCT)"); SetToolIconFilename(":/common/icons/tool-roi.png"); - SetToolTip("Display ROI from a binary image."); + SetToolTip("Display ROI from a binary image or a RT-struct file."); SetToolExperimental(false); } //------------------------------------------------------------------------------ @@ -299,7 +299,7 @@ void vvToolROIManager::Open() QString Extensions = "Images or Dicom-Struct files ( *.mha *.mhd *.hdr *.his *.dcm RS*)"; Extensions += ";;All Files (*)"; QStringList filename = - QFileDialog::getOpenFileNames(this,tr("Open binary image"), + QFileDialog::getOpenFileNames(this,tr("Open binary image or DICOM RT Struct"), mMainWindowBase->GetInputPathName(),Extensions); if (filename.size() == 0) return; if (filename.size() > 1) { OpenBinaryImage(filename); return; } @@ -317,18 +317,22 @@ void vvToolROIManager::Open() void vvToolROIManager::OpenBinaryImage(QStringList & filename) { if (filename.size() == 0) return; + + vvProgressDialog p("Reading ROI ...", true); + p.SetCancelButtonEnabled(false); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); // For each selected file, open the image - for(int i=0; i filenames; filenames.push_back(filename[i].toStdString()); reader->SetInputFilenames(filenames); reader->Update(vvImageReader::IMAGE); - QApplication::restoreOverrideCursor(); - + if (reader->GetLastError().size() != 0) { std::cerr << "Error while reading " << filename[i].toStdString() << std::endl; QString error = "Cannot open file \n"; @@ -337,10 +341,15 @@ void vvToolROIManager::OpenBinaryImage(QStringList & filename) return; } vvImage::Pointer binaryImage = reader->GetOutput(); - AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value(), + std::ostringstream oss; + oss << vtksys::SystemTools:: + GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename[i].toStdString())); + std::string name = oss.str(); + AddImage(binaryImage, name, filename[i].toStdString(), mBackgroundValueSpinBox->value(), (!mBGModeCheckBox->isChecked())); mOpenedBinaryImageFilenames.push_back(filename[i]); } + QApplication::restoreOverrideCursor(); // Update the contours UpdateAllContours(); @@ -354,14 +363,15 @@ void vvToolROIManager::OpenDicomImage(std::string filename) // GUI selector of roi vvMeshReader reader; reader.SetFilename(filename); + vvStructSelector selector; selector.SetStructures(reader.GetROINames()); + selector.SetPropagationCheckBoxFlag(false); - if (selector.exec()) { - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - + if (selector.exec()) { vvProgressDialog p("Reading ROI...", true); p.SetCancelButtonEnabled(false); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); // Read information clitk::DicomRT_StructureSet::Pointer s = clitk::DicomRT_StructureSet::New(); @@ -370,8 +380,8 @@ void vvToolROIManager::OpenDicomImage(std::string filename) // Loop on selected struct std::vector list = selector.getSelectedItems(); for (uint i=0; iAddVtkImage(filter.GetOutput()); // Add to gui - AddImage(binaryImage, s->GetROIFromROINumber(list[i])->GetName(), 0, true); + AddImage(binaryImage, s->GetROIFromROINumber(list[i])->GetName(), "", 0, true); // "" = no filename mOpenedBinaryImageFilenames.push_back(filename.c_str()); } @@ -397,7 +407,9 @@ void vvToolROIManager::OpenDicomImage(std::string filename) //------------------------------------------------------------------------------ -void vvToolROIManager::AddImage(vvImage * binaryImage, std::string filename, +void vvToolROIManager::AddImage(vvImage * binaryImage, + std::string name, + std::string filename, double BG, bool modeBG) { // Check Dimension @@ -415,9 +427,9 @@ void vvToolROIManager::AddImage(vvImage * binaryImage, std::string filename, int n = mROIList.size(); // Compute the name of the new ROI - std::ostringstream oss; - oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename)); - std::string name = oss.str(); + // std::ostringstream oss; + // oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename)); + // std::string name = oss.str(); // Set color std::vector color; @@ -486,9 +498,7 @@ void vvToolROIManager::UpdateAllContours() for(unsigned int i=0; iUpdate(); } - for(int i=0; iGetNumberOfSlicers(); i++) { - mCurrentSlicerManager->GetSlicer(i)->Render(); - } + mCurrentSlicerManager->Render(); } //------------------------------------------------------------------------------ @@ -674,6 +684,8 @@ void vvToolROIManager::ChangeColor() { mCurrentROIActor->GetROI()->GetDisplayColor()[1], mCurrentROIActor->GetROI()->GetDisplayColor()[2]); QColor c = QColorDialog::getColor(color, this, "Choose the ROI color"); + if (!c.isValid()) return;// User cancel + mCurrentROIActor->GetROI()->SetDisplayColor(c.redF(), c.greenF(), c.blueF()); mCurrentROIActor->UpdateColor(); @@ -731,6 +743,9 @@ void vvToolROIManager::ChangeDepth(int n) { //------------------------------------------------------------------------------ void vvToolROIManager::ReloadCurrentROI() { + if (mCurrentROI->GetFilename() == "") { + return; // do nothing (contour from rt struct do not reload) + } // Remove all contours/overlay first bool visible = mCurrentROIActor->IsVisible();