Changeset - 6c4c2a001b76
[Not reviewed]
snapshots
0 8 0
Hasan Yavuz ÖZDERYA - 10 years ago 2015-09-30 05:20:27
hy@ozderya.net
code cleanup

- consistent usage of "snapshot" instead of "snapShot"
- removed some dead code
- added file headers
8 files changed with 173 insertions and 68 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -87,51 +87,48 @@ MainWindow::MainWindow(QWidget *parent) 
 
                     this, &MainWindow::close);
 

	
 
    // port control signals
 
    QObject::connect(&portControl, &PortControl::portToggled,
 
                     this, &MainWindow::onPortToggled);
 

	
 
    QObject::connect(&portControl, &PortControl::skipByteRequested,
 
                     this, &MainWindow::skipByte);
 

	
 
    QObject::connect(ui->spNumOfSamples, SELECT<int>::OVERLOAD_OF(&QSpinBox::valueChanged),
 
                     this, &MainWindow::onNumOfSamplesChanged);
 

	
 
    QObject::connect(ui->cbAutoScale, &QCheckBox::toggled,
 
                     this, &MainWindow::onAutoScaleChecked);
 

	
 
    QObject::connect(ui->spYmin, SIGNAL(valueChanged(double)),
 
                     this, SLOT(onYScaleChanged()));
 

	
 
    QObject::connect(ui->spYmax, SIGNAL(valueChanged(double)),
 
                     this, SLOT(onYScaleChanged()));
 

	
 
    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<int>::OVERLOAD_OF(&QSpinBox::valueChanged),
 
                     this, &MainWindow::onNumOfChannelsChanged);
 

	
 
    // setup number format buttons
 
    numberFormatButtons.addButton(ui->rbUint8,  NumberFormat_uint8);
 
    numberFormatButtons.addButton(ui->rbUint16, NumberFormat_uint16);
 
    numberFormatButtons.addButton(ui->rbUint32, NumberFormat_uint32);
 
    numberFormatButtons.addButton(ui->rbInt8,   NumberFormat_int8);
 
    numberFormatButtons.addButton(ui->rbInt16,  NumberFormat_int16);
 
    numberFormatButtons.addButton(ui->rbInt32,  NumberFormat_int32);
 
    numberFormatButtons.addButton(ui->rbFloat,  NumberFormat_float);
 
    numberFormatButtons.addButton(ui->rbASCII,  NumberFormat_ASCII);
 

	
 
    QObject::connect(&numberFormatButtons, SIGNAL(buttonToggled(int, bool)),
 
                     this, SLOT(onNumberFormatButtonToggled(int, bool)));
 

	
 
    // init port signals
 
    QObject::connect(&(this->serialPort), SIGNAL(error(QSerialPort::SerialPortError)),
 
                     this, SLOT(onPortError(QSerialPort::SerialPortError)));
 

	
 
    // set limits for axis limit boxes
 
    ui->spYmin->setRange((-1) * std::numeric_limits<double>::max(),
snapshot.cpp
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <stddef.h>
 

	
 
#include "snapshot.h"
 
#include "snapshotview.h"
 

	
 
#include <QtDebug>
 

	
 
SnapShot::SnapShot(QMainWindow* parent, QString name) :
 
Snapshot::Snapshot(QMainWindow* parent, QString name) :
 
    QObject(parent),
 
    _showAction(name, this),
 
    _deleteAction("Delete", this)
 
{
 
    _name = name;
 

	
 
    view = NULL;
 
    mainWindow = parent;
 
    connect(&_showAction, &QAction::triggered, this, &SnapShot::show);
 
    connect(&_showAction, &QAction::triggered, this, &Snapshot::show);
 

	
 
    _deleteAction.setToolTip(QString("Delete ") + _name);
 
    connect(&_deleteAction, &QAction::triggered, this, &SnapShot::onDeleteTriggered);
 
    connect(&_deleteAction, &QAction::triggered, this, &Snapshot::onDeleteTriggered);
 
}
 

	
 
SnapShot::~SnapShot()
 
Snapshot::~Snapshot()
 
{
 
    if (view != NULL)
 
    {
 
        delete view;
 
    }
 
}
 

	
 
QAction* SnapShot::showAction()
 
QAction* Snapshot::showAction()
 
{
 
    return &_showAction;
 
}
 

	
 
QAction* SnapShot::deleteAction()
 
QAction* Snapshot::deleteAction()
 
{
 
    return &_deleteAction;
 
}
 

	
 
void SnapShot::show()
 
void Snapshot::show()
 
{
 
    if (view == NULL)
 
    {
 
        view = new SnapShotView(mainWindow, this);
 
        connect(view, &SnapShotView::closed, this, &SnapShot::viewClosed);
 
        view = new SnapshotView(mainWindow, this);
 
        connect(view, &SnapshotView::closed, this, &Snapshot::viewClosed);
 
    }
 
    view->show();
 
    view->activateWindow();
 
    view->raise();
 
}
 

	
 
void SnapShot::viewClosed()
 
void Snapshot::viewClosed()
 
{
 
    view->deleteLater();
 
    view = NULL;
 
}
 

	
 
void SnapShot::onDeleteTriggered()
 
void Snapshot::onDeleteTriggered()
 
{
 
    emit deleteRequested(this);
 
}
 

	
 
QString SnapShot::name()
 
QString Snapshot::name()
 
{
 
    return _name;
 
}
 

	
 
void SnapShot::setName(QString name)
 
void Snapshot::setName(QString name)
 
{
 
    _name = name;
 
    _showAction.setText(_name);
 
    emit nameChanged(this);
 
}
snapshot.h
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef SNAPSHOT_H
 
#define SNAPSHOT_H
 

	
 
#include <QObject>
 
#include <QMainWindow>
 
#include <QAction>
 
#include <QVector>
 
#include <QString>
 

	
 
class SnapShotView;
 
class SnapshotView;
 

	
 
class SnapShot : public QObject
 
class Snapshot : public QObject
 
{
 
    Q_OBJECT
 

	
 
public:
 
    SnapShot(QMainWindow* parent, QString name);
 
    ~SnapShot();
 
    Snapshot(QMainWindow* parent, QString name);
 
    ~Snapshot();
 

	
 
    QVector<QVector<QPointF>> data;
 
    QAction* showAction();
 
    QAction* deleteAction();
 

	
 
    QString name();
 
    void setName(QString name);
 

	
 
signals:
 
    void deleteRequested(SnapShot*);
 
    void nameChanged(SnapShot*);
 
    void deleteRequested(Snapshot*);
 
    void nameChanged(Snapshot*);
 

	
 
private:
 
    QString _name;
 
    QAction _showAction;
 
    QAction _deleteAction;
 
    QMainWindow* mainWindow;
 
    SnapShotView* view;
 
    SnapshotView* view;
 

	
 
private slots:
 
    void show();
 
    void viewClosed();
 

	
 
    void onDeleteTriggered();
 
};
 

	
 
#endif /* SNAPSHOT_H */
snapshotmanager.cpp
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <QTime>
 
#include <QMenuBar>
 
#include <QKeySequence>
 
#include <QFileDialog>
 
#include <QFile>
 
#include <QVector>
 
#include <QPointF>
 

	
 
#include "snapshotmanager.h"
 

	
 
SnapshotManager::SnapshotManager(QMainWindow* mainWindow,
 
                                 QList<FrameBuffer*>* channelBuffers) :
 
    _menu("Snapshots"),
 
    _takeSnapshotAction("Take Snapshot", this),
 
    loadSnapshotAction("Load Snapshots", this),
 
    clearAction("Clear Snapshots", this)
 
{
 
    _mainWindow = mainWindow;
 
    _channelBuffers = channelBuffers;
 

	
 
    _takeSnapshotAction.setToolTip("Take a snapshot of current plot (F5)");
 
    _takeSnapshotAction.setShortcut(QKeySequence("F5"));
 
    loadSnapshotAction.setToolTip("Load snapshots from CSV files");
 
    clearAction.setToolTip("Delete all snapshots");
 
    connect(&_takeSnapshotAction, SIGNAL(triggered(bool)),
 
            this, SLOT(takeSnapshot()));
 
    connect(&clearAction, SIGNAL(triggered(bool)),
 
            this, SLOT(clearSnapshots()));
 
    connect(&loadSnapshotAction, SIGNAL(triggered(bool)),
 
            this, SLOT(loadSnapshots()));
 

	
 
    updateMenu();
 
}
 

	
 
SnapshotManager::~SnapshotManager()
 
{
 
    for (auto snapshot : snapshots)
 
    {
 
        delete snapshot;
 
    }
 
}
 

	
 
void SnapshotManager::takeSnapshot()
 
{
 
    QString name = QTime::currentTime().toString("'Snapshot ['HH:mm:ss']'");
 
    auto snapShot = new SnapShot(_mainWindow, name);
 
    auto snapshot = new Snapshot(_mainWindow, name);
 

	
 
    unsigned numOfChannels = _channelBuffers->size();
 
    unsigned numOfSamples = _channelBuffers->at(0)->size();
 

	
 
    for (unsigned ci = 0; ci < numOfChannels; ci++)
 
    {
 
        snapShot->data.append(QVector<QPointF>(numOfSamples));
 
        snapshot->data.append(QVector<QPointF>(numOfSamples));
 
        for (unsigned i = 0; i < numOfSamples; i++)
 
        {
 
            snapShot->data[ci][i] = _channelBuffers->at(ci)->sample(i);
 
            snapshot->data[ci][i] = _channelBuffers->at(ci)->sample(i);
 
        }
 
    }
 

	
 
    addSnapshot(snapShot);
 
    addSnapshot(snapshot);
 
}
 

	
 
void SnapshotManager::addSnapshot(SnapShot* snapshot, bool update_menu)
 
void SnapshotManager::addSnapshot(Snapshot* snapshot, bool update_menu)
 
{
 
    snapshots.append(snapshot);
 
    QObject::connect(snapshot, &SnapShot::deleteRequested,
 
    QObject::connect(snapshot, &Snapshot::deleteRequested,
 
                     this, &SnapshotManager::deleteSnapshot);
 
    if (update_menu) updateMenu();
 
}
 

	
 
void SnapshotManager::updateMenu()
 
{
 
    _menu.clear();
 
    _menu.addAction(&_takeSnapshotAction);
 
    _menu.addAction(&loadSnapshotAction);
 
    if (snapshots.size())
 
    {
 
        _menu.addSeparator();
 
        for (auto ss : snapshots)
 
        {
 
            _menu.addAction(ss->showAction());
 
        }
 
        _menu.addSeparator();
 
        _menu.addAction(&clearAction);
 
    }
 
}
 

	
 
void SnapshotManager::clearSnapshots()
 
{
 
    for (auto snapshot : snapshots)
 
    {
 
        delete snapshot;
 
    }
 
    snapshots.clear();
 
    updateMenu();
 
}
 

	
 
void SnapshotManager::deleteSnapshot(SnapShot* snapshot)
 
void SnapshotManager::deleteSnapshot(Snapshot* snapshot)
 
{
 
    snapshots.removeOne(snapshot);
 
    snapshot->deleteLater(); // regular delete causes a crash when triggered from menu
 
    updateMenu();
 
}
 

	
 
void SnapshotManager::loadSnapshots()
 
{
 
    auto files = QFileDialog::getOpenFileNames(_mainWindow, tr("Load CSV File"));
 

	
 
    for (auto f : files)
 
    {
 
        if (!f.isNull()) loadSnapshotFromFile(f);
 
    }
 

	
 
    updateMenu();
 
}
 

	
 
void SnapshotManager::loadSnapshotFromFile(QString fileName)
 
{
 
    QFile file(fileName);
 
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
 
    {
 
        qCritical() << "Couldn't open file: " << fileName;
 
@@ -142,39 +160,39 @@ void SnapshotManager::loadSnapshotFromFi
 
        {
 
            qCritical() << "Parsing error at line " << lineNum
 
                        << ": number of columns is not consistent.";
 
            return;
 
        }
 

	
 
        for (unsigned ci = 0; ci < numOfChannels; ci++)
 
        {
 
            // parse column
 
            bool ok;
 
            double y = split[ci].toDouble(&ok);
 
            if (!ok)
 
            {
 
                qCritical() << "Parsing error at line " << lineNum
 
                            << ", column " << ci
 
                            << ": can't convert \"" << split[ci]
 
                            << "\" to double.";
 
                return;
 
            }
 
            data[ci].append(QPointF(lineNum-1, y));
 
        }
 
        lineNum++;
 
    }
 

	
 
    auto snapshot = new SnapShot(_mainWindow, QFileInfo(fileName).baseName());
 
    auto snapshot = new Snapshot(_mainWindow, QFileInfo(fileName).baseName());
 
    snapshot->data = data;
 

	
 
    addSnapshot(snapshot, false);
 
}
 

	
 
QMenu* SnapshotManager::menu()
 
{
 
    return &_menu;
 
}
 

	
 
QAction* SnapshotManager::takeSnapshotAction()
 
{
 
    return &_takeSnapshotAction;
 
}
snapshotmanager.h
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef SNAPSHOTMANAGER_H
 
#define SNAPSHOTMANAGER_H
 

	
 
#include <QObject>
 
#include <QAction>
 
#include <QMenu>
 

	
 
#include "framebuffer.h"
 
#include "snapshot.h"
 

	
 
// class MainWindow;
 

	
 
class SnapshotManager : public QObject
 
{
 
    Q_OBJECT
 

	
 
public:
 
    SnapshotManager(QMainWindow* mainWindow, QList<FrameBuffer*>* channelBuffers);
 
    ~SnapshotManager();
 

	
 
    QMenu* menu();
 
    QAction* takeSnapshotAction();
 

	
 
private:
 
    QMainWindow* _mainWindow;
 
    QList<FrameBuffer*>* _channelBuffers;
 

	
 
    QList<SnapShot*> snapshots;
 
    QList<Snapshot*> snapshots;
 

	
 
    QMenu _menu;
 
    QAction _takeSnapshotAction;
 
    QAction loadSnapshotAction;
 
    QAction clearAction;
 

	
 
    void addSnapshot(SnapShot* snapshot, bool update_menu=true);
 
    void addSnapshot(Snapshot* snapshot, bool update_menu=true);
 
    void updateMenu();
 

	
 
private slots:
 
    void takeSnapshot();
 
    void clearSnapshots();
 
    void deleteSnapshot(SnapShot* snapshot);
 
    void deleteSnapshot(Snapshot* snapshot);
 
    void loadSnapshots();
 
    void loadSnapshotFromFile(QString fileName);
 
};
 

	
 
#endif /* SNAPSHOTMANAGER_H */
snapshotview.cpp
Show inline comments
 
#include "snapshotview.h"
 
#include "ui_snapshotview.h"
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <QSaveFile>
 

	
 
SnapShotView::SnapShotView(QWidget *parent, SnapShot* snapShot) :
 
#include "snapshotview.h"
 
#include "ui_snapshotview.h"
 

	
 
SnapshotView::SnapshotView(QWidget *parent, Snapshot* snapshot) :
 
    QMainWindow(parent),
 
    ui(new Ui::SnapShotView),
 
    ui(new Ui::SnapshotView),
 
    renameDialog(this)
 
{
 
    _snapShot = snapShot;
 
    _snapshot = snapshot;
 

	
 
    ui->setupUi(this);
 
    ui->menuSnapshot->insertAction(ui->actionClose, snapShot->deleteAction());
 
    this->setWindowTitle(snapShot->name());
 
    ui->menuSnapshot->insertAction(ui->actionClose, snapshot->deleteAction());
 
    this->setWindowTitle(snapshot->name());
 

	
 
    unsigned numOfChannels = snapShot->data.size();
 
    unsigned numOfChannels = snapshot->data.size();
 

	
 
    for (unsigned ci = 0; ci < numOfChannels; ci++)
 
    {
 
        QwtPlotCurve* curve = new QwtPlotCurve();
 
        curves.append(curve);
 
        curve->setSamples(snapShot->data[ci]);
 
        curve->setSamples(snapshot->data[ci]);
 
        curve->setPen(Plot::makeColor(ci));
 
        curve->attach(ui->plot);
 
    }
 

	
 
    renameDialog.setWindowTitle("Rename Snapshot");
 
    renameDialog.setLabelText("Enter new name:");
 
    connect(ui->actionRename, &QAction::triggered,
 
            this, &SnapShotView::showRenameDialog);
 
            this, &SnapshotView::showRenameDialog);
 

	
 
    connect(ui->actionExport, &QAction::triggered,
 
            this, &SnapShotView::save);
 
            this, &SnapshotView::save);
 

	
 
    for (auto a : ui->plot->menuActions())
 
    {
 
        ui->menuView->addAction(a);
 
    }
 
}
 

	
 
