Bläddra i källkod

ENH: in ctkVTKColorTransferFunction.cpp, setValue(position) is working

Nicolas Rannou 15 år sedan
förälder
incheckning
aaa47be662
1 ändrade filer med 13 tillägg och 3 borttagningar
  1. 13 3
      Libs/Visualization/VTK/Core/ctkVTKColorTransferFunction.cpp

+ 13 - 3
Libs/Visualization/VTK/Core/ctkVTKColorTransferFunction.cpp

@@ -243,11 +243,21 @@ int ctkVTKColorTransferFunction::insertControlPoint(const ctkControlPoint& cp)
   return index;
 }
 //-----------------------------------------------------------------------------
-// insert point with value = 0
 int ctkVTKColorTransferFunction::insertControlPoint(qreal pos)
 {
-  // nothing
-  int index = 0;
+  CTK_D(ctkVTKColorTransferFunction);
+  int index = -1;
+  if (d->ColorTransferFunction.GetPointer() == 0)
+    {
+    return index;
+    }
+
+  // Get color at the given position
+  double* rgb = d->ColorTransferFunction->GetColor( pos );
+
+  // Add new point with the appropriate color
+  index = d->ColorTransferFunction->AddRGBPoint(
+    pos, rgb[0], rgb[1], rgb[2]);
 
   return index;
 }