1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
20 #include "vvToolStructureSetManager.h"
21 #include "vvImageReader.h"
22 #include "vvStructureSetActor.h"
24 #include "vvROIActor.h"
27 #include <QFileDialog>
28 #include <QMessageBox>
29 #include <QColorDialog>
30 #include <QAbstractEventDispatcher>
33 #include <vtkLookupTable.h>
34 #include <vtkRenderWindow.h>
36 //------------------------------------------------------------------------------
37 // Create the tool and automagically (I like this word) insert it in
38 // the main window menu.
39 ADD_TOOL(vvToolStructureSetManager);
40 //------------------------------------------------------------------------------
42 int vvToolStructureSetManager::m_NumberOfTool = 0;
43 std::vector<vvSlicerManager*> vvToolStructureSetManager::mListOfInputs;
44 std::map<vvSlicerManager*, vvToolStructureSetManager*> vvToolStructureSetManager::mListOfOpenTool;
46 //------------------------------------------------------------------------------
47 vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent,
49 vvSlicerManager * current):
50 vvToolWidgetBase(parent, f),
51 // if Qt::Widget -> No dialog in this case (in tab) ; PB = "invisible widget on menu" !
52 // if "f" normal widget
53 vvToolBase<vvToolStructureSetManager>(parent),
54 Ui::vvToolStructureSetManager()
56 Ui_vvToolStructureSetManager::setupUi(mToolWidget);
58 // this->setFixedWidth(120);
60 mCurrentStructureSetActor = 0;
61 connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
62 mCloseButton->setVisible(false);
64 mTree->header()->resizeSection(0, 30);
65 mMainWindowBase->GetTab()->setTabIcon(mTabNumber, GetToolIcon());
66 mCurrentStructureSet = NULL;
67 mCurrentStructureSetIndex = -1;
68 mGroupBoxROI->setEnabled(false);
69 mCurrentROIActor = NULL;
70 mIsAllVisibleEnabled = false;
71 mNumberOfVisibleROI = 0;
72 mNumberOfVisibleContourROI = 0;
73 mDefaultLUTColor = vtkSmartPointer<vtkLookupTable>::New();
74 for(int i=0; i<mDefaultLUTColor->GetNumberOfTableValues(); i++) {
75 double r = (rand()/(RAND_MAX+1.0));
76 double v = (rand()/(RAND_MAX+1.0));
77 double b = (rand()/(RAND_MAX+1.0));
78 mDefaultLUTColor->SetTableValue(i, r, v, b);
79 // std::cout << "mDefaultLUTColor->SetTableValue(" << i << ", " << r << ", " << v << ", " << b << ");" << std::endl;
81 #include "vvDefaultLut.h"
84 if (current == NULL) {
85 MustOpenDialogWhenCreated = true;
86 AddInputSelector("Select image");
89 MustOpenDialogWhenCreated = false;
90 mMainButtonBox->setEnabled(true);
91 mCurrentSlicerManager = current;
92 mCurrentImage = mCurrentSlicerManager->GetImage();
93 mToolWidget->setEnabled(true);
94 InputIsSelected(mCurrentSlicerManager);
97 //------------------------------------------------------------------------------
100 //------------------------------------------------------------------------------
101 vvToolStructureSetManager::~vvToolStructureSetManager()
105 // clearing the list at this point avoids
106 // segfaulting due to events being dispatched
107 // after object destruction
108 mTreeWidgetList.clear();
109 mTree->clearSelection();
111 //std::cout << "vvToolStructureSetManager::~vvToolStructureSetManager()" << std::endl;
113 //------------------------------------------------------------------------------
116 //------------------------------------------------------------------------------
118 void vvToolStructureSetManager::Initialize() {
119 SetToolName("ROIManager");
120 SetToolMenuName("Display ROI (binary image)");
121 SetToolIconFilename(":/common/icons/tool-roi.png");
122 SetToolTip("Display ROI from a binary image.");
123 SetToolExperimental(false);
125 //------------------------------------------------------------------------------
128 //------------------------------------------------------------------------------
129 void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m)
131 //std::cout << "vvToolStructureSetManager::InputIsSelected()" << std::endl;
133 //int mTabNumber = parent->GetTab()->addTab(this, "");
134 // this->setFixedWidth(120);
135 //this->setPreferedHeight(441);
137 if (mCurrentImage->GetNumberOfDimensions() != 3) {
138 QMessageBox::information(this,tr("Sorry only 3D yet"), tr("Sorry only 3D yet"));
143 HideInputSelector(); // splitter
144 mToolInputSelectionWidget->hide();
145 mLabelInputInfo->setText(QString("%1").arg(m->GetFileName().c_str()));
148 // if (!isWindow()) {
149 mListOfInputs.push_back(mCurrentSlicerManager);
150 mListOfOpenTool[mCurrentSlicerManager] = this;
153 // Connect open menus
154 connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(OpenBinaryImage()));
155 connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
156 connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
157 connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
158 connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
159 connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
160 connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
161 connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
162 connect(mReloadButton, SIGNAL(clicked()), this, SLOT(ReloadCurrentROI()));
163 connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
164 connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
166 // Browse to load image
167 if (MustOpenDialogWhenCreated)
170 //------------------------------------------------------------------------------
173 //------------------------------------------------------------------------------
174 void vvToolStructureSetManager::Open(int type) {
176 case 0: OpenBinaryImage(); return; // Open binary image;
177 case 1: DD("TODO"); return; // Open DICOM RT
178 case 2: DD("TODO"); return; // Open mesh
179 default: std::cerr << "Error ????" << std::endl; exit(0);
182 //------------------------------------------------------------------------------
185 //------------------------------------------------------------------------------
186 void vvToolStructureSetManager::AddRoiInTreeWidget(clitk::DicomRT_ROI * roi, QTreeWidget * ww) {
187 mTreeWidgetList.push_back(QSharedPointer<QTreeWidgetItem>(new QTreeWidgetItem(ww)));
188 QTreeWidgetItem * w = mTreeWidgetList.back().data();
189 w->setText(0, QString("%1").arg(roi->GetROINumber()));
190 w->setText(1, QString("%1").arg(roi->GetName().c_str()));
191 QBrush brush(QColor(roi->GetDisplayColor()[0]*255, roi->GetDisplayColor()[1]*255, roi->GetDisplayColor()[2]*255));
192 brush.setStyle(Qt::SolidPattern);
193 w->setBackground(2, brush);
194 mMapROIToTreeWidget[roi] = w;
195 mMapTreeWidgetToROI[w] = roi;
196 mTree->resizeColumnToContents(0);
197 mTree->resizeColumnToContents(1);
199 //------------------------------------------------------------------------------
202 //------------------------------------------------------------------------------
203 void vvToolStructureSetManager::UpdateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) {
206 const std::vector<clitk::DicomRT_ROI::Pointer> & rois = s->GetListOfROI();
207 for(unsigned int i=0; i<rois.size(); i++) {
208 if (mMapROIToTreeWidget.find(rois[i]) == mMapROIToTreeWidget.end())
209 AddRoiInTreeWidget(rois[i], mTree); // replace mTree with ss if several SS
212 clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
213 for(iter = s->GetROIs().begin(); iter != s->GetROIs().end(); iter++) {
214 clitk::DicomRT_ROI::Pointer roi = iter->second;
215 if (mMapROIToTreeWidget.find(roi) == mMapROIToTreeWidget.end())
216 AddRoiInTreeWidget(roi, mTree); // replace mTree with ss if several SS
219 //------------------------------------------------------------------------------
222 //------------------------------------------------------------------------------
223 int vvToolStructureSetManager::AddStructureSet(clitk::DicomRT_StructureSet * mStructureSet) {
224 // Create actor for this SS
226 QSharedPointer<vvStructureSetActor> mStructureSetActor(new vvStructureSetActor);
228 mStructureSetActor->SetStructureSet(mStructureSet);
229 mStructureSetActor->SetSlicerManager(mCurrentSlicerManager);
230 // Insert in lists and get index
231 mStructureSetsList.push_back(mStructureSet);
232 mStructureSetActorsList.push_back(mStructureSetActor);
233 int index = mStructureSetsList.size()-1;
237 //------------------------------------------------------------------------------
240 //------------------------------------------------------------------------------
241 void vvToolStructureSetManager::OpenBinaryImage()
244 if (mCurrentStructureSet == NULL) {
245 if (mStructureSetsList.size() == 0) { // Create a default SS
246 clitk::DicomRT_StructureSet::Pointer mStructureSet = clitk::DicomRT_StructureSet::New();
247 index = AddStructureSet(mStructureSet);
249 else { // Get first SS
253 index = mCurrentStructureSetIndex;
255 mCurrentStructureSet = mStructureSetsList[index];
256 mCurrentStructureSetActor = mStructureSetActorsList[index].data();
257 mCurrentStructureSetIndex = index;
259 QString Extensions = "Images files ( *.mha *.mhd *.hdr *.his)";
260 Extensions += ";;All Files (*)";
261 QStringList filename =
262 QFileDialog::getOpenFileNames(this,tr("Open binary image"),
263 mMainWindowBase->GetInputPathName(),Extensions);
264 if (filename.size() == 0) return;
265 mLoadedROIIndex.clear();
266 for(int i=0; i<filename.size(); i++) {
268 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
269 vvImageReader::Pointer reader = vvImageReader::New();
270 std::vector<std::string> filenames;
271 filenames.push_back(filename[i].toStdString());
272 reader->SetInputFilenames(filenames);
273 reader->Update(vvImageReader::IMAGE);
274 QApplication::restoreOverrideCursor();
276 if (reader->GetLastError().size() != 0) {
277 std::cerr << "Error while reading " << filename[i].toStdString() << std::endl;
278 QString error = "Cannot open file \n";
279 error += reader->GetLastError().c_str();
280 QMessageBox::information(this,tr("Reading problem"),error);
283 vvImage::Pointer binaryImage = reader->GetOutput();
284 AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value());
285 mOpenedBinaryImage.push_back(binaryImage);
290 //------------------------------------------------------------------------------
293 //------------------------------------------------------------------------------
294 void vvToolStructureSetManager::UpdateImage()
296 // Update the TreeWidget
297 UpdateStructureSetInTreeWidget(mCurrentStructureSetIndex, mCurrentStructureSet);
298 // Render loaded ROIs (the first is sufficient)
299 for(unsigned int i=0; i<mLoadedROIIndex.size(); i++) {
300 mCurrentStructureSetActor->GetROIActor(mLoadedROIIndex[i])->Update();
302 for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
303 mCurrentSlicerManager->GetSlicer(i)->Render();
306 //------------------------------------------------------------------------------
309 //------------------------------------------------------------------------------
310 void vvToolStructureSetManager::AddImage(vvImage * binaryImage, std::string filename,
311 double BG, bool m_modeBG)
313 // Check current structure set
315 if (mCurrentStructureSet == NULL) {
316 if (mStructureSetsList.size() == 0) { // Create a default SS
317 clitk::DicomRT_StructureSet::Pointer mStructureSet = clitk::DicomRT_StructureSet::New();
318 index = AddStructureSet(mStructureSet);
320 else { // Get first SS
324 index = mCurrentStructureSetIndex;
326 mCurrentStructureSet = mStructureSetsList[index];
327 mCurrentStructureSetActor = mStructureSetActorsList[index].data();
328 mCurrentStructureSetIndex = index;
331 int dim = mCurrentImage->GetNumberOfDimensions();
332 int bin_dim = binaryImage->GetNumberOfDimensions();
333 if (dim < bin_dim) { ////////// TO CHANGE FOR 3D/4D
334 std::ostringstream os;
335 os << "Error. Loaded binary image is " << bin_dim
336 << "D while selected image is " << dim << "D" << std::endl;
337 QMessageBox::information(this,tr("Reading problem"),os.str().c_str());
341 // Add a new roi to the structure
342 int n = mCurrentStructureSet->AddBinaryImageAsNewROI(binaryImage, filename);
343 mLoadedROIIndex.push_back(n);
345 mCurrentStructureSet->GetROIFromROINumber(n)->SetBackgroundValueLabelImage(BG);
347 mCurrentStructureSet->GetROIFromROINumber(n)->SetForegroundValueLabelImage(BG);
350 if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
351 double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
352 mCurrentStructureSet->GetROIFromROINumber(n)->SetDisplayColor(color[0], color[1], color[2]);
355 // Add a new roi actor
356 mCurrentStructureSetActor->CreateNewROIActor(n, m_modeBG);
358 // CheckBox for "All"
359 if (mCurrentStructureSetActor->GetROIActor(n)->IsVisible())
360 mNumberOfVisibleROI++;
361 if (mCurrentStructureSetActor->GetROIActor(n)->IsContourVisible())
362 mNumberOfVisibleContourROI++;
363 UpdateAllROIStatus();
365 //------------------------------------------------------------------------------
368 //------------------------------------------------------------------------------
369 void vvToolStructureSetManager::apply()
373 //------------------------------------------------------------------------------
376 //------------------------------------------------------------------------------
377 bool vvToolStructureSetManager::close()
379 //std::cout << "vvToolStructureSetManager::close()" << std::endl;
381 return vvToolWidgetBase::close();
383 //------------------------------------------------------------------------------
386 //------------------------------------------------------------------------------
387 void vvToolStructureSetManager::closeEvent(QCloseEvent *event)
389 //std::cout << "vvToolStructureSetManager::closeEvent()" << std::endl;
391 std::vector<vvSlicerManager*>::iterator iter = std::find(mListOfInputs.begin(), mListOfInputs.end(), mCurrentSlicerManager);
392 if (iter != mListOfInputs.end()) mListOfInputs.erase(iter);
394 // DD("how delete mListOfOpenTool ???");
395 mListOfOpenTool.erase(mCurrentSlicerManager);
397 mCheckBoxShowAll->setCheckState(Qt::Unchecked);
398 mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
399 if (mCurrentSlicerManager != 0)
400 mCurrentSlicerManager->Render();
403 if (m_NumberOfTool == 1) {
404 mMainWindow->GetTab()->removeTab(mTabNumber);
410 //------------------------------------------------------------------------------
413 //------------------------------------------------------------------------------
414 // CURRENT ROI INTERACTION
415 //------------------------------------------------------------------------------
418 //------------------------------------------------------------------------------
419 void vvToolStructureSetManager::SelectedItemChangedInTree() {
421 // Search which roi is selected
422 QList<QTreeWidgetItem *> l = mTree->selectedItems();
424 mCurrentROIActor = NULL;
426 mGroupBoxROI->setEnabled(false);
429 QTreeWidgetItem * w = l[0];
430 //std::cout << "selected item -> " << w->text(1).toStdString() << std::endl;
431 //std::cout << "m_NumberOfTool -> " << m_NumberOfTool << std::endl;
432 if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) {
433 mCurrentROIActor = NULL;
435 mGroupBoxROI->setEnabled(false);
438 clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w];
439 // Get selected roi actor
440 vvROIActor * actor = mStructureSetActorsList[mCurrentStructureSetIndex]->GetROIActor(roi->GetROINumber());
442 mCurrentROIActor = actor;
445 mGroupBoxROI->setEnabled(true);
446 mROInameLabel->setText(roi->GetName().c_str());
447 mCheckBoxShow->setChecked(actor->IsVisible());
448 mContourCheckBoxShow->setChecked(actor->IsContourVisible());
449 mContourWidthSpinBox->setValue(actor->GetContourWidth());
451 // Warning -> avoir unuseful Render here by disconnect slider
452 disconnect(mOpacitySlider, SIGNAL(valueChanged(int)),
453 this, SLOT(OpacityChanged(int)));
454 mOpacitySlider->setValue((int)lrint(actor->GetOpacity()*100));
455 mOpacitySpinBox->setValue((int)lrint(actor->GetOpacity()*100));
456 connect(mOpacitySlider, SIGNAL(valueChanged(int)),
457 this, SLOT(OpacityChanged(int)));
461 mCurrentSlicerManager->Render();
463 //------------------------------------------------------------------------------
466 //------------------------------------------------------------------------------
467 void vvToolStructureSetManager::UpdateAllROIStatus() {
469 int nb = mCurrentStructureSetActor->GetROIList().size();
470 for(int i=0; i<nb; i++) {
471 if (mCurrentStructureSetActor->GetROIList()[i]->IsVisible()) {
476 disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
477 disconnect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
478 if (nbVisible == nb) mCheckBoxShowAll->setCheckState(Qt::Checked);
480 if (nbVisible == 0) mCheckBoxShowAll->setCheckState(Qt::Unchecked);
481 else mCheckBoxShowAll->setCheckState(Qt::PartiallyChecked);
483 connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
484 connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
486 //------------------------------------------------------------------------------
488 //------------------------------------------------------------------------------
489 void vvToolStructureSetManager::VisibleROIToggled(bool b) {
490 if (mCurrentROIActor == NULL) return;
491 if (b == mCurrentROIActor->IsVisible()) return; // nothing to do
492 mCurrentROIActor->SetVisible(b);
493 UpdateAllROIStatus();
494 mCurrentSlicerManager->Render();
496 //------------------------------------------------------------------------------
499 //------------------------------------------------------------------------------
500 void vvToolStructureSetManager::VisibleContourROIToggled(bool b) {
501 if (mCurrentROIActor == NULL) return;
502 if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do
503 mCurrentROIActor->SetContourVisible(b);
504 mCurrentROIActor->UpdateColor();
505 mCurrentSlicerManager->Render();
507 //------------------------------------------------------------------------------
510 //------------------------------------------------------------------------------
511 void vvToolStructureSetManager::OpacityChanged(int v) {
512 if (mCurrentROIActor == NULL) return;
513 mCurrentROIActor->SetOpacity((double)v/100.0);
514 mCurrentROIActor->UpdateColor();
515 mCurrentSlicerManager->Render();
517 //------------------------------------------------------------------------------
520 //------------------------------------------------------------------------------
521 void vvToolStructureSetManager::AllVisibleROIToggled(int b) {
523 if ((mCheckBoxShowAll->checkState() == Qt::Checked) ||
524 (mCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true;
526 for(int i=0; i<mCurrentStructureSetActor->GetNumberOfROIs(); i++) {
527 mCurrentStructureSetActor->GetROIList()[i]->SetVisible(status);
529 if (status) mCheckBoxShowAll->setCheckState(Qt::Checked);
530 else mCheckBoxShowAll->setCheckState(Qt::Unchecked);
531 mCheckBoxShow->setChecked(status);
532 mCurrentSlicerManager->Render();
534 //------------------------------------------------------------------------------
537 //------------------------------------------------------------------------------
538 void vvToolStructureSetManager::AllVisibleContourROIToggled(bool b) {
540 if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) ||
541 (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked)) status = true;
543 for(int i=0; i<mCurrentStructureSetActor->GetNumberOfROIs(); i++) {
544 mCurrentStructureSetActor->GetROIList()[i]->SetContourVisible(status);
546 // Update current selection
547 if (status) mContourCheckBoxShowAll->setCheckState(Qt::Checked);
548 else mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
549 mContourCheckBoxShow->setChecked(status);
550 mCurrentSlicerManager->Render();
552 //------------------------------------------------------------------------------
555 //------------------------------------------------------------------------------
556 void vvToolStructureSetManager::ChangeColor() {
558 color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0],
559 mCurrentROIActor->GetROI()->GetDisplayColor()[1],
560 mCurrentROIActor->GetROI()->GetDisplayColor()[2]);
561 QColor c = QColorDialog::getColor(color, this, "Choose the ROI color");
562 mCurrentROIActor->GetROI()->SetDisplayColor(c.redF(), c.greenF(), c.blueF());
563 mCurrentROIActor->UpdateColor();
565 QTreeWidgetItem * w = mMapROIToTreeWidget[mCurrentROI];
566 QBrush brush(QColor(mCurrentROI->GetDisplayColor()[0]*255,
567 mCurrentROI->GetDisplayColor()[1]*255,
568 mCurrentROI->GetDisplayColor()[2]*255));
569 brush.setStyle(Qt::SolidPattern);
570 w->setBackground(2, brush);
572 mCurrentSlicerManager->Render();
574 //------------------------------------------------------------------------------
577 //------------------------------------------------------------------------------
578 void vvToolStructureSetManager::ChangeContourColor() {
580 color.setRgbF(mCurrentROIActor->GetContourColor()[0],
581 mCurrentROIActor->GetContourColor()[1],
582 mCurrentROIActor->GetContourColor()[2]);
583 QColor c = QColorDialog::getColor(color, this, "Choose the contour color");
584 mCurrentROIActor->SetContourColor(c.redF(), c.greenF(), c.blueF());
585 mCurrentROIActor->UpdateColor();
586 mCurrentSlicerManager->Render();
588 //------------------------------------------------------------------------------
591 //------------------------------------------------------------------------------
592 void vvToolStructureSetManager::ChangeContourWidth(int n) {
593 mCurrentROIActor->SetContourWidth(n);
594 mCurrentROIActor->UpdateColor();
595 mCurrentSlicerManager->Render();
597 //------------------------------------------------------------------------------
600 //------------------------------------------------------------------------------
601 void vvToolStructureSetManager::ReloadCurrentROI() {
603 vvImageReader::Pointer reader = vvImageReader::New();
604 reader->SetInputFilename(mCurrentROI->GetFilename());
605 reader->Update(vvImageReader::IMAGE);
606 if (reader->GetLastError() != "") {
607 QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), reader->GetLastError().c_str());
610 mCurrentROI->GetImage()->GetFirstVTKImageData()->ReleaseData();
611 mCurrentROI->SetImage(reader->GetOutput());
614 mCurrentROIActor->UpdateImage();
615 mCurrentSlicerManager->Render();
617 //------------------------------------------------------------------------------
620 //------------------------------------------------------------------------------
621 void vvToolStructureSetManager::CheckInputList(std::vector<vvSlicerManager*> & l, int & index)
623 for(unsigned int i=0; i<l.size(); i++) {
624 std::vector<vvSlicerManager*>::iterator iter = std::find(mListOfInputs.begin(), mListOfInputs.end(), l[i]);
625 if (iter != mListOfInputs.end()) {
626 for(unsigned int j=i;j<l.size(); j++) l[j] = l[j+1];
628 if (index == (int)i) index = 0;
633 //------------------------------------------------------------------------------
636 //------------------------------------------------------------------------------
638 vvToolStructureSetManager * vvToolStructureSetManager::AddImage(vvSlicerManager * m, std::string name, vvImage::Pointer image, double BG, bool m_modeBG)
640 // If the tool is open for this vvSlicerManager, use it and return
641 if (mListOfOpenTool[m]) {
642 vvToolStructureSetManager * tool = mListOfOpenTool[m];
643 tool->AddImage(image, name, BG, m_modeBG);
648 // If the tool is not open, create it
649 vvToolStructureSetManager * tool = new vvToolStructureSetManager
650 (CREATOR(vvToolStructureSetManager)->GetMainWindow(), Qt::Dialog, m);
651 tool->AddImage(image, name, BG, m_modeBG);
656 //------------------------------------------------------------------------------