forked from graeme-hattan/qwt-example
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwindow.h
70 lines (49 loc) · 1.4 KB
/
window.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
#ifndef WINDOW_H
#define WINDOW_H
#include <qwt/qwt_thermo.h>
#include <qwt/qwt_plot.h>
#include <qwt/qwt_plot_curve.h>
#include <QBoxLayout>
#include <QPushButton>
#include <mutex>
#include "CppTimer.h"
// class definition 'Window'
class Window : public QWidget
{
// must include the Q_OBJECT macro for for the Qt signals/slots framework to work with this class
Q_OBJECT
class FakeSensor : public CppTimer {
static constexpr double gain = 7.5;
public:
Window* window = nullptr;
int count = 0;
void timerEvent() {
double inVal = gain * sin( M_PI * count / 50.0 );
window->hasData(inVal);
++count;
}
};
public:
Window(); // default constructor - called when a Window is declared without arguments
~Window();
void timerEvent( QTimerEvent * );
// internal variables for the window class
private:
static constexpr int plotDataSize = 100;
QPushButton *button;
QwtThermo *thermo;
QwtPlot *plot;
QwtPlotCurve *curve;
// layout elements from Qt itself http://qt-project.org/doc/qt-4.8/classes.html
QVBoxLayout *vLayout; // vertical layout
QHBoxLayout *hLayout; // horizontal layout
FakeSensor fakeSensor;
// data arrays for the plot
double xData[plotDataSize];
double yData[plotDataSize];
long count = 0;
void reset();
void hasData(double v);
std::mutex mtx;
};
#endif // WINDOW_H