Browse Source

ENH: Add utility function ctkRangeWidget::values(double&, double&)

Instead of calling ctkRangeWidget::minimumValue() and
ctkRangeWidget::maximumValue(), ctkRangeWidget::values(double&, double&)
returns the min and max values at once
Julien Finet 15 years ago
parent
commit
dbf0654c2e
2 changed files with 15 additions and 0 deletions
  1. 10 0
      Libs/Widgets/ctkRangeWidget.cpp
  2. 5 0
      Libs/Widgets/ctkRangeWidget.h

+ 10 - 0
Libs/Widgets/ctkRangeWidget.cpp

@@ -251,6 +251,16 @@ double ctkRangeWidget::previousSliderPosition()
 */
 
 // --------------------------------------------------------------------------
+void ctkRangeWidget::values(double &minValue, double &maxValue)const
+{
+  CTK_D(const ctkRangeWidget);
+  Q_ASSERT(d->equal(d->Slider->minimumValue(), d->MinimumSpinBox->value()));
+  Q_ASSERT(d->equal(d->Slider->maximumValue(), d->MaximumSpinBox->value()));
+  minValue = d->Changing ? d->MinimumValueBeforeChange : d->Slider->minimumValue();
+  maxValue = d->Changing ? d->MaximumValueBeforeChange : d->Slider->maximumValue();
+}
+
+// --------------------------------------------------------------------------
 double ctkRangeWidget::minimumValue()const
 {
   CTK_D(const ctkRangeWidget);

+ 5 - 0
Libs/Widgets/ctkRangeWidget.h

@@ -95,6 +95,11 @@ public:
   double maximumValue()const;
 
   ///
+  /// Utility function that returns both values at the same time
+  /// Returns minimumValue and maximumValue
+  void values(double &minValue, double &maxValue)const;
+
+  ///
   /// This property holds the single step.
   /// The smaller of two natural steps that the
   /// slider provides and typically corresponds to the