brep_render/assembly_status.rs
1//! The ONE assembly-constraint status → label/color map. Both the Assembly
2//! Constraints panel's row status labels AND the viewport overlay labels (lane G)
3//! read THIS module — the status vocabulary and its colors are never re-declared
4//! anywhere else (the UI-consistency directive).
5//!
6//! Colors are the captured palette: grey `#8e8e93` (disabled), green `#30d158`
7//! (satisfied), yellow `#ffd60a` (adjusting / everything indeterminate — also
8//! the default), red `#ff3b30` (blocked / duplicate / error / failed), magenta
9//! `#ff2d92` (a named conflict: the minimal set of constraints that fight). Exposed
10//! as plain sRGB byte triples so this stays egui-free (reusable by any painter).
11
12/// The human label for a constraint `persistentData.status` word. Unknown /
13/// empty statuses read as "Pending" (a constraint that has never run).
14pub fn status_label(status: &str) -> &'static str {
15 match status {
16 "disabled" => "Disabled",
17 "satisfied" => "Satisfied",
18 "adjusted" | "adjusting" => "Adjusting",
19 "blocked" => "Blocked",
20 "pending" | "" => "Pending",
21 "duplicate" => "Duplicate",
22 "error" => "Error",
23 "conflict" => "Conflict",
24 "incomplete" => "Incomplete",
25 "invalid-selection" => "Invalid selection",
26 "unsupported-selection" | "unimplemented" => "Unimplemented",
27 "pending-component" => "Pending component",
28 "fixed" => "Locked",
29 "noop" => "No change",
30 "apply-failed" => "Failed",
31 _ => "Pending",
32 }
33}
34
35/// The status color as sRGB bytes. Grey for disabled, green for satisfied,
36/// red for the error family (blocked / duplicate / error / apply-failed),
37/// yellow (`#ffd60a`) for adjusting and every indeterminate status — the
38/// captured default.
39pub fn status_color_rgb(status: &str) -> [u8; 3] {
40 match status {
41 "disabled" => [0x8e, 0x8e, 0x93],
42 "satisfied" => [0x30, 0xd1, 0x58],
43 "blocked" | "duplicate" | "error" | "invalid-selection" | "apply-failed" => {
44 [0xff, 0x3b, 0x30]
45 }
46 "unsupported-selection" | "unimplemented" => [0xff, 0x9f, 0x0a],
47 // A named conflict: magenta, told apart from a plain error at a glance.
48 "conflict" => [0xff, 0x2d, 0x92],
49 _ => [0xff, 0xd6, 0x0a],
50 }
51}
52
53/// The status color as a CSS hex string (`#rrggbb`) — the overlay/label lanes
54/// that speak CSS-hex use this so the byte triple and the hex can never drift.
55pub fn status_color_hex(status: &str) -> String {
56 let [r, g, b] = status_color_rgb(status);
57 format!("#{r:02x}{g:02x}{b:02x}")
58}
59
60/// Rank a status for the structure tree's per-component ROLLUP dot: the WORST
61/// status across a component's constraints wins. Higher = worse. Order:
62/// error family (3) > indeterminate/adjusting (2) > satisfied (1) >
63/// disabled (0).
64pub fn status_severity(status: &str) -> u8 {
65 match status {
66 "disabled" => 0,
67 "satisfied" => 1,
68 "blocked" | "duplicate" | "error" | "apply-failed" | "conflict" => 3,
69 _ => 2,
70 }
71}
72