]> Creatis software - clitk.git/blobdiff - vv/vvSlicer.cxx
Romulo: fixed log file, AppendOn was missing
[clitk.git] / vv / vvSlicer.cxx
index f287e4d7e89e7f1de15678ba44faf3725da1c93b..24a552b251486faffaf677ebf989f9174686c883 100644 (file)
@@ -91,6 +91,9 @@ vvSlicer::vvSlicer()
   mScale = 1;
   mVFLog = 0;
   mVFWidth = 1;
+  mVFColor[0] = 0;
+  mVFColor[1] = 1;
+  mVFColor[2] = 0;
 
   std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n";
   text += "F5 = horizontal flip; F6 = vertical flip\n\n";
@@ -428,11 +431,20 @@ void vvSlicer::SetVF(vvImage::Pointer vf)
     mGlyphFilter->SetVectorModeToUseVector();
     mGlyphFilter->SetColorModeToColorByVector();
 
+    if (!mVFColorLUT)
+      mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
+
+    double mVFColorHSV[3];
+    vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
+    mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
+    mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
+    mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
+
     if (!mVFMapper)
       mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
-    //mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
     mVFMapper->SetInput(mGlyphFilter->GetOutput());
     mVFMapper->ImmediateModeRenderingOn();
+    mVFMapper->SetLookupTable(mVFColorLUT);
 
     if (!mVFActor)
       mVFActor = vtkSmartPointer<vtkActor>::New();
@@ -1196,6 +1208,18 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max)
 }
 //----------------------------------------------------------------------------
 
+//----------------------------------------------------------------------------
+double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, int X, double Y, double Z, int &ix, int &iy, int &iz, int component)
+{
+  ix = lrint(X);
+  iy = lrint(Y);
+  iz = lrint(Z);
+  image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
+  image->Update();
+  return image->GetScalarComponentAsDouble(ix, iy, iz, component);
+}
+//----------------------------------------------------------------------------
+
 //----------------------------------------------------------------------------
 void vvSlicer::Render()
 {
@@ -1248,9 +1272,9 @@ void vvSlicer::Render()
         Y <= this->GetInput()->GetWholeExtent()[3] &&
         Z >= this->GetInput()->GetWholeExtent()[4] &&
         Z <= this->GetInput()->GetWholeExtent()[5]) {
-      int ix = lrint(X);
-      int iy = lrint(Y);
-      int iz = lrint(Z);
+      int ix, iy, iz;
+      double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
+
       std::stringstream pixel1;
       std::stringstream pixel2;
       std::stringstream pixel3;
@@ -1259,9 +1283,6 @@ void vvSlicer::Render()
       pixel2 << iy;
       pixel3 << iz;
       temps << mCurrentTSlice;
-      this->GetInput()->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
-      this->GetInput()->Update();
-      double value = this->GetInput()->GetScalarComponentAsDouble(ix, iy, iz, 0);
 
       std::stringstream val;
       val << value;
@@ -1382,7 +1403,19 @@ void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
 }
 //----------------------------------------------------------------------------
 
-
-
-
+//----------------------------------------------------------------------------
+void vvSlicer::SetVFColor(double r, double g, double b)
+{
+  double mVFColorHSV[3];
+  mVFColor[0] = r;
+  mVFColor[1] = g;
+  mVFColor[2] = b;
+
+  vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
+  mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
+  mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
+  mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
+
+  this->Render();
+}