SnapShotView::~SnapShotView()
 
SnapshotView::~SnapshotView()
 
{
 
    for (auto curve : curves)
 
    {
 
        delete curve;
 
    }
 
    delete ui;
 
}
 

	
 
void SnapShotView::closeEvent(QCloseEvent *event)
 
void SnapshotView::closeEvent(QCloseEvent *event)
 
{
 
    QMainWindow::closeEvent(event);
 
    emit closed();
 
}
 

	
 
void SnapShotView::showRenameDialog()
 
void SnapshotView::showRenameDialog()
 
{
 
    renameDialog.setTextValue(_snapShot->name());
 
    renameDialog.setTextValue(_snapshot->name());
 
    renameDialog.open(this, SLOT(renameSnapshot(QString)));
 
}
 

	
 
void SnapShotView::renameSnapshot(QString name)
 
void SnapshotView::renameSnapshot(QString name)
 
{
 
    _snapShot->setName(name);
 
    _snapshot->setName(name);
 
    setWindowTitle(name);
 
}
 

	
 
void SnapShotView::save()
 
void SnapshotView::save()
 
{
 
    QString fileName = QFileDialog::getSaveFileName(this, tr("Export CSV File"));
 

	
 
    if (fileName.isNull()) return; // user canceled
 

	
 
    // TODO: remove code duplication (MainWindow::onExportCsv)
 
    QSaveFile file(fileName);
 

	
 
    if (file.open(QIODevice::WriteOnly | QIODevice::Text))
 
    {
 
        QTextStream fileStream(&file);
 

	
 
        unsigned numOfChannels = _snapShot->data.size();
 
        unsigned numOfSamples = _snapShot->data[0].size();
 
        unsigned numOfChannels = _snapshot->data.size();
 
        unsigned numOfSamples = _snapshot->data[0].size();
 

	
 
        // print header
 
        for (unsigned int ci = 0; ci < numOfChannels; ci++)
 
        {
 
            fileStream << "Channel " << ci;
 
            if (ci != numOfChannels-1) fileStream << ",";
 
        }
 
        fileStream << '\n';
 

	
 
        // print rows
 
        for (unsigned int i = 0; i < numOfSamples; i++)
 
        {
 
            for (unsigned int ci = 0; ci < numOfChannels; ci++)
 
            {
 
                fileStream << _snapShot->data[ci][i].y();
 
                fileStream << _snapshot->data[ci][i].y();
 
                if (ci != numOfChannels-1) fileStream << ",";
 
            }
 
            fileStream << '\n';
 
        }
 

	
 
        if (!file.commit())
 
        {
 
            qCritical() << "File save error during snapshot save: " << file.error();
 
        }
 
    }
 
    else
 
    {
 
        qCritical() << "File open error during snapshot save: " << file.error();
 
    }
 
}
snapshotview.h
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef SNAPSHOTVIEW_H
 
