Skip to main content

CorePlotting::TimeSeriesMapper

CorePlotting::TimeSeriesMapper

Mapper for time-series data (DataViewer-style visualization). More…

Functions

Name
std::vector< MappedElement > mapEventsToVector(DigitalEventSeries const & series, SeriesLayout const & layout, TimeFrame const & time_frame)
Map events to a vector of MappedElement.
std::vector< MappedRectElement > mapIntervalsToVector(DigitalIntervalSeries const & series, SeriesLayout const & layout, TimeFrame const & time_frame)
Map intervals to a vector of MappedRectElement.
std::vector< MappedVertex > mapAnalogToVector(AnalogTimeSeries const & series, SeriesLayout const & layout, TimeFrame const & time_frame, float y_scale, TimeFrameIndex start_time, TimeFrameIndex end_time)
Map analog series to a vector of MappedVertex.
auto mapEvents(DigitalEventSeries const & series, SeriesLayout const & layout, TimeFrame const & time_frame)
Map events to world-space positions.
auto mapEventsInRange(DigitalEventSeries const & series, SeriesLayout const & layout, TimeFrame const & query_time_frame, TimeFrameIndex start_time, TimeFrameIndex end_time, ClockTicks x_origin_time =ClockTicks(0))
Map events in a time range to world-space positions.
auto mapIntervals(DigitalIntervalSeries const & series, SeriesLayout const & layout, TimeFrame const & time_frame)
Map intervals to world-space rectangles.
auto mapIntervalsInRange(DigitalIntervalSeries const & series, SeriesLayout const & layout, TimeFrame const & query_time_frame, TimeFrameIndex start_time, TimeFrameIndex end_time, ClockTicks x_origin_time =ClockTicks(0))
Map intervals in a time range to world-space rectangles.
auto mapAnalogSeries(AnalogTimeSeries const & series, SeriesLayout const & layout, TimeFrame const & query_time_frame, float y_scale, TimeFrameIndex start_time, TimeFrameIndex end_time, ClockTicks x_origin_time =ClockTicks(0))
Map analog time series to polyline vertices.
auto mapAnalogSeriesFull(AnalogTimeSeries const & series, SeriesLayout const & layout, TimeFrame const & time_frame, float y_scale)
Map entire analog time series to polyline vertices.
auto mapAnalogSeriesWithIndices(AnalogTimeSeries const & series, SeriesLayout const & layout, TimeFrame const & query_time_frame, float y_scale, TimeFrameIndex start_time, TimeFrameIndex end_time, ClockTicks x_origin_time =ClockTicks(0))
Map analog time series to vertices with time indices for gap detection.

Detailed Description

Mapper for time-series data (DataViewer-style visualization).

Transforms time-indexed data from DataManager types into world-space coordinates suitable for rendering and hit testing. X coordinates come from TimeFrame conversion, Y coordinates from layout allocation.

Choosing the Right Mapper

Events (DigitalEventSeries):

  • mapEvents(): Lazy range over ALL events - use when iterating full series
  • mapEventsInRange(): Filtered by time range with cross-TimeFrame support - use for visible window
  • mapEventsToVector(): Materialized full series - use when random access needed

Intervals (DigitalIntervalSeries):

Analog (AnalogTimeSeries):

Model-Matrix Rendering Pattern

For OpenGL rendering with model matrices, create a “local-space” SeriesLayout with y_center=0 and height=2 (for [-1,1] range). The model matrix handles world-space positioning:

SeriesLayout local_layout{SeriesLayoutResult{0.0f, 2.0f}, "", 0};
auto events = mapEventsInRange(series, local_layout, time_frame, start, end);

This mapper is used for:

  • DataViewer: stacked time-series plots
  • Event traces: discrete events along time axis
  • Interval display: temporal regions/epochs

All range-returning methods support zero-copy single-traversal consumption.

Cross-TimeFrame contract (physical time vs indices)

Callers are expected to construct [TimeFrame](/api_generated/Classes/classTimeFrame.md) objects so that getTimeAtIndex returns comparable physical-time scalars for the same instant across frames. Index equality is not preserved across frames: the same instant may be [TimeFrameIndex](/api_generated/Classes/structTimeFrameIndex.md)20 in one frame and 50 in another. Range filtering still uses convert_time_index where needed; plotted X for a sample uses that sample’s own frame’s getTimeAtIndex, then subtracts an origin computed the same way (scalar arithmetic in one physical axis).

Functions Documentation

function mapEventsToVector

std::vector< MappedElement > mapEventsToVector(
    DigitalEventSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & time_frame
)

Map events to a vector of MappedElement.

Parameters:

  • series Event series to map
  • layout Layout allocation for Y positioning
  • time_frame TimeFrame for index→time conversion

Return: Vector of MappedElement

Materializes the event mapping for cases requiring multiple passes or random access.

function mapIntervalsToVector

std::vector< MappedRectElement > mapIntervalsToVector(
    DigitalIntervalSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & time_frame
)

Map intervals to a vector of MappedRectElement.

Parameters:

  • series Interval series to map
  • layout Layout allocation
  • time_frame TimeFrame for conversion

Return: Vector of MappedRectElement

function mapAnalogToVector

std::vector< MappedVertex > mapAnalogToVector(
    AnalogTimeSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & time_frame,
    float y_scale,
    TimeFrameIndex start_time,
    TimeFrameIndex end_time
)

Map analog series to a vector of MappedVertex.

