##// 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 double m_TStart;
9 double m_TStart;
10 /// End time
10 /// End time
11 double m_TEnd;
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 #endif // SCIQLOP_SQPDATETIME_H
19 #endif // SCIQLOP_SQPDATETIME_H
@@ -19,7 +19,8 class QString;
19 */
19 */
20 class Variable {
20 class Variable {
21 public:
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 QString name() const noexcept;
25 QString name() const noexcept;
25 QString mission() const noexcept;
26 QString mission() const noexcept;
@@ -1,11 +1,14
1 #ifndef SCIQLOP_VARIABLEMODEL_H
1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
3
3
4 #include <Common/spimpl.h>
4
5 #include <Data/SqpDateTime.h>
5
6
6 #include <QAbstractTableModel>
7 #include <QAbstractTableModel>
7 #include <QLoggingCategory>
8 #include <QLoggingCategory>
8
9
10 #include <Common/spimpl.h>
11
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
10
13
11 class IDataSeries;
14 class IDataSeries;
@@ -21,11 +24,13 public:
21 /**
24 /**
22 * Creates a new variable in the model
25 * Creates a new variable in the model
23 * @param name the name of the new variable
26 * @param name the name of the new variable
27 * @param dateTime the dateTime of the new variable
24 * @param defaultDataSeries the default data of the new variable
28 * @param defaultDataSeries the default data of the new variable
25 * @return the pointer to the new variable
29 * @return the pointer to the new variable
26 */
30 */
27 std::shared_ptr<Variable>
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 // QAbstractTableModel methods //
36 // QAbstractTableModel methods //
@@ -6,8 +6,13
6 Q_LOGGING_CATEGORY(LOG_Variable, "Variable")
6 Q_LOGGING_CATEGORY(LOG_Variable, "Variable")
7
7
8 struct Variable::VariablePrivate {
8 struct Variable::VariablePrivate {
9 explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission)
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}
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 std::unique_ptr<IDataSeries> m_DataSeries;
24 std::unique_ptr<IDataSeries> m_DataSeries;
20 };
25 };
21
26
22 Variable::Variable(const QString &name, const QString &unit, const QString &mission)
27 Variable::Variable(const QString &name, const QString &unit, const QString &mission,
23 : impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, 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 void Variable::onXRangeChanged(SqpDateTime dateTime)
61 void Variable::onXRangeChanged(SqpDateTime dateTime)
56 {
62 {
57 qCInfo(LOG_Variable()) << "onXRangeChanged detected";
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 /// in sciqlop
95 /// in sciqlop
96 auto dateTime = impl->m_TimeController->dateTime();
96 auto dateTime = impl->m_TimeController->dateTime();
97 if (auto newVariable = impl->m_VariableModel->createVariable(
97 if (auto newVariable = impl->m_VariableModel->createVariable(
98 name, generateDefaultDataSeries(*provider, dateTime))) {
98 name, dateTime, generateDefaultDataSeries(*provider, dateTime))) {
99
99
100 // store in cache
100 // store in cache
101 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
101 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
@@ -26,15 +26,15 VariableModel::VariableModel(QObject *parent)
26 }
26 }
27
27
28 std::shared_ptr<Variable>
28 std::shared_ptr<Variable>
29 VariableModel::createVariable(const QString &name,
29 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
30 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept
30 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept
31 {
31 {
32 auto insertIndex = rowCount();
32 auto insertIndex = rowCount();
33 beginInsertRows({}, insertIndex, insertIndex);
33 beginInsertRows({}, insertIndex, insertIndex);
34
34
35 /// @todo For the moment, the other data of the variable is initialized with default values
35 /// @todo For the moment, the other data of the variable is initialized with default values
36 auto variable
36 auto variable = std::make_shared<Variable>(name, QStringLiteral("unit"),
37 = std::make_shared<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
37 QStringLiteral("mission"), dateTime);
38 variable->addDataSeries(std::move(defaultDataSeries));
38 variable->addDataSeries(std::move(defaultDataSeries));
39
39
40 impl->m_Variables.push_back(variable);
40 impl->m_Variables.push_back(variable);
General Comments 0
You need to be logged in to leave comments. Login now