diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -124,7 +124,7 @@ MainWindow::MainWindow(QWidget *parent) this, &MainWindow::onNumOfSamplesChanged); connect(&plotControlPanel, &PlotControlPanel::scaleChanged, - ui->plot, &Plot::setAxis); + plotMan, &PlotManager::setAxis); connect(&plotControlPanel, &PlotControlPanel::multiPlotChanged, plotMan, &PlotManager::setMulti); @@ -170,10 +170,9 @@ MainWindow::MainWindow(QWidget *parent) plotMan->addCurve(channelMan.channelName(i), channelMan.channelBuffer(i)); } - // TODO: plotman // init auto scale - ui->plot->setAxis(plotControlPanel.autoScale(), - plotControlPanel.yMin(), plotControlPanel.yMax()); + plotMan->setAxis(plotControlPanel.autoScale(), + plotControlPanel.yMin(), plotControlPanel.yMax()); // Init sps (sample per second) counter spsLabel.setText("0sps"); diff --git a/src/plotmanager.cpp b/src/plotmanager.cpp --- a/src/plotmanager.cpp +++ b/src/plotmanager.cpp @@ -33,9 +33,13 @@ PlotManager::PlotManager(QWidget* plotAr darkBackgroundAction("Dark Background", this), showLegendAction("Legend", this) { + _autoScaled = true; + _yMin = 0; + _yMax = 1; + isDemoShown = false; + // initalize layout and single widget isMulti = false; - isDemoShown = false; scrollArea = NULL; setupLayout(isMulti); addPlotWidget(); @@ -176,6 +180,7 @@ Plot* PlotManager::addPlotWidget() plot->showMinorGrid(showMinorGridAction.isChecked()); plot->showLegend(showLegendAction.isChecked()); plot->showDemoIndicator(isDemoShown); + plot->setAxis(_autoScaled, _yMin, _yMax); return plot; } @@ -312,3 +317,14 @@ void PlotManager::darkBackground(bool en plot->darkBackground(enabled); } } + +void PlotManager::setAxis(bool autoScaled, double yAxisMin, double yAxisMax) +{ + _autoScaled = autoScaled; + _yMin = yAxisMin; + _yMax = yAxisMax; + for (auto plot : plotWidgets) + { + plot->setAxis(autoScaled, yAxisMin, yAxisMax); + } +} diff --git a/src/plotmanager.h b/src/plotmanager.h --- a/src/plotmanager.h +++ b/src/plotmanager.h @@ -61,6 +61,8 @@ public slots: void replot(); /// Enable display of a "DEMO" label on each plot void showDemoIndicator(bool show = true); + /// Set the Y axis + void setAxis(bool autoScaled, double yMin = 0, double yMax = 1); private: bool isMulti; @@ -70,6 +72,9 @@ private: QList curves; QList plotWidgets; bool isDemoShown; + bool _autoScaled; + double _yMin; + double _yMax; // menu actions QAction showGridAction;