OGS
DiagramList.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <QColor>
7#include <QDateTime>
8#include <QPainterPath>
9#include <QPoint>
10#include <vector>
11
12class SensorData;
13
18{
19public:
23
25 QColor getColor() const { return _colour; }
26
28 float height() const { return _maxY - _minY; }
29
31 float minXValue() const { return _minX; }
32
34 float maxXValue() const { return _maxX; }
35
37 float minYValue() const { return _minY; }
38
40 float maxYValue() const { return _maxY; }
41
43 const QDateTime getStartDate() const { return _startDate; }
44
46 QString getName() const { return _name; }
47
56 bool getPath(QPainterPath &path, float scaleX, float scaleY);
57
64 bool getPoint(QPointF &p, std::size_t i);
65
67 QString getXLabel() const { return _xLabel; }
68
70 QString getYLabel() const { return _yLabel; }
71
73 QString getXUnit() const { return _xUnit; }
74
76 QString getYUnit() const { return _yUnit; }
77
87 static int readList(const QString &path, std::vector<DiagramList*> &list);
88
89 static int readList(const SensorData* data, std::vector<DiagramList*> &list);
90
92 void setColor(QColor c) { _colour = c; }
93
95 void setName(QString name) { _name = name; }
96
98 void addNextPoint(float x, float y) { _coords.emplace_back(x, y); }
99
101 void truncateToRange(QDateTime const& start, QDateTime const& end);
102
104 void setStartDate(QDateTime date) { _startDate = date; }
105
107 void setXLabel(QString label) { _xLabel = label; }
108
110 void setYLabel(QString label) { _yLabel = label; }
111
116 void setList(std::vector<std::pair<float, float>> const& coords);
117
124 void setList(std::vector<std::pair<QDateTime, float>> const& coords);
125
127 void setXUnit(QString unit) { _xUnit = unit; }
128
130 void setYUnit(QString unit) { _yUnit = unit; }
131
133 std::size_t size() const;
134
136 double width() const { return _maxX - _minX; }
137
138private:
140 float calcMinXValue();
141
143 float calcMaxXValue();
144
146 float calcMinYValue();
147
149 float calcMaxYValue();
150
158 int readLine(std::ifstream inFile, QDateTime &cDate, float &cValue);
159
161 void update();
162
163 float _maxX{0};
164 float _maxY{0};
165 float _minX{0};
166 float _minY{0};
167 std::vector< std::pair<float, float> > _coords;
168 QString _name;
169 QString _xLabel;
170 QString _yLabel;
171 QString _xUnit;
172 QString _yUnit;
173 QColor _colour;
174 QDateTime _startDate;
175};
void update()
Updates the bounds of the data points contained in the list.
float minYValue() const
Returns the minimum y-value.
Definition DiagramList.h:37
float maxXValue() const
Returns the maximum x-value.
Definition DiagramList.h:34
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:76
bool getPoint(QPointF &p, std::size_t i)
const QDateTime getStartDate() const
Returns the start date of this list.
Definition DiagramList.h:43
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:67
DiagramList()
Constructor containing an empty list.
float maxYValue() const
Returns the maximum y-value.
Definition DiagramList.h:40
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:73
QString getName() const
Returns the name of the diagram.
Definition DiagramList.h:46
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:28
float minXValue() const
Returns the minimum x-value.
Definition DiagramList.h:31
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:25
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.
Definition DiagramList.h:98
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.
Definition DiagramList.h:95
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.
Definition DiagramList.h:92
QString getYLabel() const
Returns the label associated with the y-axis.
Definition DiagramList.h:70
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:52