]> Creatis software - clitk.git/blobdiff - vv/vvToolROIManager.cxx
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / vv / vvToolROIManager.cxx
index adaeeb28075d0c3a64d7dd2e017f78daf45b2e89..072d3634b23a1c26129ba466fc39c0fcae88224b 100644 (file)
@@ -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,7 +317,7 @@ 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));
@@ -359,8 +359,10 @@ 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()) { 
     vvProgressDialog p("Reading ROI...", true);
@@ -374,8 +376,8 @@ void vvToolROIManager::OpenDicomImage(std::string filename)
     // Loop on selected struct
     std::vector<int> list = selector.getSelectedItems();
     for (uint i=0; i<list.size(); i++) {
-      p.SetProgress(i, list.size());
-      
+      p.SetProgress(i, list.size());      
+       
       clitk::DicomRTStruct2ImageFilter filter;
       filter.SetCropMaskEnabled(true);
       filter.SetImage(mCurrentImage);
@@ -490,9 +492,7 @@ void vvToolROIManager::UpdateAllContours()
   for(unsigned int i=0; i<mROIList.size(); i++) {
     mROIActorsList[i]->Update();
   }
-  for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
-    mCurrentSlicerManager->GetSlicer(i)->Render();
-  }
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
@@ -678,6 +678,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();
 
@@ -735,6 +737,9 @@ void vvToolROIManager::ChangeDepth(int n) {
 
 //------------------------------------------------------------------------------
 void vvToolROIManager::ReloadCurrentROI() {
+  if (mCurrentROI->GetImage()) {
+    return; // do nothing (contour from rt struct do not reload)
+  }
 
   // Remove all contours/overlay first
   bool visible = mCurrentROIActor->IsVisible();