diff --git a/src/plot.cpp b/src/plot.cpp --- a/src/plot.cpp +++ b/src/plot.cpp @@ -28,8 +28,6 @@ #include "plot.h" #include "utils.h" -#include - static const int SYMBOL_SHOW_AT_WIDTH = 5; static const int SYMBOL_SIZE_MAX = 7; @@ -96,7 +94,6 @@ void Plot::setYAxis(bool autoScaled, dou void Plot::setXAxis(double xMin, double xMax) { - qDebug() << "setXAxis:" << xMin << xMax; _xMin = xMin; _xMax = xMax; @@ -104,6 +101,7 @@ void Plot::setXAxis(double xMin, double // set axis setAxisScale(QwtPlot::xBottom, xMin, xMax); + replot(); // Note: if we don't replot here scale at startup isn't set correctly // reset zoom base auto base = zoomer.zoomBase(); @@ -111,10 +109,7 @@ void Plot::setXAxis(double xMin, double base.setRight(xMax); zoomer.setZoomBase(base); - qDebug() << "base:" << base; - onXScaleChanged(); - replot(); } void Plot::resetAxes() diff --git a/src/plotmanager.cpp b/src/plotmanager.cpp --- a/src/plotmanager.cpp +++ b/src/plotmanager.cpp @@ -17,7 +17,6 @@ along with serialplot. If not, see . */ -#include #include "qwt_symbol.h" #include "plot.h" @@ -254,6 +253,15 @@ Plot* PlotManager::addPlotWidget() plot->showDemoIndicator(isDemoShown); plot->setYAxis(_autoScaled, _yMin, _yMax); + if (_xAxisAsIndex) + { + plot->setXAxis(0, _numOfSamples); + } + else + { + plot->setXAxis(_xMin, _xMax); + } + return plot; } @@ -458,10 +466,8 @@ void PlotManager::onNumOfSamplesChanged( { for (auto plot : plotWidgets) { - // plot->onNumOfSamplesChanged(value); plot->setXAxis(0, value); } - qDebug() << "_xAxisAsIndex" << value; } }