#define SNAPSHOTVIEW_H
 

	
 
#include <QMainWindow>
 
#include <QInputDialog>
 
#include <QFileDialog>
 
#include <QVector>
 
#include <QPointF>
 
#include <QPen>
 
#include <QCloseEvent>
 
#include <qwt_plot_curve.h>
 

	
 
#include "plot.h"
 
#include "snapshot.h"
 

	
 
namespace Ui {
 
class SnapShotView;
 
class SnapshotView;
 
}
 

	
 
class SnapShotView : public QMainWindow
 
class SnapshotView : public QMainWindow
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit SnapShotView(QWidget *parent, SnapShot* snapShot);
 
    ~SnapShotView();
 
    explicit SnapshotView(QWidget *parent, Snapshot* snapshot);
 
    ~SnapshotView();
 

	
 
signals:
 
    void closed();
 

	
 
private:
 
    Ui::SnapShotView *ui;
 
    Ui::SnapshotView *ui;
 
    QList<QwtPlotCurve*> curves;
 
    SnapShot* _snapShot;
 
    Snapshot* _snapshot;
 
    QInputDialog renameDialog;
 

	
 
    void closeEvent(QCloseEvent *event);
 

	
 
private slots:
 
    void showRenameDialog();
 
    void renameSnapshot(QString name);
 
    void save();
 
};
 

	
 
