##// END OF EJS Templates
A variable is now created with its dateTime too....
perrinel -
r228:8e4faeed90b4
parent child
Show More
@@ -9,6 +9,11 struct SqpDateTime {
9 9 double m_TStart;
10 10 /// End time
11 11 double m_TEnd;
12
13 bool contains(const SqpDateTime &dateTime)
14 {
15 return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd);
16 }
12 17 };
13 18
14 19 #endif // SCIQLOP_SQPDATETIME_H
@@ -19,7 +19,8 class QString;
19 19 */
20 20 class Variable {
21 21 public:
22 explicit Variable(const QString &name, const QString &unit, const QString &mission);
22 explicit Variable(const QString &name, const QString &unit, const QString &mission,
23 const SqpDateTime &dateTime);
23 24
24 25 QString name() const noexcept;
25 26 QString mission() const noexcept;
@@ -1,11 +1,14
1 1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 2 #define SCIQLOP_VARIABLEMODEL_H
3 3
4 #include <Common/spimpl.h>
4
5 #include <Data/SqpDateTime.h>
5 6
6 7 #include <QAbstractTableModel>
7 8 #include <QLoggingCategory>
8 9
10 #include <Common/spimpl.h>
11
9 12 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
10 13
11 14 class IDataSeries;
@@ -21,11 +24,13 public:
21 24 /**
22 25 * Creates a new variable in the model
23 26 * @param name the name of the new variable
27 * @param dateTime the dateTime of the new variable
24 28 * @param defaultDataSeries the default data of the new variable
25 29 * @return the pointer to the new variable
26 30 */
27 31 std::shared_ptr<Variable>
28 createVariable(const QString &name, std::unique_ptr<IDataSeries> defaultDataSeries) noexcept;
32 createVariable(const QString &name, const SqpDateTime &dateTime,
33 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept;
29 34
30 35 // /////////////////////////// //
31 36 // QAbstractTableModel methods //
@@ -6,8 +6,13
6 6 Q_LOGGING_CATEGORY(LOG_Variable, "Variable")
7 7
8 8 struct Variable::VariablePrivate {
9 explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission)
10 : m_Name{name}, m_Unit{unit}, m_Mission{mission}, m_DataSeries{nullptr}
9 explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission,
10 const SqpDateTime &dateTime)
11 : m_Name{name},
12 m_Unit{unit},
13 m_Mission{mission},
14 m_DateTime{dateTime},
15 m_DataSeries{nullptr}
11 16 {
12 17 }
13 18
@@ -19,8 +24,9 struct Variable::VariablePrivate {
19 24 std::unique_ptr<IDataSeries> m_DataSeries;
20 25 };
21 26
22 Variable::Variable(const QString &name, const QString &unit, const QString &mission)
23 : impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, mission)}
27 Variable::Variable(const QString &name, const QString &unit, const QString &mission,
28 const SqpDateTime &dateTime)
29 : impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, mission, dateTime)}
24 30 {
25 31 }
26 32
@@ -55,4 +61,14 IDataSeries *Variable::dataSeries() const noexcept
55 61 void Variable::onXRangeChanged(SqpDateTime dateTime)
56 62 {
57 63 qCInfo(LOG_Variable()) << "onXRangeChanged detected";
64
65 if (!impl->m_DateTime.contains(dateTime)) {
66 // The current variable dateTime isn't enough to display the dateTime requested.
67 // We have to update it to the new dateTime requested.
68 // the correspondant new data to display will be given by the cache if possible and the
69 // provider if necessary.
70 qCInfo(LOG_Variable()) << "NEW DATE NEEDED";
71
72 impl->m_DateTime = dateTime;
73 }
58 74 }
@@ -95,7 +95,7 void VariableController::createVariable(const QString &name,
95 95 /// in sciqlop
96 96 auto dateTime = impl->m_TimeController->dateTime();
97 97 if (auto newVariable = impl->m_VariableModel->createVariable(
98 name, generateDefaultDataSeries(*provider, dateTime))) {
98 name, dateTime, generateDefaultDataSeries(*provider, dateTime))) {
99 99
100 100 // store in cache
101 101 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
@@ -26,15 +26,15 VariableModel::VariableModel(QObject *parent)
26 26 }
27 27
28 28 std::shared_ptr<Variable>
29 VariableModel::createVariable(const QString &name,
29 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
30 30 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept
31 31 {
32 32 auto insertIndex = rowCount();
33 33 beginInsertRows({}, insertIndex, insertIndex);
34 34
35 35 /// @todo For the moment, the other data of the variable is initialized with default values
36 auto variable
37 = std::make_shared<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
36 auto variable = std::make_shared<Variable>(name, QStringLiteral("unit"),
37 QStringLiteral("mission"), dateTime);
38 38 variable->addDataSeries(std::move(defaultDataSeries));
39 39
40 40 impl->m_Variables.push_back(variable);
General Comments 0
You need to be logged in to leave comments. Login now