OGS
DiagramList.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <QColor>
18#include <QDateTime>
19#include <QPainterPath>
20#include <QPoint>
21#include <vector>
22
23class SensorData;
24
29{
30public:
34
36 QColor getColor() const { return _colour; }
37
39 float height() const { return _maxY - _minY; }
40
42 float minXValue() const { return _minX; }
43
45 float maxXValue() const { return _maxX; }
46
48 float minYValue() const { return _minY; }
49
51 float maxYValue() const { return _maxY; }
52
54 const QDateTime getStartDate() const { return _startDate; }
55
57 QString getName() const { return _name; }
58
67 bool getPath(QPainterPath &path, float scaleX, float scaleY);
68
75 bool getPoint(QPointF &p, std::size_t i);
76
78 QString getXLabel() const { return _xLabel; }
79
81 QString getYLabel() const { return _yLabel; }
82
84 QString getXUnit() const { return _xUnit; }
85
87 QString getYUnit() const { return _yUnit; }
88
98 static int readList(const QString &path, std::vector<DiagramList*> &list);
99
100 static int readList(const SensorData* data, std::vector<DiagramList*> &list);
101
103 void setColor(QColor c) { _colour = c; }
104
106 void setName(QString name) { _name = name; }
107
109 void addNextPoint(float x, float y) { _coords.emplace_back(x, y); }
110
112 void truncateToRange(QDateTime const& start, QDateTime const& end);
113
115 void setStartDate(QDateTime date) { _startDate = date; }
116
118 void setXLabel(QString label) { _xLabel = label; }
119
121 void setYLabel(QString label) { _yLabel = label; }
122
127 void setList(std::vector<std::pair<float, float>> const& coords);
128
135 void setList(std::vector<std::pair<QDateTime, float>> const& coords);
136
138 void setXUnit(QString unit) { _xUnit = unit; }
139
141 void setYUnit(QString unit) { _yUnit = unit; }
142
144 std::size_t size() const;
145
147 double width() const { return _maxX - _minX; }
148
149private:
151 float calcMinXValue();
152
154 float calcMaxXValue();
155
157 float calcMinYValue();
158
160 float calcMaxYValue();
161
169 int readLine(std::ifstream inFile, QDateTime &cDate, float &cValue);
170
172 void update();
173
174 float _maxX{0};
175 float _maxY{0};
176 float _minX{0};
177 float _minY{0};
178 std::vector< std::pair<float, float> > _coords;
179 QString _name;
180 QString _xLabel;
181 QString _yLabel;
182 QString _xUnit;
183 QString _yUnit;
184 QColor _colour;
185 QDateTime _startDate;
186};
A List of data points and all the necessary meta-information to draw a graph.
Definition DiagramList.h:29
void update()
Updates the bounds of the data points contained in the list.
float minYValue() const
Returns the minimum y-value.
Definition DiagramList.h:48
float maxXValue() const
Returns the maximum x-value.
Definition DiagramList.h:45
QColor _colour
void setXLabel(QString label)
Specifies the meaning of the x Axis.
QString getYUnit() const
Returns the unit associated with the y-axis.
Definition DiagramList.h:87
bool getPoint(QPointF &p, std::size_t i)
const QDateTime getStartDate() const
Returns the start date of this list.
Definition DiagramList.h:54
void setYUnit(QString unit)
Specifies the unit of the y Axis.
std::size_t size() const
Returns the number of data points.
void truncateToRange(QDateTime const &start, QDateTime const &end)
cut list entries not within the given range
QString _yLabel
QString getXLabel() const
Returns the label associated with the x-axis.
Definition DiagramList.h:78
DiagramList()
Constructor containing an empty list.
float maxYValue() const
Returns the maximum y-value.
Definition DiagramList.h:51
QDateTime _startDate
float calcMinXValue()
Returns the minimum x-value of all the data points.
QString getXUnit() const
Returns the unit associated with the x-axis.
Definition DiagramList.h:84
QString getName() const
Returns the name of the diagram.
Definition DiagramList.h:57
static int readList(const QString &path, std::vector< DiagramList * > &list)
QString _name
float height() const
Returns the height of the bounding box of all data points within the list.
Definition DiagramList.h:39
float minXValue() const
Returns the minimum x-value.
Definition DiagramList.h:42
float calcMaxXValue()
Returns the maximum x-value of all the data points.
float calcMinYValue()
Returns the minimum y-value of all the data points.
QColor getColor() const
Returns the colour of the graph.
Definition DiagramList.h:36
float calcMaxYValue()
Returns the maximum y-value of all the data points.
double width() const
Returns the width of the bounding box of all data points within the list.
std::vector< std::pair< float, float > > _coords
void addNextPoint(float x, float y)
Adds a point at (x,y) to the list.
void setStartDate(QDateTime date)
Sets the start date (i.e. the min-value of the x-axis).
int readLine(std::ifstream inFile, QDateTime &cDate, float &cValue)
QString _yUnit
QString _xLabel
void setName(QString name)
Sets the name of the graph to be displayed in the caption.
void setList(std::vector< std::pair< float, float > > const &coords)
void setXUnit(QString unit)
Specifies the unit of the x Axis.
void setColor(QColor c)
Sets the colour of the graph.
QString getYLabel() const
Returns the label associated with the y-axis.
Definition DiagramList.h:81
bool getPath(QPainterPath &path, float scaleX, float scaleY)
void setYLabel(QString label)
Specifies the meaning of the y Axis.
QString _xUnit
A container for sensor data at an observation site. The class stores a number of time series and has ...
Definition SensorData.h:63