]> Creatis software - clitk.git/blobdiff - vv/vvToolStructureSetManager.cxx
Corrected bug in landmarks with negative spacing
[clitk.git] / vv / vvToolStructureSetManager.cxx
index b04b0286c31a7656c638d436c76e1247753c8101..a698e3c5e4ca95a80ea07c5eab6dc38ff66654c2 100644 (file)
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+  ======================================================================-====*/
 
+// vv
 #include "vvToolStructureSetManager.h"
 #include "vvImageReader.h"
 #include "vvStructureSetActor.h"
 #include "vvSlicer.h"
 #include "vvROIActor.h"
 
+// Qt
 #include <QFileDialog>
 #include <QMessageBox>
 #include <QColorDialog>
 
+// vtk
 #include <vtkLookupTable.h>
 #include <vtkRenderWindow.h>
 
@@ -37,18 +40,42 @@ ADD_TOOL(vvToolStructureSetManager);
 
 //------------------------------------------------------------------------------
 vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent, Qt::WindowFlags f)
-  :vvToolWidgetBase(parent, f),
+  :vvToolWidgetBase(parent, f),//, true),
    vvToolBase<vvToolStructureSetManager>(parent),
    Ui::vvToolStructureSetManager()
 {
   // Setup the UI
+  /*
+  QWidget * aw = new QWidget(parent, f);
+  QVBoxLayout * verticalLayout = new QVBoxLayout(aw);
+  verticalLayout->addWidget(mToolInputSelectionWidget);
+  verticalLayout->addWidget(mToolWidget);
+  aw->setLayout(verticalLayout);
+  */
   Ui_vvToolStructureSetManager::setupUi(mToolWidget);
+
+  // ----------------
+  // Essai TAB
+  /*
+  //int a = mMainWindowBase->GetTab()->addTab(mToolWidget, "Toto"); 
+  int a = mMainWindowBase->GetTab()->addTab(aw, "Toto"); 
+
+  // essai avec mToolWidget ? ok  mais frame à cacher ... 
+  // Changer le construceur par defautl de widgetbase -> pas dialog, pas parent (cf doc)
+  mMainWindowBase->GetTab()->setCurrentIndex(a); 
+  mMainWindowBase->GetTab()->setTabIcon(a, QIcon(vvToolCreator<vvToolStructureSetManager>::GetInstance()->mToolIconFilename));
+  DD(this->width());
+  */
+  // ---------------
+
   mTree->clear();
   mCurrentStructureSet = NULL;
   mCurrentStructureSetIndex = -1;
   mGroupBoxROI->setEnabled(false);
   mCurrentROIActor = NULL;
-
+  mIsAllVisibleEnabled = false;
+  mNumberOfVisibleROI = 0;
+  mNumberOfVisibleContourROI = 0;
   mDefaultLUTColor = vtkLookupTable::New();
   for(unsigned int i=0; i<mDefaultLUTColor->GetNumberOfTableValues(); i++) {
     double r = (rand()/(RAND_MAX+1.0));
@@ -68,18 +95,16 @@ vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent,
 //------------------------------------------------------------------------------
 vvToolStructureSetManager::~vvToolStructureSetManager()
 {
-  DD("vvToolStructureSetManager DESTRUCTOR");
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::Initialize()
-{
-  SetToolName("StructureSetManager");
-  SetToolMenuName("StructureSet");
+void vvToolStructureSetManager::Initialize() {
+  SetToolName("ROIManager");
+  SetToolMenuName("Display ROI");
   SetToolIconFilename(":/common/icons/ducky.png");
-  SetToolTip("Display Structure Set.");
+  SetToolTip("Display ROI from label image.");
   SetToolExperimental(true);
 }
 //------------------------------------------------------------------------------
@@ -88,126 +113,79 @@ void vvToolStructureSetManager::Initialize()
 //------------------------------------------------------------------------------
 void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m)
 {
-  // Hide the input selector
-  QList<int> s;
-  s.push_back(0);
-  s.push_back(1);
-  splitter->setSizes(s);
-  // Connect open menus
-  //  connect(mOpenComboBox, SIGNAL(activated(int)), this, SLOT(open(int)));
-
-  connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(openBinaryImage()));
-
-  DD(mCurrentImage->GetNumberOfDimensions());
-
-  // Seems that the following is not needed to refresh ...
-  //  connect(m, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
-
-  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()));
-}
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-void vvToolStructureSetManager::LeftButtonReleaseEvent(int slicer)
-{
-  DD("vvToolStructureSetManager::UpdateSlice");
-  //DD(slicer);
-  //DD(view);
-  //DD(slices);
-  for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
-    if (i != slicer);
-    mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render();
+  // Refuse if 4D
+  if (mCurrentImage->GetNumberOfDimensions() != 3) {
+    QMessageBox::information(this,tr("Sorry only 3D yet"), tr("Sorry only 3D yet"));
+    close();
+    // return;
   }
+  // Hide selector
+  HideInputSelector(); // splitter
+  //  mToolInputSelectionWidget->hide();
+  // Connect open menus
+  connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(OpenBinaryImage()));
+  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(mReloadButton, SIGNAL(clicked()), this, SLOT(ReloadCurrentROI()));
+  connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
+  connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::open(int type)
-{
-  DD(type);
+void vvToolStructureSetManager::Open(int type) {
   switch (type) {
-  case 0:
-    openBinaryImage();
-    return; // Open binary image;
-  case 1:
-    DD("TODO");
-    return; // Open DICOM RT
-  case 2:
-    DD("TODO");
-    return; // Open mesh
-  default:
-    std::cerr << "Error ????" << std::endl;
-    exit(0);
+  case 0: OpenBinaryImage(); return; // Open binary image;
+  case 1: DD("TODO"); return; // Open DICOM RT
+  case 2: DD("TODO"); return; // Open mesh
+  default: std::cerr << "Error ????" << std::endl; exit(0);
   }
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::addRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTreeWidgetItem * ww)
-{
+void vvToolStructureSetManager::AddRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTreeWidget * ww) {
   QTreeWidgetItem * w = new QTreeWidgetItem(ww);
   w->setText(0, QString("%1").arg(roi->GetROINumber()));
   w->setText(1, QString("%1").arg(roi->GetName().c_str()));
   QBrush brush(QColor(roi->GetDisplayColor()[0]*255, roi->GetDisplayColor()[1]*255, roi->GetDisplayColor()[2]*255));
   brush.setStyle(Qt::SolidPattern);
-  for(int i=0; i<w->columnCount (); i++) {
-    w->setBackground(i, brush);
-  }
+  w->setBackground(2, brush);
   mMapROIToTreeWidget[roi] = w;
   mMapTreeWidgetToROI[w] = roi;
-  // Connect ROI TreeWidget
-  // TODO
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-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];
-
+void vvToolStructureSetManager::UpdateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) {
   // Insert ROI
   const std::vector<clitk::DicomRT_ROI*> & rois = s->GetListOfROI();
   for(unsigned int i=0; i<rois.size(); i++) {
     if (mMapROIToTreeWidget.find(rois[i]) == mMapROIToTreeWidget.end())
-      addRoiInTreeWidget(rois[i], ss);
+      AddRoiInTreeWidget(rois[i], mTree); // replace mTree with ss if several SS
   }
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-int vvToolStructureSetManager::addStructureSet(clitk::DicomRT_StructureSet * mStructureSet)
-{
-
+int vvToolStructureSetManager::AddStructureSet(clitk::DicomRT_StructureSet * mStructureSet) {
   // Create actor for this SS
   vvStructureSetActor * mStructureSetActor = new vvStructureSetActor;
   mStructureSetActor->SetStructureSet(mStructureSet);
   mStructureSetActor->SetSlicerManager(mCurrentSlicerManager);
-
   // Insert in lists and get index
   mStructureSetsList.push_back(mStructureSet);
   mStructureSetActorsList.push_back(mStructureSetActor);
   int index = mStructureSetsList.size()-1;
-
   // Return index
   return index;
 }
@@ -215,45 +193,32 @@ int vvToolStructureSetManager::addStructureSet(clitk::DicomRT_StructureSet * mSt
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::openBinaryImage()
-{
-  DD("openBinaryImage");
-  // Select current StructureSet (or create)
+void vvToolStructureSetManager::OpenBinaryImage() {
   int index;
-  DD(mCurrentStructureSetIndex);
   if (mCurrentStructureSet == NULL) {
     if (mStructureSetsList.size() == 0) { // Create a default SS
       clitk::DicomRT_StructureSet * mStructureSet = new clitk::DicomRT_StructureSet;
-      index = addStructureSet(mStructureSet);
-      DD(index);
-    else { // Get first SS
+      index = AddStructureSet(mStructureSet);
+    }
+    else { // Get first SS
       index = 0;
     }
   } else {
     index = mCurrentStructureSetIndex;
   }
-  DD(index);
-  // TODO -> SET THIS SS AS CURRENT
   mCurrentStructureSet = mStructureSetsList[index];
   mCurrentStructureSetActor = mStructureSetActorsList[index];
   mCurrentStructureSetIndex = index;
-  DD(mCurrentStructureSetIndex);
-  DD(mCurrentStructureSet->GetName());
-
   // Open images
   QString Extensions = "Images files ( *.mhd *.hdr *.his)";
   Extensions += ";;All Files (*)";
   QStringList filename =
     QFileDialog::getOpenFileNames(this,tr("Open binary image"),
-                                  mMainWindowBase->GetInputPathName(),Extensions);
+                                 mMainWindowBase->GetInputPathName(),Extensions);
   if (filename.size() == 0) return;
-
   std::vector<int> mLoadedROIIndex;
   for(int i=0; i<filename.size(); i++) {
-    DD(filename[i].toStdString());
-
     // Open Image
-    //init the progress events
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     vvImageReader * mReader = new vvImageReader;
     std::vector<std::string> filenames;
@@ -271,13 +236,10 @@ void vvToolStructureSetManager::openBinaryImage()
       return;
     }
     vvImage::Pointer binaryImage = mReader->GetOutput();
-    //  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
@@ -288,47 +250,64 @@ void vvToolStructureSetManager::openBinaryImage()
 
     // 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 ());
+    // Change color
     if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
       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);
+
+    // CheckBox for "All"
+    if (mCurrentStructureSetActor->GetROIActor(n)->IsVisible())
+      mNumberOfVisibleROI++;
+    if (mCurrentStructureSetActor->GetROIActor(n)->IsContourVisible())
+      mNumberOfVisibleContourROI++;
+    UpdateAllROIStatus();
   } // end loop on n selected filenames
 
   // Update the TreeWidget
-  updateStructureSetInTreeWidget(index, mCurrentStructureSet);
-
+  UpdateStructureSetInTreeWidget(index, mCurrentStructureSet);
   // Render loaded ROIs (the first is sufficient)
   for(unsigned int i=0; i<mLoadedROIIndex.size(); i++) {
     mCurrentStructureSetActor->GetROIActor(mLoadedROIIndex[i])->Update();
   }
   for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
     mCurrentSlicerManager->GetSlicer(i)->Render();
-  }
+  }  
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::apply()
+void vvToolStructureSetManager::apply() 
 {
   close();
 }
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+bool vvToolStructureSetManager::close()
+{
+  mCheckBoxShowAll->setCheckState(Qt::Unchecked);
+  mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
+  if (mCurrentSlicerManager) mCurrentSlicerManager->Render();
+  if (mCurrentStructureSetActor) {
+    for(int i=0; i<mCurrentStructureSetActor->GetNumberOfROIs(); i++) {
+      mCurrentStructureSetActor->GetROIList()[i]->SetVisible(false);
+      mCurrentStructureSetActor->GetROIList()[i]->SetContourVisible(false);
+      delete mCurrentStructureSetActor->GetROIList()[i];
+    }
+  }
+  return vvToolWidgetBase::close();
+}
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
 // CURRENT ROI INTERACTION
@@ -336,29 +315,24 @@ void vvToolStructureSetManager::apply()
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::selectedItemChangedInTree()
-{
-  DD("selectedItemChangedInTree");
-
+void vvToolStructureSetManager::SelectedItemChangedInTree() {
   // Search which roi is selected
   QList<QTreeWidgetItem *> l = mTree->selectedItems();
-  DD(l.size());
+  if (l.size() == 0) {
+    mCurrentROIActor = NULL;
+    mCurrentROI = NULL;
+    mGroupBoxROI->setEnabled(false);
+    return;
+  }
   QTreeWidgetItem * w = l[0];
   if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) {
     mCurrentROIActor = NULL;
     mCurrentROI = NULL;
     mGroupBoxROI->setEnabled(false);
-    return; // Search for SS (first)
+    return;
   }
   clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w];
-  //  DD(roi->GetName());
-
   // Get selected roi actor
-  if (mCurrentROIActor != NULL) {
-    mCurrentROIActor->SetSelected(false);
-    mCurrentROIActor->Update();
-  }
-
   vvROIActor * actor = mStructureSetActorsList[mCurrentStructureSetIndex]->GetROIActor(roi->GetROINumber());
   mCurrentROI = roi;
   mCurrentROIActor = actor;
@@ -367,48 +341,115 @@ void vvToolStructureSetManager::selectedItemChangedInTree()
   mGroupBoxROI->setEnabled(true);
   mROInameLabel->setText(roi->GetName().c_str());
   mCheckBoxShow->setChecked(actor->IsVisible());
-
-  // Warning -> avoir unuseful Render here by disconnect slider
-  //
-  disconnect(mOpacitySlider, SIGNAL(valueChanged(int)),
-             this, SLOT(opacityChanged(int)));
+  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)));
   mOpacitySlider->setValue((int)lrint(actor->GetOpacity()*100));
   mOpacitySpinBox->setValue((int)lrint(actor->GetOpacity()*100));
