Bladeren bron

Update the transfer function before updating the current point

If the current point is the last point, and a point is added anywhere
before the last point, there was an assert, because the new number of points
wasn't updated (max of the spinbox), however the current point id was
incremented.
Julien Finet 13 jaren geleden
bovenliggende
commit
fd9baa04cb
1 gewijzigde bestanden met toevoegingen van 12 en 1 verwijderingen
  1. 12 1
      Libs/Visualization/VTK/Widgets/ctkVTKScalarsToColorsWidget.cpp

+ 12 - 1
Libs/Visualization/VTK/Widgets/ctkVTKScalarsToColorsWidget.cpp

@@ -265,13 +265,24 @@ void ctkVTKScalarsToColorsWidget::onBoundsChanged()
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 void ctkVTKScalarsToColorsWidget::setCurrentPoint(vtkObject* caller, void* callData)
 void ctkVTKScalarsToColorsWidget::setCurrentPoint(vtkObject* caller, void* callData)
 {
 {
+  Q_D(ctkVTKScalarsToColorsWidget);
   vtkControlPointsItem* controlPoints = reinterpret_cast<vtkControlPointsItem*>(caller);
   vtkControlPointsItem* controlPoints = reinterpret_cast<vtkControlPointsItem*>(caller);
   long newPoint = reinterpret_cast<long>(callData);
   long newPoint = reinterpret_cast<long>(callData);
   if (!controlPoints || newPoint < -1)
   if (!controlPoints || newPoint < -1)
     {
     {
     return;
     return;
     }
     }
-  this->setCurrentControlPointsItem(controlPoints);
+  if (d->CurrentControlPointsItem != item)
+    {
+    this->setCurrentControlPointsItem(controlPoints);
+    }
+  else
+    {
+    // When a new point is added, the modified event is fired later.
+    // however we need to update the max of the current spin box before
+    // setting the new value.
+    this->updateCurrentPoint();
+    }
   this->setCurrentPoint(newPoint);
   this->setCurrentPoint(newPoint);
 }
 }