瀏覽代碼

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

Nicolas Rannou 15 年之前
父節點
當前提交
aaa47be662
共有 1 個文件被更改,包括 13 次插入3 次删除
  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;
 }