##// END OF EJS Templates
Add satic method to compute vector of in or not in ranges between...
perrinel -
r816:97f935302b90
parent child
Show More
@@ -68,6 +68,12 public:
68 QVector<SqpRange> provideInCacheRangeList(const SqpRange &range) const noexcept;
68 QVector<SqpRange> provideInCacheRangeList(const SqpRange &range) const noexcept;
69 void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
69 void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
70
70
71 static QVector<SqpRange> provideNotInCacheRangeList(const SqpRange &oldRange,
72 const SqpRange &nextRange);
73
74 static QVector<SqpRange> provideInCacheRangeList(const SqpRange &oldRange,
75 const SqpRange &nextRange);
76
71 signals:
77 signals:
72 void updated();
78 void updated();
73
79
@@ -138,7 +138,6 void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
138 impl->lockWrite();
138 impl->lockWrite();
139 if (cacheRange != impl->m_CacheRange) {
139 if (cacheRange != impl->m_CacheRange) {
140 impl->m_CacheRange = cacheRange;
140 impl->m_CacheRange = cacheRange;
141 impl->purgeDataSeries();
142 }
141 }
143 impl->unlock();
142 impl->unlock();
144 }
143 }
@@ -174,6 +173,7 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
174 impl->unlock();
173 impl->unlock();
175 }
174 }
176
175
176
177 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
177 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
178 {
178 {
179 impl->lockRead();
179 impl->lockRead();
@@ -285,7 +285,7 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const
285
285
286 if (impl->m_CacheRange != INVALID_RANGE) {
286 if (impl->m_CacheRange != INVALID_RANGE) {
287
287
288 if (this->intersect(range)) {
288 if (this->cacheIntersect(range)) {
289 if (range.m_TStart <= impl->m_CacheRange.m_TStart
289 if (range.m_TStart <= impl->m_CacheRange.m_TStart
290 && range.m_TEnd >= impl->m_CacheRange.m_TStart
290 && range.m_TEnd >= impl->m_CacheRange.m_TStart
291 && range.m_TEnd < impl->m_CacheRange.m_TEnd) {
291 && range.m_TEnd < impl->m_CacheRange.m_TEnd) {
@@ -313,3 +313,76 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const
313
313
314 return inCache;
314 return inCache;
315 }
315 }
316
317
318 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &oldRange,
319 const SqpRange &nextRange)
320 {
321
322 // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange
323 auto notInCache = QVector<SqpRange>{};
324 if (oldRange != INVALID_RANGE) {
325
326 if (!oldRange.contains(nextRange)) {
327 if (nextRange.m_TEnd <= oldRange.m_TStart || nextRange.m_TStart >= oldRange.m_TEnd) {
328 notInCache << nextRange;
329 }
330 else if (nextRange.m_TStart < oldRange.m_TStart
331 && nextRange.m_TEnd <= oldRange.m_TEnd) {
332 notInCache << SqpRange{nextRange.m_TStart, oldRange.m_TStart};
333 }
334 else if (nextRange.m_TStart < oldRange.m_TStart && nextRange.m_TEnd > oldRange.m_TEnd) {
335 notInCache << SqpRange{nextRange.m_TStart, oldRange.m_TStart}
336 << SqpRange{oldRange.m_TEnd, nextRange.m_TEnd};
337 }
338 else if (nextRange.m_TStart < oldRange.m_TEnd) {
339 notInCache << SqpRange{oldRange.m_TEnd, nextRange.m_TEnd};
340 }
341 else {
342 qCCritical(LOG_Variable()) << tr("Detection of unknown case.")
343 << QThread::currentThread();
344 }
345 }
346 }
347 else {
348 notInCache << nextRange;
349 }
350
351 return notInCache;
352 }
353
354 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &oldRange,
355 const SqpRange &nextRange)
356 {
357 // This code assume that cach is contigue. Can return 0 or 1 SqpRange
358
359 auto inCache = QVector<SqpRange>{};
360
361 if (oldRange != INVALID_RANGE) {
362
363 if (oldRange.intersect(nextRange)) {
364 if (nextRange.m_TStart <= oldRange.m_TStart && nextRange.m_TEnd >= oldRange.m_TStart
365 && nextRange.m_TEnd < oldRange.m_TEnd) {
366 inCache << SqpRange{oldRange.m_TStart, nextRange.m_TEnd};
367 }
368
369 else if (nextRange.m_TStart >= oldRange.m_TStart
370 && nextRange.m_TEnd <= oldRange.m_TEnd) {
371 inCache << nextRange;
372 }
373 else if (nextRange.m_TStart > oldRange.m_TStart && nextRange.m_TEnd > oldRange.m_TEnd) {
374 inCache << SqpRange{nextRange.m_TStart, oldRange.m_TEnd};
375 }
376 else if (nextRange.m_TStart <= oldRange.m_TStart
377 && nextRange.m_TEnd >= oldRange.m_TEnd) {
378 inCache << oldRange;
379 }
380 else {
381 qCCritical(LOG_Variable()) << tr("Detection of unknown case.")
382 << QThread::currentThread();
383 }
384 }
385 }
386
387 return inCache;
388 }
General Comments 0
You need to be logged in to leave comments. Login now