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
21pub struct EngineState {
22 pub scene: RenderScene,
23 pub camera: ViewCamera,
24 pub controls: ArcballControls,
25 pub settings: RenderSettings,
26 pub emphasis: Emphasis,
27 /// In-scene overlay widgets: datums/dimensions/curves, transform
28 /// gizmo, ViewCube — fed as JSON, drawn by the render core's overlay pass.
29 pub widgets: WidgetRegistry,
30 /// The engine-owned editable model recipe (ordered features + rollback
31 /// index) — the SINGLE source of truth for the model. The UI never keeps its
32 /// own copy; it mutates/reads this through the `history_*` / feature methods.
33 pub history: History,
34 /// The build report (`{featureErrors, unresolved, displayErrors}`) of the
35 /// last history run, so the UI can show it without re-running.
36 history_report: String,
37 /// The Properties-panel metadata store: user attributes keyed by OBJECT NAME
38 /// (solid / face / edge kernel name), NOT feature id — so a record survives
39 /// feature edits as long as the object's name persists. Persisted with the
40 /// model (a top-level `metadata` field in the history document); see the
41 /// [`crate::metadata`] module for the store + the object-info/measurement API.
42 pub metadata: crate::metadata::MetadataStore,
43 /// Bumped whenever settings change so the renderer re-derives per-solid
44 /// base styles (a cheap key, not a per-frame diff).
45 pub settings_generation: u64,
46 /// The engine sets this whenever the camera/scene/emphasis changed; the
47 /// presentation shell renders only when it is set (R22 on-demand render —
48 /// the OrthoCameraIdle matrix-compare analogue, made explicit).
49 pub dirty: bool,
50 /// The modal reference-selection state (the ref-select widget). `Some` while
51 /// the user is picking references for a feature-dialog field; `None`
52 /// otherwise. The picked-name list here is the SINGLE source of truth while
53 /// active (the UI reads it back; the viewport appends to it on a pick).
54 pub ref_select: Option<RefSelectState>,
55 /// Which entity KINDS a plain viewport click may select (the selection
56 /// filter, mirroring the earlier `SelectionFilter.allowedSelectionTypes`). `select_top_at`
57 /// consults it via `pick_filtered`; see the appended `SelectionFilter` impl
58 /// block near the end of this file for the state + honoring logic.
59 pub selection_filter: SelectionFilter,
60 /// The transform-controls gizmo controller: which feature (if any) has the
61 /// move/rotate gizmo armed (via the in-viewport center-sphere toggle), plus the
62 /// in-flight handle drag. All the arm/drag/apply logic lives in the appended
63 /// transform-gizmo impl block near the end of this file.
64 pub transform_gizmo: TransformArm,
65 /// The COMPONENT Move gizmo controller (assemblies §8.5): which ACOMP
66 /// instance has the bbox-center move/rotate gizmo armed, the translate/
67 /// rotate cycle mode, and the commit-on-release drag. Exclusive with
68 /// `transform_gizmo` (shared widget slot). See `component_move.rs`.
69 pub component_move: ComponentMoveArm,
70 /// The active engine-native sketch edit (`Some` while in sketch mode). Holds
71 /// the live [`crate::sketch::SketchSession`] plus the pre-entry camera + roll
72 /// to restore on exit. All the enter/exit/new logic lives in the appended
73 /// sketch-mode impl block at the END of this file.
74 sketch_edit: Option<SketchEdit>,
75 /// Sketch-mode camera lock. When true (the default on every sketch entry), the
76 /// camera is held flat-on to the sketch plane and an empty drag only PANS —
77 /// no orbit. Toggling it back on re-faces the camera to the plane. Meaningful
78 /// only while `sketch_edit` is `Some`. See the sketch-mode impl block.
79 sketch_camera_locked: bool,
80 /// Set for ONE frame when the sketch entity-LIST panel hovers a row (it calls
81 /// [`sketch_hover_entity`](Self::sketch_hover_entity)). The viewport, which
82 /// draws AFTER the panel and would otherwise `sketch_clear_hover` because the
83 /// pointer is off the viewport, consumes this flag via
84 /// [`take_sketch_list_hover`](Self::take_sketch_list_hover) and keeps the
85 /// panel-set hover so list→canvas highlight survives the frame.
86 sketch_list_hover_active: bool,
87 /// Transient user-facing notices (e.g. a sketch solve that failed after an
88 /// edit). The shell drains them each frame via [`take_notices`](Self::take_notices)
89 /// into a toast overlay; the engine only queues. Replaces the swallowed
90 /// `eprintln!` on the interactive re-solve paths.
91 notices: Vec<String>,
92 /// Committed-sketch visibility: the feature ids whose persistent committed-sketch
93 /// overlay is HIDDEN (its Scene-tree checkbox off). Absent = visible. See the
94 /// committed-sketch impl block appended at the END of this file.
95 hidden_sketches: std::collections::HashSet<String>,
96 /// The committed-sketch feature ids whose overlay groups were fed on the LAST
97 /// [`refresh_committed_sketches`](Self::refresh_committed_sketches), so an id that
98 /// is no longer shown (rolled back, deleted, hidden, or became the active edit)
99 /// can have its now-stale groups cleared.
100 shown_sketch_ids: Vec<String>,
101 /// The named plane FRAMES the last history run resolved `(frame name, frame)`.
102 /// Stored so [`refresh_construction_datums`](Self::refresh_construction_datums)
103 /// (and datum selection) can display/pick the construction datum/plane frames
104 /// without re-running. Filled from the run's
105 /// [`crate::pipeline::SceneBuildReport::frames`]; the D/P filter is applied at
106 /// display time (a frame name maps to its producing feature TYPE via the
107 /// history). See the appended construction-datum impl block at the END.
108 construction_frames: Vec<(String, brep_kernel::Frame)>,
109 /// The solved sketch PROFILES the last history run produced `(sketch id,
110 /// profile)`. Stored so [`refresh_committed_sketches`](Self::refresh_committed_sketches)
111 /// can synthesize each committed sketch's SHEET SOLID (planar face + named
112 /// boundary edges + corner vertices) without re-running. Filled from the run's
113 /// [`crate::pipeline::SceneBuildReport::profiles`]; rollback / active-edit /
114 /// visibility gating is applied at display time.
115 sketch_profiles: Vec<(String, brep_kernel::SketchProfile)>,
116 /// The named PATH chains the last history run produced `(path name, curves)`.
117 /// Stored alongside [`sketch_profiles`](Self::sketch_profiles) so
118 /// [`refresh_committed_sketches`](Self::refresh_committed_sketches) can draw the
119 /// sketch geometry no closed profile covers: a sketch's OPEN chain publishes no
120 /// profile, so the sheet builder had nothing to draw it from and an open sketch
121 /// was invisible in 3D. Filled from the run's
122 /// [`crate::pipeline::SceneBuildReport::paths`]; the per-segment `{id}:G{gid}`
123 /// entries are the display input (the whole-chain `{id}` entry duplicates them
124 /// and `{id}:REF:{source}` is projected reference geometry).
125 sketch_paths: Vec<(String, Vec<brep_kernel::NurbsCurve>)>,
126 /// The named axis LINES the last history run produced `(axis name, line)`.
127 /// Stored so the feature-dimension angle gizmo can resolve a revolve `axis`
128 /// reference to a world line without re-running. Filled from the run's
129 /// [`crate::pipeline::SceneBuildReport::axes`].
130 sketch_axes: Vec<(String, brep_kernel::Axis)>,
131 /// Construction datum/plane visibility: the frame NAMES whose datum plane is
132 /// HIDDEN (its Scene-tree checkbox off). Absent = visible. Mirrors
133 /// [`hidden_sketches`].
134 hidden_datums: std::collections::HashSet<String>,
135 /// The datum frame NAMES fed to the widget on the LAST
136 /// [`refresh_construction_datums`](Self::refresh_construction_datums). The datum
137 /// feed REPLACES its set wholesale each call, so this is a bookkeeping mirror of
138 /// what is currently shown (parallels [`shown_sketch_ids`]).
139 shown_datum_names: Vec<String>,
140 /// The history-run seam (M2a of the off-thread runner). Owns the scene-free
141 /// runner + its delta baseline (`name → last-emitted handle`) ACROSS reruns:
142 /// [`rerun_history`](Self::rerun_history) SUBMITS a run tagged with
143 /// [`run_generation`](Self::run_generation), and [`pump`](Self::pump) drains
144 /// the completed reply and [`apply_run_output`](Self::apply_run_output)s its
145 /// delta to [`Self::scene`]. The [`InlineRunner`](crate::runner::InlineRunner)
146 /// default runs synchronously (submit → immediate poll, byte-identical to the
147 /// old in-place reconcile); a background thread/worker impl slots in behind the
148 /// same trait in M2b/M3. Reset on a document switch
149 /// ([`set_history_json`](Self::set_history_json)) so a new model rebuilds fully.
150 pub(crate) runner: Box<dyn crate::runner::HistoryRunner>,
151 /// Monotonic run counter: bumped each time [`rerun_history`](Self::rerun_history)
152 /// SUBMITS a run, and stamped onto the reply so a stale reply (a newer run that
153 /// finished first) can be dropped. `run_generation != applied_generation` means
154 /// a run is in flight (always equal for the synchronous Inline runner).
155 run_generation: u64,
156 /// The generation of the last reply [`pump`](Self::pump) APPLIED — the high-water
157 /// mark that gates stale replies.
158 applied_generation: u64,
159 /// A pending one-shot "frame the scene once the in-flight run lands" request.
160 /// Import / Open SUBMIT an async run (native [`ThreadRunner`], wasm worker) and
161 /// want to `zoom_to_fit` the RESULT — but the scene is still empty when they
162 /// return, so an immediate fit frames nothing (bbox empty → no-op). Instead they
163 /// set this flag and [`pump`](Self::pump) performs the fit on the first apply that
164 /// leaves the run no longer pending. Under the synchronous Inline runner the run
165 /// applies inside the submitting call's own `pump`, so the fit is still immediate.
166 pending_fit: bool,
167 /// EAGER provenance `name → creating-feature id` for the current resident
168 /// solids, shipped with each run ([`crate::pipeline::RunOutput::provenance`]) and
169 /// replaced wholesale in [`apply_run_output`](Self::apply_run_output). Answers
170 /// `creating_feature` + the Info tab's `creatingFeature` WITHOUT a cold
171 /// `execute_history` — the freeze side-door once the run lives off-thread.
172 pub(crate) provenance: std::collections::HashMap<String, String>,
173 /// EAGER ENTITY ORIGIN `face/edge NAME → ORIGINATING feature id` (FIRST writer in
174 /// timeline order), shipped with each run
175 /// ([`crate::pipeline::RunOutput::entity_origin`]) and replaced wholesale in
176 /// [`apply_run_output`](Self::apply_run_output). Unlike `provenance` (the SOLID's
177 /// LAST writer) this is the feature that gave the face/edge its NAME — the answer
178 /// `creating_feature` returns for a face/edge (the "Edit owning feature" action +
179 /// the Info tab's `creatingFeature`), so it rolls to the entity's origin, not the
180 /// owning solid's last producer.
181 pub(crate) entity_origin: std::collections::HashMap<String, String>,
182 /// Object-info MEASUREMENT cache `name → merged object-info JSON`, filled by
183 /// [`pump_queries`](crate::metadata) from the runner's replies and served every
184 /// frame a selection persists (so `object_info_json` fires ONE query per
185 /// selection, not one per frame). Invalidated on any geometry change
186 /// (`apply_run_output`) or metadata edit (`set_metadata_attribute`).
187 pub(crate) info_cache: std::collections::HashMap<String, String>,
188 /// In-flight measurement queries `id → object NAME` — the key needed to MERGE a
189 /// reply back into the info cache (inject `name` + `creatingFeature`, the latter
190 /// now resolved by the entity name itself). Cleared alongside `info_cache` on a
191 /// geometry change so a stale reply is dropped rather than caching a superseded
192 /// measurement.
193 pub(crate) pending_query: std::collections::HashMap<u64, String>,
194 /// Monotonic measurement-query id (pairs a [`crate::runner::MeasureReply`] back
195 /// with its `pending_query` entry).
196 pub(crate) next_query_id: u64,
197 /// Off-thread mesh reconstructions awaiting a runner reply.
198 pub(crate) pending_mesh_imports: std::collections::HashSet<u64>,
199 /// Monotonic id for pairing mesh import replies with submissions.
200 pub(crate) next_mesh_import_id: u64,
201 /// The scene's assembly COMPONENT records (deterministic id order), a
202 /// PROJECTION captured by the main-side assembly sync (`assembly_ops`) —
203 /// the Assembly Structure tree's source. Empty for componentless documents.
204 pub(crate) assembly_components: Vec<brep_kernel::ComponentRecord>,
205 /// The [`Self::applied_generation`] the last assembly sync ran against
206 /// (`None` = never synced). `ensure_assembly_synced` re-syncs when a newer
207 /// display run has been applied. See `assembly_ops`.
208 pub(crate) assembly_synced_generation: Option<u64>,
209 /// Re-entrancy guard for the parts-library resync in [`Self::pump`] (a
210 /// refused run re-runs, and `rerun_history` pumps).
211 pub(crate) library_resync: bool,
212 /// The kernel parts-library revision the document's `partsLibrary` block
213 /// was last refreshed from (`sync_assembly`). Serializing the store is
214 /// proportional to the embedded part payload, so it is re-read only when
215 /// the library actually changed, not once per edit.
216 pub(crate) parts_library_block_revision: Option<u64>,
217 /// The assembly-constraint viewport overlays (build-spec §8.4) — the cached
218 /// [`crate::constraint_overlays::ConstraintOverlay`] records the engine last
219 /// built from the kernel session (`assembly_overlay_json` + state), the source
220 /// of the drawn leader/arrow group, the label feed, and the grabbable-handle
221 /// hit regions. Refreshed after every history apply and every constraint
222 /// mutation; see the appended assembly-overlay impl block.
223 pub(crate) constraint_overlays: Vec<crate::constraint_overlays::ConstraintOverlay>,
224 /// A live GRAB on a constraint's distance-arrow / angle-arc handle (`Some`
225 /// between `constraint_drag_begin` and `constraint_drag_release`): the drag
226 /// previews the value locally and COMMITS on release via
227 /// `assembly_update_constraint_json` (which auto-solves).
228 pub(crate) constraint_drag: Option<ConstraintDrag>,
229 /// The `world_per_pixel` the constraint overlay buffers were last baked at
230 /// (screen-constant arc/rod sizing): `ensure_constraint_overlay_current`
231 /// re-bakes when the camera zoom moves it materially. `0.0` = never baked.
232 constraint_overlay_wpp: f64,
233 /// The `world_per_pixel` the FEATURE-DIMENSION gizmo group
234 /// (`feature-dim-leaders`) was last baked at. The leaders' rod/cone/origin
235 /// sphere — and the angular arc's whole world RADIUS — are
236 /// `pixels × world_per_pixel`, so a zoom makes the drawn gizmo stale;
237 /// `ensure_feature_dimension_overlay_current` re-bakes on a material move.
238 /// `0.0` = nothing baked (gizmo disarmed / not in dimension mode).
239 /// See `feature_dims`.
240 pub(crate) feature_dim_overlay_wpp: f64,
241 /// The `world_per_pixel` the live SKETCH overlay groups (geometry, points,
242 /// preview, `sketch-dim-leaders`, `sketch-constraint-glyphs`) were last baked
243 /// at — construction dashes, dimension arrowheads and constraint glyphs are
244 /// all screen-constant. `ensure_sketch_overlay_current` re-bakes on a material
245 /// zoom. `0.0` = nothing baked (not in sketch mode). See `sketch_input`.
246 pub(crate) sketch_overlay_wpp: f64,
247 /// The constraint id whose referenced ELEMENTS the panel/label hover is
248 /// currently highlighting (dedupe key so a held hover doesn't re-bump the
249 /// emphasis generation every frame).
250 constraint_hovered: Option<String>,
251 /// Set for ONE frame when a constraint LABEL hover applied the element
252 /// highlight; the viewport's modeling hover branch consumes it (mirrors
253 /// [`Self::take_sketch_list_hover`]) so the scene hover doesn't clobber it.
254 constraint_label_hover_active: bool,
255 /// The constraint SELECTED via its viewport label chip (`Some` = selected):
256 /// drives the chip's selected accent, the context bar's Delete-constraint
257 /// action, and clears with the selection (Esc / Clear / delete). Read
258 /// through [`Self::selected_constraint`], which prunes a stale id.
259 selected_constraint: Option<String>,
260 /// The STEP product structure a [`Self::probe_step_assembly`] parsed, held
261 /// until the import dialog's button decides its fate: consumed by
262 /// [`Self::import_probed_step_assembly`], dropped by
263 /// [`Self::discard_probed_step_assembly`] (Cancel), by the next probe, or by
264 /// a document switch. The ONE parse of a structured STEP import lives here —
265 /// the dialog needs the counts BEFORE the user chooses, and re-parsing
266 /// multi-MB Part-21 text on the way back would double the most expensive step
267 /// of the import. See `model_io`'s import block.
268 pub(crate) pending_step_assembly: Option<brep_kernel::StepAssembly>,
269}
270
271/// A live constraint-handle drag: which constraint + which `inputParams` field
272/// (`distance` / `angle`), the params snapshot the commit mutates, and the live
273/// preview value the overlay/label show while dragging.
274#[derive(Debug, Clone)]
275pub struct ConstraintDrag {
276 pub id: String,
277 pub field: &'static str,
278 pub params: serde_json::Value,
279 pub preview: f64,
280}
281
282/// WHO a finished reference-selection commits to: a history FEATURE's params
283/// (the original widget) or an ASSEMBLY CONSTRAINT's `inputParams` (same modal,
284/// different commit lane — see `assembly_ops::begin_ref_select_for_constraint`).
285#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
286pub enum RefSelectTarget {
287 #[default]
288 Feature,
289 AssemblyConstraint,
290}
291
292/// The modal state of the reference-selection widget while it is ACTIVE: which
293/// feature-dialog field is being filled, what it accepts, and the running list
294/// of picked kernel names (the source of truth — added by picking in the view,
295/// removed via the per-line X). See the ref-select methods below.
296#[derive(Debug, Clone, Default)]
297pub struct RefSelectState {
298 /// The id of the feature whose param is being edited.
299 pub feature_id: String,
300 /// The JSON path into that feature's `inputParams` the names write to
301 /// (`["targetSolid"]`, `["boolean","targets"]`, `["faceRef"]`, …).
302 pub path: Vec<String>,
303 /// A human label for the modal heading (the field's label).
304 pub label: String,
305 /// The allowed pick kinds (`["SOLID"]`, `["FACE"]`, …) — the type constraint.
306 pub filter: Vec<String>,
307 /// Whether the field takes a LIST of references (else a single one).
308 pub multiple: bool,
309 /// The picked kernel names — the running selection (source of truth).
310 pub names: Vec<String>,
311 /// The rollback step to restore on Finish/Cancel (the edited feature's own
312 /// step): entering the mode rolls to the pre-feature "before" state, so we
313 /// remember where to return.
314 pub restore_index: usize,
315 /// Which surface Finish commits the names to (feature params vs an
316 /// assembly constraint's `inputParams`). Defaults to [`RefSelectTarget::Feature`].
317 pub target: RefSelectTarget,
318}
319
320impl Default for EngineState {
321 fn default() -> Self {
322 Self {
323 scene: RenderScene::new(),
324 camera: ViewCamera::default(),
325 controls: ArcballControls::new(),
326 settings: RenderSettings::default(),
327 emphasis: Emphasis::default(),
328 widgets: WidgetRegistry::new(),
329 history: History::default(),
330 history_report: String::new(),
331 metadata: crate::metadata::MetadataStore::new(),
332 settings_generation: 1,
333 dirty: true,
334 ref_select: None,
335 selection_filter: SelectionFilter::default(),
336 transform_gizmo: TransformArm::default(),
337 component_move: ComponentMoveArm::default(),
338 sketch_edit: None,
339 sketch_camera_locked: true,
340 sketch_list_hover_active: false,
341 notices: Vec::new(),
342 hidden_sketches: std::collections::HashSet::new(),
343 shown_sketch_ids: Vec::new(),
344 construction_frames: Vec::new(),
345 sketch_profiles: Vec::new(),
346 sketch_paths: Vec::new(),
347 sketch_axes: Vec::new(),
348 hidden_datums: std::collections::HashSet::new(),
349 shown_datum_names: Vec::new(),
350 runner: Box::new(crate::runner::InlineRunner::new()),
351 run_generation: 0,
352 applied_generation: 0,
353 pending_fit: false,
354 provenance: std::collections::HashMap::new(),
355 entity_origin: std::collections::HashMap::new(),
356 info_cache: std::collections::HashMap::new(),
357 pending_query: std::collections::HashMap::new(),
358 next_query_id: 0,
359 pending_mesh_imports: std::collections::HashSet::new(),
360 next_mesh_import_id: 0,
361 assembly_components: Vec::new(),
362 assembly_synced_generation: None,
363 library_resync: false,
364 parts_library_block_revision: None,
365 constraint_overlays: Vec::new(),
366 constraint_drag: None,
367 constraint_overlay_wpp: 0.0,
368 feature_dim_overlay_wpp: 0.0,
369 sketch_overlay_wpp: 0.0,
370 constraint_hovered: None,
371 constraint_label_hover_active: false,
372 selected_constraint: None,
373 pending_step_assembly: None,
374 }
375 }
376}
377
378impl EngineState {
379 pub fn new() -> Self {
380 Self::default()
381 }
382
383 fn pick_options(&self) -> PickOptions {
384 PickOptions {
385 double_sided: self.settings.pick_double_sided,
386 ..PickOptions::default()
387 }
388 }
389}
390
391/// Has the camera's `world_per_pixel` moved MATERIALLY (>0.5%) away from the
392/// value an overlay group's screen-constant sizing was baked at?
393///
394/// The ONE judgement every camera-keyed overlay re-bake shares
395/// (`ensure_overlays_current` and the per-group ensures it drives), so
396/// "what counts as a zoom" cannot drift between them. `baked == 0.0` means
397/// "never baked" — a state each caller handles itself, so it reads as NOT
398/// stale here. The band is what keeps a quiet frame quiet: float jitter in the
399/// camera never trips it, so there is no per-frame re-bake loop.
400pub(crate) fn overlay_wpp_stale(baked: f64, now: f64) -> bool {
401 baked > 0.0 && (now - baked).abs() > baked * 0.005
402}
403
404// ============================================================================
405// MODULE MAP — engine_state is split into topic children. THIS file is the
406// module root: it keeps the EngineState/RefSelectState structs, Default, the
407// constructor + shared pick_options, the child `mod` declarations, and the
408// re-exports that preserve the original `engine_state::*` public paths.
409// Append new work to the matching child (or add a new child + re-export here).
410// ============================================================================
411
412/// The assembly surface (Wave-3): main-side session sync + component
413/// projection, constraint CRUD with the document fold (pose-authority
414/// contract), the insert-component flow, component fix/select actions, the
415/// constraint flavor of the reference picker, and `document_signature` — the
416/// ONE parts-library `sourceSignature` hash every writer shares.
417mod assembly_ops;
418/// Assembly-constraint viewport overlays (build-spec §8.4): overlay refresh from
419/// the kernel session, the grabbable distance/angle handle pick + drag preview +
420/// `assembly_update_constraint_json` commit, movedSolids re-tessellation, the
421/// drag-path document fold, label feed + element hover, and tests.
422mod assembly_overlay;
423/// BOM export (assemblies build-spec §9): the `{partName, sourceKey,
424/// quantity}` parts list off the main-side parts library + live component
425/// projection, serialized as CSV / JSON for the file dialog's Export modal.
426mod bom;
427/// Camera & view commands (zoom-to-fit, resize, pointer/wheel ingestion,
428/// projection, standard views, camera state/matrices, world→screen) plus the
429/// widget-overlay feeds (datums/overlay/dimensions/transform JSON), the
430/// ViewCube (incl. `apply_look_direction`), `datum_pick`, the widget
431/// transform-handle hover/pick/drag path, and `dimension_anchors_json`.
432mod camera_widgets;
433/// Committed-sketch persistent overlays: sheet-solid synthesis from stored
434/// profiles (`refresh_committed_sketches`), per-sketch visibility, the
435/// Scene-tree rows + `sketch_entities_json`, and the committed-sketch tests.
436mod committed_sketches;
437/// The COMPONENT Move gizmo (assemblies §8.5): translate→rotate→off cycle at
438/// the member-bbox center, fixed-refusal, free-move drag with the pose commit
439/// (and re-solve) on release. See `ComponentMoveArm`.
440mod component_move;
441/// Assembly COMPONENT read surface: the app-side component projection derived
442/// from the history's ACOMP features + the scene's namespaced solid names
443/// (`component_of_solid` / `component_info` / `component_bbox_center`), and its
444/// tests + shared assembly fixtures.
445mod components;
446/// Construction datum/plane display: frame→feature mapping,
447/// `refresh_construction_datums`, datum visibility + selection + entity rows,
448/// and the construction-datum tests.
449mod construction_datums;
450/// Expressions & configurator surface (`expressions_json`, `set_expressions`,
451/// `configurator_json`, `expression_variables_json`) + parsing helpers + tests.
452mod expressions;
453/// The feature-dimension gizmo (dimension arrows / angle arc / center-sphere
454/// toggle): arm state, `__brep`-style annotation JSON, overlay publishing,
455/// drag + set-value writeback, `FEATURE_DIM_OVERLAY`, fd_* math helpers, tests.
456mod feature_dims;
457/// The assembly interference check (build-spec §9): the bbox-prefiltered
458/// pairwise non-destructive INTERSECT sweep over component instances
459/// (`interference_check`), its report types, and the pure pair planner.
460mod interference;
461/// History runs & the feature CRUD surface: `run_history_json`, the
462/// runner/pump/apply seam, history JSON accessors, roll/update/add/delete/
463/// reorder, engine undo/redo, `load_model_and_fit`, `parse_color_overrides`,
464/// and the history-cache rollback tests.
465mod history_ops;
466/// Model I/O: `import_step_feature`, `export_step_text`, `export_stl_text`,
467/// `triangle_normal`, and the io tests.
468mod model_io;
469/// Construction PLANES as ordinary pick candidates: the combined
470/// scene+plane-card candidate list (`pick_candidates_at`), the planes-aware
471/// single-hit pick (`pick_top_at`), the shared candidate ordering, and the
472/// plane-pick tests. Read its header for how a plane competes for a pick.
473mod plane_pick;
474/// Scene & object queries: `pick_json`/`hover_json`, settings + emphasis +
475/// visibility + color overrides, `scene_listing_json`, `depth_range_bbox`,
476/// `scene_entities_json`/select-by-name, mass properties + object info, tests.
477mod scene_query;
478/// The selection-filter state + kind gating (`SelectionFilter`,
479/// `select_filtered_at`, hide-selected) and its tests.
480mod selection_filter;
481/// Selection & hover UX: clear/select-top/selection JSON, the modal
482/// ref-select widget (incl. `set_json_at`), hover/candidate cycling, and the
483/// live sketch overlay feed (`set_sketch_overlay`/`clear_sketch_overlay`) +
484/// selection UX tests.
485mod selection_ux;
486/// Sketch editing ops appended after dimensions: dimension labels/value/drag,
487/// sketch undo/redo + diagnostics dump, trim, external edge refs
488/// (pick/link/reproject), and hand-draw strokes.
489mod sketch_edit_ops;
490/// Sketch-mode viewport input: overlay refresh, uv picking, hover/click/drag,
491/// the draw tools + pending-geometry helpers, and delete-selection.
492mod sketch_input;
493/// Sketch mode session: `SketchDrag`/`SketchEdit` state, plane-frame helpers,
494/// enter/exit/new sketch, and the camera lock.
495mod sketch_mode;
496/// Sketch entity-list panel rows + notices + solver settings
497/// (`SketchEntityRow`), and the constraint palette/actions
498/// (`SketchConstraintAction`, add-constraint builders, ground/construction
499/// toggles, cleanup).
500mod sketch_panel;
501/// The transform-controls gizmo: `GizmoMode`/`TransformArm`, arm/drag/apply,
502/// pose ⇄ params JSON, quaternion helpers (`rotate_euler_xyz_f64`), tests.
503mod transform_gizmo;
504
505// Re-exports preserving the original `engine_state::*` public surface.
506pub use assembly_ops::{document_signature, ComponentInsert};
507pub use component_move::ComponentMoveArm;
508pub use components::ComponentInfo;
509pub use interference::{InterferencePair, InterferenceReport};
510pub use model_io::{
511 EmbeddedOnly, PartSink, StepAssemblyImport, StepAssemblyProbe, StepAssemblyReport,
512};
513/// Shared assembly test fixtures (a two-instance ACOMP document) for the
514/// crate's pipeline/runner tests.
515#[cfg(test)]
516pub(crate) use components::component_fixtures;
517pub use selection_filter::SelectionFilter;
518pub use sketch_mode::{SketchDrag, SketchEdit};
519pub use sketch_panel::{SketchConstraintAction, SketchEntityRow};
520pub use transform_gizmo::{GizmoMode, TransformArm};
521pub(crate) use transform_gizmo::rotate_euler_xyz_f64;
522
523#[cfg(test)]
524mod tests;
525
526#[cfg(test)]
527mod sketch_mode_tests;