Changeset - 77513ca7b1d4
[Not reviewed]
snapshots
0 3 2
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-09-20 07:53:03
hy@ozderya.net
made SnapShot a class, clicking its action opens snapshot view
5 files changed with 72 insertions and 14 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -71,6 +71,7 @@ add_executable(${PROGRAM_NAME} WIN32
 
  scalepicker.cpp
 
  scalezoomer.cpp
 
  portlist.cpp
 
  snapshot.cpp
 
  snapshotview.cpp
 
  ${UI_FILES}
 
  ${RES_FILES}
mainwindow.cpp
Show inline comments
 
@@ -730,8 +730,7 @@ void MainWindow::messageHandler(QtMsgTyp
 
void MainWindow::takeSnapShot()
 
{
 
    qDebug() << "taking a snopshot yay!";
 
    auto snapShot = new SnapShot();
 
    snapShot->name = QString("SnapShot");
 
    auto snapShot = new SnapShot(this, "New Snapshot");
 

	
 
    for (unsigned ci = 0; ci < numOfChannels; ci++)
 
    {
 
@@ -744,9 +743,6 @@ void MainWindow::takeSnapShot()
 
    snapshots.append(snapShot);
 

	
 
    updateSnapShotMenu();
 

	
 
    auto sv = new SnapShotView(this, snapShot);
 
    sv->show();
 
}
 

	
 
void MainWindow::updateSnapShotMenu()
 
@@ -758,7 +754,7 @@ void MainWindow::updateSnapShotMenu()
 
        ui->menuSnapShots->addSeparator();
 
        for (auto ss : snapshots)
 
        {
 
            ui->menuSnapShots->addAction(ss->name);
 
            ui->menuSnapShots->addAction(ss->menuAction());
 
        }
 
        ui->menuSnapShots->addSeparator();
 
        ui->menuSnapShots->addAction(ui->actionClearSnapShots);
snapshot.cpp
Show inline comments
 
new file 100644
 

	
 
#include <stddef.h>
 

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

	
 
#include <QtDebug>
 

	
 
SnapShot::SnapShot(QMainWindow* parent, QString name) :
 
    QObject(parent),
 
    _menuAction(name, this)
 
{
 
    view = NULL;
 
    mainWindow = parent;
 
    connect(&_menuAction, &QAction::triggered, this, &SnapShot::show);
 
}
 

	
 
QAction* SnapShot::menuAction()
 
{
 
    return &_menuAction;
 
}
 

	
 
void SnapShot::show()
 
{
 
    if (view == NULL)
 
    {
 
        qDebug() << "view == NULL";
 
        view = new SnapShotView(mainWindow, this);
 
    }
 
    view->show();
 
}
 

	
 
void SnapShot::hide()
 
{
 

	
 
}
snapshot.h
Show inline comments
 
new file 100644
 
#ifndef SNAPSHOT_H
 
#define SNAPSHOT_H
 

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

	
 
class SnapShotView;
 

	
 
class SnapShot : public QObject
 
{
 
    Q_OBJECT
 

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

	
 
    // QString _name;
 
    QVector<QVector<QPointF>> data;
 
    QAction* menuAction();
 

	
 
public slots:
 
    void show();
 
    void hide();
 

	
 
private:
 
    QAction _menuAction;
 
    QMainWindow* mainWindow;
 
    SnapShotView* view;
 
};
 

	
 
#endif /* SNAPSHOT_H */
snapshotview.h
Show inline comments
 
@@ -7,14 +7,7 @@
 
#include <QPen>
 
#include <qwt_plot_curve.h>
 
#include "plot.h"
 

	
 
class SnapShotView;
 
struct SnapShot
 
{
 
    QString name;
 
    QVector<QVector<QPointF>> data;
 
    SnapShotView* view;
 
};
 
#include "snapshot.h"
 

	
 
namespace Ui {
 
class SnapShotView;
0 comments (0 inline, 0 general)