浏览代码

Update range and values of ctkVTKScalarsToColorsWidget

In some scenarii, the axes limits and values were changed at once, so when
the range slider range was updated, the slider value was not up to date.
Julien Finet 14 年之前
父节点
当前提交
f79879aaf9
共有 1 个文件被更改,包括 10 次插入10 次删除
  1. 10 10
      Libs/Visualization/VTK/Widgets/ctkVTKScalarsToColorsWidget.cpp

+ 10 - 10
Libs/Visualization/VTK/Widgets/ctkVTKScalarsToColorsWidget.cpp

@@ -205,14 +205,7 @@ void ctkVTKScalarsToColorsWidget::onPlotAdded(vtkPlot* plot)
 // ----------------------------------------------------------------------------
 void ctkVTKScalarsToColorsWidget::onBoundsChanged()
 {
-  Q_D(ctkVTKScalarsToColorsWidget);
-  double bounds[8];
-  d->View->chartBounds(bounds);
-  /// The bounds have already been set to the axes in ctkVTKChartView::boundAxesToChartBounds()
-  d->XRangeSlider->setRange(bounds[vtkAxis::BOTTOM * 2],
-                            bounds[vtkAxis::BOTTOM * 2 + 1]);
-  d->YRangeSlider->setRange(bounds[vtkAxis::LEFT * 2],
-                            bounds[vtkAxis::LEFT * 2 + 1]);
+  this->onAxesModified();
 }
 
 // ----------------------------------------------------------------------------
@@ -466,11 +459,18 @@ void ctkVTKScalarsToColorsWidget::onAxesModified()
   vtkAxis* xAxis = d->CurrentControlPointsItem ?
     d->CurrentControlPointsItem->GetXAxis() : d->View->chart()->GetAxis(vtkAxis::BOTTOM);
   Q_ASSERT(xAxis);
+
+  bool wasBlocking = d->XRangeSlider->blockSignals(true);
+  d->XRangeSlider->setRange(xAxis->GetMinimumLimit(), xAxis->GetMaximumLimit());
   d->XRangeSlider->setValues(xAxis->GetMinimum(), xAxis->GetMaximum());
+  d->XRangeSlider->blockSignals(wasBlocking);
+
   vtkAxis* yAxis = d->CurrentControlPointsItem ?
     d->CurrentControlPointsItem->GetYAxis() : d->View->chart()->GetAxis(vtkAxis::LEFT);
   Q_ASSERT(yAxis);
+
+  wasBlocking = d->YRangeSlider->blockSignals(true);
+  d->YRangeSlider->setRange(yAxis->GetMinimumLimit(), yAxis->GetMaximumLimit());
   d->YRangeSlider->setValues(yAxis->GetMinimum(), yAxis->GetMaximum());
-  //  d->View->scene()->SetDirty(true);
-  //emit this->axesModified();
+  d->YRangeSlider->blockSignals(wasBlocking);
 }