34 [](
auto const& c0,
auto const& c1)
35 { return c0.first < c1.first; });
40 return std::numeric_limits<float>::max();
45 float max = std::numeric_limits<float>::lowest();
46 std::size_t nCoords =
_coords.size();
47 for (std::size_t i = 0; i < nCoords; i++)
59 float min = std::numeric_limits<float>::max();
60 std::size_t nCoords =
_coords.size();
61 for (std::size_t i = 0; i < nCoords; i++)
73 float max = std::numeric_limits<float>::lowest();
74 std::size_t nCoords =
_coords.size();
75 for (std::size_t i = 0; i < nCoords; i++)
90 QPainterPath pp(QPointF(p.x() * scaleX, p.y() * scaleY));
93 std::size_t nCoords =
_coords.size();
94 for (std::size_t i = 1; i < nCoords; i++)
97 path.lineTo(QPointF(p.x() * scaleX, p.y() * scaleY));
160 QTextStream in(&file);
162 if (!file.open(QIODevice::ReadOnly))
164 qDebug(
"Could not open file...");
168 QString line = in.readLine();
169 QStringList fields = line.split(
'\t');
170 int nLists(fields.size() - 1);
172 if (fields.size() >= 2)
175 for (
int i = 0; i < nLists; i++)
178 l->setName(fields.takeFirst());
186 bool first_loop(
true);
188 QDateTime currentDate;
189 unsigned line_count(1);
193 line = in.readLine();
195 fields = line.split(
'\t');
196 if (fields.size() >= (nLists + 1))
198 QString
const stringDate = fields.takeFirst();
202 startDate = currentDate;
203 for (
int i = 0; i < nLists; i++)
205 lists[i]->setStartDate(startDate);
210 auto const numberOfSecs =
211 static_cast<float>(startDate.secsTo(currentDate));
212 for (
int i = 0; i < nLists; i++)
214 float const value =
static_cast<float>(
216 ",",
".", fields.takeFirst().toStdString())
219 lists[i]->addNextPoint(numberOfSecs, value);
224 WARN(
"DiagramList::readList(): Unexpected format in line {:d}.",
233 qDebug(
"Unexpected file format...");
240 for (
int i = 0; i < nLists; i++)
249 std::vector<DiagramList*>& lists)
251 std::vector<SensorDataType>
const& time_series_names(
253 int nLists(time_series_names.size());
255 std::vector<std::size_t> time_steps;
261 for (std::size_t i = start; i <= end; i += stepsize)
263 time_steps.push_back(i);
278 std::size_t nValues(time_steps.size());
280 for (
int i = 0; i < nLists; i++)
282 auto const* time_series = data->
getTimeSeries(time_series_names[i]);
289 l->setName(QString::fromStdString(
291 l->setXLabel(
"Time");
297 QDateTime
const startDate(
299 lists[i]->setStartDate(startDate);
300 for (std::size_t j = 0; j < nValues; j++)
302 QDateTime
const currentDate(
305 static_cast<float>(startDate.secsTo(currentDate));
306 lists[i]->addNextPoint(numberOfSecs, (*time_series)[j]);
311 l->setXUnit(
"time step");
312 for (std::size_t j = 0; j < nValues; j++)
314 lists[i]->addNextPoint(
static_cast<float>(time_steps[j]),
327 auto start_secs =
static_cast<float>(
_startDate.secsTo(start));
332 auto end_secs =
static_cast<float>(
_startDate.secsTo(end));
333 if (end_secs < start_secs)
335 end_secs =
_coords.back().first;
338 if (start_secs == 0 && end_secs ==
_coords.back().first)
345 [&](std::pair<float, float>
const& c)
346 { return (c.first < start_secs || c.first > end_secs); }),
351 c.first -= start_secs;
357 std::vector<std::pair<QDateTime, float>>
const& coords)
365 std::transform(coords.begin(), coords.end(), std::back_inserter(
_coords),
366 [
this](
auto const& p)
368 return std::make_pair(
369 static_cast<float>(_startDate.daysTo(p.first)),
384 std::copy(coords.begin(), coords.end(), std::back_inserter(
_coords));
Definition of the DiagramList class.
QDateTime getDateTime(QString const &stringDate)
Converts string into QDateTime-format.
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the SensorData class.
void update()
Updates the bounds of the data points contained in the list.
bool getPoint(QPointF &p, std::size_t i)
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
DiagramList()
Constructor containing an empty list.
float calcMinXValue()
Returns the minimum x-value of all the data points.
static int readList(const QString &path, std::vector< DiagramList * > &list)
float calcMaxXValue()
Returns the maximum x-value of all the data points.
float calcMinYValue()
Returns the minimum y-value of all the data points.
float calcMaxYValue()
Returns the maximum y-value of all the data points.
std::vector< std::pair< float, float > > _coords
void setList(std::vector< std::pair< float, float > > const &coords)
bool getPath(QPainterPath &path, float scaleX, float scaleY)
A container for sensor data at an observation site. The class stores a number of time series and has ...
std::size_t getEndTime() const
Returns the last time step.
const std::vector< float > * getTimeSeries(SensorDataType time_series_name) const
Returns the time series with the given name.
const std::vector< std::size_t > & getTimeSteps() const
Returns the time step vector (if it exists)
std::size_t getStartTime() const
Returns the first time step.
const std::vector< SensorDataType > & getTimeSeriesNames() const
Returns all time series names contained in this container.
std::size_t getStepSize() const
static std::string convertSensorDataType2String(SensorDataType t)
Converts Sensor Data Types to Strings.
std::string replaceString(const std::string &searchString, const std::string &replaceString, std::string stringToReplace)
std::string int2date(int date)