Parameters:

  • series Analog series to map
  • layout Layout allocation
  • time_frame TimeFrame for conversion
  • y_scale Y scaling factor
  • start_time Start of range
  • end_time End of range

Return: Vector of MappedVertex

function mapEvents

inline auto mapEvents(
    DigitalEventSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & time_frame
)

Map events to world-space positions.

Parameters:

  • series Event series to map
  • layout Layout allocation for Y positioning
  • time_frame TimeFrame for index→time conversion

See:

Return: Range of MappedElement

Transforms DigitalEventSeries events into (x, y, entity_id) tuples where:

  • X = absolute time from TimeFrame
  • Y = layout.y_transform.offset (constant for all events)

Returns a lazy range over ALL events. For visible-window filtering, use mapEventsInRange() instead.

function mapEventsInRange

inline auto mapEventsInRange(
    DigitalEventSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & query_time_frame,
    TimeFrameIndex start_time,
    TimeFrameIndex end_time,
    ClockTicks x_origin_time =ClockTicks(0)
)

Map events in a time range to world-space positions.

Parameters:

  • series Event series to map
  • layout Layout allocation for Y positioning
  • query_time_frame TimeFrame for range query (defines start/end coordinate space)
  • start_time Start of visible range (in query_time_frame coordinates)
  • end_time End of visible range (in query_time_frame coordinates)

See:

Return: Owning range of MappedElement for events in range

Uses getEventsWithIdsInRange for proper cross-TimeFrame support and EntityId preservation. The query_time_frame defines the coordinate system for start_time/end_time, while the series’ internal TimeFrame is used for the actual event positions.

Returns an owning range that can be iterated or materialized at the call site.

function mapIntervals

inline auto mapIntervals(
    DigitalIntervalSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & time_frame
)

Map intervals to world-space rectangles.

Parameters:

  • series Interval series to map
  • layout Layout allocation for Y positioning and height
  • time_frame TimeFrame for index→time conversion

See:

Return: Range of MappedRectElement

Transforms DigitalIntervalSeries into (x, y, width, height, entity_id) tuples where:

  • X = absolute start time from TimeFrame
  • Width = absolute end time - start time
  • Y = layout.y_transform.offset - height/2
  • Height = layout.y_transform.gain * 2 (full allocated height)

function mapIntervalsInRange

inline auto mapIntervalsInRange(
    DigitalIntervalSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & query_time_frame,
    TimeFrameIndex start_time,
    TimeFrameIndex end_time,
    ClockTicks x_origin_time =ClockTicks(0)
)

Map intervals in a time range to world-space rectangles.

Parameters:

  • series Interval series to map
  • layout Layout allocation for Y positioning and height
  • query_time_frame TimeFrame for range query (defines start/end coordinate space)
  • start_time Start of visible range (in query_time_frame coordinates)
  • end_time End of visible range (in query_time_frame coordinates)

See:

Return: Owning range of MappedRectElement for intervals in range

Uses getIntervalsWithIdsInRange for proper cross-TimeFrame support. Intervals are clipped to the visible range.

Returns an owning range that can be iterated or materialized at the call site.

function mapAnalogSeries

inline auto mapAnalogSeries(
    AnalogTimeSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & query_time_frame,
    float y_scale,
    TimeFrameIndex start_time,
    TimeFrameIndex end_time,
    ClockTicks x_origin_time =ClockTicks(0)
)

Map analog time series to polyline vertices.

Parameters:

  • series Analog time series to map
  • layout Layout allocation for Y positioning and scaling
  • time_frame TimeFrame for index→time conversion
  • y_scale Scaling factor for Y values (e.g., 1/std_dev for normalization)
  • start_time Start of visible range
  • end_time End of visible range

See:

Return: Range of MappedVertex

Transforms AnalogTimeSeries samples into (x, y) vertices where:

  • X = absolute time from TimeFrame
  • Y = layout-transformed data value

The layout transform scales and offsets the raw values: Y = value * y_scale + y_offset

Where:

  • y_scale = allocated_height / (2.0 * data_range) if normalizing
  • y_offset = allocated_y_center

function mapAnalogSeriesFull

inline auto mapAnalogSeriesFull(
    AnalogTimeSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & time_frame,
    float y_scale
)

Map entire analog time series to polyline vertices.

Parameters:

  • series Analog time series to map
  • layout Layout allocation for Y positioning and scaling
  • time_frame TimeFrame for index→time conversion
  • y_scale Scaling factor for Y values

See:

Return: Range of MappedVertex

Convenience overload for mapping the full series.

function mapAnalogSeriesWithIndices

inline auto mapAnalogSeriesWithIndices(
    AnalogTimeSeries const & series,
    SeriesLayout const & layout,
    TimeFrame const & query_time_frame,
    float y_scale,
    TimeFrameIndex start_time,
    TimeFrameIndex end_time,
    ClockTicks x_origin_time =ClockTicks(0)
)

Map analog time series to vertices with time indices for gap detection.

Parameters:

  • series Analog time series to map
  • layout Layout allocation for Y positioning and scaling
  • time_frame TimeFrame for index→time conversion
  • y_scale Scaling factor for Y values
  • start_time Start of visible range
  • end_time End of visible range

See:

Return: Range of MappedAnalogVertex

Returns MappedAnalogVertex which includes the original time frame index, enabling the caller to detect gaps based on index discontinuities.


Updated on 2026-11-13 at 20:25:42 +0000