brep_render/engine_state.rs
1//! [`EngineState`] — the windowing-agnostic viewer state machine the host UI
2//! programs against (R3): scene + camera + controls + settings + emphasis, plus
3//! the whole event/command/query surface (run-history feed, pointer/wheel
4//! ingestion, camera commands, picking, world→screen, visibility). No GPU, no
5//! canvas — the wasm `Engine` and the winit desktop shell both wrap this; it is
6//! fully unit-testable on native.
7//!
8//! Everything crosses the R3 boundary as plain JSON/scalars: the host never holds a
9//! renderer object, only names, ids, and JSON.
10
11use crate::controls::ArcballControls;
12use crate::history::History;
13use crate::pick::{self, PickOptions};
14use crate::scene::RenderScene;
15use crate::style::{Emphasis, RenderSettings};
16use crate::view::ViewCamera;
17use crate::widgets::{gizmo_camera, WidgetOverlay, WidgetRegistry};
18use brep_kernel::HistoryRequest;
19use std::collections::HashMap;
20
21/// One DIALOG row's hover state — which panel lit it, the row's own TEXT, and
22/// what that text resolved to in the scene.
23///
24/// The row text is the memo key rather than the candidate's name because the two
25/// differ whenever the derived-face fallback fires (a fillet's `Edges` row reads
26/// `A|B[0]` while the face it lights is `F1:BLEND:A|B[0]` — see
27/// [`EngineState::hover_entity_by_name`]). An unresolvable row memoizes as
28/// `candidate: None`, so a held hover over a name the scene does not carry scans
29/// the scene ONCE, not once per frame.
30#[derive(Clone)]
31pub(crate) struct DialogHover {
32 /// Which panel set it (`"history"`, `"constraints"`, `"pmi"`, `"refsel"`) —
33 /// [`EngineState::dialog_hover_end`] acts only for the owner that set it, so a
34 /// pane that never hovered a row cannot end another pane's hover.
35 pub(crate) owner: &'static str,
36 /// The row's TEXT, exactly as the dialog listed it.
37 pub(crate) row: String,
38 /// What it resolved to, or `None` for a row the scene does not carry.
39 pub(crate) candidate: Option<pick::PickCandidate>,
40}
41
42pub struct EngineState {
43 pub scene: RenderScene,
44 pub camera: ViewCamera,
45 pub controls: ArcballControls,
46 pub settings: RenderSettings,
47 pub emphasis: Emphasis,
48 /// In-scene overlay widgets: datums/dimensions/curves, transform
49 /// gizmo, ViewCube — fed as JSON, drawn by the render core's overlay pass.
50 pub widgets: WidgetRegistry,
51 /// The engine-owned editable model recipe (ordered features + rollback
52 /// index) — the SINGLE source of truth for the model. The UI never keeps its
53 /// own copy; it mutates/reads this through the `history_*` / feature methods.
54 pub history: History,
55 interference_sessions: std::collections::BTreeMap<String, interference::InterferenceCursor>,
56 interference_sequence: u64,
57 illustration_snapshot: Option<illustration::IllustrationSnapshot>,
58 geometry_diagnostics: std::collections::BTreeMap<String, serde_json::Value>,
59 /// The build report (`{featureErrors, unresolved, displayErrors}`) of the
60 /// last history run, so the UI can show it without re-running.
61 history_report: String,
62 /// The Properties-panel metadata store: user attributes keyed by OBJECT NAME
63 /// (solid / face / edge kernel name), NOT feature id — so a record survives
64 /// feature edits as long as the object's name persists. Persisted with the
65 /// model (a top-level `metadata` field in the history document); see the
66 /// [`crate::metadata`] module for the store + the object-info/measurement API.
67 pub metadata: crate::metadata::MetadataStore,
68 /// Derived preview data stays outside the recipe and undo history: the
69 /// document's own picture at a history edit serial (opened with it, or the
70 /// last one a save rendered), and the last picture a save produced by key.
71 document_thumbnail: std::cell::RefCell<Option<(u64, serde_json::Value)>>,
72 thumbnail_cache: std::cell::RefCell<Option<(Vec<u64>, serde_json::Value)>>,
73 /// Bumped whenever settings change so the renderer re-derives per-solid
74 /// base styles (a cheap key, not a per-frame diff).
75 pub settings_generation: u64,
76 /// The engine sets this whenever the camera/scene/emphasis changed; the
77 /// presentation shell renders only when it is set (R22 on-demand render —
78 /// the OrthoCameraIdle matrix-compare analogue, made explicit).
79 pub dirty: bool,
80 /// The modal reference-selection state (the ref-select widget). `Some` while
81 /// the user is picking references for a feature-dialog field; `None`
82 /// otherwise. The picked-name list here is the SINGLE source of truth while
83 /// active (the UI reads it back; the viewport appends to it on a pick).
84 pub ref_select: Option<RefSelectState>,
85 /// Which entity KINDS a plain viewport click may select (the selection
86 /// filter, mirroring the earlier `SelectionFilter.allowedSelectionTypes`). `select_top_at`
87 /// consults it via `pick_filtered`; see the appended `SelectionFilter` impl
88 /// block near the end of this file for the state + honoring logic.
89 pub selection_filter: SelectionFilter,
90 /// The transform-controls gizmo controller: which feature (if any) has the
91 /// move/rotate gizmo armed (via the in-viewport center-sphere toggle), plus the
92 /// in-flight handle drag. All the arm/drag/apply logic lives in the appended
93 /// transform-gizmo impl block near the end of this file.
94 pub transform_gizmo: TransformArm,
95 /// The COMPONENT Move gizmo controller (assemblies §8.5): which ACOMP
96 /// instance has the bbox-center move/rotate gizmo armed, the translate/
97 /// rotate cycle mode, and the commit-on-release drag. Exclusive with
98 /// `transform_gizmo` (shared widget slot). See `component_move.rs`.
99 pub component_move: ComponentMoveArm,
100 /// The active engine-native sketch edit (`Some` while in sketch mode). Holds
101 /// the live [`crate::sketch::SketchSession`] plus the pre-entry camera + roll
102 /// to restore on exit. All the enter/exit/new logic lives in the appended
103 /// sketch-mode impl block at the END of this file.
104 sketch_edit: Option<SketchEdit>,
105 /// Sketch-mode camera lock. When true (the default on every sketch entry), the
106 /// camera is held flat-on to the sketch plane and an empty drag only PANS —
107 /// no orbit. Toggling it back on re-faces the camera to the plane. Meaningful
108 /// only while `sketch_edit` is `Some`. See the sketch-mode impl block.
109 sketch_camera_locked: bool,
110 /// Set for ONE frame when the sketch entity-LIST panel hovers a row (it calls
111 /// [`sketch_hover_entity`](Self::sketch_hover_entity)). The viewport, which
112 /// draws AFTER the panel and would otherwise `sketch_clear_hover` because the
113 /// pointer is off the viewport, consumes this flag via
114 /// [`take_sketch_list_hover`](Self::take_sketch_list_hover) and keeps the
115 /// panel-set hover so list→canvas highlight survives the frame.
116 sketch_list_hover_active: bool,
117 /// Transient user-facing notices (e.g. a sketch solve that failed after an
118 /// edit). The shell drains them each frame via [`take_notices`](Self::take_notices)
119 /// into a toast overlay; the engine only queues. Replaces the swallowed
120 /// `eprintln!` on the interactive re-solve paths.
121 notices: Vec<String>,
122 /// Notices that are NOT errors — a warning, or a success such as "Updated 2
123 /// part(s)" — with their severity, queued by
124 /// [`push_notice_as`](Self::push_notice_as). Beside [`Self::notices`] rather
125 /// than in it, so every existing `push_notice` stays an error unchanged.
126 graded_notices: Vec<(NoticeSeverity, String)>,
127 /// Committed-sketch visibility: the feature ids whose persistent committed-sketch
128 /// overlay is HIDDEN (its Scene-tree checkbox off). Absent = visible. See the
129 /// committed-sketch impl block appended at the END of this file.
130 hidden_sketches: std::collections::HashSet<String>,
131 /// The committed-sketch feature ids whose overlay groups were fed on the LAST
132 /// [`refresh_committed_sketches`](Self::refresh_committed_sketches), so an id that
133 /// is no longer shown (rolled back, deleted, hidden, or became the active edit)
134 /// can have its now-stale groups cleared.
135 shown_sketch_ids: Vec<String>,
136 /// The board bodies fed on the LAST
137 /// [`refresh_board_geometry`](Self::refresh_board_geometry), in stack order,
138 /// so a body this build did not produce can be swept out of the scene.
139 /// Parallels [`shown_sketch_ids`].
140 shown_board_ids: Vec<String>,
141 /// The eCAD board those bodies were built from — the rebuild test. A
142 /// SCHEMATIC edit rewrites the whole `pcb` block with the same board inside
143 /// it, and this is what makes that edit free.
144 board_built_from: Option<brep_ecad_core::board::Board>,
145 /// The pin-to-net map those bodies' NET COLOURS were built from. The board
146 /// alone does not decide them — a copper island carries the net of the pads
147 /// it touches, and which net a pad carries is the SCHEMATIC's answer — so
148 /// this is the second half of the rebuild test. Empty for a board with no
149 /// placements, which can carry no net at all.
150 board_pin_nets: std::collections::BTreeMap<(brep_ecad_core::Uuid, String), String>,
151 /// What that build cost, for the Scene tree and the tests.
152 board_build: board_geometry::BoardBuild,
153 /// The built bodies themselves, KEPT across runs. The scene reconcile drops
154 /// every derived body, so without this a dense board would be re-meshed on
155 /// every history run; a clone of these is what goes back in instead.
156 board_displays: Vec<crate::scene::SolidDisplay>,
157 /// The named plane FRAMES the last history run resolved `(frame name, frame)`.
158 /// Stored so [`refresh_construction_datums`](Self::refresh_construction_datums)
159 /// (and datum selection) can display/pick the construction datum/plane frames
160 /// without re-running. Filled from the run's
161 /// [`crate::pipeline::SceneBuildReport::frames`]; the D/P filter is applied at
162 /// display time (a frame name maps to its producing feature TYPE via the
163 /// history). See the appended construction-datum impl block at the END.
164 construction_frames: Vec<(String, brep_kernel::Frame)>,
165 /// The solved sketch PROFILES the last history run produced `(sketch id,
166 /// profile)`. Stored so [`refresh_committed_sketches`](Self::refresh_committed_sketches)
167 /// can synthesize each committed sketch's SHEET SOLID (planar face + named
168 /// boundary edges + corner vertices) without re-running. Filled from the run's
169 /// [`crate::pipeline::SceneBuildReport::profiles`]; rollback / active-edit /
170 /// visibility gating is applied at display time.
171 sketch_profiles: Vec<(String, brep_kernel::SketchProfile)>,
172 /// The named PATH chains the last history run produced `(path name, curves)`.
173 /// Stored alongside [`sketch_profiles`](Self::sketch_profiles) so
174 /// [`refresh_committed_sketches`](Self::refresh_committed_sketches) can draw the
175 /// sketch geometry no closed profile covers: a sketch's OPEN chain publishes no
176 /// profile, so the sheet builder had nothing to draw it from and an open sketch
177 /// was invisible in 3D. Filled from the run's
178 /// [`crate::pipeline::SceneBuildReport::paths`]; the per-segment `{id}:G{gid}`
179 /// entries are the display input (the whole-chain `{id}` entry duplicates them
180 /// and `{id}:REF:{source}` is projected reference geometry).
181 sketch_paths: Vec<(String, Vec<brep_kernel::NurbsCurve>)>,
182 /// The named world POINTS the last history run produced `(point name, point)`.
183 /// Stored alongside [`sketch_paths`](Self::sketch_paths) so
184 /// [`refresh_committed_sketches`](Self::refresh_committed_sketches) can draw the
185 /// sketch points no segment covers: a points-only sketch (a hole-placement
186 /// sketch) publishes no profile and no path, so it had nothing to draw from
187 /// and was invisible in 3D. Filled from the run's
188 /// [`crate::pipeline::SceneBuildReport::points`]; the per-point `{id}:P{pid}`
189 /// entries are the display input (construction points are skipped at draw
190 /// time, like construction geometry).
191 sketch_points: Vec<(String, brep_kernel::ScenePoint)>,
192 /// The named axis LINES the last history run produced `(axis name, line)`.
193 /// Stored so the feature-dimension angle gizmo can resolve a revolve `axis`
194 /// reference to a world line without re-running. Filled from the run's
195 /// [`crate::pipeline::SceneBuildReport::axes`].
196 sketch_axes: Vec<(String, brep_kernel::Axis)>,
197 /// The wire-harness routing report of the last APPLIED run (`None` before
198 /// the first run). Filled from [`crate::pipeline::SceneBuildReport::wire_harness`];
199 /// the harness panel reads it, the committed-curve display reads the port
200 /// kinds off it. See the appended wire-harness impl block.
201 wire_harness_report: Option<brep_kernel::WireHarnessReport>,
202 /// The PORTS tail's report of the last APPLIED run (`None` before the first
203 /// run, and for a document that declares no `ports` block). Filled from
204 /// [`crate::pipeline::SceneBuildReport::ports`]; the Qualify panel reads it,
205 /// and it is the only place the tail's refused names and unresolved
206 /// references surface, the tail not being a feature.
207 ports_report: Option<brep_kernel::PortsReport>,
208 /// The PMI tail's report of the last APPLIED run (`pmi_ops.rs`).
209 pub(crate) pmi_report: Option<brep_kernel::PmiReport>,
210 /// The ACTIVE PMI view (engine memory, never persisted): its camera,
211 /// display state and explode poses are applied; its annotations drawn.
212 pub(crate) pmi_active_view: Option<String>,
213 /// The annotation whose form the PMI panel shows (engine memory). Never
214 /// assign `Some` here: go through [`EngineState::open_pmi_annotation`], the
215 /// one place that counts the open.
216 pub(crate) pmi_open_annotation: Option<String>,
217 /// The VIEW whose form the PMI panel shows (engine memory) — exclusive
218 /// with [`Self::pmi_open_annotation`], since the pane shows one dialog.
219 /// Never assign `Some` here: go through [`EngineState::open_pmi_view`].
220 pub(crate) pmi_open_view: Option<String>,
221 /// The annotation SELECTED in the PMI tree or by its viewport label: the
222 /// tree row's highlight and the label's accent. Cleared with the selection
223 /// (Esc / Clear / a click on empty space); read through
224 /// [`EngineState::pmi_selected_annotation`], which prunes a stale id.
225 pub(crate) pmi_selected_annotation: Option<String>,
226 /// The VIEW selected in the PMI tree — its row's highlight. Selecting a
227 /// view never ACTIVATES it (a double click does); exclusive with
228 /// [`Self::pmi_selected_annotation`], since the tree selects one row.
229 /// Read through [`EngineState::pmi_selected_view`], which prunes a stale id.
230 pub(crate) pmi_selected_view: Option<String>,
231 /// How many times a PMI dialog — an annotation's or a view's — has been
232 /// OPENED: monotonic, never reset, closes do not count. The app's dialog
233 /// door keys on it beside the subject so a re-open of the dialog that is
234 /// ALREADY open is still one open event (a viewport label double click on the
235 /// annotation whose form is up, which a user makes precisely because they
236 /// are on another tab).
237 pub(crate) pmi_dialog_opens: u64,
238 /// The modeling camera / visibility / wireframe remembered on entering
239 /// the PMI workbench, restored when a view deactivates or the workbench
240 /// is left.
241 pub(crate) pmi_modeling: Option<pmi_ops::PmiModelingSnapshot>,
242 /// The un-exploded displays of the solids the active view's explode
243 /// annotations posed, for an exact restore.
244 pub(crate) pmi_explode_originals: std::collections::HashMap<String, crate::scene::SolidDisplay>,
245 /// A balloon whose dragged bubble could not be re-projected yet because
246 /// the scene did not hold its occurrence's exact solids: re-derived when
247 /// the topology reply lands (`pmi_refresh_stale_balloon`).
248 pub(crate) pmi_balloon_stale: Option<String>,
249 /// `(world_per_pixel, view direction)` the PMI overlay was last baked at.
250 pub(crate) pmi_overlay_key: Option<(f64, [f64; 3])>,
251 pub(crate) pmi_hovered: Option<String>,
252 pub(crate) pmi_label_hover_active: bool,
253 /// The sheet the sheet viewport shows (engine memory, never persisted).
254 /// `None` = the 3D view (`sheet_ops.rs`).
255 pub(crate) sheet_open: Option<String>,
256 /// The sheet or placed view whose form the Sheets pane shows. Never assign
257 /// `Some` here: go through [`EngineState::open_sheet_object`], the one
258 /// place that counts the open.
259 pub(crate) sheet_open_object: Option<String>,
260 /// How many times a sheet object's form has been OPENED — the sheet half
261 /// of the same counter as [`Self::pmi_dialog_opens`], read by the
262 /// app's dialog door so a re-open of the object already open still counts.
263 pub(crate) sheet_object_opens: u64,
264 /// The placed view, sheet dimension or ordinate set SELECTED in the Sheets
265 /// tree or on the paper: the tree row's highlight and the object's accent
266 /// on the sheet. Cleared with the selection; read through
267 /// [`EngineState::sheet_selected_object`], which prunes a stale id.
268 pub(crate) sheet_selected_object: Option<String>,
269 /// The last projected sheet, kept until the model or the block moves: a
270 /// sheet is a hidden-line pass over the whole model and must never run
271 /// per frame.
272 pub(crate) sheet_cache: Option<sheet_ops::SheetCache>,
273 /// The sheet's exact passes on the runner and waiting for it.
274 pub(crate) sheet_lines: sheet_ops::SheetLinesWork,
275 /// The open document's name, as the shell means it (the tab, the file, the
276 /// root PRODUCT of a STEP export). Engine memory, never persisted: the
277 /// document does not carry its own name, the SHELL owns it, and it is here
278 /// because a drawing sheet's TITLE BLOCK prints it. Set every frame by the
279 /// app from the active tab (a no-op when unchanged).
280 pub(crate) document_name: String,
281 /// What the spline-anchor cage overlay was last fed for — `(spline id,
282 /// selected anchor, applied run generation)` — so the per-frame refresh
283 /// the history panel makes while an SP form is open is a no-op until one
284 /// of those moves. See `spline_edit.rs`.
285 spline_overlay_key: Option<(String, Option<usize>, u64)>,
286 /// Whether the ports placed components carry (`ACOMP1:PORT1`) draw their
287 /// sheets. The app sets it from the active workbench — one that shows the
288 /// Wire Harness panel; a document's own PORT features always draw.
289 component_ports_visible: bool,
290 /// The spline whose anchor editor is open (fed by the history panel with
291 /// the cage overlay), so a viewport click on one of its anchor dots selects
292 /// that anchor; the index of the last such pick, until the panel takes it.
293 spline_edit_feature: Option<String>,
294 spline_anchor_picked: Option<usize>,
295 /// Construction datum/plane visibility: the frame NAMES whose datum plane is
296 /// HIDDEN (its Scene-tree checkbox off). Absent = visible. Mirrors
297 /// [`hidden_sketches`].
298 hidden_datums: std::collections::HashSet<String>,
299 /// The datum frame NAMES fed to the widget on the LAST
300 /// [`refresh_construction_datums`](Self::refresh_construction_datums). The datum
301 /// feed REPLACES its set wholesale each call, so this is a bookkeeping mirror of
302 /// what is currently shown (parallels [`shown_sketch_ids`]).
303 shown_datum_names: Vec<String>,
304 /// The history-run seam (M2a of the off-thread runner). Owns the scene-free
305 /// runner + its delta baseline (`name → last-emitted handle`) ACROSS reruns:
306 /// [`rerun_history`](Self::rerun_history) SUBMITS a run tagged with
307 /// [`run_generation`](Self::run_generation), and [`pump`](Self::pump) drains
308 /// the completed reply and [`apply_run_output`](Self::apply_run_output)s its
309 /// delta to [`Self::scene`]. The [`InlineRunner`](crate::runner::InlineRunner)
310 /// default runs synchronously (submit → immediate poll, byte-identical to the
311 /// old in-place reconcile); a background thread/worker impl slots in behind the
312 /// same trait in M2b/M3. Reset on a document switch
313 /// ([`set_history_json`](Self::set_history_json)) so a new model rebuilds fully.
314 pub(crate) runner: Box<dyn crate::runner::HistoryRunner>,
315 plugins: plugins::Plugins,
316 /// Monotonic run counter: bumped each time [`rerun_history`](Self::rerun_history)
317 /// SUBMITS a run, and stamped onto the reply so a stale reply (a newer run that
318 /// finished first) can be dropped. `run_generation != applied_generation` means
319 /// a run is in flight (always equal for the synchronous Inline runner).
320 run_generation: u64,
321 /// The generation of the last reply [`pump`](Self::pump) APPLIED — the high-water
322 /// mark that gates stale replies.
323 applied_generation: u64,
324 /// The latest [`crate::runner::RunProgress`] of the run in flight (a
325 /// background runner posts one before each feature it executes), or
326 /// `None` when nothing is running. Names what the spinner is waiting on.
327 run_progress: Option<crate::runner::RunProgress>,
328 /// The feature the last CANCELLED run was executing (`Some("")` when the
329 /// run was cancelled before any progress arrived), cleared by the next
330 /// submit. The history header shows it until the model is rebuilt.
331 cancelled_run: Option<String>,
332 /// A TRANSIENT expressions source the runs evaluate instead of the
333 /// document's own (the family table's row preview). Never written into
334 /// the history: not saved, not undone, not dirty. See
335 /// [`Self::set_expression_preview`].
336 expression_preview: Option<ExpressionPreview>,
337 /// How many run replies came back from the runner (applied or dropped as
338 /// stale). A run the runner coalesced away never replies, so this counts
339 /// the runs actually EXECUTED.
340 runs_replied: u64,
341 /// Displays shipped by replies [`pump`](Self::pump) DROPPED as superseded,
342 /// by solid name, latest wins. A background runner executes every run it
343 /// is handed and its delta baseline (`name → last-emitted handle`) advances
344 /// on each, so a later reply can say "unchanged, keep yours" about a
345 /// display that only ever travelled in a dropped reply (the reporter's
346 /// arrow-head drag: the frame that built the new radius was superseded by
347 /// the still-pointer frames that replayed its handle). The keep is served
348 /// from here when the scene's display is not the handle it names. Cleared
349 /// with the runner's baseline (document switch, cancel) and whenever a
350 /// fresh display for the name is applied.
351 superseded_displays: HashMap<String, crate::scene::SolidDisplay>,
352 /// A pending one-shot "frame the scene once the in-flight run lands" request.
353 /// Import / Open SUBMIT an async run (native [`ThreadRunner`], wasm worker) and
354 /// want to `zoom_to_fit` the RESULT — but the scene is still empty when they
355 /// return, so an immediate fit frames nothing (bbox empty → no-op). Instead they
356 /// set this flag and [`pump`](Self::pump) performs the fit on the first apply that
357 /// leaves the run no longer pending. Under the synchronous Inline runner the run
358 /// applies inside the submitting call's own `pump`, so the fit is still immediate.
359 pending_fit: bool,
360 /// EAGER provenance `name → creating-feature id` for the current resident
361 /// solids, shipped with each run ([`crate::pipeline::RunOutput::provenance`]) and
362 /// replaced wholesale in [`apply_run_output`](Self::apply_run_output). Answers
363 /// `creating_feature` + the Info tab's `creatingFeature` WITHOUT a cold
364 /// `execute_history` — the freeze side-door once the run lives off-thread.
365 pub(crate) provenance: std::collections::HashMap<String, String>,
366 /// EAGER ENTITY ORIGIN `face/edge NAME → ORIGINATING feature id` (FIRST writer in
367 /// timeline order), shipped with each run
368 /// ([`crate::pipeline::RunOutput::entity_origin`]) and replaced wholesale in
369 /// [`apply_run_output`](Self::apply_run_output). Unlike `provenance` (the SOLID's
370 /// LAST writer) this is the feature that gave the face/edge its NAME — the answer
371 /// `creating_feature` returns for a face/edge (the "Edit owning feature" action +
372 /// the Info tab's `creatingFeature`), so it rolls to the entity's origin, not the
373 /// owning solid's last producer.
374 pub(crate) entity_origin: std::collections::HashMap<String, String>,
375 /// Object-info MEASUREMENT cache `name → merged object-info JSON`, filled by
376 /// [`pump_queries`](crate::metadata) from the runner's replies and served every
377 /// frame a selection persists (so `object_info_json` fires ONE query per
378 /// selection, not one per frame). Invalidated on any geometry change
379 /// (`apply_run_output`) or metadata edit (`set_metadata_attribute`).
380 pub(crate) info_cache: std::collections::HashMap<String, String>,
381 /// In-flight measurement queries `id → object NAME` — the key needed to MERGE a
382 /// reply back into the info cache (inject `name` + `creatingFeature`, the latter
383 /// now resolved by the entity name itself). Cleared alongside `info_cache` on a
384 /// geometry change so a stale reply is dropped rather than caching a superseded
385 /// measurement.
386 pub(crate) pending_query: std::collections::HashMap<u64, String>,
387 /// Monotonic measurement-query id (pairs a [`crate::runner::MeasureReply`] back
388 /// with its `pending_query` entry).
389 pub(crate) next_query_id: u64,
390 /// Off-thread mesh reconstructions awaiting a runner reply.
391 pub(crate) pending_mesh_imports: std::collections::HashMap<u64, MeshImportDestination>,
392 pub(crate) mesh_preview_results: std::collections::VecDeque<crate::runner::MeshImportReply>,
393 /// Monotonic id for pairing mesh import replies with submissions.
394 pub(crate) next_mesh_import_id: u64,
395 /// Topology requests in flight (see [`crate::runner::TopologyRequest`]).
396 pub(crate) pending_topology: std::collections::HashSet<u64>,
397 /// Every resident handle asked for since the last applied run, answered or
398 /// not: a handle the runner could not clone is not asked for again until a
399 /// run brings new handles.
400 pub(crate) topology_asked: std::collections::HashSet<u32>,
401 /// Monotonic id for pairing topology replies with requests.
402 pub(crate) next_topology_id: u64,
403 /// The run's ASSEMBLY tail as the runner read it
404 /// ([`crate::pipeline::AssemblySync`]) — the constraint state, statuses, DOF
405 /// and overlay rows every assembly panel reads, adopted from the reply of the
406 /// last applied run. `None` for a componentless document. This is what
407 /// replaced the second, main-side `execute_history`: see `assembly_ops`.
408 pub(crate) assembly_sync: Option<crate::pipeline::AssemblySync>,
409 /// The scene's assembly COMPONENT records (deterministic id order), adopted
410 /// from [`Self::assembly_sync`] — the Assembly Structure tree's source.
411 /// Empty for componentless documents.
412 pub(crate) assembly_components: Vec<crate::pipeline::ComponentSnapshot>,
413 /// The [`Self::applied_generation`] the main-side kernel assembly SESSION was
414 /// last installed for (`None` = never). Only a constraint MUTATION needs one
415 /// — its solve runs against the resident geometry of the thread that asks —
416 /// so only `ensure_assembly_session` sets this. See `assembly_ops`.
417 pub(crate) assembly_session_generation: Option<u64>,
418 /// Every output name the last applied run CONSUMED
419 /// ([`crate::pipeline::RunOutput::consumed`]) — what the committed-sketch
420 /// refresh hides a consumed sketch by, and what it used to re-execute the
421 /// whole history on the UI thread to learn.
422 pub(crate) consumed_names: std::collections::HashSet<String>,
423 /// Re-entrancy guard for the parts-library resync in [`Self::pump`] (a
424 /// refused run re-runs, and `rerun_history` pumps).
425 pub(crate) library_resync: bool,
426 /// The assembly-constraint viewport overlays — the cached
427 /// [`crate::constraint_overlays::ConstraintOverlay`] records the engine last
428 /// built from the kernel session (`assembly_overlay_json` + state), the source
429 /// of the drawn leader/arrow group, the label feed, and the grabbable-handle
430 /// hit regions. Refreshed after every history apply and every constraint
431 /// mutation; see the appended assembly-overlay impl block.
432 pub(crate) constraint_overlays: Vec<crate::constraint_overlays::ConstraintOverlay>,
433 /// A live GRAB on a constraint's distance-arrow / angle-arc handle (`Some`
434 /// between `constraint_drag_begin` and `constraint_drag_release`): the drag
435 /// previews the value locally and COMMITS on release via
436 /// `assembly_update_constraint_json` (which auto-solves).
437 pub(crate) constraint_drag: Option<ConstraintDrag>,
438 /// The `world_per_pixel` the constraint overlay buffers were last baked at
439 /// (screen-constant arc/rod sizing): `ensure_constraint_overlay_current`
440 /// re-bakes when the camera zoom moves it materially. `0.0` = never baked.
441 constraint_overlay_wpp: f64,
442 /// The `world_per_pixel` the FEATURE-DIMENSION gizmo group
443 /// (`feature-dim-leaders`) was last baked at. The leaders' rod/cone/origin
444 /// sphere — and the angular arc's whole world RADIUS — are
445 /// `pixels × world_per_pixel`, so a zoom makes the drawn gizmo stale;
446 /// `ensure_feature_dimension_overlay_current` re-bakes on a material move.
447 /// `0.0` = nothing baked (gizmo disarmed / not in dimension mode).
448 /// See `feature_dims`.
449 pub(crate) feature_dim_overlay_wpp: f64,
450 /// The `world_per_pixel` the live SKETCH overlay groups (geometry, points,
451 /// preview, `sketch-dim-leaders`, `sketch-constraint-glyphs`) were last baked
452 /// at — construction dashes, dimension arrowheads and constraint glyphs are
453 /// all screen-constant. `ensure_sketch_overlay_current` re-bakes on a material
454 /// zoom. `0.0` = nothing baked (not in sketch mode). See `sketch_input`.
455 pub(crate) sketch_overlay_wpp: f64,
456 /// The constraint id whose referenced ELEMENTS the panel/label hover is
457 /// currently highlighting (dedupe key so a held hover doesn't re-bump the
458 /// emphasis generation every frame).
459 constraint_hovered: Option<String>,
460 /// Set for ONE frame when a constraint LABEL hover applied the element
461 /// highlight; the viewport's modeling hover branch consumes it (mirrors
462 /// [`Self::take_sketch_list_hover`]) so the scene hover doesn't clobber it.
463 constraint_label_hover_active: bool,
464 /// The SCENE-TREE row the pointer is over, as the pick candidate its hover
465 /// lit (the row→viewport highlight). Kept so
466 /// [`scene_tree_hover_end`](Self::scene_tree_hover_end) clears ONLY a hover
467 /// the tree itself set — never one the viewport lit in the meantime — and as
468 /// the dedupe key that keeps a held row hover from re-bumping the emphasis
469 /// generation every frame. See `scene_query.rs`.
470 scene_tree_hovered: Option<pick::PickCandidate>,
471 /// Set for ONE frame while a Scene-tree row is hovered; the viewport's
472 /// modeling hover branch consumes it via
473 /// [`take_scene_tree_hover`](Self::take_scene_tree_hover) and skips the
474 /// pointer-off-viewport `clear_hover` (mirrors
475 /// [`Self::take_sketch_list_hover`]) so the row-set highlight survives.
476 scene_tree_hover_active: bool,
477 /// The DIALOG row the pointer is over — a feature form's reference line, its
478 /// read-only `Outputs` line, or the reference picker card's picked-name line
479 /// (the row→viewport highlight, the twin of the Scene tree's above). Its OWN
480 /// slot, not the tree's: History, Constraints, PMI and the Scene tree can all
481 /// be on screen at once in a split dock, and a shared slot would let the pane
482 /// that draws second end the hover the pane that drew first had just set. See
483 /// [`DialogHover`] for what it memoizes and `scene_query.rs` for the API.
484 dialog_hovered: Option<DialogHover>,
485 /// Set for ONE frame while a dialog row is hovered; the viewport's modeling
486 /// hover branch consumes it via [`take_dialog_hover`](Self::take_dialog_hover)
487 /// and skips the pointer-off-viewport `clear_hover` (mirrors
488 /// [`Self::take_scene_tree_hover`]) so the row-set highlight survives.
489 dialog_hover_active: bool,
490 /// The constraint SELECTED via its viewport label chip (`Some` = selected):
491 /// drives the chip's selected accent, the context bar's Delete-constraint
492 /// action, and clears with the selection (Esc / Clear / delete). Read
493 /// through [`Self::selected_constraint`], which prunes a stale id.
494 selected_constraint: Option<String>,
495 /// The feature SELECTED in the history tree, beside the geometry selection
496 /// that selecting it made. It stays selected only while that geometry
497 /// selection is unchanged — a viewport pick, Esc or Clear replaces the
498 /// geometry and so deselects the feature. Read through
499 /// [`Self::selected_feature`].
500 selected_feature: Option<(String, selection_ux::FeatureSelection)>,
501 /// How many times a constraint's dialog has been OPENED through
502 /// [`Self::assembly_set_constraint_open`] — the constraint half of the same
503 /// counter as [`Self::pmi_dialog_opens`], read by the app's dialog door
504 /// so a re-open of the constraint already open still counts. The flag
505 /// itself lives in the kernel (it is part of the saved document), so this
506 /// counts the OPENS this engine performed, not the flag's history.
507 pub(crate) constraint_opens: u64,
508 /// The STEP product structure a [`Self::probe_step_assembly`] parsed, held
509 /// until the import dialog's button decides its fate: consumed by
510 /// [`Self::import_probed_step_assembly`], dropped by
511 /// [`Self::discard_probed_step_assembly`] (Cancel), by the next probe, or by
512 /// a document switch. The ONE parse of a structured STEP import lives here —
513 /// the dialog needs the counts BEFORE the user chooses, and re-parsing
514 /// multi-MB Part-21 text on the way back would double the most expensive step
515 /// of the import. See `model_io`'s import block.
516 pub(crate) pending_step_assembly: Option<brep_kernel::StepAssembly>,
517 /// STEP probes submitted to the runner and not yet answered (their ids).
518 pub(crate) pending_step_probes: std::collections::HashSet<u64>,
519 /// Answered probes awaiting [`Self::take_step_probe`], oldest first.
520 pub(crate) step_probe_results: std::collections::VecDeque<(u64, StepProbeOutcome)>,
521 /// Monotonic id pairing a probe reply with its submission.
522 pub(crate) next_step_probe_id: u64,
523}
524
525/// What a STEP probe found, as the file panel consumes it (see
526/// [`EngineState::submit_step_probe`]).
527#[derive(Debug, Clone, PartialEq)]
528pub enum StepProbeOutcome {
529 /// Product structure: the parsed assembly is stashed for
530 /// [`EngineState::import_probed_step_assembly`]; these are its counts.
531 Structure(model_io::StepAssemblyProbe),
532 /// No structure worth keeping — take the flat lane.
533 Flat,
534 /// The text did not parse as Part 21; the flat lane refuses it with its
535 /// own wording.
536 Failed(String),
537}
538
539/// A live constraint-handle drag: which constraint + which `inputParams` field
540/// (`distance` / `angle`), the params snapshot the commit mutates, and the live
541/// preview value the overlay/label show while dragging.
542#[derive(Debug, Clone)]
543pub struct ConstraintDrag {
544 pub id: String,
545 pub field: &'static str,
546 pub params: serde_json::Value,
547 pub preview: f64,
548}
549
550/// WHO a finished reference-selection commits to: a history FEATURE's params
551/// (the original widget) or an ASSEMBLY CONSTRAINT's `inputParams` (same modal,
552/// different commit lane — see `assembly_ops::begin_ref_select_for_constraint`).
553#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
554pub enum RefSelectTarget {
555 #[default]
556 Feature,
557 AssemblyConstraint,
558 /// ONE SPLINE ANCHOR's port attachment: `path` is unused, the picked name
559 /// must be a PORT feature id (a click on a port's drawn sheet), and Finish
560 /// writes `persistentData.spline.points[index].attachment` (see
561 /// `spline_edit.rs`).
562 SplineAnchor { index: usize },
563 /// A PMI annotation's reference field: `feature_id` is the annotation id;
564 /// Finish writes the picked names into its params through the PMI block
565 /// (`pmi_ops.rs`). Vertex picks are `{solid}@x,y,z` in WORLD coordinates.
566 Pmi,
567 /// ONE CONNECTION POINT's reference field: `feature_id` is the point's
568 /// part-local ADDRESS (`J1.VCC`) — a connection point is data, not a
569 /// feature, so there is no id to carry — and `path` is the block key the
570 /// pick writes (`pointRef` / `directionRef`). Finish writes it through
571 /// `ports_ops::ports_commit_ref`, and NOTHING ROLLS: a point resolves at
572 /// the tail of the run, so the geometry it may name is what is on screen.
573 PortPoint { field: ports_ops::PortRefField },
574 /// A drawing-sheet object's reference field — a dimension's anchors, an
575 /// ordinate set's datum or members, a section's cutting line, a detail's
576 /// centre or rim: `feature_id` is the object id, the picks are ANCHORS
577 /// clicked on the open sheet's paper (`sheet_ops.rs`), and nothing rolls.
578 Sheet,
579}
580
581/// The modal state of the reference-selection widget while it is ACTIVE: which
582/// feature-dialog field is being filled, what it accepts, and the running list
583/// of picked kernel names (the source of truth — added by picking in the view,
584/// removed via the per-line X). See the ref-select methods below.
585#[derive(Debug, Clone, Default)]
586pub struct RefSelectState {
587 /// The id of the feature whose param is being edited.
588 pub feature_id: String,
589 /// The JSON path into that feature's `inputParams` the names write to
590 /// (`["targetSolid"]`, `["boolean","targets"]`, `["faceRef"]`, …).
591 pub path: Vec<String>,
592 /// A human label for the modal heading (the field's label).
593 pub label: String,
594 /// The allowed pick kinds (`["SOLID"]`, `["FACE"]`, …) — the type constraint.
595 pub filter: Vec<String>,
596 /// Whether the field takes a LIST of references (else a single one).
597 pub multiple: bool,
598 /// The picked kernel names — the running selection (source of truth).
599 pub names: Vec<String>,
600 /// The rollback step to restore on Finish/Cancel (the edited feature's own
601 /// step): entering the mode rolls to the pre-feature "before" state, so we
602 /// remember where to return.
603 pub restore_index: usize,
604 /// Which surface Finish commits the names to (feature params vs an
605 /// assembly constraint's `inputParams`). Defaults to [`RefSelectTarget::Feature`].
606 pub target: RefSelectTarget,
607}
608
609impl Default for EngineState {
610 fn default() -> Self {
611 Self {
612 scene: RenderScene::new(),
613 camera: ViewCamera::default(),
614 controls: ArcballControls::new(),
615 settings: RenderSettings::default(),
616 emphasis: Emphasis::default(),
617 widgets: WidgetRegistry::new(),
618 history: History::default(),
619 history_report: String::new(),
620 metadata: crate::metadata::MetadataStore::new(),
621 document_thumbnail: std::cell::RefCell::new(None),
622 thumbnail_cache: std::cell::RefCell::new(None),
623 settings_generation: 1,
624 dirty: true,
625 ref_select: None,
626 selection_filter: SelectionFilter::default(),
627 transform_gizmo: TransformArm::default(),
628 component_move: ComponentMoveArm::default(),
629 sketch_edit: None,
630 sketch_camera_locked: true,
631 sketch_list_hover_active: false,
632 notices: Vec::new(),
633 graded_notices: Vec::new(),
634 hidden_sketches: std::collections::HashSet::new(),
635 shown_sketch_ids: Vec::new(),
636 shown_board_ids: Vec::new(),
637 board_built_from: None,
638 board_pin_nets: Default::default(),
639 board_build: board_geometry::BoardBuild::default(),
640 board_displays: Vec::new(),
641 construction_frames: Vec::new(),
642 sketch_profiles: Vec::new(),
643 sketch_paths: Vec::new(),
644 sketch_points: Vec::new(),
645 sketch_axes: Vec::new(),
646 wire_harness_report: None,
647 ports_report: None,
648 sheet_open: None,
649 sheet_open_object: None,
650 sheet_object_opens: 0,
651 sheet_selected_object: None,
652 sheet_cache: None,
653 sheet_lines: Default::default(),
654 document_name: String::new(),
655 pmi_report: None,
656 pmi_active_view: None,
657 pmi_open_annotation: None,
658 pmi_open_view: None,
659 pmi_selected_annotation: None,
660 pmi_selected_view: None,
661 pmi_dialog_opens: 0,
662 pmi_modeling: None,
663 pmi_explode_originals: std::collections::HashMap::new(),
664 pmi_balloon_stale: None,
665 pmi_overlay_key: None,
666 pmi_hovered: None,
667 pmi_label_hover_active: false,
668 spline_overlay_key: None,
669 component_ports_visible: false,
670 spline_edit_feature: None,
671 spline_anchor_picked: None,
672 hidden_datums: std::collections::HashSet::new(),
673 shown_datum_names: Vec::new(),
674 runner: Box::new(crate::runner::InlineRunner::new()),
675 plugins: plugins::Plugins::default(),
676 interference_sessions: Default::default(),
677 interference_sequence: 0,
678 illustration_snapshot: None,
679 geometry_diagnostics: Default::default(),
680 run_generation: 0,
681 applied_generation: 0,
682 run_progress: None,
683 cancelled_run: None,
684 expression_preview: None,
685 runs_replied: 0,
686 superseded_displays: HashMap::new(),
687 pending_fit: false,
688 provenance: std::collections::HashMap::new(),
689 entity_origin: std::collections::HashMap::new(),
690 info_cache: std::collections::HashMap::new(),
691 pending_query: std::collections::HashMap::new(),
692 next_query_id: 0,
693 pending_mesh_imports: std::collections::HashMap::new(),
694 mesh_preview_results: std::collections::VecDeque::new(),
695 next_mesh_import_id: 0,
696 pending_topology: std::collections::HashSet::new(),
697 topology_asked: std::collections::HashSet::new(),
698 next_topology_id: 0,
699 assembly_components: Vec::new(),
700 assembly_sync: None,
701 assembly_session_generation: None,
702 consumed_names: std::collections::HashSet::new(),
703 library_resync: false,
704 constraint_overlays: Vec::new(),
705 constraint_drag: None,
706 constraint_overlay_wpp: 0.0,
707 feature_dim_overlay_wpp: 0.0,
708 sketch_overlay_wpp: 0.0,
709 constraint_hovered: None,
710 constraint_label_hover_active: false,
711 scene_tree_hovered: None,
712 scene_tree_hover_active: false,
713 dialog_hovered: None,
714 dialog_hover_active: false,
715 selected_constraint: None,
716 selected_feature: None,
717 constraint_opens: 0,
718 pending_step_assembly: None,
719 pending_step_probes: std::collections::HashSet::new(),
720 step_probe_results: std::collections::VecDeque::new(),
721 next_step_probe_id: 1,
722 }
723 }
724}
725
726impl EngineState {
727 pub fn new() -> Self {
728 Self::default()
729 }
730
731 fn pick_options(&self) -> PickOptions {
732 PickOptions {
733 double_sided: self.settings.pick_double_sided,
734 ..PickOptions::default()
735 }
736 }
737}
738
739/// Has the camera's `world_per_pixel` moved MATERIALLY (>0.5%) away from the
740/// value an overlay group's screen-constant sizing was baked at?
741///
742/// The ONE judgement every camera-keyed overlay re-bake shares
743/// (`ensure_overlays_current` and the per-group ensures it drives), so
744/// "what counts as a zoom" cannot drift between them. `baked == 0.0` means
745/// "never baked" — a state each caller handles itself, so it reads as NOT
746/// stale here. The band is what keeps a quiet frame quiet: float jitter in the
747/// camera never trips it, so there is no per-frame re-bake loop.
748pub(crate) fn overlay_wpp_stale(baked: f64, now: f64) -> bool {
749 baked > 0.0 && (now - baked).abs() > baked * 0.005
750}
751
752// ============================================================================
753// MODULE MAP — engine_state is split into topic children. THIS file is the
754// module root: it keeps the EngineState/RefSelectState structs, Default, the
755// constructor + shared pick_options, the child `mod` declarations, and the
756// re-exports that preserve the original `engine_state::*` public paths.
757// Append new work to the matching child (or add a new child + re-export here).
758// ============================================================================
759
760/// The assembly surface (Wave-3): main-side session sync + component
761/// projection, constraint CRUD with the document fold (pose-authority
762/// contract), the insert-component flow, component fix/select actions, the
763/// constraint flavor of the reference picker, and `document_signature` — the
764/// ONE parts-library `sourceSignature` hash every writer shares.
765mod assembly_ops;
766/// Assembly-constraint viewport overlays: overlay refresh from the kernel
767/// session, the grabbable distance/angle handle pick + drag preview +
768/// `assembly_update_constraint_json` commit, movedSolids re-tessellation, the
769/// drag-path document fold, label feed + element hover, and tests.
770mod assembly_overlay;
771/// BOM export: the `{partName, sourceKey, quantity}` parts list off the
772/// main-side parts library + live component projection, serialized as CSV /
773/// JSON for the file dialog's Export modal.
774mod bom;
775/// Camera & view commands (zoom-to-fit, resize, pointer/wheel ingestion,
776/// projection, standard views, camera state/matrices, world→screen) plus the
777/// widget-overlay feeds (datums/overlay/dimensions/transform JSON), the
778/// ViewCube (incl. `apply_look_direction`), `datum_pick`, the widget
779/// transform-handle hover/pick/drag path, and `dimension_anchors_json`.
780mod camera_widgets;
781/// Committed-sketch persistent overlays: sheet-solid synthesis from stored
782/// profiles (`refresh_committed_sketches`), per-sketch visibility, the
783/// Scene-tree rows + `sketch_entities_json`, and the committed-sketch tests.
784/// The board's 3D bodies (substrate + copper + via barrels), derived from the
785/// document's `pcb` block after every run — see the module notes.
786mod board_geometry;
787mod committed_sketches;
788/// The COMPONENT Move gizmo (assemblies §8.5): translate→rotate→off cycle at
789/// the member-bbox center, fixed-refusal, free-move drag with the pose commit
790/// (and re-solve) on release. See `ComponentMoveArm`.
791mod component_move;
792/// Assembly COMPONENT read surface: the app-side component projection derived
793/// from the history's ACOMP features + the scene's namespaced solid names
794/// (`component_of_solid` / `component_info` / `component_bbox_center`), and its
795/// tests + shared assembly fixtures.
796mod components;
797/// Construction datum/plane display: frame→feature mapping,
798/// `refresh_construction_datums`, datum visibility + selection + entity rows,
799/// and the construction-datum tests.
800mod construction_datums;
801/// Expressions & configurator surface (`expressions_json`, `set_expressions`,
802/// `configurator_json`, `expression_variables_json`) + parsing helpers + tests.
803mod expressions;
804pub use expressions::ExpressionPreview;
805/// The feature-dimension gizmo (dimension arrows / angle arc / center-sphere
806/// toggle): arm state, `__brep`-style annotation JSON, overlay publishing,
807/// drag + set-value writeback, `FEATURE_DIM_OVERLAY`, fd_* math helpers, tests.
808mod feature_dims;
809/// The assembly interference check: the bbox-prefiltered pairwise
810/// non-destructive INTERSECT sweep over component instances
811/// (`interference_check`), its report types, and the pure pair planner.
812mod interference;
813mod batch;
814mod plugins;
815mod illustration;
816/// History runs & the feature CRUD surface: `run_history_json`, the
817/// runner/pump/apply seam, history JSON accessors, roll/update/add/delete/
818/// reorder, engine undo/redo, `load_model_and_fit`,
819/// and the history-cache rollback tests.
820mod history_ops;
821/// Model I/O: `import_step_feature`, `export_step_text`, `export_stl_text`,
822/// `triangle_normal`, and the io tests.
823mod model_io;
824/// Construction PLANES as ordinary pick candidates: the combined
825/// scene+plane-card candidate list (`pick_candidates_at`), the planes-aware
826/// single-hit pick (`pick_top_at`), the shared candidate ordering, and the
827/// plane-pick tests. Read its header for how a plane competes for a pick.
828mod plane_pick;
829/// Scene & object queries: `pick_json`/`hover_json`, settings + emphasis +
830/// visibility + color overrides, `scene_listing_json`, `depth_range_bbox`,
831/// `scene_entities_json`/select-by-name, mass properties + object info, tests.
832mod scene_query;
833/// The selection-filter state + kind gating (`SelectionFilter`,
834/// `select_filtered_at`, hide-selected) and its tests.
835mod selection_filter;
836/// Selection & hover UX: clear/select-top/selection JSON, the modal
837/// ref-select widget (incl. `set_json_at`), hover/candidate cycling, and the
838/// live sketch overlay feed (`set_sketch_overlay`/`clear_sketch_overlay`) +
839/// selection UX tests.
840mod selection_ux;
841/// Sketch editing ops appended after dimensions: dimension labels/value/drag,
842/// sketch undo/redo + diagnostics dump, trim, external edge refs
843/// (pick/link/reproject), and hand-draw strokes.
844mod sketch_edit_ops;
845/// Sketch-mode viewport input: overlay refresh, uv picking, hover/click/drag,
846/// the draw tools + pending-geometry helpers, and delete-selection.
847mod sketch_input;
848/// Sketch mode session: `SketchDrag`/`SketchEdit` state, plane-frame helpers,
849/// enter/exit/new sketch, and the camera lock.
850mod sketch_mode;
851/// Sketch entity-list panel rows + notices + solver settings
852/// (`SketchEntityRow`), and the constraint palette/actions
853/// (`SketchConstraintAction`, add-constraint builders, ground/construction
854/// toggles, cleanup).
855mod sketch_panel;
856/// The transform-controls gizmo: `GizmoMode`/`TransformArm`, arm/drag/apply,
857/// pose ⇄ params JSON, quaternion helpers (`rotate_euler_xyz_f64`), tests.
858mod transform_gizmo;
859/// The wire-harness surface: the document's `wireHarness` block (connection
860/// add / edit / remove / bundles toggle — checkpointed document edits that
861/// re-run the history, whose tail routes them), the applied run's routing
862/// report, the endpoint list, and the panel's hover highlight.
863mod wire_harness_ops;
864/// The PORTS surface: the ports tail's report of the last applied run — the
865/// one place the tail's resolved points, refused names and unresolved
866/// references reach a caller, the tail not being a feature.
867mod ports_ops;
868pub use ports_ops::PortRefField;
869// Every harness wire as a BOM line with its cut length (MF QTY), or the reason
870// the last applied run cannot give one.
871mod wire_bom;
872mod pmi_ops;
873mod pmi_section;
874pub use pmi_ops::{pmi_view_params, pmi_view_schema, world_vertex_ref, PmiModelingSnapshot, PmiViewPatch};
875// Drawing sheets: the `sheets` block, the open sheet and the projection cache.
876mod sheet_ops;
877pub(crate) mod pmi_overlay;
878/// The 3D spline-anchor editor: the resolved anchor list, the value edits
879/// (position / distances / flip / side / add / remove / reorder / detach),
880/// the anchor flavour of the transform gizmo, the port-attach flavour of the
881/// reference picker, and the direction-cage overlay.
882mod spline_edit;
883
884// Re-exports preserving the original `engine_state::*` public surface.
885pub use assembly_ops::{document_signature, ComponentInsert};
886pub use board_geometry::{
887 default_color as board_default_color, BoardBuild, BOARD_SOLID_PREFIX, SUBSTRATE_SOLID,
888 VIAS_SOLID,
889};
890pub use bom::PART_ATTRIBUTES;
891pub use component_move::ComponentMoveArm;
892pub use components::ComponentInfo;
893pub use interference::{InterferencePair, InterferenceReport};
894pub use model_io::{
895 EmbeddedOnly, PartSink, StepAssemblyImport, StepAssemblyProbe, StepAssemblyReport,
896};
897pub use selection_filter::SelectionFilter;
898pub use sketch_mode::{SketchDrag, SketchEdit};
899pub use sketch_panel::{NoticeSeverity, SketchConstraintAction, SketchEntityRow};
900pub use wire_harness_ops::ConnectionPatch;
901pub use wire_bom::{WireBomLine, WireLengthState};
902pub use spline_edit::SplineAnchorRow;
903pub use transform_gizmo::{GizmoMode, TransformArm};
904pub(crate) use transform_gizmo::rotate_euler_xyz_f64;
905
906
907
908
909/// Reconstruction results either append to a document or remain uncommitted.
910#[derive(Clone, Copy, PartialEq, Eq)]
911pub(crate) enum MeshImportDestination {
912 Document,
913 Preview,
914}