Skip to main content

SketchSession

Struct SketchSession 

Source
pub struct SketchSession {
    pub doc: SketchDoc,
    pub plane: PlaneFrame,
    pub diagnostics: SketchDiagnostics,
    pub selection: Vec<Value>,
    pub hovered: Option<Value>,
    pub tool: Option<String>,
    pub dim_offsets: Map<String, Value>,
    pub colors: SketchColors,
    pub solver_settings: SketchSolverSettings,
}
Expand description

State for one active sketch.

Fields§

§doc: SketchDoc

The solved sketch (points carry solved coordinates).

§plane: PlaneFrame

The plane the sketch’s (u, v) coordinates are embedded in.

§diagnostics: SketchDiagnostics

The last solve’s read-only diagnostics (DOF, over/under status, mobility).

§selection: Vec<Value>

Selected entities — a set of entity refs ({"kind":"point"|"geometry","id":<id>}; see point_ref/geometry_ref).

§hovered: Option<Value>

The entity ref currently under the cursor, or None.

§tool: Option<String>

The active drawing tool.

§dim_offsets: Map<String, Value>

Persisted dimension label offsets.

§colors: SketchColors

The overlay color palette — a live SketchColors view of the display settings (RenderSettings::sketch_colors). The engine sets this on entry and re-syncs it when the settings change; every overlay builder reads from here so the sketch colors are managed in the settings like the rest of the display. Defaults to SketchColors::default so a session built in a test (or before the engine syncs) renders the standard theme.

§solver_settings: SketchSolverSettings

User-tunable solver knobs (the Solver Settings panel). Read by every resolve; default reproduces the historical solve.

Implementations§

Source§

impl SketchSession

Source

pub fn new(doc: SketchDoc, plane: PlaneFrame) -> Result<Self, String>

Build a session from a (possibly unsolved) doc + plane, solving it once.

Source

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

Re-solve the current doc, refreshing coordinates + diagnostics in place, honoring the session’s solver_settings.

Source

pub fn overlay_json(&self, world_per_pixel: f64) -> String

The set_overlay JSON for this solved sketch (see tessellate::overlay_json). world_per_pixel sizes construction dashes.

Source

pub fn tessellation(&self, world_per_pixel: f64) -> SketchTessellation

The flat overlay buffers (for tests / verification stats).

Source

pub fn overlay_json_with_state(&self, world_per_pixel: f64) -> String

The set_overlay JSON with the live hover + selection colored in (S2). Empty hover + selection reproduce overlay_json exactly.

Source

pub fn dim_leaders_overlay_json(&self, world_per_pixel: f64) -> String

The set_overlay JSON for the sketch-dim-leaders group (S5): the per-type leader/arrow segments for every dimensional constraint, offset by its stored {du, dv} (see dimensions). Always emitted (empty when the sketch has no dimensions) so a stale group clears on the next refresh.

Source

pub fn dim_leaders_overlay_json_with_state( &self, world_per_pixel: f64, ) -> String

Like dim_leaders_overlay_json but emphasizes the live hovered / selected dimensional constraint (amber selected, light-blue hovered — matching points/geometry). Used by the interactive overlay refresh.

Source

pub fn constraint_glyphs_overlay_json(&self, world_per_pixel: f64) -> String

The set_overlay JSON for the sketch-constraint-glyphs group (S6c): the small screen-constant line-art marks for every GEOMETRIC (non-dimensional) constraint — perpendicular, parallel, horizontal/vertical, coincident, equal, … (see constraint_glyphs). Painted in the shared constraint green. Always emitted (empty when the sketch has no geometric constraints) so a stale group clears on the next refresh.

Source

pub fn constraint_glyphs_overlay_json_with_state( &self, world_per_pixel: f64, ) -> String

Like constraint_glyphs_overlay_json but emphasizes the live hovered / selected geometric constraint (amber selected, light-blue hovered — matching points/geometry). Used by the interactive refresh.

