Skip to main content

kithe_plot/controller/
action.rs

1//! View-to-controller intents.
2//!
3//! Every user interaction is represented as an `Action` and dispatched to the controller.
4
5use crate::model::{
6    AxisKind, Color, ImageFormat, ImageSize, LegendPosition, LineStyle, MarkerShape, RangePolicy,
7    ScaleType, SeriesId,
8};
9
10/// EN: UI intents emitted by View and consumed by Controller.
11/// RU: Namereniya UI, kotorye otpravlyaet View i obrabatyvaet Controller.
12#[allow(missing_docs)]
13pub enum Action {
14    /// EN: Import a CSV file from disk into the data table.
15    /// RU: Zagruska CSV-fayla s diska v tablitsu dannyh.
16    ImportFromCsv { path: String },
17
18    /// EN: Import a TXT/whitespace-delimited file from disk into the data table.
19    /// RU: Zagruska TXT-fayla s razdelitelyami probela v tablitsu dannyh.
20    ImportFromTxt { path: String },
21
22    /// EN: Set the chart title (non-empty enforced by controller).
23    /// RU: Ustanovit zagolovok grafa (ne mozhet byt pustym).
24    SetChartTitle(String),
25
26    /// EN: Set axis displayed label text (non-empty enforced by controller).
27    /// RU: Ustanovit podpis osi (ne mozhet byt pustoy).
28    SetAxisLabel {
29        axis: AxisKind,
30        label: String,
31    },
32
33    /// EN: Set the tick label font size for the axis (clamped to >= 8).
34    /// RU: Ustanovit razmer shrifta deleniya osi (ne menee 8).
35    SetAxisLabelFontSize {
36        axis: AxisKind,
37        font_size: u32,
38    },
39
40    /// EN: Set the axis title font size (clamped to >= 8).
41    /// RU: Ustanovit razmer shrifta nazvaniya osi (ne menee 8).
42    SetAxisTitleFontSize {
43        axis: AxisKind,
44        font_size: u32,
45    },
46
47    /// EN: Switch axis scale (Linear/Log10/LogE). Log scales drop non-positive values.
48    /// RU: Perekluchit shkalu osi (Linear/Log10/LogE). Pri log-shkale nepoloshitelnye znacheniya ignoriruyutsya.
49    SetAxisScale {
50        axis: AxisKind,
51        scale: ScaleType,
52    },
53
54    /// EN: Set axis range policy (Auto or Manual[min, max]). Manual validated so min < max.
55    /// RU: Ustanovit diapazon osi (Auto ili Manual[min, max]). Dlya Manual min < max obyazatelno.
56    SetAxisRange {
57        axis: AxisKind,
58        range: RangePolicy,
59    },
60
61    /// EN: Override major tick step (None = auto).
62    /// RU: Zadat shag osnovnyh dekeniy (None = avto).
63    SetAxisMajorTickStep {
64        axis: AxisKind,
65        step: Option<f64>,
66    },
67
68    /// EN: Set number of minor ticks per major step.
69    /// RU: Kolichestvo vtorostepennyh dekeniy na odin osnovnoy shag.
70    SetAxisMinorTicks {
71        axis: AxisKind,
72        per_major: u16,
73    },
74
75    /// EN: Add a new data series; x/y columns may be empty to use defaults.
76    /// RU: Dobavit novuyu seriyu; stolbtsy x/y mogut byt pustymi (po umolchaniyu).
77    AddSeries {
78        name: String,
79        x_column: String,
80        y_column: String,
81    },
82
83    /// EN: Remove existing series by id (controller prevents removing the last one).
84    /// RU: Udalit sushchestvuyushchuyu seriyu po id (nelzya udalit poslednyuyu).
85    RemoveSeries {
86        series_id: SeriesId,
87    },
88
89    /// EN: Rename series.
90    /// RU: Pereimenovat seriyu.
91    RenameSeries {
92        series_id: SeriesId,
93        name: String,
94    },
95
96    /// EN: Toggle series visibility.
97    /// RU: Perekluchit vidimost serii.
98    SetSeriesVisibility {
99        series_id: SeriesId,
100        visible: bool,
101    },
102
103    /// EN: Change the X column for the series (must exist in the table).
104    /// RU: Izmenit X-stolbets serii (dolzhen sushchestvovat v tablice).
105    SetSeriesXColumn {
106        series_id: SeriesId,
107        x_column: String,
108    },
109
110    /// EN: Change the Y column for the series (must exist in the table).
111    /// RU: Izmenit Y-stolbets serii (dolzhen sushchestvovat v tablice).
112    SetSeriesYColumn {
113        series_id: SeriesId,
114        y_column: String,
115    },
116
117    /// EN: Set series color (RGBA bytes).
118    /// RU: Ustanovit tsvet serii (RGBA v baytah).
119    SetSeriesColor {
120        series_id: SeriesId,
121        color: Color,
122    },
123
124    /// EN: Set series line width (> 0 enforced).
125    /// RU: Ustanovit tolshchinu linii serii (> 0 obyazatelno).
126    SetSeriesLineWidth {
127        series_id: SeriesId,
128        width: f32,
129    },
130
131    /// EN: Set series line style (Solid/Dashed/Dotted).
132    /// RU: Ustanovit stil linii serii (Solid/Dashed/Dotted).
133    SetSeriesLineStyle {
134        series_id: SeriesId,
135        line_style: LineStyle,
136    },
137
138    /// EN: Enable/disable markers and/or change marker size.
139    /// RU: Vklyuchit/otklyuchit markery i/ili izmenit ih razmer.
140    SetSeriesMarker {
141        series_id: SeriesId,
142        marker: Option<MarkerShape>,
143        size: f32,
144    },
145
146    /// EN: Toggle legend visibility.
147    /// RU: Perekluchit vidimost legendy.
148    SetLegendVisible(bool),
149
150    /// EN: Set legend title (None = no title; controller trims/filters empty strings).
151    /// RU: Ustanovit zagolovok legendy (None = bez zagolovka; pustye stroki otsekaetsya).
152    SetLegendTitle(Option<String>),
153
154    /// EN: Change legend position (top/bottom left/right).
155    /// RU: Izmenit pozitsiyu legendy (verh/nis levo/pravo).
156    SetLegendPosition(LegendPosition),
157
158    /// EN: Set legend font size (>= 8).
159    /// RU: Ustanovit razmer shrifta legendy (>= 8).
160    SetLegendFontSize(u32),
161
162    /// EN: Set legend font color.
163    /// RU: Ustanovit tsvet shrifta legendy.
164    SetLegendFontColor(Color),
165
166    /// EN: Set outer margin around the chart area (in pixels).
167    /// RU: Ustanovit vneshniy otstup vokrug grafa (pikseli).
168    SetLayoutMargin(u32),
169
170    /// EN: Set bottom label area size (affects X axis tick labels and title).
171    /// RU: Ustanovit vysotu nizhney oblasti podpisey (vliyaet na X-metki i zagolovok osi).
172    SetXLabelAreaSize(u32),
173
174    /// EN: Set left label area size (affects Y axis tick labels and title).
175    /// RU: Ustanovit shirinu levoy oblasti podpisey (vliyaet na Y-metki i zagolovok osi).
176    SetYLabelAreaSize(u32),
177
178    /// EN: Set chart title font size (>= 8).
179    /// RU: Ustanovit razmer shrifta zagolovka grafa (>= 8).
180    SetLabelFontSize(u32),
181
182    /// EN: Set chart title font color.
183    /// RU: Ustanovit tsvet shrifta zagolovka grafa.
184    SetLabelFontColor(Color),
185
186    /// EN: Export plot to a file path in a given format and size.
187    /// RU: Eksportirovat grafik v ukazannyy fail, format i razmer.
188    RequestSaveAs {
189        path: String,
190        format: ImageFormat,
191        size: ImageSize,
192    },
193
194    /// EN: Undo last command if any.
195    /// RU: Otmennit poslednyuyu komandu esli ona est.
196    Undo,
197
198    /// EN: Redo last undone command if any.
199    /// RU: Povtorit poslednyuyu otmennennuyu komandu esli ona est.
200    Redo,
201
202    /// EN: Reserved for future: reset all plot settings to defaults.
203    /// RU: Zarezervirovano: sbrosit vse nastroiki grafa k znacheniyam po umolchaniyu.
204    ResetPlot,
205}