-  connect(mOpacitySlider, SIGNAL(valueChanged(int)),
-          this, SLOT(opacityChanged(int)));
-
-  actor->SetSelected(true); // remove old selection
-  // The following must not render !!
-  DD("before update");
-  actor->Update(); // To change in UpdateSelecte
-  DD("after update");
+  connect(mOpacitySlider, SIGNAL(valueChanged(int)), 
+         this, SLOT(OpacityChanged(int)));
+  actor->Update(); 
 
+  // Final rendering
   mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::visibleROIToggled(bool b)
-{
+void vvToolStructureSetManager::UpdateAllROIStatus() {
+  int nbVisible = 0;
+  int nb = mCurrentStructureSetActor->GetROIList().size();
+  for(int i=0; i<nb; i++) {
+    if (mCurrentStructureSetActor->GetROIList()[i]->IsVisible()) {
+      nbVisible++;
+    }
+  }
+
+  disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));  
+  disconnect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
+  if (nbVisible == nb) mCheckBoxShowAll->setCheckState(Qt::Checked);
+  else {
+    if (nbVisible == 0) mCheckBoxShowAll->setCheckState(Qt::Unchecked);
+    else mCheckBoxShowAll->setCheckState(Qt::PartiallyChecked);
+  }
+  connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
+  connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::VisibleROIToggled(bool b) {
+  if (mCurrentROIActor == NULL) return;
+  if (b == mCurrentROIActor->IsVisible()) return; // nothing to do
   mCurrentROIActor->SetVisible(b);
+  UpdateAllROIStatus();
+  mCurrentSlicerManager->Render(); 
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::opacityChanged(int v)
-{
+void vvToolStructureSetManager::VisibleContourROIToggled(bool b) {
+  if (mCurrentROIActor == NULL) return;
+  if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do
+  mCurrentROIActor->SetContourVisible(b);
+  mCurrentROIActor->UpdateColor();
+  mCurrentSlicerManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::OpacityChanged(int v) {
+  if (mCurrentROIActor == NULL) return;
   mCurrentROIActor->SetOpacity((double)v/100.0);
   mCurrentROIActor->UpdateColor();
-  mCurrentSlicerManager->Render();
+  mCurrentSlicerManager->Render(); 
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolStructureSetManager::changeColor()
-{
+void vvToolStructureSetManager::AllVisibleROIToggled(int b) {
+  bool status = false;
+  if ((mCheckBoxShowAll->checkState() == Qt::Checked) ||
+      (mCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
+
+  for(int i=0; i<mCurrentStructureSetActor->GetNumberOfROIs(); i++) {
+    mCurrentStructureSetActor->GetROIList()[i]->SetVisible(status);
+  }
+  if (status) mCheckBoxShowAll->setCheckState(Qt::Checked);
+  else  mCheckBoxShowAll->setCheckState(Qt::Unchecked);
+  mCheckBoxShow->setChecked(status);
+  mCurrentSlicerManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::AllVisibleContourROIToggled(bool b) {
+  bool status = false;
+  if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) ||
+      (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
+  // Update current 
+  for(int i=0; i<mCurrentStructureSetActor->GetNumberOfROIs(); i++) {
+    mCurrentStructureSetActor->GetROIList()[i]->SetContourVisible(status);
+  }
+  // Update current selection
+  if (status) mContourCheckBoxShowAll->setCheckState(Qt::Checked);
+  else  mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
+  mContourCheckBoxShow->setChecked(status);
+  mCurrentSlicerManager->Render(); 
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::ChangeColor() {
   QColor color;
   color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0],
                 mCurrentROIActor->GetROI()->GetDisplayColor()[1],
@@ -422,18 +463,52 @@ void vvToolStructureSetManager::changeColor()
                       mCurrentROI->GetDisplayColor()[1]*255,
                       mCurrentROI->GetDisplayColor()[2]*255));
   brush.setStyle(Qt::SolidPattern);
-  for(int i=0; i<w->columnCount (); i++) {
-    w->setBackground(i, brush);
-  }
+  w->setBackground(2, brush);
+  // Render
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::ChangeContourColor() {
+  QColor color;
+  color.setRgbF(mCurrentROIActor->GetContourColor()[0], 
+               mCurrentROIActor->GetContourColor()[1], 
+               mCurrentROIActor->GetContourColor()[2]);
+  QColor c = QColorDialog::getColor(color, this, "Choose the contour color");
+  mCurrentROIActor->SetContourColor(c.redF(), c.greenF(), c.blueF());
+  mCurrentROIActor->UpdateColor();
+  mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::ChangeContourWidth(int n) {
+  mCurrentROIActor->SetContourWidth(n);
+  mCurrentROIActor->UpdateColor();
+  mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
 
 //------------------------------------------------------------------------------
-//void vvToolStructureSetManager::getActorFromROI() {
-//  mStructureSetActorsList[mCurrentStructureSetIndex]->GetROIActor(n);
-//}
+void vvToolStructureSetManager::ReloadCurrentROI() {
+  // Reload image
+  vvImageReader * mReader = new vvImageReader;
+  mReader->SetInputFilename(mCurrentROI->GetFilename());
+  mReader->Update(IMAGE);
+  if (mReader->GetLastError() != "") {
+    QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), mReader->GetLastError().c_str());
+    return;
+  }
+  mCurrentROI->SetImage(mReader->GetOutput());
+  
+  // Update visu"
+  mCurrentROIActor->UpdateImage();
+  mCurrentSlicerManager->Render();    
+}
 //------------------------------------------------------------------------------