Skip to content

Commit

Permalink
Updating the history of a tasks now resets its history view.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brotcrunsher committed Jan 6, 2025
1 parent 2e69fba commit bd4b3ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Examples/ExampleMother/EMTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ int32_t SubsystemTask::drawTable(float scale, const char* title, const std::func
{
t.history.add(t.inputFloat);
t.execDone();
t.historyViewDirty = true;
requiresWrite = true;
}
}
Expand Down Expand Up @@ -870,14 +871,19 @@ bbe::Vector2 SubsystemTask::drawTabHistoryView()
static int32_t selection = 0;
ImGui::bbe::combo("History Selection", historyTitles, &selection);

const Task& task = tasks[historyIndices[selection]];
Task& task = tasks[historyIndices[selection]];
const bbe::List<float>& history = task.history;
bbe::List<float> time;
for (size_t i = 0; i < history.getLength(); i++)
{
time.add((float)i);
}

if (task.historyViewDirty)
{
task.historyViewDirty = false;
ImPlot::SetNextAxesToFit();
}
if (ImPlot::BeginPlot("History", { -1, 250 })) {
ImPlot::SetupAxes("Time", "Value");
ImPlot::PlotLine(task.title.getRaw(), time.getRaw(), history.getRaw(), time.getLength());
Expand Down
1 change: 1 addition & 0 deletions Examples/ExampleMother/EMTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct Task
mutable bool armedToPlaySoundDone = false;
bbe::TimePoint execPointBuffer;
bbe::TimePoint yearlyBuffer;
bool historyViewDirty = false;

private:
bool timePointElapsed(const bbe::TimePoint& tp, bool& armed) const;
Expand Down

0 comments on commit bd4b3ed

Please sign in to comment.