Skip to main content

EngineState

Struct EngineState 

Source
pub struct EngineState {
Show 13 fields pub scene: RenderScene, pub camera: ViewCamera, pub controls: ArcballControls, pub settings: RenderSettings, pub emphasis: Emphasis, pub widgets: WidgetRegistry, pub history: History, pub metadata: MetadataStore, pub settings_generation: u64, pub dirty: bool, pub ref_select: Option<RefSelectState>, pub selection_filter: SelectionFilter, pub transform_gizmo: TransformArm, /* private fields */
}

Fields§

§scene: RenderScene§camera: ViewCamera§controls: ArcballControls§settings: RenderSettings§emphasis: Emphasis§widgets: WidgetRegistry

In-scene overlay widgets: datums/dimensions/curves, transform gizmo, ViewCube — fed as JSON, drawn by the render core’s overlay pass.

§history: History

The engine-owned editable model recipe (ordered features + rollback index) — the SINGLE source of truth for the model. The UI never keeps its own copy; it mutates/reads this through the history_* / feature methods.

§metadata: MetadataStore

The Properties-panel metadata store: user attributes keyed by OBJECT NAME (solid / face / edge kernel name), NOT feature id — so a record survives feature edits as long as the object’s name persists. Persisted with the model (a top-level metadata field in the history document); see the crate::metadata module for the store + the object-info/measurement API.

§settings_generation: u64

Bumped whenever settings change so the renderer re-derives per-solid base styles (a cheap key, not a per-frame diff).

§dirty: bool

The engine sets this whenever the camera/scene/emphasis changed; the presentation shell renders only when it is set (R22 on-demand render — the OrthoCameraIdle matrix-compare analogue, made explicit).

§ref_select: Option<RefSelectState>

The modal reference-selection state (the ref-select widget). Some while the user is picking references for a feature-dialog field; None otherwise. The picked-name list here is the SINGLE source of truth while active (the UI reads it back; the viewport appends to it on a pick).

§selection_filter: SelectionFilter

Which entity KINDS a plain viewport click may select (the selection filter, mirroring the earlier SelectionFilter.allowedSelectionTypes). select_top_at consults it via pick_filtered; see the appended SelectionFilter impl block near the end of this file for the state + honoring logic.

§transform_gizmo: TransformArm

The transform-controls gizmo controller: which feature (if any) has the move/rotate gizmo armed (via the in-viewport center-sphere toggle), plus the in-flight handle drag. All the arm/drag/apply logic lives in the appended transform-gizmo impl block near the end of this file.

Implementations§

Source§

impl EngineState

Source

pub fn zoom_to_fit(&mut self)

Frame the whole scene (used right after the first history feed).

Source

pub fn resize(&mut self, css_width: f64, css_height: f64)

Update the CSS viewport size (used by all camera math). The physical framebuffer size + DPR are the presentation shell’s concern.

Source

pub fn pointer_down(&mut self, x: f64, y: f64, button: i32) -> bool

Source

pub fn pointer_move(&mut self, x: f64, y: f64) -> bool

Source

pub fn pointer_up(&mut self) -> bool

Source

pub fn wheel(&mut self, delta_y: f64, cursor: Option<[f64; 2]>) -> bool

Source

pub fn set_controls_enabled(&mut self, enabled: bool)

Source

pub fn toggle_projection(&mut self) -> &'static str

Source

pub fn set_projection(&mut self, kind: &str)

Source

pub fn standard_view(&mut self, name: &str) -> bool

Source

pub fn camera_state_json(&self) -> String

Source

pub fn apply_camera_state_json(&mut self, json: &str) -> Result<(), String>

Source

pub fn world_per_pixel(&self) -> f64

Source

pub fn world_to_screen_json(&self, points_json: &str) -> Result<String, String>

Project world points to CSS-pixel screen coords for host anchoring. Input is [[x,y,z], …]; output [[sx, sy, depth, inFront], …] where inFront is 1 when the point is in front of the eye plane.

Source

pub fn camera_matrices_json(&self) -> String

The camera matrices for the host overlays’ per-frame world→screen / screen→world hot path: { viewProj:[16], viewProjInverse:[16], viewport:[w,h] }. Both matrices are column-major (index = col*4 + row); viewProj maps world → wgpu clip (x,y in −1..1, z in 0..1) and viewport is the CSS-pixel size. This lets dimensions + sketch drop the compat mirror camera and read the engine’s own view-projection directly (see world_to_screen_json for one-shots).

Source§

impl EngineState

Source

pub fn build_widget_overlay(&self) -> Option<WidgetOverlay>

Build this frame’s overlay-widget geometry, or None when nothing is enabled (skips the overlay passes entirely).

Source

pub fn set_datums_json(&mut self, json: &str) -> Result<(), String>

Source

pub fn set_overlay_json(&mut self, json: &str) -> Result<(), String>

Feed the general overlay geometry channel (set_overlay): arbitrary named tri/line/point groups (feature-dialog previews and other display-only geometry), drawn in the widget overlay pass.

Source

pub fn set_dimensions_json(&mut self, json: &str) -> Result<(), String>

Source

pub fn set_transform_json(&mut self, json: &str) -> Result<(), String>

Source

pub fn set_viewcube_enabled(&mut self, enabled: bool)

Source

pub fn viewcube_rect_json(&self) -> String

The ViewCube corner rect {x,y,w,h} (CSS px) so the host can decide whether to forward a pointer event.

Source

pub fn viewcube_hover(&mut self, local_x: f64, local_y: f64) -> bool

Update the ViewCube hover from cube-local pixels; returns whether it changed (a hover-out is (None) with local coords outside).

Source

pub fn viewcube_clear_hover(&mut self) -> bool

Source

pub fn viewcube_click(&mut self, local_x: f64, local_y: f64) -> bool

Click the ViewCube at cube-local pixels: snap the shared camera to the region’s standard view (keeping the current pivot distance). Returns true if a region was hit.

Source

pub fn datum_pick(&self, x: f64, y: f64) -> String

Pick the datum plane/axis under a screen pixel; returns its name (empty when none). The host merges this with solid picking into SelectionFilter.

Source

pub fn transform_hover(&mut self, x: f64, y: f64) -> u32

Update the transform-gizmo hover from a screen pixel; returns the handle under the pointer (0 = none). Marks dirty when the highlight changed.

Source

pub fn transform_pick(&self, x: f64, y: f64) -> u32

The transform-gizmo handle under a screen pixel (0 = none) — the host echoes it back to start a drag.

Source

pub fn transform_drag( &mut self, handle: u32, sx: f64, sy: f64, cx: f64, cy: f64, ) -> String

Compute a transform drag (frame-space + world delta) as JSON for the feature-edit commit. Marks the handle active for the highlight.

Source

pub fn transform_drag_end(&mut self)

Source

pub fn dimension_anchors_json(&self) -> String

Per-dimension label placement: [{id, anchor:[x,y,z], screen:[sx,sy,inFront]}] — the host pins each text label at screen.

Source§

impl EngineState

Source

pub fn refresh_committed_sketches(&mut self)

(Re)build the persistent committed-sketch SHEET SOLIDS. For every committed sketch that should show — committed_sketch_ids minus [hidden_sketches] — synthesize its planar sheet from the run’s solved profile and insert it as a scene solid (keyed by the sketch id, dim-cyan, flagged is_sketch); remove any sheet inserted on the PREVIOUS refresh but not this one (rolled back, deleted, hidden, or became the active edit). A sketch with no closed profile (open / underconstrained) yields no sheet and is skipped. Marks dirty.

Source

pub fn sketch_visible(&self, id: &str) -> bool

Whether the committed sketch id’s persistent overlay is shown (absent from [hidden_sketches] = visible).

