-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream.h
126 lines (95 loc) · 3.22 KB
/
stream.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
123
124
125
126
#ifndef STREAM_H
#define STREAM_H
#include "axis.h"
#include "cache.h"
#include <QByteArray>
#include <QColor>
#include <QList>
#include <QObject>
#include <QSharedPointer>
#include <QString>
#include <QUuid>
struct color
{
float red;
float green;
float blue;
};
#define COLOR_TO_ARRAY(color) (&(color).red)
struct drawable
{
QList<QSharedPointer<CacheEntry>> data;
int64_t timeOffset;
float ymin;
float ymax;
struct color color;
bool dataDensity;
bool selected;
bool alwaysConnect;
};
/* Both Stream and Axis need declarations of each other. */
class YAxis;
class PlotArea;
class Stream : public QObject
{
Q_OBJECT
Q_PROPERTY(bool dataDensity MEMBER dataDensity)
Q_PROPERTY(bool selected READ getSelected WRITE setSelected NOTIFY selectedChanged)
Q_PROPERTY(bool alwaysConnect READ getAlwaysConnect WRITE setAlwaysConnect NOTIFY alwaysConnectChanged)
Q_PROPERTY(QColor color READ getColor WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(QList<qreal> timeOffset READ getTimeOffset WRITE setTimeOffset NOTIFY timeOffsetChanged)
Q_PROPERTY(DataSource* dataSource READ getDataSource WRITE setDataSource NOTIFY dataSourceChanged)
Q_PROPERTY(QString uuid READ getUUID WRITE setUUID NOTIFY uuidChanged)
public:
Stream(QObject* parent = nullptr);
Stream(const QString& u, DataSource* dataSource, QObject* parent = nullptr);
Stream(const QUuid& u, DataSource* dataSource, QObject* parent = nullptr);
bool toDrawable(struct drawable& d) const;
bool getSelected() const;
void setSelected(bool isSelected);
bool getAlwaysConnect() const;
void setAlwaysConnect(bool shouldAlwaysConnect);
Q_INVOKABLE bool setColor(float red, float green, float blue);
Q_INVOKABLE bool setColor(QColor color);
Q_INVOKABLE QColor getColor();
void setTimeOffset(int64_t offset);
Q_INVOKABLE void setTimeOffset(QList<qreal> offset);
Q_INVOKABLE QList<qreal> getTimeOffset();
Q_INVOKABLE void setDataSource(DataSource* source);
Q_INVOKABLE DataSource* getDataSource();
Q_INVOKABLE void setUUID(QString uuidstr);
Q_INVOKABLE QString getUUID();
QUuid uuid;
/* The currently visible cache entries. */
QList<QSharedPointer<CacheEntry>> data;
/* The axis to which this stream is assigned. */
YAxis* axis;
/* The Plot Area on which this stream is rendered. */
PlotArea* plotarea;
/* The time offset at which this stream should be drawn. */
int64_t timeOffset;
/* The color that this stream should have. */
struct color color;
/* True if this stream, when rendered, should plot the data density
* rather than the values.
*/
bool dataDensity;
/* True if this stream should be rendered as if it is selected. */
bool selected;
/* True if the points of this stream should always be joined. */
bool alwaysConnect;
signals:
void selectedChanged();
void colorChanged();
void timeOffsetChanged();
void dataSourceChanged();
void uuidChanged();
void alwaysConnectChanged();
private:
void init();
/* The source to query to get data for this stream. */
DataSource* source;
/* True if the source has been set. */
bool sourceset;
};
#endif // STREAM_H