From c6b3af1efcdb3893615504a86ae8f39e32d36eb2 Mon Sep 17 00:00:00 2001 From: TheOtherMarcus Date: Tue, 9 Jan 2024 11:52:29 +0100 Subject: [PATCH] Added a clear() function to Lua timeseries. (#898) Co-authored-by: Marcus Andersson --- plotjuggler_base/include/PlotJuggler/reactive_function.h | 2 ++ plotjuggler_base/src/reactive_function.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/plotjuggler_base/include/PlotJuggler/reactive_function.h b/plotjuggler_base/include/PlotJuggler/reactive_function.h index 2333b7893..601cfe43e 100644 --- a/plotjuggler_base/include/PlotJuggler/reactive_function.h +++ b/plotjuggler_base/include/PlotJuggler/reactive_function.h @@ -29,6 +29,8 @@ struct TimeseriesRef unsigned size() const; + void clear() const; + PJ::PlotData* _plot_data = nullptr; }; diff --git a/plotjuggler_base/src/reactive_function.cpp b/plotjuggler_base/src/reactive_function.cpp index d8915d046..d9c713a36 100644 --- a/plotjuggler_base/src/reactive_function.cpp +++ b/plotjuggler_base/src/reactive_function.cpp @@ -114,6 +114,7 @@ void ReactiveLuaFunction::prepareLua() _timeseries_ref["at"] = &TimeseriesRef::at; _timeseries_ref["set"] = &TimeseriesRef::set; _timeseries_ref["atTime"] = &TimeseriesRef::atTime; + _timeseries_ref["clear"] = &TimeseriesRef::clear; //--------------------------------------- _created_timeseries = _lua_engine.new_usertype("Timeseries"); @@ -194,6 +195,11 @@ unsigned TimeseriesRef::size() const return _plot_data->size(); } +void TimeseriesRef::clear() const +{ + _plot_data->clear(); +} + CreatedSeriesBase::CreatedSeriesBase(PlotDataMapRef* data_map, const std::string& name, bool timeseries) {