1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! Plot interaction-mode actions, mirroring silx `silx.gui.plot.actions.mode`.
//!
//! silx exposes `ZoomModeAction` (`mode.py:45`) and `PanModeAction`
//! (`mode.py:108`) as checkable `QAction`s that call
//! `plot.setInteractiveMode("zoom" | "pan")`. egui is immediate-mode, so each
//! action here is a plain function that performs the one state transition the
//! corresponding silx `QAction._actionTriggered` does — setting the
//! [`PlotWidget`]'s [`PlotInteractionMode`] — without the `QAction`,
//! `checkable`, or signal machinery.
//!
//! [`zoom_mode`] and [`pan_mode`] mirror silx directly. silx has no
//! `MaskModeAction` — its `MaskToolsWidget` owns its pencil draw mode rather
//! than exposing it as a plot mode action — so [`mask_draw_mode`] is a
//! port-specific mode setter for [`PlotInteractionMode::MaskDraw`], grouped here
//! with the other mode setters because it sets a plot interaction mode.
//! [`select_mode`] sets the port's [`PlotInteractionMode::Select`] (item / ROI
//! handle editing), which has no standalone silx action either.
//!
//! These are thin setters over [`PlotWidget::set_interaction_mode`]: a single
//! state transition each, named after the silx actions so they group with the
//! other `actions/*` ports. The load-bearing per-mode gating lives in
//! `apply_interaction` (tested there); the only logic here is the mode each
//! setter maps to, exercised by `mode_for_*` pure helpers below.
use cratePlotWidget;
use cratePlotInteractionMode;
/// The interaction mode [`zoom_mode`] sets (silx `ZoomModeAction`,
/// `mode.py:45`). Pure, so the mapping is unit-testable without a GPU backend.
/// The interaction mode [`pan_mode`] sets (silx `PanModeAction`,
/// `mode.py:108`). Pure, so the mapping is unit-testable without a GPU backend.
/// The interaction mode [`mask_draw_mode`] sets (port-specific pencil/mask draw
/// mode; silx's `MaskToolsWidget` owns this). Pure, so the mapping is
/// unit-testable without a GPU backend.
/// The interaction mode [`select_mode`] sets (port-specific item / ROI-handle
/// select mode). Pure, so the mapping is unit-testable without a GPU backend.
/// Put `plot` into box-zoom mode (silx `ZoomModeAction._actionTriggered` →
/// `plot.setInteractiveMode("zoom")`, `mode.py:45`).
/// Put `plot` into pan mode (silx `PanModeAction._actionTriggered` →
/// `plot.setInteractiveMode("pan")`, `mode.py:108`).
/// Put `plot` into pencil / mask-draw mode ([`PlotInteractionMode::MaskDraw`]),
/// where the primary drag is reserved for mask painting. Mirrors silx
/// `MaskToolsWidget` activating the plot's pencil draw interaction
/// (`MaskToolsWidget.py:849-876`); silx has no standalone `MaskModeAction`, so
/// this is the port's mode setter for that state.
/// Put `plot` into select mode ([`PlotInteractionMode::Select`]), where primary
/// clicks select items and primary drags edit ROI handles without starting a
/// box zoom. Port-specific (no standalone silx action).