Просмотр исходного кода

Don't fire unnecessary events

When updating the current point, because of rounding errors, setting the
(almost) same value to a widget would update the transfer function again.
Julien Finet лет назад: 14
Родитель
Сommit
e8368abbf7
1 измененных файлов с 15 добавлено и 0 удалено
  1. 15 0
      Libs/Visualization/VTK/Widgets/ctkVTKScalarsToColorsWidget.cpp

+ 15 - 0
Libs/Visualization/VTK/Widgets/ctkVTKScalarsToColorsWidget.cpp

@@ -55,6 +55,9 @@ protected:
 public:
   ctkVTKScalarsToColorsWidgetPrivate(ctkVTKScalarsToColorsWidget& object);
   void setupUi(QWidget* widget);
+
+  bool blockSignals(bool);
+
   vtkControlPointsItem* CurrentControlPointsItem;
 };
 
@@ -106,6 +109,15 @@ void ctkVTKScalarsToColorsWidgetPrivate::setupUi(QWidget* widget)
 }
 
 // ----------------------------------------------------------------------------
+bool ctkVTKScalarsToColorsWidget::blockSignals(bool block)
+{
+  d->ColorPickerButton->blockSignals(block);
+  d->OpacitySpinBox->blockSignals(block);
+  d->MidPointSpinBox->blockSignals(block);
+  return d->SharpnessSpinBox->blockSignals(block);
+}
+
+// ----------------------------------------------------------------------------
 // ctkVTKScalarsToColorsWidget methods
 
 // ----------------------------------------------------------------------------
@@ -283,6 +295,8 @@ void ctkVTKScalarsToColorsWidget::updateCurrentPoint()
 
   double point[4];
   d->CurrentControlPointsItem->GetControlPoint(pointId, point);
+
+  bool oldBlock = d->blockSignals(true);
   d->OpacitySpinBox->setValue(point[1]);
   d->MidPointSpinBox->setValue(point[2]);
   d->SharpnessSpinBox->setValue(point[3]);
@@ -298,6 +312,7 @@ void ctkVTKScalarsToColorsWidget::updateCurrentPoint()
     QColor color = QColor::fromRgbF(xrgbms[1], xrgbms[2], xrgbms[3]);
     d->ColorPickerButton->setColor(color);
     }
+  d->blockSignals(oldBlock);
 }
 
 // ----------------------------------------------------------------------------