# HG changeset patch # User Hasan Yavuz Ă–ZDERYA # Date 2015-03-16 16:41:13 # Node ID 44b87d87610b20e6184e0bd51c0631ede679d4e7 # Parent 649401566a84c8c61c3a9d873464d86536319b0e implemented "Clear" plot button diff --git a/mainwindow.cpp b/mainwindow.cpp --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -42,6 +42,9 @@ MainWindow::MainWindow(QWidget *parent) QObject::connect(ui->spYmax, SIGNAL(valueChanged(double)), this, SLOT(onYScaleChanged())); + QObject::connect(ui->actionClear, SIGNAL(triggered(bool)), + this, SLOT(clearPlot())); + // setup number format buttons numberFormatButtons.addButton(ui->rbUint8, NumberFormat_uint8); numberFormatButtons.addButton(ui->rbUint16, NumberFormat_uint16); @@ -265,6 +268,15 @@ void MainWindow::addData(double data) ui->plot->replot(); } +void MainWindow::clearPlot() +{ + dataArray.fill(0.0); + + // update plot + curve.setSamples(dataX, dataArray); + ui->plot->replot(); +} + void MainWindow::onNumOfSamplesChanged(int value) { unsigned int oldNum = this->numOfSamples; diff --git a/mainwindow.h b/mainwindow.h --- a/mainwindow.h +++ b/mainwindow.h @@ -67,6 +67,8 @@ private slots: void onNumberFormatButtonToggled(int numberFormatId, bool checked); void selectNumberFormat(NumberFormat numberFormatId); + void clearPlot(); + signals: void portToggled(bool open); };