Changeset - 6d13d2fee0f9
[Not reviewed]
default
0 4 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-07-23 23:11:55
hy@ozderya.net
fix unzoom with non-autoscaled axis mode
4 files changed with 22 insertions and 2 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -134,12 +134,14 @@ MainWindow::MainWindow(QWidget *parent) 
 
        curves[i]->attach(ui->plot);
 
    }
 

	
 
    // 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)
 
    {
 
        selectNumberFormat((NumberFormat) numberFormatButtons.checkedId());
 
    }
 
@@ -728,6 +730,21 @@ void MainWindow::messageHandler(QtMsgTyp
 

	
 
    if (type != QtDebugMsg)
 
    {
 
        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();
 
}
mainwindow.h
Show inline comments
 
@@ -84,12 +84,13 @@ private:
 
    QList<DataArray> channelsData;
 

	
 
    // `data` contains i th channels data
 
    void addChannelData(unsigned int channel, DataArray data);
 

	
 
    Zoomer* zoomer;
 
    void unzoomed();
 

	
 
    NumberFormat numberFormat;
 
    unsigned int sampleSize; // number of bytes in the selected number format
 
    double (MainWindow::*readSample)();
 

	
 
    // note that serialPort should already have enough bytes present
zoomer.cpp
Show inline comments
 
@@ -35,10 +35,9 @@ void Zoomer::zoom(int up)
 
    }
 

	
 
    QwtPlotZoomer::zoom(up);
 

	
 
    if (up == 0)
 
    {
 
        this->plot()->setAxisAutoScale(QwtPlot::yLeft);
 
        this->plot()->replot();
 
        emit unzoomed();
 
    }
 
}
zoomer.h
Show inline comments
 
@@ -26,9 +26,12 @@ class Zoomer : public QwtPlotZoomer
 
{
 
    Q_OBJECT
 

	
 
public:
 
    Zoomer(QWidget *, bool doReplot=true);
 
    void zoom(int up);
 

	
 
signals:
 
    void unzoomed();
 
};
 

	
 
#endif // ZOOMER_H
0 comments (0 inline, 0 general)