+//------------------------------------------------------------------------------
+QSharedPointer<vvROIActor> vvToolSegmentation::CreateMaskActor(vvImage::Pointer image, int i, int colorID, bool BGMode)
+{
+ static int depth = 1;
+ depth += 1;
+ QSharedPointer<vvROIActor> actor = QSharedPointer<vvROIActor>(new vvROIActor);
+ double * color = mDefaultLUTColor->GetTableValue(colorID % mDefaultLUTColor->GetNumberOfTableValues ());
+ std::vector<double> c;
+ c.push_back(color[0]);
+ c.push_back(color[1]);
+ c.push_back(color[2]);
+ clitk::DicomRT_ROI::Pointer roi = clitk::DicomRT_ROI::New();
+ roi->SetFromBinaryImage(image, i, std::string("toto"), c, std::string("titi"));
+ if (BGMode) {
+ actor->SetBGMode(true);
+ }
+ else {
+ roi->SetForegroundValueLabelImage(i); // FG mode
+ actor->SetBGMode(false); // FG mode
+ }
+ actor->SetROI(roi);
+ actor->SetSlicerManager(mCurrentSlicerManager);
+ actor->Initialize(depth+i, true); // +1 to start at 1 not 0
+ actor->SetContourVisible(false);
+ actor->SetVisible(true);
+ return actor;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolSegmentation::MousePositionChanged(int slicer)
+{
+ if (mCurrentState == State_Default) return; // Do nothing in this case
+
+ double x = mCurrentSlicerManager->GetSlicer(slicer)->GetCurrentPosition()[0];
+ double y = mCurrentSlicerManager->GetSlicer(slicer)->GetCurrentPosition()[1];
+ double z = mCurrentSlicerManager->GetSlicer(slicer)->GetCurrentPosition()[2];
+ vtkImageData * image = mCurrentCCLImage->GetFirstVTKImageData();
+ double Xover = (x - image->GetOrigin()[0]) / image->GetSpacing()[0];
+ double Yover = (y - image->GetOrigin()[1]) / image->GetSpacing()[1];
+ double Zover = (z - image->GetOrigin()[2]) / image->GetSpacing()[2];
+ int ix, iy, iz;
+
+ if (Xover >= image->GetWholeExtent()[0] &&
+ Xover <= image->GetWholeExtent()[1] &&
+ Yover >= image->GetWholeExtent()[2] &&
+ Yover <= image->GetWholeExtent()[3] &&
+ Zover >= image->GetWholeExtent()[4] &&
+ Zover <= image->GetWholeExtent()[5]) {
+ mCurrentLabelUnderMousePointer =
+ mCurrentSlicerManager->GetSlicer(0)->GetScalarComponentAsDouble(image, Xover, Yover, Zover, ix, iy, iz, 0);
+ // DD(Xover); DD(Yover); DD(Zover);
+ // DD(ix); DD(iy); DD(iz);
+ // DD(valueOver);
+ }
+ else {
+ // DD("out of mask");
+ mCurrentLabelUnderMousePointer = 0; // BG is always 0 in CCL
+ }
+ // DD(mCurrentLabelUnderMousePointer);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolSegmentation::RemoveLabel() {
+ DD("RemoveLabel");
+ if (mCurrentLabelUnderMousePointer == 0) return;
+ // First actor=0 and is label 1. Label 0 is not an actor, it is BG
+ int actorNumber = mCurrentLabelUnderMousePointer-1;
+ // Set actor invisible
+ mCurrentCCLActors[actorNumber]->SetVisible(false);