Source

pub fn set_sketch_visible(&mut self, id: &str, visible: bool)

Show/hide the committed sketch id’s persistent overlay (the Scene-tree checkbox). Toggles [hidden_sketches], rebuilds the committed overlays (so the group is fed or cleared immediately), and marks dirty.

Source

pub fn committed_sketches(&self) -> Vec<(String, bool)>

The committed sketches to list in the Scene tree: every "S" feature at the current rollback (minus the active edit), each with its live visibility — the ordered (id, visible) list the Scene panel snapshots.

Source

pub fn sketch_entities_json(&self) -> String

The committed sketches as JSON ([{"name":<id>,"visible":<bool>}]) — the sibling of scene_entities_json the Scene panel publishes for the headed verifier (kept a SEPARATE method so the solids array’s shape is unchanged).

Source§

impl EngineState

Source

pub fn datum_feature_for_name(&self, name: &str) -> Option<(String, String)>

The producing (feature id, feature type) of a datum/plane frame NAME, but ONLY when the name is an actually-resolved D/P frame at the current rollback — the provenance the Properties Info tab reports for a selected datum.

Source

pub fn refresh_construction_datums(&mut self)

(Re)build the persistent construction datum/plane overlays. Feeds every D/P frame the last run resolved (minus [hidden_datums]) to the datum-plane widget channel as a screen-constant NAMED plane in the calm datum color — or the selection accent when it is in emphasis.selected_datums. The feed REPLACES the widget’s datum set wholesale, so a departed/hidden/rolled-back plane is auto-dropped; shown_datum_names mirrors what was fed. Marks dirty.

Source

pub fn datum_visible(&self, name: &str) -> bool

Whether the construction datum/plane name’s plane is shown (absent from [hidden_datums] = visible).

Source

pub fn set_datum_visible(&mut self, name: &str, visible: bool)

Show/hide the construction datum/plane name’s plane (the Scene-tree checkbox). Toggles [hidden_datums] and re-feeds the datum planes so the plane appears/disappears immediately.

Source

pub fn construction_datums(&self) -> Vec<(String, bool)>

The construction datums/planes to list in the Scene tree: every D/P frame at the current rollback, each with its live visibility (hidden ones included, like committed_sketches).

Source

pub fn datum_entities_json(&self) -> String

The construction datums/planes as JSON ([{"name","visible"}]) — the datum sibling of sketch_entities_json the Scene panel publishes (__brepDatums) for the headed verifier.

Source

pub fn select_datum(&mut self, name: &str) -> bool

Select a construction datum/plane by frame NAME (replacing the whole selection): a Scene-tree row click or a viewport datum pick. Only a name that is an actually-resolved D/P frame at the current rollback selects; others return false without changing the selection. Re-feeds the datum planes so the selected one shows the accent, and bumps the generation.

Source§

impl EngineState

Source

pub fn expressions_json(&self) -> String

The history’s expressions source string (the variable sheet the panel’s editor binds to). Raw source text — despite the _json suffix it mirrors the other engine readouts’ naming; the verifier reads it verbatim.

Source

pub fn set_expressions(&mut self, expressions: &str) -> String

Replace the expressions source and re-run the rolled-to prefix so every feature param referencing a variable (e.g. sizeX = "boxW") rebuilds with the new value — the panel’s live-update path. Returns the build-report JSON.

Source

pub fn configurator_json(&self) -> String

The history’s configurator object (typed named inputs) as JSON — a read/display surface for the panel; deeper configurator editing is deferred.

Source

pub fn expression_variables_json(&self) -> String

The parsed variable list for the sheet’s name/value view: [{ "name": "...", "expr": "..." }, …] — one entry per name = rhs; assignment in the expressions source, in source order. The RHS is shown verbatim (its DEFINING expression); evaluating it to a live scalar needs the kernel’s private Env, so a computed value column is deferred — the text editor + re-run is the source of truth for applied values.

Source§

impl EngineState

Source

pub fn gizmo_mode(&self) -> &'static str

The armed ◎ gizmo mode: "none", "transform", or "dimension". Drives the ◎ highlight + the app’s dimension-overlay draw / input routing.

Source

pub fn dimension_armed_for(&self, feature_id: &str) -> bool

Whether the DIMENSION gizmo is armed for THIS feature (drives the ◎ dimension-mode highlight).

Source

pub fn dimension_armed_feature(&self) -> String

The dimension-armed feature id (empty unless in dimension mode).

Source

pub fn arm_dimension(&mut self, feature_id: &str)

Arm the DIMENSION gizmo for feature_id: hide the transform widget, show the annotation overlay. Re-arming a different feature moves it.

Source

pub fn transform_center_pick(&self, x: f64, y: f64) -> bool

Whether a screen-px pick in TRANSFORM mode lands on the orange CENTER free-move sphere (HANDLE_CENTER). The viewport uses this to make a bare click on the center TOGGLE to the dimension arrows (via toggle_to_dimension) instead of swallowing it as a generic handle click. False in any other gizmo mode.

Source

pub fn dimension_origin_pick(&self, x: f64, y: f64) -> bool

Whether a screen-px pick in DIMENSION mode lands on an orange ORIGIN sphere of the armed feature’s dimension arrows. Each distinct annotation draws such a sphere — a LINEAR dim at its point_a (a cube’s three axis dims share one, a cone/pyramid draw two), an ANGULAR dim at its arc center (the vertex; its sweep-END sphere is the angle DRAG handle, not a toggle) — so every one is projected via the camera and hit-tested against the screen-constant sphere radius. The viewport uses this to TOGGLE back to the transform gizmo (via toggle_to_transform), which is the ONLY way an angular-only feature (a revolve) reaches transform. False in any other gizmo mode. The hit radius mirrors the gizmo center’s own tolerance (PX_CENTER_RAD + 2.0, transform.rs) so the two toggle targets match.

Source

pub fn dimension_arrow_pick(&self, x: f64, y: f64) -> Option<String>

Whether a screen-px pick in DIMENSION mode lands on a dimension ARROWHEAD (a linear leader’s orange cone TIP at point_b, or an angular arc’s orange sweep-END handle sphere). Returns the grabbed annotation’s field_key — the viewport routes a DRAG that starts here to [feature_dimension_drag](Self:: feature_dimension_drag), editing that param live (Fix 4). None in any other gizmo mode / when no arrowhead is under the pointer. Distinct from dimension_origin_pick: that grabs the SHARED origin sphere (a mode toggle), this grabs an arrowHEAD (a value edit). The nearest arrowhead within the screen-constant hit radius wins.

Source

pub fn toggle_to_dimension(&mut self)

Toggle the armed ◎ gizmo from TRANSFORM to DIMENSION for the currently transform-armed feature (the orange center-sphere click). No-op unless a feature is transform-armed.

Source

pub fn toggle_to_transform(&mut self)

Toggle the armed ◎ gizmo from DIMENSION to TRANSFORM for the currently dimension-armed feature (the orange origin-sphere click). No-op unless a feature is dimension-armed.

Source

pub fn feature_dimension_annotations_json(&self, feature_id: &str) -> String

The dimension annotations for feature_id as JSON: [{ fieldKey, pointA, pointB, value, label, mid }] (world-space points; mid is the leader midpoint the app anchors the label at). [] when the feature type has no FD-1 builder.

Source

pub fn feature_dimension_state_json(&self) -> String

The { mode, feature, annotations } snapshot the headless verifier reads (published as __brepFeatureDim).

Source

pub fn refresh_feature_dimension_overlay(&mut self)

(Re)project the dimension leaders onto the current geometry. Called on arm

  • after every param change (drag / value edit / rerun in dimension mode).
Source

pub fn feature_dimension_drag( &mut self, feature_id: &str, field_key: &str, x: f64, y: f64, )

