Skip to content

Commit

Permalink
Added method to expose raw index to the Lua interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Almagro committed Apr 29, 2024
1 parent 3a90d88 commit 0c6521b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plotjuggler_base/include/PlotJuggler/reactive_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ struct TimeseriesRef

double atTime(double t) const;

int getRawIndexAtTime(double t) const;

unsigned size() const;

void clear() const;
Expand Down
6 changes: 6 additions & 0 deletions plotjuggler_base/src/reactive_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

//---------------------------------------
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0c6521b

Please sign in to comment.