#endif // SNAPSHOTVIEW_H
snapshotview.ui
Show inline comments
 
<?xml version="1.0" encoding="UTF-8"?>
 
<ui version="4.0">
 
 <class>SnapShotView</class>
 
 <widget class="QMainWindow" name="SnapShotView">
 
 <class>SnapshotView</class>
 
 <widget class="QMainWindow" name="SnapshotView">
 
  <property name="geometry">
 
   <rect>
 
    <x>0</x>
 
    <y>0</y>
 
    <width>544</width>
 
    <height>449</height>
 
   </rect>
 
  </property>
 
  <property name="windowTitle">
 
   <string>MainWindow</string>
 
  </property>
 
  <widget class="QWidget" name="centralwidget">
 
   <layout class="QVBoxLayout" name="verticalLayout">
 
    <item>
 
     <widget class="Plot" name="plot" native="true"/>
 
    </item>
 
   </layout>
 
  </widget>
 
  <widget class="QMenuBar" name="menubar">
 
   <property name="geometry">
 
    <rect>
 
     <x>0</x>
 
     <y>0</y>
 
     <width>544</width>
 
@@ -65,39 +65,39 @@
 
   <property name="text">
 
    <string>Close</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Close Window</string>
 
   </property>
 
   <property name="shortcut">
 
    <string>Ctrl+W</string>
 
   </property>
 
  </action>
 
 </widget>
 
 <customwidgets>
 
  <customwidget>
 
   <class>Plot</class>
 
   <extends>QWidget</extends>
 
   <header>plot.h</header>
 
   <container>1</container>
 
  </customwidget>
 
 </customwidgets>
 
 <resources/>
 
 <connections>
 
  <connection>
 
   <sender>actionClose</sender>
 
   <signal>triggered()</signal>
 
   <receiver>SnapShotView</receiver>
 
   <receiver>SnapshotView</receiver>
 
   <slot>close()</slot>
 
   <hints>
 
    <hint type="sourcelabel">
 
     <x>-1</x>
 
     <y>-1</y>
 
    </hint>
 
    <hint type="destinationlabel">
 
     <x>271</x>
 
     <y>224</y>
 
    </hint>
 
   </hints>
 
  </connection>
 
 </connections>
 
</ui>
0 comments (0 inline, 0 general)