]> Creatis software - clitk.git/blob - vv/vvToolROIManager.cxx
Temporary hide "open dicom" button
[clitk.git] / vv / vvToolROIManager.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ===========================================================================**/
18
19 // vv
20 #include "vvToolROIManager.h"
21 #include "vvImageReader.h"
22 #include "vvROIActor.h"
23 #include "vvSlicer.h"
24 #include "vvROIActor.h"
25 #include "vvMeshReader.h"
26 #include "vvStructSelector.h"
27
28 // Qt
29 #include <QFileDialog>
30 #include <QMessageBox>
31 #include <QColorDialog>
32 #include <QAbstractEventDispatcher>
33  
34 // vtk
35 #include <vtkLookupTable.h>
36 #include <vtkRenderWindow.h>
37
38 //------------------------------------------------------------------------------
39 // Create the tool and automagically (I like this word) insert it in
40 // the main window menu.
41 ADD_TOOL(vvToolROIManager);
42 //------------------------------------------------------------------------------
43
44 //------------------------------------------------------------------------------
45 vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f):
46   QWidget(parent->GetTab()), 
47   vvToolBase<vvToolROIManager>(parent),
48   Ui::vvToolROIManager()
49 {
50   // Store parent
51   mMainWindow = parent;
52   
53   // Assume the initial tab ROI index is 2
54   mIndexFirstTab = 2;
55
56   // Get the ROI Tab
57   QWidget * tab = qFindChild<QWidget*>(parent->GetTab(), "ROItab");
58   
59   // Set it as current
60   parent->GetTab()->setCurrentIndex(mIndexFirstTab);
61   
62   // Check if widget already used
63   if (tab->layout()->isEmpty()) {
64     tab->layout()->addWidget(this);
65   }
66   else {
67     close();
68     return;
69   }
70   
71   // Build the UI
72   Ui_vvToolROIManager::setupUi(this);
73   setAttribute(Qt::WA_DeleteOnClose);
74   mTree->clear();
75   mTree->header()->resizeSection(0, 30);
76   
77   // Temporary disable "Load dicom" button
78   frame_4->hide();
79
80   // Set default LUT
81   mDefaultLUTColor = vtkSmartPointer<vtkLookupTable>::New();
82   for(int i=0; i<mDefaultLUTColor->GetNumberOfTableValues(); i++) {
83     double r = (rand()/(RAND_MAX+1.0));
84     double v = (rand()/(RAND_MAX+1.0));
85     double b = (rand()/(RAND_MAX+1.0));
86     mDefaultLUTColor->SetTableValue(i, r, v, b);
87   }
88 #include "vvDefaultLut.h"
89
90   // Initialization
91   mNumberOfVisibleROI = 0;
92   mNumberOfVisibleContourROI = 0;
93
94   // Select the current image as the target
95   int i = parent->GetSlicerManagerCurrentIndex();
96   InputIsSelected(parent->GetSlicerManagers()[i]);
97
98   // Connect event from mainwindow to this widget
99   connect(parent, SIGNAL(AnImageIsBeingClosed(vvSlicerManager *)), 
100           this, SLOT(AnImageIsBeingClosed(vvSlicerManager *)));
101   connect(parent, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)), 
102           this, SLOT(SelectedImageHasChanged(vvSlicerManager *)));
103   connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(OpenBinaryImage()));
104   connect(mOpenDicomButton, SIGNAL(clicked()), this, SLOT(OpenDicomImage()));
105   connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
106   connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
107   connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
108   connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
109   connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
110   connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
111   connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
112   connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
113   connect(mReloadButton, SIGNAL(clicked()), this, SLOT(ReloadCurrentROI()));
114   connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
115   connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
116   connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
117 }
118 //------------------------------------------------------------------------------
119
120
121 //------------------------------------------------------------------------------
122 vvToolROIManager::~vvToolROIManager()
123 {
124   std::cout << "vvToolROIManager::~vvToolROIManager()" << std::endl;
125 }
126 //------------------------------------------------------------------------------
127
128
129 //------------------------------------------------------------------------------
130 // STATIC
131 void vvToolROIManager::Initialize() {
132   SetToolName("ROIManager");
133   SetToolMenuName("Display ROI (binary image)");
134   SetToolIconFilename(":/common/icons/tool-roi.png");
135   SetToolTip("Display ROI from a binary image.");
136   SetToolExperimental(true);
137 }
138 //------------------------------------------------------------------------------
139
140
141 //------------------------------------------------------------------------------
142 void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
143 {
144   mSlicerManager = m;
145
146   // Initialization
147   mSlicerManager = m;
148   mCurrentImage = mSlicerManager->GetImage();
149
150   // Refuse if 4D
151   if (mCurrentImage->GetNumberOfDimensions() != 3) {
152     QMessageBox::information(this,tr("Sorry only 3D yet"), tr("Sorry only 3D yet"));
153     close();
154     return;
155   }
156
157   // Change gui
158   mLabelInputInfo->setText(QString("%1").arg(m->GetFileName().c_str()));
159
160   // Auto display browser to select new contours 
161   OpenBinaryImage();
162 }
163 //------------------------------------------------------------------------------
164
165
166 //------------------------------------------------------------------------------
167 void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
168 {
169   DD("AnImageIsBeingClosed");
170   if (m == mSlicerManager) { 
171     close();
172     return;
173   }
174 }
175 //------------------------------------------------------------------------------
176
177
178 //------------------------------------------------------------------------------
179 void vvToolROIManager::close()
180 {
181   DD("close");
182   QWidget::close();
183 }
184 //------------------------------------------------------------------------------
185
186
187 //------------------------------------------------------------------------------
188 void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
189   //  DD("SelectedImageHasChanged");
190   if (m != mSlicerManager) hide(); 
191   else {
192     show();
193   }
194 }
195 //------------------------------------------------------------------------------
196
197
198 //------------------------------------------------------------------------------
199 void vvToolROIManager::OpenBinaryImage() 
200 {
201   // Open images
202   QString Extensions = "Images files ( *.mha *.mhd *.hdr *.his)";
203   Extensions += ";;All Files (*)";
204   QStringList filename =
205     QFileDialog::getOpenFileNames(this,tr("Open binary image"),
206                                   mMainWindowBase->GetInputPathName(),Extensions);
207   if (filename.size() == 0) return;
208   
209   // For each selected file, open the image
210   for(int i=0; i<filename.size(); i++) {
211     // Open Image
212     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
213     vvImageReader::Pointer reader = vvImageReader::New();
214     std::vector<std::string> filenames;
215     filenames.push_back(filename[i].toStdString());
216     reader->SetInputFilenames(filenames);
217     reader->Update(vvImageReader::IMAGE);
218     QApplication::restoreOverrideCursor();
219
220     if (reader->GetLastError().size() != 0) {
221       std::cerr << "Error while reading " << filename[i].toStdString() << std::endl;
222       QString error = "Cannot open file \n";
223       error += reader->GetLastError().c_str();
224       QMessageBox::information(this,tr("Reading problem"),error);
225       return;
226     }
227     vvImage::Pointer binaryImage = reader->GetOutput();
228     AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value(),
229              (!mBGModeCheckBox->isChecked()));
230     mOpenedBinaryImage.push_back(binaryImage);
231   }
232
233   // Update the contours
234   UpdateAllContours(); 
235 }
236 //------------------------------------------------------------------------------
237
238
239 //------------------------------------------------------------------------------
240 void vvToolROIManager::OpenDicomImage() 
241 {
242   DD("OpenDicomImage");
243   QString Extensions = "Dicom Files ( *.dcm RS*)";
244   Extensions += ";;All Files (*)";
245   QString file = QFileDialog::getOpenFileName(this,tr("Merge Images"), 
246                                               mMainWindow->GetInputPathName(), 
247                                               Extensions);
248   if (file.isNull()) return;
249
250   //  AddDCStructContour(index, file);
251   vvMeshReader reader;
252   reader.SetFilename(file.toStdString());
253   vvStructSelector selector;
254   selector.SetStructures(reader.GetROINames());
255   // selector.EnablePropagationCheckBox(); FIXME Disable
256
257   // FIXME : change text -> allow to save binary image
258
259   if (selector.exec()) {
260     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
261     reader.SetSelectedItems(selector.getSelectedItems());
262     reader.SetImage(mSlicerManager->GetImage());
263     reader.Update();
264
265     // std::vector<vvMesh::Pointer> contours=reader.GetOutput();
266     // for (std::vector<vvMesh::Pointer>::iterator i=contours.begin();
267     //      i!=contours.end(); i++)
268     //   AddContour(index,*i,selector.PropagationEnabled());
269     QApplication::restoreOverrideCursor();
270   }
271
272
273
274 }
275 //------------------------------------------------------------------------------
276
277
278 //------------------------------------------------------------------------------
279 void vvToolROIManager::AddImage(vvImage * binaryImage, std::string filename, 
280                                 double BG, bool modeBG) 
281 {
282   // Check Dimension
283   int dim = mCurrentImage->GetNumberOfDimensions();
284   int bin_dim = binaryImage->GetNumberOfDimensions();
285   if (dim < bin_dim) {
286     std::ostringstream os;
287     os << "Error. Loaded binary image is " << bin_dim
288        << "D while selected image is " << dim << "D" << std::endl;
289     QMessageBox::information(this,tr("Reading problem"),os.str().c_str());
290     return;
291   }
292   
293   // Compute roi index
294   int n = mROIList.size();
295   
296   // Compute the name of the new ROI
297   std::ostringstream oss;
298   oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename));
299   std::string name = oss.str();
300   
301   // Set color
302   std::vector<double> color;
303   color.push_back(1);
304   color.push_back(0);
305   color.push_back(0);
306
307   // Create ROI
308   clitk::DicomRT_ROI::Pointer roi = clitk::DicomRT_ROI::New();
309   roi->SetFromBinaryImage(binaryImage, n, name, color, filename);
310
311   // Add a new roi to the list
312   mROIList.push_back(roi);
313  
314   // Set BG or FG mode
315   if (modeBG) 
316     roi->SetBackgroundValueLabelImage(BG);
317   else 
318     roi->SetForegroundValueLabelImage(BG);
319   
320   // Change color
321   if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
322     double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
323     roi->SetDisplayColor(color[0], color[1], color[2]);
324   }
325   
326   // Add a new roi actor
327   QSharedPointer<vvROIActor> actor = QSharedPointer<vvROIActor>(new vvROIActor);
328   actor->SetBGMode(modeBG);
329   actor->SetROI(roi);
330   actor->SetSlicerManager(mSlicerManager);
331   actor->Initialize(n+1); // depth is n+1 to start at 1
332   mROIActorsList.push_back(actor);
333   
334   // CheckBox for "All"
335   if (actor->IsVisible()) mNumberOfVisibleROI++;
336   if (actor->IsContourVisible()) mNumberOfVisibleContourROI++;
337   
338   // Add ROI in tree
339   mTreeWidgetList.push_back(QSharedPointer<QTreeWidgetItem>(new QTreeWidgetItem(mTree)));
340   QTreeWidgetItem * w = mTreeWidgetList.back().data();
341   w->setText(0, QString("%1").arg(roi->GetROINumber()));
342   w->setText(1, QString("%1").arg(roi->GetName().c_str()));
343   w->setText(3, QString("%1").arg(actor->GetDepth()));  
344   QBrush brush(QColor(roi->GetDisplayColor()[0]*255, 
345                       roi->GetDisplayColor()[1]*255, 
346                       roi->GetDisplayColor()[2]*255));
347   brush.setStyle(Qt::SolidPattern);
348   w->setBackground(2, brush);
349   mMapROIToTreeWidget[roi] = w;
350   mMapTreeWidgetToROI[w] = roi;
351   mTree->resizeColumnToContents(0);
352   mTree->resizeColumnToContents(1);
353
354   // Update 
355   UpdateAllROIStatus(); 
356 }
357 //------------------------------------------------------------------------------
358
359
360 //------------------------------------------------------------------------------
361 void vvToolROIManager::UpdateAllContours() 
362 {
363   // Render loaded ROIs (the first is sufficient)
364   for(unsigned int i=0; i<mROIList.size(); i++) {
365     mROIActorsList[i]->Update();
366   }
367   for(int i=0; i<mSlicerManager->GetNumberOfSlicers(); i++) {
368     mSlicerManager->GetSlicer(i)->Render();
369   }  
370 }
371 //------------------------------------------------------------------------------
372
373
374 //------------------------------------------------------------------------------
375 void vvToolROIManager::UpdateAllROIStatus() {
376   int nbVisible = 0;
377   int nb = mROIList.size();
378   for(int i=0; i<nb; i++) {
379     if (mROIActorsList[i]->IsVisible()) {
380       nbVisible++;
381     }
382   }
383
384   // change the states
385   disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));  
386   disconnect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
387   if (nbVisible == nb) mCheckBoxShowAll->setCheckState(Qt::Checked);
388   else {
389     if (nbVisible == 0) mCheckBoxShowAll->setCheckState(Qt::Unchecked);
390     else mCheckBoxShowAll->setCheckState(Qt::PartiallyChecked);
391   }
392   connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
393   connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
394 }
395 //------------------------------------------------------------------------------
396
397
398 //------------------------------------------------------------------------------
399 void vvToolROIManager::SelectedItemChangedInTree() {
400   
401   // Search which roi is selected
402   QList<QTreeWidgetItem *> l = mTree->selectedItems();
403   if (l.size() == 0) {
404     //    mCurrentROIActor = 0;
405     mCurrentROI = NULL;
406     mGroupBoxROI->setEnabled(false);
407     return;
408   }
409   QTreeWidgetItem * w = l[0];
410   if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) {
411     //    mCurrentROIActor = 0;
412     mCurrentROI = NULL;
413     mGroupBoxROI->setEnabled(false);
414     return;
415   }
416   clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w];
417   // Get selected roi actor
418   QSharedPointer<vvROIActor> actor = mROIActorsList[roi->GetROINumber()];
419   mCurrentROI = roi;
420   mCurrentROIActor = actor;
421
422   // Warning -> avoid unuseful Render here by disconnect slider 
423   // Update GUI
424   disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
425   disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
426   disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
427   disconnect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
428   disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
429   disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
430   disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
431   disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
432
433   mGroupBoxROI->setEnabled(true);
434   mROInameLabel->setText(roi->GetName().c_str());
435   mCheckBoxShow->setChecked(actor->IsVisible());
436   mContourCheckBoxShow->setChecked(actor->IsContourVisible());
437   mContourWidthSpinBox->setValue(actor->GetContourWidth());
438   mDepthSpinBox->setValue(actor->GetDepth());
439   w->setText(3, QString("%1").arg(actor->GetDepth()));
440   mOpacitySlider->setValue((int)lrint(actor->GetOpacity()*100));
441   mOpacitySpinBox->setValue((int)lrint(actor->GetOpacity()*100));
442
443   connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
444   connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
445   connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
446   connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
447   connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
448   connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
449   connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
450   connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
451
452   
453   // Set the current color to the selected ROI name
454   mROInameLabel->setAutoFillBackground(true);// # This is important!!
455   mROInameLabel->setStyleSheet("QLabel { background-color : red; color : blue; }");
456   QColor color = QColor(mCurrentROI->GetDisplayColor()[0]*255,
457                         mCurrentROI->GetDisplayColor()[1]*255,
458                         mCurrentROI->GetDisplayColor()[2]*255);
459   QString values = QString("%1, %2, %3").arg(color.red()).arg(color.green()).arg(color.blue());
460   mROInameLabel->setStyleSheet("QLabel { background-color: rgb("+values+"); }");
461
462   // is this needed ?
463   //  actor->Update(); 
464   // Final rendering
465   // mCurrentSlicerManager->Render();
466 }
467 //------------------------------------------------------------------------------
468
469
470 //------------------------------------------------------------------------------
471 void vvToolROIManager::VisibleROIToggled(bool b) {
472   if (mCurrentROIActor == NULL) return;
473   if (b == mCurrentROIActor->IsVisible()) return; // nothing to do
474   mCurrentROIActor->SetVisible(b);
475   UpdateAllROIStatus();
476   mSlicerManager->Render(); 
477 }
478 //------------------------------------------------------------------------------
479
480
481 //------------------------------------------------------------------------------
482 void vvToolROIManager::VisibleContourROIToggled(bool b) {
483   if (mCurrentROIActor == NULL) return;
484   if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do
485   mCurrentROIActor->SetContourVisible(b);
486   mCurrentROIActor->UpdateColor();
487   mSlicerManager->Render(); 
488 }
489 //------------------------------------------------------------------------------
490
491
492 //------------------------------------------------------------------------------
493 void vvToolROIManager::OpacityChanged(int v) {
494   if (mCurrentROIActor == NULL) return;
495   mCurrentROIActor->SetOpacity((double)v/100.0);
496   mCurrentROIActor->UpdateColor();
497   mSlicerManager->Render(); 
498 }
499 //------------------------------------------------------------------------------
500
501
502 //------------------------------------------------------------------------------
503 void vvToolROIManager::AllVisibleROIToggled(int b) {
504   bool status = false;
505   if ((mCheckBoxShowAll->checkState() == Qt::Checked) ||
506       (mCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
507
508   for(uint i=0; i<mROIList.size(); i++) {
509     mROIActorsList[i]->SetVisible(status);
510   }
511   if (status) mCheckBoxShowAll->setCheckState(Qt::Checked);
512   else  mCheckBoxShowAll->setCheckState(Qt::Unchecked);
513   mCheckBoxShow->setChecked(status);
514   mSlicerManager->Render(); 
515 }
516 //------------------------------------------------------------------------------
517
518
519 //------------------------------------------------------------------------------
520 void vvToolROIManager::AllVisibleContourROIToggled(bool b) {
521   bool status = false;
522   if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) ||
523       (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
524   // Update current 
525   for(uint i=0; i<mROIActorsList.size(); i++) {
526     mROIActorsList[i]->SetContourVisible(status);
527   }
528   // Update current selection
529   if (status) mContourCheckBoxShowAll->setCheckState(Qt::Checked);
530   else  mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
531   mContourCheckBoxShow->setChecked(status);
532   mSlicerManager->Render(); 
533 }
534 //------------------------------------------------------------------------------
535
536
537 //------------------------------------------------------------------------------
538 void vvToolROIManager::ChangeColor() {
539   QColor color;
540   color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0],
541                 mCurrentROIActor->GetROI()->GetDisplayColor()[1],
542                 mCurrentROIActor->GetROI()->GetDisplayColor()[2]);
543   QColor c = QColorDialog::getColor(color, this, "Choose the ROI color");
544   mCurrentROIActor->GetROI()->SetDisplayColor(c.redF(), c.greenF(), c.blueF());
545   mCurrentROIActor->UpdateColor();
546
547   QTreeWidgetItem * w = mMapROIToTreeWidget[mCurrentROI];
548   QBrush brush(QColor(mCurrentROI->GetDisplayColor()[0]*255,
549                       mCurrentROI->GetDisplayColor()[1]*255,
550                       mCurrentROI->GetDisplayColor()[2]*255));
551   brush.setStyle(Qt::SolidPattern);
552   w->setBackground(2, brush);
553   // Render
554   mSlicerManager->Render();
555 }
556 //------------------------------------------------------------------------------
557
558
559 //------------------------------------------------------------------------------
560 void vvToolROIManager::ChangeContourColor() {
561   QColor color;
562   color.setRgbF(mCurrentROIActor->GetContourColor()[0], 
563                 mCurrentROIActor->GetContourColor()[1], 
564                 mCurrentROIActor->GetContourColor()[2]);
565   QColor c = QColorDialog::getColor(color, this, "Choose the contour color");
566   mCurrentROIActor->SetContourColor(c.redF(), c.greenF(), c.blueF());
567   mCurrentROIActor->UpdateColor();
568   mSlicerManager->Render();
569 }
570 //------------------------------------------------------------------------------
571
572
573 //------------------------------------------------------------------------------
574 void vvToolROIManager::ChangeContourWidth(int n) {
575   mCurrentROIActor->SetContourWidth(n);
576   mCurrentROIActor->UpdateColor();
577   mSlicerManager->Render();
578 }
579 //------------------------------------------------------------------------------
580
581
582 //------------------------------------------------------------------------------
583 void vvToolROIManager::ChangeDepth(int n) {
584   mCurrentROIActor->SetDepth(n);
585   mCurrentROIActor->UpdateImage();
586   mSlicerManager->Render();
587   QList<QTreeWidgetItem *> l = mTree->selectedItems();
588   QTreeWidgetItem * w = l[0];
589   w->setText(3, QString("%1").arg(mCurrentROIActor->GetDepth()));
590 }
591 //------------------------------------------------------------------------------
592
593
594 //------------------------------------------------------------------------------
595 void vvToolROIManager::ReloadCurrentROI() {
596   // Reload image
597   vvImageReader::Pointer reader = vvImageReader::New();
598   reader->SetInputFilename(mCurrentROI->GetFilename());
599   reader->Update(vvImageReader::IMAGE);
600   if (reader->GetLastError() != "") {
601     QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), 
602                              reader->GetLastError().c_str());
603     return;
604   }
605   mCurrentROI->GetImage()->GetFirstVTKImageData()->ReleaseData();
606   mCurrentROI->SetImage(reader->GetOutput());
607   
608   // Update visu"
609   mCurrentROIActor->UpdateImage();
610   mSlicerManager->Render();    
611 }
612 //------------------------------------------------------------------------------