diff --git a/mainwindow.cpp b/mainwindow.cpp --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "utils.h" #include "version.h" #include "floatswap.h" @@ -112,6 +114,9 @@ MainWindow::MainWindow(QWidget *parent) QObject::connect(ui->actionClear, SIGNAL(triggered(bool)), this, SLOT(clearPlot())); + QObject::connect(ui->actionSnapShot, SIGNAL(triggered(bool)), + this, SLOT(takeSnapShot())); + // setup number of channels spinbox QObject::connect(ui->spNumOfChannels, SELECT::OVERLOAD_OF(&QSpinBox::valueChanged), @@ -241,6 +246,12 @@ MainWindow::~MainWindow() { serialPort.close(); } + + for (auto snapshot : snapshots) + { + delete snapshot; + } + delete ui; ui = NULL; // we check if ui is deleted in messageHandler } @@ -745,3 +756,23 @@ void MainWindow::messageHandler(QtMsgTyp ui->statusBar->showMessage(msg, 5000); } } + +void MainWindow::takeSnapShot() +{ + qDebug() << "taking a snopshot yay!"; + auto snapShot = new SnapShot(); + snapShot->name = QString("SnapShot"); + + for (unsigned ci = 0; ci < numOfChannels; ci++) + { + snapShot->data.append(QVector(numOfSamples)); + for (unsigned i = 0; i < numOfSamples; i++) + { + snapShot->data[ci][i] = channelBuffers[ci]->sample(i); + } + } + snapshots.append(snapShot); + + auto sv = new SnapShotView(this, snapShot); + sv->show(); +}