浏览代码

Add dontMoveFirstAndLast to ctkVTKScalarsToColorsView::MovePoints

It can be useful to move only the inside points of the transfer functions
instead of all the points. Add an option to do it.
Julien Finet 13 年之前
父节点
当前提交
90029f682b

+ 6 - 8
Libs/Visualization/VTK/Widgets/ctkVTKScalarsToColorsView.cpp

@@ -587,24 +587,22 @@ void ctkVTKScalarsToColorsView::boundAxesToChartBounds()
 }
 
 // ----------------------------------------------------------------------------
-void ctkVTKScalarsToColorsView::moveAllPoints(double xOffset, double yOffset)
+void ctkVTKScalarsToColorsView::moveAllPoints(double xOffset, double yOffset,
+                                              bool dontMoveFirstAndLast)
 {
   vtkVector2f offset(xOffset, yOffset);
   foreach(vtkControlPointsItem* controlPointsItem, this->controlPointsItems())
     {
-    vtkSmartPointer<vtkIdTypeArray> ids;
-    ids.TakeReference(controlPointsItem->GetControlPointsIds());
-    controlPointsItem->MovePoints(offset, ids.GetPointer());
+    controlPointsItem->MovePoints(offset, dontMoveFirstAndLast);
     }
 }
 
 // ----------------------------------------------------------------------------
-void ctkVTKScalarsToColorsView::spreadAllPoints(double factor)
+void ctkVTKScalarsToColorsView::spreadAllPoints(double factor,
+                                                bool dontSpreadFirstAndLast)
 {
   foreach(vtkControlPointsItem* controlPointsItem, this->controlPointsItems())
     {
-    vtkSmartPointer<vtkIdTypeArray> ids;
-    ids.TakeReference(controlPointsItem->GetControlPointsIds());\
-    controlPointsItem->SpreadPoints(factor, ids.GetPointer());
+    controlPointsItem->SpreadPoints(factor, dontSpreadFirstAndLast);
     }
 }

+ 4 - 2
Libs/Visualization/VTK/Widgets/ctkVTKScalarsToColorsView.h

@@ -98,13 +98,15 @@ public slots:
 
   /// Move all the control points by a given offset.
   /// \sa vtkControlPoints::movePoints()
-  void moveAllPoints(double xOffset, double yOffset = 0.);
+  void moveAllPoints(double xOffset, double yOffset = 0.,
+                     bool dontMoveFirstAndLast = false);
 
   /// Spread all the control points by a given offset.
   /// A value >0 will space the control points, a value <0. will contract
   /// them.
   /// \sa vtkControlPoints::spreadPoints()
-  void spreadAllPoints(double factor = 1.);
+  void spreadAllPoints(double factor = 1.,
+                       bool dontMoveFirstAndLast = false);
 
 protected slots:
   void onBoundsChanged();

+ 16 - 8
Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.cpp

@@ -470,16 +470,20 @@ void ctkVTKVolumePropertyWidget::onAxesModified()
 }
 
 // ----------------------------------------------------------------------------
-void ctkVTKVolumePropertyWidget::moveAllPoints(double xOffset, double yOffset)
+void ctkVTKVolumePropertyWidget::moveAllPoints(double xOffset, double yOffset,
+                                               bool dontMoveFirstAndLast)
 {
   Q_D(ctkVTKVolumePropertyWidget);
   if (d->VolumeProperty)
     {
     d->VolumeProperty->InvokeEvent(vtkCommand::StartEvent);
     }
-  d->ScalarOpacityWidget->view()->moveAllPoints(xOffset, yOffset);
-  d->ScalarColorWidget->view()->moveAllPoints(xOffset, yOffset);
-  d->GradientWidget->view()->moveAllPoints(xOffset, yOffset);
+  d->ScalarOpacityWidget->view()
+    ->moveAllPoints(xOffset, yOffset, dontMoveFirstAndLast);
+  d->ScalarColorWidget->view()
+    ->moveAllPoints(xOffset, yOffset, dontMoveFirstAndLast);
+  d->GradientWidget->view()
+    ->moveAllPoints(xOffset, yOffset, dontMoveFirstAndLast);
   if (d->VolumeProperty)
     {
     d->VolumeProperty->InvokeEvent(vtkCommand::EndEvent);
@@ -487,12 +491,16 @@ void ctkVTKVolumePropertyWidget::moveAllPoints(double xOffset, double yOffset)
 }
 
 // ----------------------------------------------------------------------------
-void ctkVTKVolumePropertyWidget::spreadAllPoints(double factor)
+void ctkVTKVolumePropertyWidget::spreadAllPoints(double factor,
+                                                 bool dontSpreadFirstAndLast)
 {
   Q_D(ctkVTKVolumePropertyWidget);
   d->VolumeProperty->InvokeEvent(vtkCommand::StartEvent);
-  d->ScalarOpacityWidget->view()->spreadAllPoints(factor);
-  d->ScalarColorWidget->view()->spreadAllPoints(factor);
-  d->GradientWidget->view()->spreadAllPoints(factor);
+  d->ScalarOpacityWidget->view()
+    ->spreadAllPoints(factor, dontSpreadFirstAndLast);
+  d->ScalarColorWidget->view()
+    ->spreadAllPoints(factor, dontSpreadFirstAndLast);
+  d->GradientWidget->view()
+    ->spreadAllPoints(factor, dontSpreadFirstAndLast);
   d->VolumeProperty->InvokeEvent(vtkCommand::EndEvent);
 }

+ 4 - 2
Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.h

@@ -66,14 +66,16 @@ public slots:
   /// Move all the control points of the opacity, colors and gradient
   /// of a give offset.
   /// \sa vtkControlPoints::movePoints()
-  void moveAllPoints(double xOffset, double yOffset = 0.);
+  void moveAllPoints(double xOffset, double yOffset = 0.,
+                     bool dontSpreadFirstAndLast = false);
 
   /// Spread all the control points of the opacity, colors and gradient
   /// by a given offset.
   /// A value >0 will space the control points, a value <0. will contract
   /// them.
   /// \sa vtkControlPoints::spreadPoints()
-  void spreadAllPoints(double factor = 1.);
+  void spreadAllPoints(double factor = 1.,
+                       bool dontSpreadFirstAndLast = false);
 
   void showThreshold(bool enable);