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