diff --git a/core/include/Variable/Variable.h b/core/include/Variable/Variable.h index 5a6a9ed..7e90f90 100644 --- a/core/include/Variable/Variable.h +++ b/core/include/Variable/Variable.h @@ -47,10 +47,8 @@ public: bool cacheIsInside(const SqpRange &range) const noexcept; QVector provideNotInCacheRangeList(const SqpRange &range); - - -public slots: void setDataSeries(std::shared_ptr dataSeries) noexcept; + void mergeDataSeries(std::shared_ptr dataSeries) noexcept; signals: void updated(); @@ -62,5 +60,6 @@ private: // Required for using shared_ptr in signals/slots SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_REGISTRY, std::shared_ptr) +SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_VECTOR_REGISTRY, QVector >) #endif // SCIQLOP_VARIABLE_H diff --git a/core/src/Variable/Variable.cpp b/core/src/Variable/Variable.cpp index 494cce7..89bfb6f 100644 --- a/core/src/Variable/Variable.cpp +++ b/core/src/Variable/Variable.cpp @@ -61,6 +61,26 @@ void Variable::setDataSeries(std::shared_ptr dataSeries) noexcept return; } + impl->m_DataSeries = dataSeries->clone(); + + // // Inits the data series of the variable + // if (!impl->m_DataSeries) { + // impl->m_DataSeries = dataSeries->clone(); + // } + // else { + // impl->m_DataSeries->merge(dataSeries.get()); + // } +} + +void Variable::mergeDataSeries(std::shared_ptr dataSeries) noexcept +{ + qCDebug(LOG_Variable()) << "Variable::setDataSeries" << QThread::currentThread()->objectName(); + if (!dataSeries) { + /// @todo ALX : log + return; + } + + // Add or merge the data // Inits the data series of the variable if (!impl->m_DataSeries) { impl->m_DataSeries = dataSeries->clone(); @@ -68,6 +88,13 @@ void Variable::setDataSeries(std::shared_ptr dataSeries) noexcept else { impl->m_DataSeries->merge(dataSeries.get()); } + + // sub the data + auto subData = this->dataSeries()->subData(this->cacheRange()); + qCCritical(LOG_Variable()) << "TORM: Variable::mergeDataSeries sub" << subData->range(); + this->setDataSeries(subData); + qCCritical(LOG_Variable()) << "TORM: Variable::mergeDataSeries set" + << this->dataSeries()->range(); } IDataSeries *Variable::dataSeries() const noexcept @@ -127,10 +154,10 @@ QVector Variable::provideNotInCacheRangeList(const SqpRange &range) else if (range.m_TStart < impl->m_CacheRange.m_TStart && range.m_TEnd > impl->m_CacheRange.m_TEnd) { notInCache << SqpRange{range.m_TStart, impl->m_CacheRange.m_TStart} - << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TStart}; + << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd}; } else if (range.m_TStart < impl->m_CacheRange.m_TEnd) { - notInCache << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TStart}; + notInCache << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd}; } else { qCCritical(LOG_Variable()) << tr("Detection of unknown case.")