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