diff --git a/plotjuggler_base/include/PlotJuggler/reactive_function.h b/plotjuggler_base/include/PlotJuggler/reactive_function.h index 601cfe43e..cf05e4229 100644 --- a/plotjuggler_base/include/PlotJuggler/reactive_function.h +++ b/plotjuggler_base/include/PlotJuggler/reactive_function.h @@ -27,6 +27,8 @@ struct TimeseriesRef double atTime(double t) const; + int getRawIndexAtTime(double t) const; + unsigned size() const; void clear() const; diff --git a/plotjuggler_base/src/reactive_function.cpp b/plotjuggler_base/src/reactive_function.cpp index 27d54d1bf..b861b87ec 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["getRawIndexAtTime"] = &TimeseriesRef::getRawIndexAtTime; _timeseries_ref["clear"] = &TimeseriesRef::clear; //--------------------------------------- @@ -190,6 +191,11 @@ double TimeseriesRef::atTime(double t) const return _plot_data->at(i).y; } +int TimeseriesRef::getRawIndexAtTime(double t) const +{ + return _plot_data->getIndexFromX(t); +} + unsigned TimeseriesRef::size() const { return _plot_data->size();