23 [](
auto const& c0,
auto const& c1)
24 { return c0.first < c1.first; });
29 return std::numeric_limits<float>::max();
34 float max = std::numeric_limits<float>::lowest();
35 std::size_t nCoords =
_coords.size();
36 for (std::size_t i = 0; i < nCoords; i++)
48 float min = std::numeric_limits<float>::max();
49 std::size_t nCoords =
_coords.size();
50 for (std::size_t i = 0; i < nCoords; i++)
62 float max = std::numeric_limits<float>::lowest();
63 std::size_t nCoords =
_coords.size();
64 for (std::size_t i = 0; i < nCoords; i++)
79 QPainterPath pp(QPointF(p.x() * scaleX, p.y() * scaleY));
82 std::size_t nCoords =
_coords.size();
83 for (std::size_t i = 1; i < nCoords; i++)
86 path.lineTo(QPointF(p.x() * scaleX, p.y() * scaleY));
149 QTextStream in(&file);
151 if (!file.open(QIODevice::ReadOnly))
153 qDebug(
"Could not open file...");
157 QString line = in.readLine();
158 QStringList fields = line.split(
'\t');
159 int nLists(fields.size() - 1);
161 if (fields.size() >= 2)
164 for (
int i = 0; i < nLists; i++)
167 l->setName(fields.takeFirst());
175 bool first_loop(
true);
177 QDateTime currentDate;
178 unsigned line_count(1);
182 line = in.readLine();
184 fields = line.split(
'\t');
185 if (fields.size() >= (nLists + 1))
187 QString
const stringDate = fields.takeFirst();
191 startDate = currentDate;
192 for (
int i = 0; i < nLists; i++)
194 lists[i]->setStartDate(startDate);
199 auto const numberOfSecs =
200 static_cast<float>(startDate.secsTo(currentDate));
201 for (
int i = 0; i < nLists; i++)
203 float const value =
static_cast<float>(
205 ",",
".", fields.takeFirst().toStdString())
208 lists[i]->addNextPoint(numberOfSecs, value);
213 WARN(
"DiagramList::readList(): Unexpected format in line {:d}.",
222 qDebug(
"Unexpected file format...");
229 for (
int i = 0; i < nLists; i++)
238 std::vector<DiagramList*>& lists)
240 std::vector<SensorDataType>
const& time_series_names(
242 int nLists(time_series_names.size());
244 std::vector<std::size_t> time_steps;
250 for (std::size_t i = start; i <= end; i += stepsize)
252 time_steps.push_back(i);
267 std::size_t nValues(time_steps.size());
269 for (
int i = 0; i < nLists; i++)
271 auto const* time_series = data->
getTimeSeries(time_series_names[i]);
278 l->setName(QString::fromStdString(
280 l->setXLabel(
"Time");
286 QDateTime
const startDate(
288 lists[i]->setStartDate(startDate);
289 for (std::size_t j = 0; j < nValues; j++)
291 QDateTime
const currentDate(
294 static_cast<float>(startDate.secsTo(currentDate));
295 lists[i]->addNextPoint(numberOfSecs, (*time_series)[j]);
300 l->setXUnit(
"time step");
301 for (std::size_t j = 0; j < nValues; j++)
303 lists[i]->addNextPoint(
static_cast<float>(time_steps[j]),
316 auto start_secs =
static_cast<float>(
_startDate.secsTo(start));
321 auto end_secs =
static_cast<float>(
_startDate.secsTo(end));
322 if (end_secs < start_secs)
324 end_secs =
_coords.back().first;
327 if (start_secs == 0 && end_secs ==
_coords.back().first)
334 [&](std::pair<float, float>
const& c)
335 { return (c.first < start_secs || c.first > end_secs); }),
340 c.first -= start_secs;
346 std::vector<std::pair<QDateTime, float>>
const& coords)
354 std::transform(coords.begin(), coords.end(), std::back_inserter(
_coords),
355 [
this](
auto const& p)
357 return std::make_pair(
358 static_cast<float>(_startDate.daysTo(p.first)),
373 std::copy(coords.begin(), coords.end(), std::back_inserter(
_coords));
QDateTime getDateTime(QString const &stringDate)
Converts string into QDateTime-format.
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
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)