##// END OF EJS Templates
Separate the initialization of the properties of the graph of the update of the units of the graph....
Separate the initialization of the properties of the graph of the update of the units of the graph. The initialization of the properties is carried out when adding a variable in the graph, the update of the units is carried out when loading the data of this variable

File last commit:

r1190:767abfa514f1
r1254:41b7c6aab8be
Show More
SqpRange.h
66 lines | 1.9 KiB | text/x-c | CLexer
#ifndef SCIQLOP_SQPRANGE_H
#define SCIQLOP_SQPRANGE_H
#include <QObject>
#include <QDebug>
#include <Common/DateUtils.h>
#include <Common/MetaTypes.h>
#include <cmath>
/**
* @brief The SqpRange struct holds the information of time parameters
*/
struct SqpRange {
/// Creates SqpRange from dates and times
static SqpRange fromDateTime(const QDate &startDate, const QTime &startTime,
const QDate &endDate, const QTime &endTime)
{
return {DateUtils::secondsSinceEpoch(QDateTime{startDate, startTime, Qt::UTC}),
DateUtils::secondsSinceEpoch(QDateTime{endDate, endTime, Qt::UTC})};
}
/// Start time (UTC)
double m_TStart;
/// End time (UTC)
double m_TEnd;
bool contains(const SqpRange &dateTime) const noexcept
{
return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd);
}
bool intersect(const SqpRange &dateTime) const noexcept
{
return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd);
}
bool operator==(const SqpRange &other) const
{
auto equals = [](const auto &v1, const auto &v2) {
return (std::isnan(v1) && std::isnan(v2)) || v1 == v2;
};
return equals(m_TStart, other.m_TStart) && equals(m_TEnd, other.m_TEnd);
}
bool operator!=(const SqpRange &other) const { return !(*this == other); }
};
const auto INVALID_RANGE
= SqpRange{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
inline QDebug operator<<(QDebug d, SqpRange obj)
{
auto tendDateTimeStart = DateUtils::dateTime(obj.m_TStart);
auto tendDateTimeEnd = DateUtils::dateTime(obj.m_TEnd);
d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd;
return d;
}
// Required for using shared_ptr in signals/slots
SCIQLOP_REGISTER_META_TYPE(SQPRANGE_REGISTRY, SqpRange)
#endif // SCIQLOP_SQPRANGE_H