pub struct Sketch3dSession {
pub doc: Sketch3dDoc,
pub diagnostics: Sketch3dDiagnostics,
pub selection: RefSelection,
pub tool: Option<String>,
pub work_plane: WorkPlane,
pub colors: SketchColors,
pub lost_references: Vec<(String, Vec<Value>)>,
}Expand description
State for one active 3D sketch.
Fields§
§doc: Sketch3dDocThe solved document (points carry solved coordinates).
diagnostics: Sketch3dDiagnosticsThe last solve’s diagnostics.
selection: RefSelectionSelected entity refs ({"kind":"point"|"geometry"|"constraint","id":…})
and the entity under the cursor — the planar session’s set.
tool: Option<String>The armed draw tool (None = select).
work_plane: WorkPlaneThe working plane a free click lands on.
colors: SketchColorsThe overlay palette (the planar sketch’s, shared).
lost_references: Vec<(String, Vec<Value>)>Linked references the backdrop can no longer resolve: (name, the fixed point ids holding its last position).
Implementations§
Source§impl Sketch3dSession
impl Sketch3dSession
Sourcepub fn new(doc: Sketch3dDoc) -> Result<Self, String>
pub fn new(doc: Sketch3dDoc) -> Result<Self, String>
Build a session from a (possibly unsolved) doc, solving it once.
pub fn is_selected(&self, entity_ref: &Value) -> bool
pub fn toggle_selection(&mut self, entity_ref: Value)
pub fn clear_selection(&mut self)
pub fn set_hover(&mut self, entity_ref: Option<Value>)
Sourcepub fn selection_by_kind(&self) -> (Vec<Value>, Vec<Value>, Vec<Value>)
pub fn selection_by_kind(&self) -> (Vec<Value>, Vec<Value>, Vec<Value>)
The selected entity refs split by kind: (point ids, geometry ids, constraint ids).
Sourcepub fn sample_geometry(
&self,
geometry: &Sketch3dGeometry,
world_per_pixel: f64,
) -> Option<Vec<[f64; 3]>>
pub fn sample_geometry( &self, geometry: &Sketch3dGeometry, world_per_pixel: f64, ) -> Option<Vec<[f64; 3]>>
Sample a geometry into an ordered world polyline (None for a missing
point or a degenerate shape). A point geometry samples to nothing; a
reference plane draws as a square about its origin, sized in pixels.
Sourcepub fn pick_entity(
&self,
camera: &ViewCamera,
x: f64,
y: f64,
radius_px: f64,
) -> Option<Value>
pub fn pick_entity( &self, camera: &ViewCamera, x: f64, y: f64, radius_px: f64, ) -> Option<Value>
The entity under CSS-pixel (x, y) within radius_px: a POINT wins over
geometry when one is in range, else the nearest geometry whose projected
polyline passes within range. Construction geometry is pickable.
Sourcepub fn constraint_glyphs(
&self,
world_per_pixel: f64,
) -> Vec<(Value, [f64; 3], &'static str)>
pub fn constraint_glyphs( &self, world_per_pixel: f64, ) -> Vec<(Value, [f64; 3], &'static str)>
One mark per non-dimensional constraint: (id, centre, shape). Marks
sharing an anchor are stacked, so each stays selectable.
Sourcepub fn pick_draggable_point(
&self,
camera: &ViewCamera,
x: f64,
y: f64,
radius_px: f64,
) -> Option<(Value, bool)>
pub fn pick_draggable_point( &self, camera: &ViewCamera, x: f64, y: f64, radius_px: f64, ) -> Option<(Value, bool)>
The nearest DRAGGABLE point under (x, y) (id + its authored fixed
flag): a point the solver reports movable.
Sourcepub fn drag_points_from_ref(
&self,
entity_ref: &Value,
) -> Option<Vec<(Value, [f64; 3], bool)>>
pub fn drag_points_from_ref( &self, entity_ref: &Value, ) -> Option<Vec<(Value, [f64; 3], bool)>>
The points a drag of entity_ref moves: the one point, or every
(deduped, movable) point of a geometry; None for a locked point or a
constraint.
Sourcepub fn tessellation(&self, world_per_pixel: f64) -> SketchTessellation
pub fn tessellation(&self, world_per_pixel: f64) -> SketchTessellation
Tessellate the solved sketch with hover + selection coloring.
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 the solved geometry + points.
Sourcepub fn preview_overlay_json(
&self,
pending: &[Value],
hover: Option<[f64; 3]>,
) -> String
pub fn preview_overlay_json( &self, pending: &[Value], hover: Option<[f64; 3]>, ) -> String
The set_overlay JSON for the armed tool’s rubber band: the pending
points joined, and the last one joined to the hovered world point.
Always the sketch3d-preview group (empty when nothing is pending).
Sourcepub fn workplane_overlay_json(&self, world_per_pixel: f64) -> String
pub fn workplane_overlay_json(&self, world_per_pixel: f64) -> String
The set_overlay JSON for the working plane: a dashed square through
the anchor with its two in-plane axes, sized in pixels so it reads the
same at any zoom. Hidden (empty group) while the select tool is armed —
it matters only where a click lands.
Sourcepub fn dimension_labels(&self) -> Vec<Sketch3dDimLabel>
pub fn dimension_labels(&self) -> Vec<Sketch3dDimLabel>
One label per dimensional constraint, anchored at the dimension’s natural midpoint.
Sourcepub fn applicable_constraints(&self) -> Vec<ApplicableConstraint>
pub fn applicable_constraints(&self) -> Vec<ApplicableConstraint>
The constraints the palette offers for the current selection, each with the point ids it would take, in palette order.
Sourcepub fn measure(&self, ctype: &str, ids: &[Value]) -> Option<f64>
pub fn measure(&self, ctype: &str, ids: &[Value]) -> Option<f64>
The value a dimensional constraint over ids would be SEEDED with — the
current measurement, so adding a dimension changes nothing until the
user edits it.
Sourcepub fn lost_reference_of(&self, constraint: &Sketch3dConstraint) -> Option<&str>
pub fn lost_reference_of(&self, constraint: &Sketch3dConstraint) -> Option<&str>
The name of the lost reference a constraint depends on, if any.
Sourcepub fn lost_reference_messages(&self) -> Vec<String>
pub fn lost_reference_messages(&self) -> Vec<String>
One sentence per lost reference, naming the constraints that need it.
Sourcepub fn entity_rows_json(&self) -> Value
pub fn entity_rows_json(&self) -> Value
Rows for the entity lists: (kind, id, label) per point, geometry and
constraint, with the mobility / conflict state the list colors by.
Auto Trait Implementations§
impl Forget for Sketch3dSession
impl Freeze for Sketch3dSessionwhere
*const u8 is !null: Freeze,
PhantomData<Sketch3dPoint>: Freeze,
PhantomData<Sketch3dGeometry>: Freeze,
PhantomData<Sketch3dConstraint>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
*const LeafNode<String, String> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, String)>>: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
PhantomData<(String, Vec<Value>)>: Freeze,
impl Move for Sketch3dSession
impl RefUnwindSafe for Sketch3dSession
impl Send for Sketch3dSession
impl Sync for Sketch3dSession
impl Unpin for Sketch3dSession
impl UnsafeUnpin for Sketch3dSessionwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Sketch3dPoint>: UnsafeUnpin,
PhantomData<Sketch3dGeometry>: UnsafeUnpin,
PhantomData<Sketch3dConstraint>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const LeafNode<String, String> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, String)>>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
PhantomData<(String, Vec<Value>)>: UnsafeUnpin,
impl UnwindSafe for Sketch3dSession
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.