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
One sketch’s live session: solved document + plane + diagnostics, with stubs for the interaction state later slices own.
Fields§
§doc: SketchDocThe solved sketch (points carry solved coordinates).
plane: PlaneFrameThe plane the sketch’s (u, v) coordinates are embedded in.
diagnostics: SketchDiagnosticsThe last solve’s read-only diagnostics (DOF, over/under status, mobility).
selection: Vec<Value>Selected entities (S2) — 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 (S2), or None.
tool: Option<String>The active drawing tool (S3). Unused in S0.
dim_offsets: Map<String, Value>Persisted dimension label offsets (S5). Unused in S0.
colors: SketchColorsThe 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: SketchSolverSettingsUser-tunable solver knobs (the Solver Settings panel). Read by every
resolve; default reproduces the historical solve.
Implementations§
Source§impl SketchSession
impl SketchSession
Sourcepub fn new(doc: SketchDoc, plane: PlaneFrame) -> Result<Self, String>
pub fn new(doc: SketchDoc, plane: PlaneFrame) -> Result<Self, String>
Build a session from a (possibly unsolved) doc + plane, solving it once.
Sourcepub fn resolve(&mut self) -> Result<(), String>
pub fn resolve(&mut self) -> Result<(), String>
Re-solve the current doc, refreshing coordinates + diagnostics in place,
honoring the session’s solver_settings.
Sourcepub fn overlay_json(&self, world_per_pixel: f64) -> String
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.
Sourcepub fn tessellation(&self, world_per_pixel: f64) -> SketchTessellation
pub fn tessellation(&self, world_per_pixel: f64) -> SketchTessellation
The flat overlay buffers (for tests / verification stats).
Sourcepub fn overlay_json_with_state(&self, world_per_pixel: f64) -> String
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.
Sourcepub fn dim_leaders_overlay_json(&self, world_per_pixel: f64) -> String
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.
Sourcepub fn dim_leaders_overlay_json_with_state(
&self,
world_per_pixel: f64,
) -> String
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.
Sourcepub fn constraint_glyphs_overlay_json(&self, world_per_pixel: f64) -> String
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.
Sourcepub fn constraint_glyphs_overlay_json_with_state(
&self,
world_per_pixel: f64,
) -> String
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.
Sourcepub fn dimension_labels(&self, world_per_pixel: f64) -> Vec<DimLabel>
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.
Sourcepub fn preview_overlay_json(
&self,
world_per_pixel: f64,
pending: &[Value],
hover_uv: Option<(f64, f64)>,
stroke: &[(f64, f64)],
) -> String
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).
Sourcepub fn is_selected(&self, entity_ref: &Value) -> bool
pub fn is_selected(&self, entity_ref: &Value) -> bool
Whether entity_ref is in the selection set (matched via refs_equal).
Sourcepub fn toggle_selection(&mut self, entity_ref: Value)
pub fn toggle_selection(&mut self, entity_ref: Value)
Toggle entity_ref in the selection set: remove it if present, else add it.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection set.
Sourcepub fn pick_entity(&self, u: f64, v: f64, radius: f64) -> Option<Value>
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.
Sourcepub fn pick_constraint(
&self,
u: f64,
v: f64,
radius: f64,
world_per_pixel: f64,
) -> Option<Value>
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.
Sourcepub fn pick_draggable_point(
&self,
u: f64,
v: f64,
radius: f64,
) -> Option<(Value, bool)>
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.
Sourcepub fn drag_points_from_ref(
&self,
entity_ref: &Value,
) -> Option<Vec<(Value, f64, f64, bool)>>
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).
Sourcepub fn seed_rectangle_circle() -> Result<Self, String>
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§
impl Freeze for SketchSession
impl RefUnwindSafe for SketchSession
impl Send for SketchSession
impl Sync for SketchSession
impl Unpin for SketchSession
impl UnsafeUnpin for SketchSession
impl UnwindSafe for SketchSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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