From f23c8cc9e4611fa0a60ff4e8c6525488b4d2b868 2017-06-28 14:50:02 From: mperrinel Date: 2017-06-28 14:50:02 Subject: [PATCH] Merge branch 'feature/DeltaTOnPan' into develop --- 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/Data/SqpDateTime.h b/core/include/Data/SqpDateTime.h index 7ecec9f..dc43dc1 100644 --- a/core/include/Data/SqpDateTime.h +++ b/core/include/Data/SqpDateTime.h @@ -15,6 +15,11 @@ struct SqpDateTime { { return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd); } + + bool intersect(const SqpDateTime &dateTime) + { + return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd); + } }; // Required for using shared_ptr in signals/slots diff --git a/core/include/Variable/Variable.h b/core/include/Variable/Variable.h index 7ac0c1c..c6688c0 100644 --- a/core/include/Variable/Variable.h +++ b/core/include/Variable/Variable.h @@ -29,11 +29,13 @@ 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; bool contains(const SqpDateTime &dateTime); + bool intersect(const SqpDateTime &dateTime); void setDataSeries(std::unique_ptr dataSeries) noexcept; public slots: diff --git a/core/src/Variable/Variable.cpp b/core/src/Variable/Variable.cpp index 9db3be1..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,17 +78,10 @@ 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 impl->m_DateTime.contains(dateTime); +} - return true; +bool Variable::intersect(const SqpDateTime &dateTime) +{ + return impl->m_DateTime.intersect(dateTime); } diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index 8f909b5..e9be9e5 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -111,14 +111,44 @@ void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange for (auto it = impl->m_VariableToPlotMultiMap.cbegin(); it != impl->m_VariableToPlotMultiMap.cend(); ++it) { + auto variable = it->first; - auto tolerance = 0.1 * (t2.upper - t2.lower); - auto dateTime = SqpDateTime{t2.lower - tolerance, t2.upper + tolerance}; + qCInfo(LOG_VisualizationGraphWidget()) + << tr("TORM: VisualizationGraphWidget::onRangeChanged") + << variable->dataSeries()->xAxisData()->size(); + auto dateTime = SqpDateTime{t2.lower, t2.upper}; - qCInfo(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged") - << variable->dataSeries()->xAxisData()->size(); if (!variable->contains(dateTime)) { - sqpApp->variableController().requestDataLoading(variable, 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; + // 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; + // 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); + variableDateTimeWithTolerance.m_TStart -= tolerance; + variableDateTimeWithTolerance.m_TEnd += tolerance; + } + variable->setDateTime(dateTime); + + // CHangement detected, we need to ask controller to request data loading + sqpApp->variableController().requestDataLoading(variable, + variableDateTimeWithTolerance); } } } @@ -127,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) { @@ -143,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: