diff --git a/mainwindow.cpp b/mainwindow.cpp --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -137,6 +137,8 @@ MainWindow::MainWindow(QWidget *parent) // init zoomer zoomer = new Zoomer(ui->plot->canvas(), false); zoomer->setZoomBase(); + QObject::connect(zoomer, &Zoomer::unzoomed, + this, &MainWindow::unzoomed); // init number format if (numberFormatButtons.checkedId() >= 0) @@ -731,3 +733,18 @@ void MainWindow::messageHandler(QtMsgTyp ui->statusBar->showMessage(msg, 5000); } } + +void MainWindow::unzoomed() +{ + if (ui->cbAutoScale->isChecked()) + { + ui->plot->setAxisAutoScale(QwtPlot::yLeft); + } + else + { + ui->plot->setAxisScale(QwtPlot::yLeft, ui->spYmin->value(), + ui->spYmax->value()); + } + ui->plot->setAxisAutoScale(QwtPlot::xBottom); + ui->plot->replot(); +} diff --git a/mainwindow.h b/mainwindow.h --- a/mainwindow.h +++ b/mainwindow.h @@ -87,6 +87,7 @@ private: void addChannelData(unsigned int channel, DataArray data); Zoomer* zoomer; + void unzoomed(); NumberFormat numberFormat; unsigned int sampleSize; // number of bytes in the selected number format diff --git a/zoomer.cpp b/zoomer.cpp --- a/zoomer.cpp +++ b/zoomer.cpp @@ -38,7 +38,6 @@ void Zoomer::zoom(int up) if (up == 0) { - this->plot()->setAxisAutoScale(QwtPlot::yLeft); - this->plot()->replot(); + emit unzoomed(); } } diff --git a/zoomer.h b/zoomer.h --- a/zoomer.h +++ b/zoomer.h @@ -29,6 +29,9 @@ class Zoomer : public QwtPlotZoomer public: Zoomer(QWidget *, bool doReplot=true); void zoom(int up); + +signals: + void unzoomed(); }; #endif // ZOOMER_H