Skip to main content

fret_chart/retained/
output.rs

1use std::collections::BTreeMap;
2
3use delinea::engine::window::DataWindow;
4use delinea::{BrushSelection2D, LinkEvent, RowRange, SeriesId};
5
6use crate::LinkAxisKey;
7use crate::retained::TooltipTextLine;
8
9#[derive(Debug, Default, Clone, PartialEq)]
10pub struct ChartCanvasOutputSnapshot {
11    pub brush_selection_2d: Option<BrushSelection2D>,
12    pub brush_x_row_ranges_by_series: BTreeMap<SeriesId, RowRange>,
13    pub link_events: Vec<LinkEvent>,
14    pub tooltip_lines: Vec<TooltipTextLine>,
15    /// The current effective domain windows keyed in `LinkAxisKey` space.
16    ///
17    /// This is used by `LinkedChartGroup` to propagate domain window changes even when link
18    /// events are not observed (for example, when a consumer polls outputs rather than draining
19    /// per-step event queues).
20    pub domain_windows_by_key: BTreeMap<LinkAxisKey, Option<DataWindow>>,
21}
22
23#[derive(Debug, Default, Clone, PartialEq)]
24pub struct ChartCanvasOutput {
25    pub revision: u64,
26    /// Monotonic-ish counter that advances when `snapshot.link_events` is updated with a new
27    /// non-empty batch of link events.
28    ///
29    /// This exists because link events are inherently transient, and consumers (like
30    /// `LinkedChartGroup`) need a stable way to detect that a new event batch was produced even
31    /// if they observe the output model later.
32    pub link_events_revision: u64,
33    pub snapshot: ChartCanvasOutputSnapshot,
34}