TimelineSeries.h header

#include <ew/app/TimelineSeries.h>

Namespace ew::app

ArrangedTimelineSeries struct

struct ew::app::ArrangedTimelineSeries

One series lane after a persisted arrangement is applied (TL-92): its "Entity: field" label and the hidden/collapsed flags it should be drawn with. The same shape is used both as the OUTPUT of arrangeTimelineSeries (the ordered, annotated lanes to draw) and as the INPUT to setTimelineSeriesArrangement (the lanes as they should now appear), since a series lane behaves like any other lane.

Members

QString ew::app::ArrangedTimelineSeries::label

The series' "Entity: field" label.

bool ew::app::ArrangedTimelineSeries::hidden = false

Whether this series lane is hidden (dropped from the draw).

bool ew::app::ArrangedTimelineSeries::collapsed = false

Whether this series lane is collapsed to a thin strip.

bool operator==(const ArrangedTimelineSeries &, const ArrangedTimelineSeries &)=default

Value equality over all fields, for testing and change detection.

TimelineSeries struct

struct ew::app::TimelineSeries

A quantitative series extracted from an entity's state-over-time (TL-89 / TL-90): the numeric readings of one field key, plotted against the timeline's axis so growth and decline read as a curve. The points are sorted ascending by instant and carry at most one reading per instant.

Members

QString ew::app::TimelineSeries::key

The field key this series plots (the same key space as Entity::value / TimedFieldValue::key).

std::vector<TimelineSeriesPoint> ew::app::TimelineSeries::points

The readings, ascending by instant, one per instant. Empty when the key has no numeric timed values.

bool operator==(const TimelineSeries &, const TimelineSeries &)=default

Value equality over both fields, for testing and change detection.

TimelineSeriesPoint struct

struct ew::app::TimelineSeriesPoint

One point of a quantitative series on the timeline (TL-89): a value recorded at an instant. The instant is minutes since the project's story epoch, matching timeline events and lifespans; the value is the parsed numeric reading.

Members

qint64 ew::app::TimelineSeriesPoint::instant = 0

When the reading was taken, in minutes since the project's story epoch.

double ew::app::TimelineSeriesPoint::value = 0.0

The numeric value at that instant.

bool operator==(const TimelineSeriesPoint &, const TimelineSeriesPoint &)=default

Value equality over both fields, for testing and change detection.

Functions

std::vector< ArrangedTimelineSeries > ew::app::arrangeTimelineSeries(const std::vector< QString > &discoveredLabels, const std::vector< ew::core::TimelineSeriesArrangement > &arrangements)

Applies a persisted series arrangement (TL-92) to the auto-discovered series labels: emits the series named by an arrangement entry first, in the entries' order, each carrying its hidden and collapsed flags, then every discovered series the arrangement did not mention, in natural (discovery) order and neither hidden nor collapsed – so a brand-new series appears at the end rather than vanishing. A stale entry naming a series that no longer exists, or a duplicate entry, is skipped. discoveredLabels is the auto-discovery order (one per drawable series). Pure – the series-lane ordering/hiding is machine-checkable, matching how event lanes are arranged (TL-46).

std::vector< QString > ew::app::numericSeriesKeys(const std::vector< ew::core::TimedFieldValue > &values)

The distinct field keys in values that carry at least one numeric timed value – the keys that can be drawn as a series (TL-89). Sorted, de-duplicated. A key that only ever holds non-numeric values (a status, a name) is omitted. Pure.

std::optional< double > ew::app::parseSeriesValue(const QString &text)

Parses a stored field value as a finite number, or std::nullopt when it is not numeric (TL-89's "the numeric ones are a series"). Leading and trailing whitespace is ignored; the rest of the text must be a complete C-locale number (so "1200", "-3.5", "1.2e3" parse; "King", "42 souls", "1,200", and the empty string do not). A value that parses to a non-finite number (an overflowing literal) is rejected too, so a series never carries an inf or NaN.

int ew::app::seriesValueToY(double value, double low, double high, int bandTop, int bandHeight)

Maps a series value to the y pixel it plots at within a lane band (TL-89), so the series-lane geometry stays out of the paint path and is machine-checkable. value in the range [low, high] maps across the band [bandTop, bandTop + bandHeight), inverted so the HIGH value sits at the top and the LOW value at the bottom (the natural reading of a graph). A few pixels of padding at each edge keep the extreme points off the band's border. A flat series (high == low, or a band with no height) draws along the band's middle. value outside [low, high] is clamped, so a caller need not pre-clip. Pure.

std::vector< ew::core::TimelineSeriesArrangement > ew::app::setTimelineSeriesArrangement(const std::vector< ArrangedTimelineSeries > &orderedSeries)

Rebuilds the persisted series arrangement (TL-92) from the series as they should now appear, in draw order (each carrying its hidden/collapsed). VECTOR ORDER becomes the draw order. The counterpart of arrangeTimelineSeries: the desktop passes its current ordered series list (after a move/hide/collapse), and the result is stored on TimelineViewSettings, undoable via SetTimelineViewSettingsCommand. A lane needs a label to be identified. Pure.

TimelineSeries ew::app::timelineSeries(const std::vector< ew::core::TimedFieldValue > &values, const QString &key)

Extracts the numeric series for key from values (an entity's TimedFieldValue set, which is in no particular order): keeps only entries whose key matches and whose value parses numeric (parseSeriesValue), sorts them ascending by instant, and keeps the LAST value given for any instant (a corrected reading overrides an earlier one). Non-numeric entries and other keys are ignored; missing instants are simply absent points (a gap). Pure.

std::optional< std::pair< double, double > > ew::app::timelineSeriesValueRange(const TimelineSeries &series)

The value range (minimum, maximum) across a series' points, or std::nullopt when it has none – the span a series lane's own scale is built over (TL-92). Pure.

std::vector< ew::core::TimedFieldValue > ew::app::withTimedReading(std::vector< ew::core::TimedFieldValue > values, const QString &key, qint64 instant, double value)

Returns values with a reading of value recorded for key at instant – the model edit behind entering a value directly on a series lane (TL-91). An existing reading at that exact (key, instant) is replaced (a corrected reading overriding an earlier one, matching how timelineSeries keeps the last value for an instant); otherwise the new reading is appended. Other keys and other instants are carried through untouched, so a value entered on one series never disturbs another. The number is stored in a round-trip-faithful text form. The caller wraps the result in a SetEntityTimedValuesCommand so the change is one undoable step. Pure.