forked from CWRUChielLab/GDAQRec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotter.h
122 lines (103 loc) · 2.92 KB
/
plotter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef PLOTTER_H
#define PLOTTER_H
#include <QMap>
#include <QPixmap>
#include <QVector>
#include <QWidget>
#include <QTimer>
#include <QMutex>
#include <QDateTime>
#include <QFile>
#include "DAQReader.h"
#include "QuadFilter.h"
class QToolButton;
class PlotSettings;
class Plotter : public QWidget
{
Q_OBJECT
public:
Plotter(QWidget *parent = 0);
QSize minimumSizeHint() const;
QSize sizeHint() const;
public slots:
void zoomIn();
void zoomOut();
void toggleRecording();
void newData();
void daqError(const QString& errorMessage);
void startedRecording();
void stoppedRecording();
void newDocument();
void open();
void save();
void settings();
void filtering();
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
void wheelEvent(QWheelEvent *event);
void closeEvent(QCloseEvent* event);
private:
bool offerToSave();
void clearPlot();
void updateRubberBandRegion();
void updateFilteredData();
void refreshPixmap();
void drawGrid(QPainter *painter);
void drawCurves(QPainter *painter);
void updateSettings();
enum { Margin = 50 };
DAQSettings daqSettings;
double fileSamplingRate;
QToolButton *newButton;
QToolButton *openButton;
QToolButton *saveButton;
QToolButton *settingsButton;
QToolButton *filteringButton;
QToolButton *recordButton;
QToolButton *zoomInButton;
QToolButton *zoomOutButton;
typedef QMap<int, QVector<QPointF> > CurveMap;
CurveMap curveMap;
typedef QMap<int, QVector<QuadFilter> > FilterMap;
FilterMap filterMap;
CurveMap filteredCurveMap;
QVector<PlotSettings> zoomStack;
int curZoom;
bool rubberBandIsShown;
QRect rubberBandRect;
QPixmap pixmap; // offscreen rendering buffer
bool saved;
QDateTime startTime;
DAQReader daqReader;
QString filename;
double traceOffset;
QFile sharedTimestamp;
uchar* sharedTimestampMemMap;
#ifdef Q_WS_MAC
bool recording;
#endif
};
class PlotSettings
{
public:
PlotSettings();
void scroll(double dx, double dy);
void adjust();
double spanX() const { return maxX - minX; }
double spanY() const { return maxY - minY; }
double minX;
double maxX;
int numXTicks;
double minY;
double maxY;
int numYTicks;
bool includesRightEdge;
private:
static void adjustAxis(double &min, double &max, int &numTicks);
};
#endif