Drag a dimension handle: project the pointer pixel (x, y) onto the annotation’s world axis (pointA → pointB), take the distance along the axis from pointA as the new value (correcting for any transform scale so the PARAM — not the scaled world length — is what changes), set the param, and re-run the history live. Degenerate projections (parallel ray / zero axis) no-op.

Source

pub fn feature_dimension_set_value( &mut self, feature_id: &str, field_key: &str, input: &str, )

Edit a dimension value from a label field: a plain numeric literal sets the param to that number; otherwise the input is treated as an EXPRESSION — evaluated LIVE against the history’s expressions + configurator (the kernel eval_expression) and, on success, STORED as the expression string (the kernel re-evaluates it via ctx.number, so it stays live). A blank / bad-expression input no-ops (never corrupts the feature). Re-runs live.

Source§

impl EngineState

Source

pub fn run_history_json( &mut self, request_json: &str, overrides_json: Option<&str>, ) -> Result<String, String>

Run a whole history and reconcile the display scene (R10 incremental): reused solids keep their buffers, the rest re-tessellate. overrides_json is an optional {name: "#rrggbb"} metadata-color map. Returns the build report JSON ({featureErrors, unresolved, displayErrors}). Marks dirty.

Source

pub fn pump(&mut self)

Drain every completed run reply and APPLY it — the POLL/APPLY half of the M2a seam. Called from rerun_history for the Inline runner’s immediate apply, and once per frame from the app so a future async runner’s completed runs land on the main thread. A reply older than applied_generation (a newer run that finished first) is dropped.

Source

pub fn queries_pending(&self) -> bool

Whether a measurement query is still in flight (its reply not yet drained) — the query analogue of run_pending, so the app keeps the frame loop alive until a background runner’s measurement lands and displays. Always false for the synchronous Inline runner.

Source

pub fn run_pending(&self) -> bool

Whether a submitted run has not yet been applied (run_generation != applied_generation). Always false for the synchronous Inline runner (submit → immediate pump keeps the two in lockstep); a background runner uses it to keep the frame loop alive until its reply lands.

Source

pub fn has_solids(&self) -> bool

Whether the display scene currently holds at least one solid. Used by the app’s async-safe first-frame framing: under a background runner (thread / worker) the seed run lands a frame (or many) after boot, so the shell waits for has_solids() && !run_pending() before its one-shot zoom_to_fit.

Source

pub fn set_runner(&mut self, runner: Box<dyn HistoryRunner>)

Swap in a different history runner (the platform injects its own — the native app installs a ThreadRunner; wasm keeps the default Inline until M3’s worker). Resets the new runner’s delta baseline so the next run rebuilds fully. Call BEFORE seeding a document so the seed builds through the installed runner.

Source

pub fn set_history_json(&mut self, request_json: &str) -> Result<String, String>

Load a whole history document (a saved part file parses as one); the engine now OWNS this recipe. Rolls to the last feature and builds it.

The document’s top-level metadata field (the Properties-panel name-keyed store) is lifted out into Self::metadata before the feature list is handed to the kernel — loading a part REPLACES the store wholesale (a document with no metadata clears it), mirroring the previous metadata manager’s load semantics. Round-trips with Self::history_request_json.

Source

pub fn history_request_json(&self) -> String

The whole history request document (persistence / debugging), with the Properties-panel metadata store folded back in as the top-level metadata field so save→open round-trips it. The field is written only when the store is non-empty, so an un-annotated model persists byte-for-byte as before.

Source

pub fn history_listing_json(&self) -> String

The tree listing { step, features:[{index,type,id}] } for the UI panel.

Source

pub fn history_report_json(&self) -> String

The last build report JSON.

Source

pub fn history_len(&self) -> usize

Source

pub fn history_rollback(&self) -> usize

The rolled-to (selected) feature index.

Source

pub fn feature_type_at(&self, index: usize) -> Option<String>

Source

pub fn feature_id_at(&self, index: usize) -> Option<String>

Source

pub fn feature_params_json(&self, index: usize) -> String

The inputParams document of feature index ("null" if none) — the dialog’s editing-buffer source.

Source

pub fn next_feature_id(&mut self, base: &str) -> String

Mint the id for a NEW feature: {base}{N} where base is the feature’s shortName (crate::features::feature_short_name) and N is the part history’s persistent GLOBAL counter (monotonic, never reused, round-trips save/load — see History::next_feature_id). &mut because the counter advances; if the caller’s add_feature then fails the number is simply skipped (monotonic-with-gaps is the contract, not an error).

Source

pub fn roll_to(&mut self, index: usize) -> String

Roll the model to feature index: re-run features[0..=index].

Source

pub fn update_feature_params( &mut self, id: &str, input_params_json: &str, ) -> Result<String, String>

Replace feature id’s input params and re-run at the current rollback → the viewport updates live.

Source

pub fn add_feature(&mut self, feature_json: &str) -> Result<String, String>

Append a feature (a full {type, inputParams, …} descriptor) and roll to it. The caller assigns a unique id (see Self::next_feature_id).

Source

pub fn delete_feature(&mut self, id: &str) -> String

Delete the feature with id id (no-op if absent) and re-run, clamping the rolled-to step.

Source

pub fn reorder_feature(&mut self, index: usize, up: bool) -> String

Move feature index one slot up/down (reorder), keeping it selected.

Source§

impl EngineState

Source

pub fn can_undo(&self) -> bool

Whether an undo step is available (to enable the toolbar’s Undo button).

Source

pub fn can_redo(&self) -> bool

Whether a redo step is available.

Source

pub fn undo(&mut self) -> String

Undo the last model mutation: restore the previous document + rolled-to step, then re-run + reconcile the scene. Returns the build report; a no-op (empty undo stack) returns the last report unchanged.

Source

pub fn redo(&mut self) -> String

Redo the last undone model mutation (symmetric with Self::undo).

Source§

impl EngineState

Source

pub fn load_model_and_fit( &mut self, request_json: &str, ) -> Result<String, String>

Load a whole model document (a saved .BREP.json recipe) and FRAME it: set_history_json (which rolls to the last feature) followed by zoom_to_fit. The one call the file panel’s Open needs — the model IS the engine-owned history, so opening a file is loading its request JSON and reframing. Returns the build-report JSON.

Source§

impl EngineState

Source

pub fn import_step_feature(&mut self, step_text: &str) -> Result<String, String>

Import a STEP document into the model: append an IMPORT3D feature whose inputParams.stepText is the raw ISO-10303-21 text (the exact headless source the kernel importer reads — no fileToImport data-URL marshaling needed), mint it a persistent-counter id, roll to it, and rebuild. Returns the build report JSON (imported bodies + any per-feature error). A non-STEP payload is refused up front so a bad upload never leaves a dead feature.

Source

pub fn export_step_text(&self) -> Result<String, String>

Export the CURRENT model’s resident solids to an ISO-10303-21 STEP document. Collects the resident handles of the rolled-to model (a warm re-run of the same prefix the display scene was built from — see crate::pipeline::resident_solid_handles) and hands them to the kernel’s brep_kernel::export_step_handles, so the exact NURBS topology is serialized (never the display mesh). Errs clearly when the model is empty.

Source

pub fn export_stl_text(&self) -> Result<String, String>

Export the CURRENT display scene to an ASCII STL string (one solid with a per-triangle geometric normal for every mesh triangle of every displayed solid). STL is a triangle-soup format with no multi-body concept, so all solids fold into a single solid brep … endsolid brep. String-shaped so it crosses the same string ModelStore seam the STEP lane uses. Errs when the scene has no triangles.

Source§

impl EngineState

Source

pub fn pick_json(&self, x: f64, y: f64) -> String

