+ // Tab insertion, check that another tool does not already exist for this image
+ std::vector<vvToolBaseBase*> & tools =
+ vvToolManager::GetInstance()->GetToolCreatorFromName(GetToolName())->GetListOfTool();
+ if (tools.size() > 0) {
+ for(uint i=0; i<tools.size()-1; i++) { // current tool is last
+ vvToolROIManager * t = dynamic_cast<vvToolROIManager*>(tools[i]);
+ if (mCurrentSlicerManager == t->GetCurrentSlicerManager()) {
+ QMessageBox::warning(this, "ROIManager tool", "Already a ROI for this image, abort.");
+ close();
+ return;
+ }
+ }
+ }
+
+ // Display tool in the correct tab
+ QWidget * tab = qFindChild<QWidget*>(mMainWindow->GetTab(), "ROItab");
+ tab->layout()->addWidget(this);
+
+ // If not read in a file we start automatically the browser to load
+ // a roi file (binary image)
+ if (ReadStateFlag) {
+ mOpenFileBrowserFlag = false;
+ InputIsSelected(mCurrentSlicerManager);
+ mOpenFileBrowserFlag = true;
+ }
+ else InputIsSelected(mCurrentSlicerManager);
+
+ // Load ROI (if read in the XML files, empty otherwise)
+ OpenBinaryImage(mROIFilenames);
+
+ // Set the options to the open roi
+ for(uint i=0; i<mROIActorsParamList.size(); i++) {
+ QSharedPointer<vvROIActor> roi = mROIActorsList[i];
+ QSharedPointer<vvROIActor> roi_param = mROIActorsParamList[i];
+ roi->CopyParameters(roi_param);
+
+ // Update Tree
+ QTreeWidgetItem * w = mMapROIToTreeWidget[roi->GetROI()];
+ QBrush brush(QColor(roi->GetROI()->GetDisplayColor()[0]*255,
+ roi->GetROI()->GetDisplayColor()[1]*255,
+ roi->GetROI()->GetDisplayColor()[2]*255));
+ brush.setStyle(Qt::SolidPattern);
+ w->setBackground(2, brush);
+ w->setText(3, QString("%1").arg(roi->GetDepth()));
+ roi->UpdateColor();
+ }
+
+ // Display the ROI
+ UpdateAllContours();
+ UpdateAllROIStatus();
+
+ // Connect event from mainwindow to this widget
+ connect(mMainWindow, SIGNAL(AnImageIsBeingClosed(vvSlicerManager *)),
+ this, SLOT(AnImageIsBeingClosed(vvSlicerManager *)));
+ connect(mMainWindow, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)),
+ this, SLOT(SelectedImageHasChanged(vvSlicerManager *)));
+ connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(OpenBinaryImage()));
+ connect(mOpenDicomButton, SIGNAL(clicked()), this, SLOT(OpenDicomImage()));
+ connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
+ connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
+ connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
+ connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
+ connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
+ connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
+ connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
+ connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
+ connect(mReloadButton, SIGNAL(clicked()), this, SLOT(ReloadCurrentROI()));
+ connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
+ connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));