Implemented history writer
This commit is contained in:
@@ -204,6 +204,13 @@ void RenderPlotPanel(App& app, int plotIdx, bool& paused) {
|
||||
zc.t0 <= app.plotXMin(plotIdx) + 1e-9 &&
|
||||
zc.t1 >= app.plotXMax(plotIdx) - 1e-9));
|
||||
|
||||
/* History zoom cache (disk-backed, for ranges beyond in-memory ring) */
|
||||
auto& hc = app.histZoomCache(plotIdx);
|
||||
const bool useHistData = !trigView && !live && !useZoomData &&
|
||||
hc.valid &&
|
||||
hc.t0 <= app.plotXMin(plotIdx) + 1e-9 &&
|
||||
hc.t1 >= app.plotXMax(plotIdx) - 1e-9;
|
||||
|
||||
/* Fill tStore/vStore[si] from the frozen view (paused) or the live ring */
|
||||
auto readBase = [&](size_t si, const Signal& sig, const std::string& key) {
|
||||
if (paused && snap.valid) {
|
||||
@@ -249,6 +256,18 @@ void RenderPlotPanel(App& app, int plotIdx, bool& paused) {
|
||||
if (!found) {
|
||||
readBase(si, sig, key);
|
||||
}
|
||||
} else if (useHistData) {
|
||||
bool found = false;
|
||||
for (const auto& hs : hc.signals) {
|
||||
if (hs.name != key) continue;
|
||||
tStore[si] = hs.t;
|
||||
vStore[si] = hs.v;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
readBase(si, sig, key);
|
||||
}
|
||||
} else {
|
||||
readBase(si, sig, key);
|
||||
}
|
||||
@@ -375,6 +394,13 @@ void RenderPlotPanel(App& app, int plotIdx, bool& paused) {
|
||||
}
|
||||
}
|
||||
|
||||
/* History indicator */
|
||||
if (useHistData) {
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored(ImVec4(0.980f,0.702f,0.529f,1.f),
|
||||
ICON_FA_CLOCK_ROTATE_LEFT " HIST");
|
||||
}
|
||||
|
||||
/* Norm mode + cursors toggles */
|
||||
ImGui::SameLine();
|
||||
{
|
||||
@@ -659,7 +685,9 @@ void RenderPlotPanel(App& app, int plotIdx, bool& paused) {
|
||||
}
|
||||
} else if (!live) {
|
||||
/* Non-live: debounced — every zoom/pan settles into one
|
||||
* request, so each zoom level gets fresh resolution. */
|
||||
* request, so each zoom level gets fresh resolution.
|
||||
* If the range is covered by the in-memory ring, use regular
|
||||
* zoom; otherwise try historyZoom (disk-backed). */
|
||||
static double rangeChangedAt[kPlotSlotsMax] = {};
|
||||
static double lastT0[kPlotSlotsMax] = {}, lastT1[kPlotSlotsMax] = {};
|
||||
const double now = ImGui::GetTime();
|
||||
@@ -670,9 +698,17 @@ void RenderPlotPanel(App& app, int plotIdx, bool& paused) {
|
||||
rangeChangedAt[plotIdx] = now;
|
||||
} else if (rangeChangedAt[plotIdx] > 0.0 &&
|
||||
now - rangeChangedAt[plotIdx] > 0.35 &&
|
||||
!zc.pending &&
|
||||
!(zc.valid && zc.t0 == t0 && zc.t1 == t1)) {
|
||||
if (!csv.empty()) { app.requestZoom(plotIdx, t0, t1, csv); }
|
||||
!csv.empty()) {
|
||||
/* Try regular zoom first */
|
||||
if (!zc.pending && !(zc.valid && zc.t0 == t0 && zc.t1 == t1)) {
|
||||
app.requestZoom(plotIdx, t0, t1, csv);
|
||||
}
|
||||
/* Also try history zoom if history is available */
|
||||
const auto& hi = app.historyInfo();
|
||||
if (hi.enabled && !hc.pending &&
|
||||
!(hc.valid && hc.t0 == t0 && hc.t1 == t1)) {
|
||||
app.requestHistoryZoom(plotIdx, t0, t1, csv);
|
||||
}
|
||||
rangeChangedAt[plotIdx] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user