Ranked candidate list under CSS-pixel (x, y), kernel names, priority VERTEX > EDGE > FACE > … > SOLID. Feeds the host’s multi-candidate popup.

Source

pub fn hover_json(&self, x: f64, y: f64) -> String

The single best candidate under (x, y) (hover), or null.

Source

pub fn apply_settings_json(&mut self, json: &str) -> Result<(), String>

Source

pub fn settings_json(&self) -> String

The FULL current settings as JSON (the round-trip counterpart of [apply_settings_json]): the schema-driven form seeds its widgets from this and the storage seam persists it.

Source

pub fn solid_color_overrides_json(&self) -> String

The current per-solid metadata color overrides as JSON — [{"name": "...", "override": "#rrggbb" | null}, …]. Lets a UI list the scene’s solids with their current override so the picker reflects state.

Source

pub fn apply_emphasis_json(&mut self, json: &str) -> Result<(), String>

Source

pub fn set_visible(&mut self, name: &str, visible: bool) -> bool

Source

pub fn set_color_override( &mut self, name: &str, color_hex: Option<&str>, ) -> bool

Set (or clear) a solid’s LIVE per-solid color override (R14) without a history rerun — the app assigning a metadata color updates the view immediately. color_hex is a CSS hex string (#rrggbb); None or an empty/unparseable string clears back to the hashed/uniform base color. Marks dirty; returns false if the solid name is unknown.

Source

pub fn scene_listing_json(&self) -> String

Source

pub fn depth_range_bbox(&self) -> Aabb

The bbox the camera depth-range fit should use: the visible SOLIDS unioned with the pushed OVERLAY groups (sketch curves/points, dimension leaders, constraint glyphs). Folding in the overlay stops orbiting an editing sketch from clipping it against the solids-only bounds (the reported clipping when “Lock to sketch” is off). Callers must bind this to a local before camera.fit_depth_range (which needs &mut self.camera).

Source§

impl EngineState

Source

pub fn scene_entities_json(&self) -> String

A RICHER scene listing than scene_listing_json (which is counts only): per solid the individual face + edge kernel NAMES and vertex refs (topo id + world position), plus visibility — the shape the engine-native Scene tree lists entities from and the headed verifier asserts against. Vertices carry no kernel name, so they are keyed by topo id + world position (the same shape the emphasis vertex-ref selection uses).

Source

pub fn select_by_name(&mut self, kind: &str, name: &str) -> bool

Drive the engine SELECTION by kernel NAME from a UI tree (the name-based analogue of select_top_at, which picks under the cursor). Replaces the current selection with the single named solid / face / edge so clicking a Scene-tree row highlights that entity in the viewport (the render pass reads emphasis). Vertices have no kernel name — use select_vertex_by_position. Returns false for an unknown kind or an empty name.

Source

pub fn select_vertex_by_position( &mut self, solid: &str, position: [f64; 3], ) -> bool

Select a single vertex by its owning solid + world position — vertices have no kernel name, so emphasis keys them by solid + position (matched with a tolerance in the render pass). Replaces the current selection. Returns false for an empty solid name.

Source§

impl EngineState

Source

pub fn mass_properties_json(&self, name: Option<&str>, density: f64) -> String

Mass properties for the Inspector panel, from the kernel’s exact (divergence-theorem) integrator. name = Some(solid) reports that resident solid; None reports the whole model. density (mass units per mm³; the kernel length convention is millimetres) scales mass and the inertia tensor — the centroid and principal axes are density-independent.

Returns JSON:

{ "ok": true, "target": "Box", "solidCount": 1, "density": 1.0,
  "volume": 5738.05, "surfaceArea": 2927.79, "mass": 5738.05,
  "centroid": [10.0, 10.0, 10.0],
  "inertia": [[..],[..],[..]] | null,
  "principalMoments": [a,b,c] | null,
  "principalAxes": [[..],[..],[..]] | null }

A single resolved solid carries the full centroidal inertia tensor + principal axes/moments; a multi-solid aggregate reports summed volume / area / mass and the volume-weighted centroid, with the tensor fields null (select one solid for its inertia). ok:false with a message on no solids / an unknown name / an integrator failure.

Source§

impl EngineState

Source

pub fn selection_filter(&self) -> SelectionFilter

The current selection filter (a cheap Copy) — a panel reads it to seed its toggles, edits the copy, and writes back via [set_selection_filter].

Source

pub fn set_selection_filter(&mut self, filter: SelectionFilter)

Replace the whole selection filter. Purely a policy change (no geometry or camera moves), so it does NOT mark the scene dirty; the NEXT click honors it.

Source

pub fn set_kind_pickable(&mut self, kind: &str, on: bool)

Toggle one kind’s pickability by name ("SOLID"/"FACE"/"EDGE"/"VERTEX").

Source

pub fn selection_filter_json(&self) -> String

The filter as JSON ({"SOLID":true,"FACE":false,"EDGE":false,"VERTEX":false}) — lets a UI / the headed verifier read the pickable-kind state.

Source

pub fn apply_selection_filter_json(&mut self, json: &str) -> Result<(), String>

Apply a partial filter JSON (any subset of the four keys); absent keys keep their current value. The round-trip counterpart of [selection_filter_json].

Source

pub fn select_filtered_at(&mut self, x: f64, y: f64) -> bool

The filter-honoring plain-click selection (what [select_top_at] delegates to): resolve the TOP-priority candidate under (x, y) whose kind the filter admits (via pick::pick_filtered with the enabled kinds) and select THAT kind, replacing the current selection. A miss — or a click while the filter admits nothing — clears the selection. Returns whether something selected.

Source

pub fn has_selection(&self) -> bool

Whether ANYTHING is currently selected (solids/faces/edges/vertices) — distinct from emphasis.is_empty() (which also counts hover). Drives the selection action bar’s visibility.

Source

pub fn hide_selected(&mut self) -> usize

Toggle the visibility of EXACTLY what is selected (the action bar’s Hide/Show): each selected SOLID flips its whole-solid visibility (set_visible); each selected FACE / EDGE / VERTEX flips only that sub-entity (set_entity_visible, the same per-entity mask the Scene-tree checkboxes use — a hidden face’s triangles are simply not drawn). Every target toggles INDEPENDENTLY off its own live state (hide if visible, show if hidden), so a mixed / repeat click flips each item. Returns how many targets were toggled. Leaves the selection as-is, so a second click toggles the same items back.

Source§

impl EngineState

Source

pub fn clear_selection(&mut self) -> bool

Clear the current SELECTION (Esc): drop all selected solids/faces/edges/ vertices (hover is left untouched). Bumps the emphasis generation + marks dirty only when something was actually cleared. Returns whether it changed.

Source

pub fn select_top_at(&mut self, x: f64, y: f64) -> bool

Select the top-priority pick under CSS-pixel (x, y) that the SELECTION FILTER admits — replacing the current selection (a plain viewport click). A miss (or a click when the filter admits nothing) clears the selection. Marks dirty when the selection changed; returns whether something was selected. The by-kind honoring lives in [select_filtered_at] in the appended selection-filter impl block (kept separate so concurrent edits to this primary block don’t conflict).

Source

pub fn selection_json(&self) -> String

The current SELECTION (not hover) as JSON { solids:[..], faces:[..], edges:[..], vertices: n } — lets a UI / the headed verifier read selection state (e.g. assert Esc cleared it).

Source

pub fn ref_select_active(&self) -> bool

True while the reference-selection modal is active (the shell hides the rest of the UI and the viewport routes clicks to picking).

Source

pub fn begin_ref_select( &mut self, feature_id: &str, path: Vec<String>, label: String, filter: Vec<String>, multiple: bool, seed_names: Vec<String>, )

Enter reference-selection mode for feature feature_id’s param at path. Seeds the running list from seed_names (the field’s current value), rolls the model to the pre-feature “before” state (the step just before the edited feature ran), and highlights the seeded names. filter constrains the pick kind (["SOLID"], ["FACE"], …); multiple allows a list.

Source

pub fn ref_select_names(&self) -> Vec<String>

The running list of picked names (empty when not active) — the modal UI reads this back to draw its one-per-line list.

Source

pub fn ref_select_label(&self) -> String

The active field’s label (for the modal heading), or empty.

Source

pub fn ref_select_prompt(&self) -> String

A one-line summary of the active field for the modal heading: "Tool solids (SOLID, multiple)".

Source

pub fn ref_select_click(&mut self, x: f64, y: f64)

A viewport click while active: type-constrained-pick the nearest allowed hit under CSS-pixel (x, y) and add its name to the running list (single fields replace; multiple fields append, de-duplicated). Re-lights the highlight. No-op on a miss / an empty (unnamed) hit.

Source

pub fn ref_select_remove(&mut self, index: usize)

Remove the name at index from the running list (the modal’s per-line X).

Source

pub fn finish_ref_select(&mut self)

Finish: write the running names into the edited feature’s params at the field path, restore the rolled-to step, clear the highlight, and re-run so the feature rebuilds with the chosen references.

Source

pub fn cancel_ref_select(&mut self)

Cancel: discard the running selection, clear the highlight, restore the rolled-to step, and re-run (no param change).

Source§

impl EngineState

Source

pub fn hover_at(&mut self, x: f64, y: f64) -> bool

Hover-highlight the TOP-priority pick under CSS-pixel (x, y) whose kind the selection filter admits, setting it HOVERED in emphasis (the renderer tints it). A miss — or a filter admitting nothing — clears the hover. No-ops (returns false, no dirty) when the hovered entity is unchanged, so a stationary pointer over the same face doesn’t re-render every frame (the k === prevK early-out). Returns whether the hover state changed.

Source

pub fn clear_hover(&mut self) -> bool

Clear the hover highlight (pointer moved to empty space / off the viewport). Bumps the emphasis generation + marks dirty only when a hover was actually lit. Returns whether it changed. (Distinct from clear_selection, which leaves hover alone.)

Source

pub fn hovered_json(&self) -> String

The current HOVER (not selection) as JSON { solids:[..], faces:[..], edges:[..], vertices: n } — the hover twin of selection_json so a UI / the headed verifier can assert that moving the pointer over a face lit the hover emphasis.

Source

pub fn select_toggle_at(&mut self, x: f64, y: f64) -> bool

TOGGLE the top admitted pick under CSS-pixel (x, y) in the current selection (a Ctrl/Cmd+click): add it if absent, remove it if present, leaving the rest of the selection intact (unlike [select_top_at], which REPLACES). A miss — or a filter admitting nothing — leaves the selection untouched (additive mode never clears). Returns whether a hit was toggled.

Source

pub fn candidates_at(&self, x: f64, y: f64) -> String

The RANKED, filter-respecting candidates under CSS-pixel (x, y) as JSON [{kind, name, solid, depth}] — the “candidates under the cursor” list (feeds the disambiguation popup + the headed verifier).

Sorted EXACTLY as the previous app sorted its pick list (kind PRIORITY first, then depth) — pick::pick already ranks by (kind, depth, screen_dist) and appends the owning SOLID entries at the very end, so filtering by the enabled kinds preserves that order.

Source

pub fn candidates_filtered_at(&self, x: f64, y: f64) -> Vec<PickCandidate>

The same ranked, filter-respecting candidate list as typed values (the in-process egui popup consumes these directly, then re-hovers / selects a chosen one via hover_candidate / select_candidate / toggle_candidate). EMPTY when the filter admits nothing (not the pick_filtered “empty filter = any” case).

Source

pub fn hover_candidate(&mut self, candidate: &PickCandidate)

Hover a SPECIFIC candidate (the popup entry the pointer is over) — sets it HOVERED in emphasis, replacing any prior hover.

Source

pub fn select_candidate(&mut self, candidate: &PickCandidate)

REPLACE the selection with a specific candidate (a plain click on a popup entry) — reuses the same bucketing as a plain viewport click.

Source

pub fn toggle_candidate(&mut self, candidate: &PickCandidate) -> bool

TOGGLE a specific candidate in the selection (a Ctrl/Cmd+click on a popup entry, or the select_toggle_at hit): add if absent, remove if present. Returns whether it is NOW selected (true = added, false = removed). Bumps the emphasis generation + marks dirty.

Source§

impl EngineState

Source

pub fn set_sketch_overlay(&mut self, session: &SketchSession)

Display a solved crate::sketch::SketchSession as a read-only overlay. The plane geometry is tessellated to world space and pushed via set_overlay_json; construction dashes are sized against the LIVE camera so they stay screen-constant.

Source

pub fn clear_sketch_overlay(&mut self)

Remove the sketch overlay groups (feeding empty same-named groups upserts them to empty, which the overlay channel treats as a removal — other overlay groups are left untouched).

Source§

impl EngineState

Source

pub fn sketch_dimension_labels_json(&self) -> String

The dimension labels for the active sketch (S5): one entry per dimensional constraint — [{ id, text, world:[x,y,z], value, valueExpr, mode }]. world is the label anchor in world space; brep-app projects it via world_to_screen_json and draws editable text there. [] when not in sketch mode.

Source

pub fn sketch_dimension_value_json(&self, constraint_id: &Value) -> String

The current {value, valueExpr, mode} for a dimensional constraint (S5) — the seed for the inline edit field. {} when the constraint is absent / not in sketch mode. mode is "distance" | "radius" | "diameter" | "angle". For a diameter dim value is the DISPLAYED diameter (twice the stored radius), so the edit field round-trips what the user sees.

Source

pub fn sketch_set_dimension_value( &mut self, constraint_id: &Value, input: &str, ) -> bool

Edit a dimensional constraint’s value (S5), a port of the previous double-click edit:

  • A PLAIN NUMBER (^-?\d*\.?\d+$, optional exponent) → set value and REMOVE valueExpr / valueExprMode (a literal dimension).
  • Otherwise → an EXPRESSION: set valueExpr, evaluate it LIVE against the history’s expressions + configurator (the kernel’s eval_expression). On eval success set value; on FAILURE keep the old value and return false (never corrupt the doc). A diameter dim stores half the entered/ evaluated diameter as the solver radius and tags valueExprMode:"diameter".

Sets valueNeedsSetup:false once a real value lands, re-solves (swallowing errors), refreshes the overlay + marks dirty. Returns whether the value was applied. No-op returning false when the constraint is absent / not in sketch mode.

Source

pub fn sketch_dimension_drag_to( &mut self, constraint_id: &Value, x: f64, y: f64, )

Drag a dimension label to CSS-pixel (x, y) (S5): map the pixel to plane (u, v) (the S2 pixel→plane math), compute the label offset {du, dv} = (label uv) − (the dimension’s anchor uv), and store it in session.dim_offsets keyed by the constraint id. Refreshes the overlay (leaders + labels follow the cursor). No-op when not in sketch mode / the ray misses the plane / the constraint is not dimensional.

Source§

impl EngineState

Source

pub fn sketch_undo(&mut self) -> bool

Undo the last sketch edit (S6a) — pop the undo stack, stash the current state on redo, restore. Returns whether anything was undone. A no-op (false) when not in sketch mode or the stack is empty.

Source

pub fn sketch_redo(&mut self) -> bool

Redo the last undone sketch edit (S6a) — the inverse of [sketch_undo]. Returns whether anything was redone.

Source

pub fn sketch_can_undo(&self) -> bool

Whether a sketch undo is available (drives the mode-bar Undo button).

Source

pub fn sketch_can_redo(&self) -> bool

Whether a sketch redo is available (drives the mode-bar Redo button).

Source

pub fn sketch_dimension_drag_end(&mut self)

End a dimension-label drag gesture (S6a): reset the first-move snapshot guard so the NEXT drag records its own single undo step. No-op when not in sketch mode. Called from the viewport when the label drag stops.

Source

pub fn sketch_diagnostics_dump_json(&self, feature_id: &str) -> String

A debug dump of a SKETCH feature’s document + solved diagnostics (S6a — the dumpSketchDiagnostics button). Uses the LIVE session when that feature is being edited, else reads the persisted sketch/basis off the history and solves a throwaway session. Returns { error } when the feature is absent / not a sketch / unparseable.

Source§

impl EngineState

Source

pub fn sketch_trim_at(&mut self, x: f64, y: f64) -> bool

Trim the geometry under CSS-pixel (x, y) (S6b): map to plane uv (the S2 pixel→plane math) and trim the geometry there. Returns whether the doc changed. A no-op returning false when not in sketch mode, the ray misses the plane, or no geometry is under the cursor.

Source

pub fn sketch_trim_uv(&mut self, u: f64, v: f64) -> bool

The plane-space trim core (sketch_trim_at delegates here; so does the tool state machine, which already has uv). Picks the nearest geometry within the grab radius, snapshots undo, trims it (split or delete), re-solves + refreshes. Returns whether the doc changed; a no-op pops its own undo snapshot so it never leaves a dead step.

Source§

impl EngineState

Source

pub fn sketch_pick_edge_at(&mut self, x: f64, y: f64) -> bool

Link (as a construction reference) the 3D solid edge under CSS-pixel (x, y) into the active sketch (S6b-2). Ranks the pixel through the modeling picker, takes the top EDGE candidate, and delegates to [sketch_link_edge]. Returns whether a link was made / updated. A no-op returning false when not in sketch mode or no scene edge is under the cursor.

Link a scene edge by kernel NAME into the active sketch as an external reference (the headless-testable core sketch_pick_edge_at delegates to). Fetches the edge’s world polyline from the scene, projects it into the sketch plane, classifies + materializes (or updates) the reference, records one undo snapshot (popped on a no-op), re-solves, and refreshes. Returns whether the doc changed. A no-op returning false when not in sketch mode or the edge is absent / degenerate.

Source

pub fn sketch_external_ref_count(&self) -> usize

The number of external-reference edge links in the active sketch (0 when not in sketch mode) — the __brepSketch verifier readout.

Source§

impl EngineState

Source

pub fn sketch_handdraw_begin(&mut self, x: f64, y: f64)

Begin a freehand stroke at CSS-pixel (x, y) (a handdraw drag start): map to plane uv and delegate. No-op when not in sketch mode or the ray misses the plane.

Source

pub fn sketch_handdraw_move(&mut self, x: f64, y: f64)

Extend the freehand stroke toward CSS-pixel (x, y) (a handdraw drag move).

Source

pub fn sketch_handdraw_begin_uv(&mut self, u: f64, v: f64)

Begin a freehand stroke at plane (u, v) (the headless-testable core): snapshot for undo (S6a), clear any prior stroke, and seed it with the start sample. The undo snapshot is popped in [sketch_handdraw_end] if the stroke produces nothing. No-op when not in sketch mode.

Source

pub fn sketch_handdraw_move_uv(&mut self, u: f64, v: f64)

Append plane (u, v) to the live stroke (the headless-testable core), throttled so a sample nearer than ~2px world to the last is skipped. No-op when not in sketch mode or no stroke is live.

Source

pub fn sketch_handdraw_end(&mut self) -> bool

End the freehand stroke (a handdraw drag stop): recognize it into one shape and materialize the geometry, re-solve, and clear the stroke + preview. A stroke that is too short (fewer than 3 samples) or too tiny (extent below the grab radius) is discarded, popping the undo snapshot recorded at begin so no dead step remains. Returns whether geometry was created. No-op returning false when not in sketch mode / no stroke is live.

Source

pub fn sketch_handdraw_len(&self) -> usize

The number of samples in the live handdraw stroke (0 when none / not in sketch mode) — the __brepSketch verifier readout.

Source§

impl EngineState

Source

pub fn sketch_uv_at(&self, x: f64, y: f64) -> Option<(f64, f64)>

Map CSS-pixel (x, y) to the active sketch plane’s (u, v) via the camera pick ray ∩ the sketch plane. None when not in sketch mode or the ray misses the plane (parallel / behind).

Source

pub fn sketch_hover_at(&mut self, x: f64, y: f64) -> bool

Update the sketch hover to the entity under CSS-pixel (x, y) (S2). Returns whether the hover changed. A no-op returning false when not in sketch mode.

Source

pub fn sketch_clear_hover(&mut self) -> bool

Clear the sketch hover (pointer left the viewport / moved over the ViewCube). Returns whether a hover was cleared.

Source

pub fn sketch_click_at(&mut self, x: f64, y: f64, additive: bool)

Click-select in sketch mode: pick the entity under (x, y); nothing → clear the selection; else additive (Ctrl/Cmd) toggles it in the set, a plain click replaces the set with just it. Re-pushes the overlay + marks dirty.

Source

pub fn sketch_drag_begin(&mut self, x: f64, y: f64) -> bool

Begin a point drag if a DRAGGABLE point is under (x, y) (S2): remember it (id + original fixed flag). Returns true iff a point was grabbed (the viewport routes the drag to the sketch; otherwise it orbits the camera). A locked / fully-constrained point is not draggable, so an empty-space or locked-point drag falls through to a camera orbit.

Source

pub fn sketch_drag_to(&mut self, x: f64, y: f64)

Drag the grabbed target to (x, y) (S2): pin every grabbed point at its ORIGINAL position plus the cursor delta (fixed = true) so the solver anchors the whole shape there, re-solve, then restore each point’s ORIGINAL fixed flag. Absolute-from-anchor (never incremental), so a rigid geometry translate tracks the cursor 1:1 without drifting as the solver nudges points between frames. A resolve error rolls every grabbed point back to its pre-drag coords (the last good state). No-op when nothing is grabbed / not in sketch mode / the ray misses the plane.

Source

pub fn sketch_drag_end(&mut self)

End a point drag (S2): clear the grab, then one final re-solve + overlay refresh. No-op when no drag is live.

Source

pub fn sketch_selection_count(&self) -> usize

The number of selected sketch entities (0 when not in sketch mode) — the mode bar / verifier readout.

Source

pub fn sketch_selected_constraint_count(&self) -> usize

The number of selected CONSTRAINTS (refs whose kind is "constraint"; 0 when not in sketch mode) — the __brepSketch verifier readout for constraint selection + delete.

Source§

impl EngineState

Source

pub fn sketch_set_tool(&mut self, tool: Option<&str>)

Set (or clear) the active draw tool: "select"/None → selection mode (S2); "point"|"line"|"rect"|"circle"|"arc"|"bezier" arm the corresponding draw tool; "handdraw" arms the freehand stroke tool (S6b-3); "trim" arms the trim tool (S6b); "pickEdges" arms the external-edge link tool (S6b-2). Clears any in-progress click buffer + preview and refreshes the overlay. No-op when not in sketch mode.

Source

pub fn sketch_active_tool(&self) -> Option<&str>

The active draw tool ("point"|"line"|"rect"|"circle"|"arc"), or None in selection mode / when not in sketch mode.

Source

pub fn sketch_pending_len(&self) -> usize

The number of in-progress draw-tool clicks buffered (0 in selection mode / when not in sketch mode) — the UI/preview + verifier readout.

Source

pub fn sketch_tool_click_at(&mut self, x: f64, y: f64)

A draw-tool click at CSS-pixel (x, y): map to plane uv (the S2 pixel→plane math) and drive the tool state machine. No-op when not in sketch mode, in selection mode, or the ray misses the plane.

Source

pub fn sketch_tool_place_uv(&mut self, u: f64, v: f64)

The per-tool placement logic, in plane (u, v) (the headless-testable core sketch_tool_click_at delegates to). Snaps to existing points within the grab radius so shared vertices coincide; appends geometry and re-solves when a primitive completes; carries the line chain via pending.

Source

pub fn sketch_tool_cancel(&mut self)

Abort the in-progress draw geometry (Escape / right-click): clear the pending clicks + preview and refresh. No-op when not in sketch mode.

Source§

impl EngineState

Source

pub fn sketch_delete_selection(&mut self) -> bool

Delete the selected sketch entities (S3b): the selected geometries + points, plus any geometry orphaned by a deleted vertex, plus orphaned points and the constraints referencing any removed point. Re-solves + refreshes the overlay. Returns true when something was deleted; false when not in sketch mode or the selection is empty.

Source§

impl EngineState

Source

pub fn sketch_mode(&self) -> bool

True while a sketch is being edited (the shell hides the normal side panel and shows the sketch-mode bar).

Source

pub fn sketch_edit_session(&self) -> Option<&SketchSession>

The live sketch session while in sketch mode (for the DOF readout / overlay / the headless verifier), else None.

Source

pub fn sketch_edit_feature_id(&self) -> Option<&str>

The id of the feature being edited while in sketch mode, else None.

Source

pub fn sketch_camera_locked(&self) -> bool

Whether the sketch camera is locked flat to the plane (only panning). On by default every sketch entry; the sketch-mode bar’s checkbox reflects this.

Source

pub fn toggle_sketch_camera_lock(&mut self)

Toggle the sketch camera lock. Turning it ON re-faces the camera to the current sketch plane (so “off → spin around → on” snaps back flat); turning it OFF just frees orbiting. No-op outside sketch mode.

Source

pub fn enter_sketch_mode(&mut self, feature_id: &str) -> Result<String, String>

Enter sketch mode for the "S" feature with id feature_id: snapshot the camera + rolled-to step, roll to the step BEFORE the sketch (its backdrop), read the persisted plane basis + sketch doc off the history JSON, solve a live session, orient the camera onto the plane, and push the read-only overlay. Returns the session’s diagnostics JSON. Errors when the feature is absent or is not a sketch.

Source

pub fn exit_sketch_mode(&mut self, commit: bool) -> String

Exit sketch mode. commit writes the edited doc back to the feature’s persistentData.sketch; a non-commit exit of a brand-new sketch DELETES the feature (a fresh sketch nobody kept). Restores the snapshotted camera + rolled-to step, clears the overlay, re-runs the history, and returns the build report. A no-op (returns "{}") when not in sketch mode.

Source

pub fn new_sketch(&mut self, plane: &str) -> Result<String, String>

Create a NEW engine-native sketch on a base plane ("XY" | "XZ" | "YZ") and enter sketch mode on it. The feature persists an analytic basis (computed via crate::sketch::PlaneFrame) and an empty sketch doc; a cancel exit deletes it. Returns the new session’s diagnostics JSON. Errors on an unknown plane name.

Source§

impl EngineState

Source

pub fn push_notice(&mut self, message: impl Into<String>)

Queue a transient user-facing notice (shown as a toast by the shell) and, on native, also log it. Bounded so a pathological loop can’t grow it.

Source

pub fn take_notices(&mut self) -> Vec<String>

Drain the queued notices (the shell calls this once per frame and shows each as a toast).

Source

pub fn sketch_point_rows(&self) -> Vec<SketchEntityRow>

The Points list: P{id} (x, y) plus ⛓ external / ◐ construction / ⏚ ground markers, mirroring the previous Points rows.

Source

pub fn sketch_geometry_rows(&self) -> Vec<SketchEntityRow>

The Curves list: {type}:{id} [p0,p1,…] (◐ for construction), mirroring the previous Curves rows.

Source

pub fn sketch_constraint_rows(&self) -> Vec<SketchEntityRow>

The Constraints list: {id} {type} {value} [points], mirroring the previous Constraints rows.

Source

pub fn sketch_select_entity(&mut self, kind: &str, id: Value, additive: bool)

Select an entity BY ref from a list row (mirrors [sketch_click_at]): a plain click replaces the selection, an additive (Ctrl/Cmd) click toggles it.

Source

pub fn sketch_hover_entity(&mut self, kind: &str, id: Value)

Hover an entity BY ref from a list row (list→canvas highlight). Sets the one-frame guard so the viewport — which draws after the panel and would otherwise clear the hover because the pointer is off the viewport — keeps it.

Source

pub fn take_sketch_list_hover(&mut self) -> bool

Consume the “list panel set the hover this frame” guard (read + reset). The viewport calls this before its off-viewport sketch_clear_hover so a panel-set hover survives the frame.

Source

pub fn sketch_solver_settings(&self) -> Option<SketchSolverSettings>

The active sketch’s solver settings (the Solver Settings panel reads this). None when not editing a sketch.

Source

pub fn sketch_set_solver_settings(&mut self, settings: SketchSolverSettings)

Replace the active sketch’s solver settings and re-solve so the change takes effect immediately. No-op when not editing a sketch.

Source§

impl EngineState

Source

pub fn sketch_applicable_constraints(&self) -> Vec<SketchConstraintAction>

The ordered palette of constraints applicable to the active sketch selection (a faithful port of #refreshContextBar). Empty when not in sketch mode or the selection surfaces no constraint. The Fix/Unfix + construction + cleanup affordances are exposed separately (see sketch_selection_all_grounded / sketch_selection_all_construction / sketch_cleanup_unused_points).

Source

pub fn sketch_add_constraint(&mut self, symbol: &str) -> bool

Add the constraint named by symbol from the current selection (a port of createConstraint): build the ordered point-id list, dedup on type + sorted-points, append (dimensional → value:null), then re-solve + refresh (keeping the selection). Returns whether a constraint was added.

Source

pub fn sketch_toggle_ground(&mut self) -> bool

Toggle the ground () constraint on the selected points: if ALL selected points are already grounded → remove those grounds (and clear their fixed flag); else add a for each ungrounded selected point (and set fixed). Re-solves + refreshes. Returns whether anything changed. No-op with no point selected / not in sketch mode.

Source

pub fn sketch_toggle_construction(&mut self) -> bool

Flip the construction flag on ALL selected points AND geometries: if every selected entity is already construction → make them regular, else make them all construction. Re-solves + refreshes. Returns whether anything was selected. No-op with nothing selected / not in sketch mode.

Source

pub fn sketch_cleanup_unused_points(&mut self) -> bool

Remove points referenced by NO geometry AND no constraint (the 🧹 action). Re-solves + refreshes only when something was dropped. Returns whether a point was removed. No-op when not in sketch mode.

Source

pub fn sketch_constraint_count(&self) -> usize

The number of constraints in the active sketch (0 when not in sketch mode) — the verifier / palette readout.

Source

pub fn sketch_selection_all_grounded(&self) -> Option<bool>

Whether the selected points are ALL grounded (Some(true)), NOT all grounded (Some(false)), or no point is selected (None) — labels the Fix vs Unfix button.

Source

pub fn sketch_selection_all_construction(&self) -> Option<bool>

Whether the selected points + geometries are ALL construction (Some(true)), NOT all construction (Some(false)), or nothing is selected (None) — labels the ◐ construction-toggle button’s direction.

Source§

impl EngineState

Source

pub fn transform_armed(&self) -> bool

Whether the TRANSFORM gizmo (move/rotate) is armed for ANY feature. False in dimension mode — the two ◎ modes are exclusive, so the transform gizmo arms/handles never render while dimensions are shown.

Source

pub fn transform_armed_feature(&self) -> String

The transform-gizmo-armed feature id (empty unless in transform mode).

Source

pub fn transform_armed_for(&self, feature_id: &str) -> bool

Whether the TRANSFORM gizmo is armed for THIS feature.

Source

pub fn arm_transform(&mut self, feature_id: &str)

Arm the TRANSFORM gizmo for feature_id and feed it at the feature’s transform frame. Re-arming a different feature moves the gizmo to it. Clears any dimension overlay (the modes are exclusive).

Source

pub fn disarm_transform(&mut self)

Disarm: hide BOTH gizmos + drop any in-flight drag.

Source

pub fn sync_transform_gizmo(&mut self)

(Re)feed the widget gizmo at the armed feature’s frame: origin = position, axes = the feature’s rotated basis (intrinsic XYZ Euler order, matching the kernel bake). Auto-disarms if the feature vanished. Called every drag frame from transform_drag_to so the widget tracks the moving pose live (Fix 3); the drag delta resolves against the frozen grab frame, so this re-sync never feeds back into the drag math.

Source

pub fn feature_has_transform(&self, feature_id: &str) -> bool

Whether feature feature_id carries a transform param (a Transform group), so it CAN show a transform gizmo. The panel’s auto-arm-on-expand uses this: a feature with NO dimension gizmo but WITH a transform (datum/helix/pattern/port) arms the TRANSFORM gizmo directly on expand, instead of being left with no gizmo at all now that the ◎ arm button is gone. (armed_pose alone can’t gate this — it defaults to identity for a transform-less feature, so a boolean/fillet would show a spurious gizmo.)

Source

pub fn transform_gizmo_anchor(&self) -> Option<(f64, f64)>

The armed gizmo origin projected to VIEWPORT-LOCAL px (the center handle sits here). The history panel publishes it so the headed verifier can locate + drag the gizmo. None when disarmed / behind the camera.

Source

pub fn transform_axis_labels_json(&self) -> String

The transform gizmo’s axis-end labels as JSON: [{ text:"XC"|"YC"|"ZC", rgb:[r,g,b], world:[x,y,z] }]. The app projects each world point and draws the colored egui label just past the matching cone tip (X=red, Y=green, Z=blue). [] unless the TRANSFORM gizmo is armed.

Source

pub fn transform_press(&mut self, x: f64, y: f64) -> bool

Begin a gizmo drag at viewport px (x, y) when the gizmo is armed AND a handle is under the pointer. Returns whether a handle was grabbed — the viewport routes the drag to the gizmo (not the camera) when true; a press on empty space returns false and still orbits.

Source

pub fn transform_dragging(&self) -> bool

Whether a gizmo handle drag is in flight.

Source

pub fn transform_drag_to(&mut self, cx: f64, cy: f64)

Continue the in-flight gizmo drag to viewport px (cx, cy): resolve the world delta from the grab (against the frozen grab-time frame), apply it to the grab pose, write it back into the feature’s transform, and re-run so the model follows live. Then re-sync the VISIBLE gizmo to the moved pose so the widget tracks the pointer in real time (Fix 3) — the delta stays anchored to drag.start, so this visual sync never feeds back on itself.

Source

pub fn transform_release(&mut self)

End the drag: clear the active-handle highlight + re-sync the gizmo to the feature’s final (moved) pose (unpin the frame).

Source§

impl EngineState

Source

pub fn new() -> Self

Source§

impl EngineState

Source

pub fn object_metadata_json(&self, name: &str) -> String

One object’s metadata record as JSON { key: value, ... } ({} if none).

Source

pub fn set_metadata_attribute(&mut self, name: &str, key: &str, value: &str)

Set (or overwrite) one metadata attribute of an object by NAME. String value; the well-known density key drives the object’s weight.

Source

pub fn remove_metadata_attribute(&mut self, name: &str, key: &str) -> bool

Remove one metadata attribute of an object. Returns whether it existed.

Source

pub fn metadata_json(&self) -> String

The whole metadata store as JSON { name: { key: value } }.

Source§

impl EngineState

Source

pub fn creating_feature(&self, name: &str) -> Option<(String, String)>

The feature that PRODUCED an object, as (feature id, feature type). For a face/edge the owning solid’s producer is reported. None if the name is unknown or has no known producer. Reads the EAGER provenance the last run shipped (name → creating-feature id), so it never re-runs the history — the freeze side-door context_bar hit every selected frame is now O(1).

Source

pub fn object_info_json(&mut self, name: &str) -> String

The full Properties-panel info for an object by NAME: its resolved kind, the right measurements, and provenance. Units are millimetres.

  • Solid{ ok, name, kind:"solid", volume, surfaceArea, edgeLengthTotal, density, weight, creatingFeature }, where weight = density · volume and density comes from the object’s metadata (default DEFAULT_DENSITY).
  • Face{ ok, name, kind:"face", solid, area, edgeLengthTotal, creatingFeature } (edgeLengthTotal = its boundary edges).
  • Edge{ ok, name, kind:"edge", solid, length, creatingFeature }.

{ ok:false, name, message } for an empty/unknown name, a non-resident solid, or a kernel measurement failure.

The real solid/face/edge MEASUREMENT is routed to the HistoryRunner (so the warm-registry runner answers it, never the potentially-cold main side) and CACHED here keyed by name — fired once per selection, served from the cache every subsequent frame. For the synchronous InlineRunner the submit → pump_queries resolves same-call, so this returns the merged JSON immediately and stays byte-identical to the pre-seam in-process result; a background ThreadRunner returns a pending placeholder for the frame(s) until its reply lands (drained by pump_queries). The cache is invalidated on any geometry change (apply_run_output) or metadata edit (set_metadata_attribute).

Source

pub fn pump_queries(&mut self)

Drain every completed measurement reply from the runner and fold it into the name-keyed info cache — the query counterpart of EngineState::pump. Called once per frame from pump AND synchronously from Self::object_info_json (so the Inline runner resolves same-call). Each reply is MERGED with the main-injected name + creatingFeature (from the eager provenance) into the final object-info JSON.

Source§

impl EngineState

Source

pub fn set_entity_visible( &mut self, solid: &str, kind: EntityKind, index: usize, visible: bool, ) -> bool

Show/hide ONE face/edge/vertex of a solid, by its index in the solid’s face/edge/vertex list — the same index the Scene tree enumerates. Marks dirty. Returns false if the solid is unknown.

Source

pub fn set_group_visible( &mut self, solid: &str, kind: EntityKind, visible: bool, ) -> bool

Show/hide a WHOLE group (all faces / all edges / all vertices of a solid). Marks dirty. Returns false if the solid is unknown.

Source

pub fn entity_visible( &self, solid: &str, kind: EntityKind, index: usize, ) -> Option<bool>

Whether entity index of kind on solid is shown (None if unknown).

Source

pub fn group_visibility( &self, solid: &str, kind: EntityKind, ) -> Option<GroupState>

The group tristate for solid’s kind (None if the solid is unknown).

Source

pub fn scene_visibility_json(&self) -> String

Per-entity + group visibility as JSON — the readout the headed verifier asserts against (a companion to scene_entities_json, which lists the entities but not their per-entity visibility): [{name, visible, faces:{group, states:[bool;n]}, edges:{…}, vertices:{…}}] where states[i] is entity i’s visibility and group is "all"|"partial"|"none".

Trait Implementations§

Source§

impl Default for EngineState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>