From 6be77fcf75e0a01a2aa915dbaec9f51b181a3903 Mon Sep 17 00:00:00 2001 From: Marcus Andersson Date: Sun, 31 Dec 2023 23:14:39 +0100 Subject: [PATCH] Added a clear() function to Lua timeseries. --- 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) {