diff --git a/src/traceAnalyzer/businessObjects/timespan.cpp b/src/traceAnalyzer/businessObjects/timespan.cpp index bfd5a4fc..5c9fca56 100644 --- a/src/traceAnalyzer/businessObjects/timespan.cpp +++ b/src/traceAnalyzer/businessObjects/timespan.cpp @@ -42,6 +42,11 @@ bool Timespan::contains(traceTime time) const return (begin <= time && time <= end); } +bool Timespan::contains(const Timespan& other) const +{ + return (other.begin >= begin && other.end <= end); +} + bool Timespan::overlaps(const Timespan& other) const { return other.Begin() < this->end && this->begin < other.End(); diff --git a/src/traceAnalyzer/businessObjects/timespan.h b/src/traceAnalyzer/businessObjects/timespan.h index c0a29358..82c62cd0 100644 --- a/src/traceAnalyzer/businessObjects/timespan.h +++ b/src/traceAnalyzer/businessObjects/timespan.h @@ -55,6 +55,7 @@ public: traceTime Middle() const { return (begin + end) / 2; } void setEnd(traceTime time) { end = time; } bool contains(traceTime time) const; + bool contains(const Timespan& other) const; bool overlaps(const Timespan& other) const; void shift(traceTime offset); }; diff --git a/src/traceAnalyzer/presentation/traceplot.cpp b/src/traceAnalyzer/presentation/traceplot.cpp index 21accc5a..1fd0dc75 100644 --- a/src/traceAnalyzer/presentation/traceplot.cpp +++ b/src/traceAnalyzer/presentation/traceplot.cpp @@ -631,17 +631,24 @@ void TracePlot::currentTraceTimeChanged() bool drawDependencies = getDrawingProperties().drawDependenciesOption.draw != DependencyOption::Disabled; - transactions = - navigator->TraceFile().getTransactionsInTimespan(GetCurrentTimespan(), drawDependencies); + Timespan newTimespan = GetCurrentTimespan(); + + if (!loadedTimespan.contains(newTimespan)) + { + loadedTimespan = Timespan{newTimespan.Begin() - newTimespan.timeCovered(), newTimespan.End() + newTimespan.timeCovered()}; + + transactions = navigator->TraceFile().getTransactionsInTimespan(loadedTimespan, + drawDependencies); #ifdef EXTENSION_ENABLED - if (drawDependencies) - { - navigator->TraceFile().updateDependenciesInTimespan(GetCurrentTimespan()); - } + if (drawDependencies) + { + navigator->TraceFile().updateDependenciesInTimespan(loadedTimespan); + } #endif + } - setAxisScale(xBottom, GetCurrentTimespan().Begin(), GetCurrentTimespan().End()); + setAxisScale(xBottom, newTimespan.Begin(), newTimespan.End()); dependenciesSubMenu->setEnabled(navigator->TraceFile().checkDependencyTableExists()); diff --git a/src/traceAnalyzer/presentation/traceplot.h b/src/traceAnalyzer/presentation/traceplot.h index 597e11be..6643eeb6 100644 --- a/src/traceAnalyzer/presentation/traceplot.h +++ b/src/traceAnalyzer/presentation/traceplot.h @@ -136,6 +136,8 @@ private: TracePlotLineDataSource* tracePlotLineDataSource; + Timespan loadedTimespan; + void setUpTracePlotItem(); void setUpDrawingProperties(); void setUpGrid(); diff --git a/src/traceAnalyzer/presentation/tracescroller.cpp b/src/traceAnalyzer/presentation/tracescroller.cpp index 51e3eaf2..8a9c75ca 100644 --- a/src/traceAnalyzer/presentation/tracescroller.cpp +++ b/src/traceAnalyzer/presentation/tracescroller.cpp @@ -43,6 +43,7 @@ #include #include #include +#include TraceScroller::TraceScroller(QWidget* parent) : QwtPlot(parent), @@ -217,17 +218,26 @@ void TraceScroller::currentTraceTimeChanged() Timespan spanOnTracePlot = tracePlot->GetCurrentTimespan(); canvasClip->setInterval(spanOnTracePlot.Begin(), spanOnTracePlot.End()); - Timespan span = GetCurrentTimespan(); - transactions = navigator->TraceFile().getTransactionsInTimespan(span, drawDependencies); + + Timespan newTimespan = GetCurrentTimespan(); + + if (!loadedTimespan.contains(newTimespan)) + { + loadedTimespan = Timespan{newTimespan.Begin() - newTimespan.timeCovered(), + newTimespan.End() + newTimespan.timeCovered()}; + + transactions = + navigator->TraceFile().getTransactionsInTimespan(loadedTimespan, drawDependencies); #ifdef EXTENSION_ENABLED - if (drawDependencies) - { - navigator->TraceFile().updateDependenciesInTimespan(span); - } + if (drawDependencies) + { + navigator->TraceFile().updateDependenciesInTimespan(loadedTimespan); + } #endif + } - setAxisScale(xBottom, span.Begin(), span.End()); + setAxisScale(xBottom, newTimespan.Begin(), newTimespan.End()); replot(); } diff --git a/src/traceAnalyzer/presentation/tracescroller.h b/src/traceAnalyzer/presentation/tracescroller.h index a738a520..5f89a9c3 100644 --- a/src/traceAnalyzer/presentation/tracescroller.h +++ b/src/traceAnalyzer/presentation/tracescroller.h @@ -57,6 +57,9 @@ private: TraceNavigator* navigator; TracePlot* tracePlot; TracePlotLineDataSource* tracePlotLineDataSource; + + Timespan loadedTimespan; + constexpr static int tracePlotEnlargementFactor = 4; void setUpTracePlotItem(); void setUpDrawingProperties();