Source

pub fn dimension_labels(&self, world_per_pixel: f64) -> Vec<DimLabel>

The per-constraint dimension labels (S5): one DimLabel per dimensional constraint, each anchored in world space (plane.to_world of the label uv + its stored offset). brep-app projects world → screen and draws the editable value text there.

Source

pub fn preview_overlay_json( &self, world_per_pixel: f64, pending: &[Value], hover_uv: Option<(f64, f64)>, stroke: &[(f64, f64)], ) -> String

The set_overlay JSON for the active draw tool’s in-progress rubber-band preview (S3a): the dim dashed geometry from the pending anchor points (their ids, resolved to uv against the live doc) toward hover_uv, plus the raw freehand stroke (S6b-3) as a dim solid polyline while a handdraw drag is live. Always a sketch-preview group (empty when there is nothing to preview yet).

Source

pub fn is_selected(&self, entity_ref: &Value) -> bool

Whether entity_ref is in the selection set (matched via refs_equal).

Source

pub fn toggle_selection(&mut self, entity_ref: Value)

Toggle entity_ref in the selection set: remove it if present, else add it.

Source

pub fn clear_selection(&mut self)

Clear the selection set.

Source

pub fn set_hover(&mut self, entity_ref: Option<Value>)

Set (or clear) the hovered entity ref.

Source

pub fn pick_entity(&self, u: f64, v: f64, radius: f64) -> Option<Value>

The entity ref nearest to plane coordinate (u, v) within radius — a POINT wins over geometry when one is in range (points take priority), else the nearest geometry whose polyline passes within radius. Construction geometry is included (it is pickable). None when nothing is in range.

Source

pub fn pick_constraint( &self, u: f64, v: f64, radius: f64, world_per_pixel: f64, ) -> Option<Value>

The CONSTRAINT nearest to (u, v) within radius — a constraint entity ref ({"kind":"constraint","id":<id>}), or None. A GEOMETRIC constraint is picked near its glyph line-art (the exact segments constraint_glyphs draws); a DIMENSIONAL one near its leader/arrow lines (NOT its value label — the label is the egui value-editor affordance). Solver-internal temporary helpers are never pickable. world_per_pixel sizes the screen-constant glyph/leader placement (so picking tracks what is drawn). The CALLER enforces priority: points > geometry > constraint (see EngineState::sketch_entity_at), so a glyph over a point never shadows the point.

Source

pub fn pick_draggable_point( &self, u: f64, v: f64, radius: f64, ) -> Option<(Value, bool)>

The nearest DRAGGABLE point to (u, v) within radius (its id + authored fixed flag), or None. A point is draggable only if the solver reports it movable (a locked / grounded point has no free coordinates to drag), so a drag on a fully-constrained point falls through to a camera orbit.

Source

pub fn drag_points_from_ref( &self, entity_ref: &Value, ) -> Option<Vec<(Value, f64, f64, bool)>>

The point-set to DRAG for a hovered entity ref ({"kind","id"}) — the grab path grabs exactly what’s highlighted rather than re-picking at egui’s offset drag-start position. A "point" ref → that point iff it is MOVABLE; a "geometry" ref → ALL of its (deduped) points when at least one is movable (a rigid translate). Each entry is (id, orig_x, orig_y, orig_fixed). None for a locked point, a fully-locked geometry, or a stale/unknown ref (the caller then falls through to a camera gesture — it never drags something the user is not pointing at).

Source

pub fn seed_rectangle_circle() -> Result<Self, String>

Seed a standalone demo sketch (S0 milestone): a fully-constrained 20×12 rectangle grounded at the origin PLUS a free (unconstrained) circle beside it, both on the XY plane. The mix proves the pipeline end to end — the rectangle solves to locked (white), the circle stays movable (blue), and the sketch reports dof = 4 (the circle’s four free coordinates).

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, !>

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>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,