From 1a61ee1f7b0838beed2f8fc4e2ce595e5306f141 2017-06-28 14:49:37 From: mperrinel Date: 2017-06-28 14:49:37 Subject: [PATCH] Implementation of the new Dela T computation strategy --- diff --git a/app/src/Main.cpp b/app/src/Main.cpp index 9a79cbc..d8daf09 100644 --- a/app/src/Main.cpp +++ b/app/src/Main.cpp @@ -65,10 +65,12 @@ int main(int argc, char *argv[]) #if __GNUC__ #if __x86_64__ || __ppc64__ - pluginDir.cd("../lib64/SciQlop"); + if (!pluginDir.cd("../lib64/SciQlop")) { + pluginDir.cd("../lib64/sciqlop"); + } #else - pluginDir.cd("../lib/SciQlop"); -#endif + __x86_64__ || __ppc64__ if (!pluginDir.cd("../lib/SciQlop")) { pluginDir.cd("../lib/sciqlop"); } + #endif #endif qCDebug(LOG_PluginManager()) << QObject::tr("Plugin directory: %1").arg(pluginDir.absolutePath()); diff --git a/core/include/Variable/Variable.h b/core/include/Variable/Variable.h index d7d0299..c6688c0 100644 --- a/core/include/Variable/Variable.h +++ b/core/include/Variable/Variable.h @@ -29,6 +29,7 @@ public: QString mission() const noexcept; QString unit() const noexcept; SqpDateTime dateTime() const noexcept; + void setDateTime(const SqpDateTime &dateTime) noexcept; /// @return the data of the variable, nullptr if there is no data IDataSeries *dataSeries() const noexcept; diff --git a/core/src/Variable/Variable.cpp b/core/src/Variable/Variable.cpp index 9b2a67f..ff099c6 100644 --- a/core/src/Variable/Variable.cpp +++ b/core/src/Variable/Variable.cpp @@ -50,6 +50,11 @@ SqpDateTime Variable::dateTime() const noexcept return impl->m_DateTime; } +void Variable::setDateTime(const SqpDateTime &dateTime) noexcept +{ + impl->m_DateTime = dateTime; +} + void Variable::setDataSeries(std::unique_ptr dataSeries) noexcept { if (!impl->m_DataSeries) { @@ -73,19 +78,7 @@ IDataSeries *Variable::dataSeries() const noexcept bool Variable::contains(const SqpDateTime &dateTime) { - if (!impl->m_DateTime.contains(dateTime)) { - // The current variable dateTime isn't enough to display the dateTime requested. - // We have to update it to the new dateTime requested. - // the correspondant new data to display will be given by the cache if possible and the - // provider if necessary. - qCInfo(LOG_Variable()) << "NEW DATE NEEDED"; - - // impl->m_DateTime = dateTime; - - return false; - } - - return true; + return impl->m_DateTime.contains(dateTime); } bool Variable::intersect(const SqpDateTime &dateTime) diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index dbbe055..e9be9e5 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -120,30 +120,35 @@ void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange if (!variable->contains(dateTime)) { + auto variableDateTimeWithTolerance = dateTime; if (variable->intersect(dateTime)) { auto variableDateTime = variable->dateTime(); if (variableDateTime.m_TStart < dateTime.m_TStart) { dateTime.m_TStart = variableDateTime.m_TStart; - // add 20% tolerance for left (start) side - auto tolerance = 0.2 * (dateTime.m_TEnd - dateTime.m_TStart); - dateTime.m_TStart -= tolerance; + // START is set to the old one. tolerance have to be added to the right + // add 10% tolerance for right (end) side + auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart); + variableDateTimeWithTolerance.m_TEnd += tolerance; } - if (variableDateTime.m_TEnd > dateTime.m_TEnd) { dateTime.m_TEnd = variableDateTime.m_TEnd; - // add 20% tolerance for right (end) side - auto tolerance = 0.2 * (dateTime.m_TEnd - dateTime.m_TStart); - dateTime.m_TEnd += tolerance; + // END is set to the old one. tolerance have to be added to the left + // add 10% tolerance for left (start) side + auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart); + variableDateTimeWithTolerance.m_TStart -= tolerance; } } else { // add 10% tolerance for each side auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart); - dateTime.m_TStart -= tolerance; - dateTime.m_TEnd += tolerance; + variableDateTimeWithTolerance.m_TStart -= tolerance; + variableDateTimeWithTolerance.m_TEnd += tolerance; } - // CHangement detected, we need to - sqpApp->variableController().requestDataLoading(variable, dateTime); + variable->setDateTime(dateTime); + + // CHangement detected, we need to ask controller to request data loading + sqpApp->variableController().requestDataLoading(variable, + variableDateTimeWithTolerance); } } } @@ -152,7 +157,8 @@ void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept { auto zoomOrientations = QFlags{}; - // Lambda that enables a zoom orientation if the key modifier related to this orientation has + // Lambda that enables a zoom orientation if the key modifier related to this orientation + // has // been pressed auto enableOrientation = [&zoomOrientations, event](const auto &orientation, const auto &modifier) { @@ -168,7 +174,8 @@ void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept void VisualizationGraphWidget::onDataCacheVariableUpdated() { // NOTE: - // We don't want to call the method for each component of a variable unitarily, but for all + // We don't want to call the method for each component of a variable unitarily, but for + // all // its components at once (eg its three components in the case of a vector). // The unordered_multimap does not do this easily, so the question is whether to: