pub struct WidgetRegistry {
pub viewcube_enabled: bool,
/* private fields */
}Expand description
The engine-side widget registry (one per engine).
Fields§
§viewcube_enabled: boolThe ViewCube is always-on once enabled by the host UI (its retired counterpart is deleted in the same change set).
Implementations§
Source§impl WidgetRegistry
impl WidgetRegistry
pub fn new() -> Self
Sourcepub fn has_main_overlay(&self) -> bool
pub fn has_main_overlay(&self) -> bool
Any main-overlay widget geometry present (excludes the ViewCube, which draws in its own pass).
Sourcepub fn overlay_groups_bbox(&self) -> Aabb
pub fn overlay_groups_bbox(&self) -> Aabb
World-space AABB of the pushed overlay GROUPS — the set_overlay geometry
(the sketch curves + points, dimension leaders, constraint glyphs, datums,
curves). EXCLUDES the screen-constant transform gizmo + ViewCube (own passes).
Folded into the camera depth-range fit so orbiting an editing sketch doesn’t
clip the overlay against the SOLIDS-ONLY scene bounds (the reported
sketch-clipping bug when “Lock to sketch” is off). Empty when no groups.
Sourcepub fn set_datums_json(&mut self, json: &str) -> Result<(), String>
pub fn set_datums_json(&mut self, json: &str) -> Result<(), String>
Replace the datum / curve display set. Shape:
{planes:[{name,origin,x,y,size?,color?,selected?,hovered?}], axes:[{name,point,direction,length,color?,selected?,hovered?}], frames:[{origin,x,y,z,px?}], curves:[{points:[[x,y,z]...],closed?,color?,selected?,hovered?}]}.
Sourcepub fn set_overlay_json(&mut self, json: &str) -> Result<(), String>
pub fn set_overlay_json(&mut self, json: &str) -> Result<(), String>
Replace/upsert the GENERAL overlay geometry channel (set_overlay).
Shape: {groups:[{name, renderOrder?, tris:{positions,colors,normals?}, lines:{positions,colors}, points?:{positions,colors,size?}}]}. Each group
UPSERTS by name; a group whose geometry is entirely empty REMOVES that
name; an empty (or missing) groups array CLEARS every group.
Sourcepub fn overlay_group_names(&self) -> Vec<&str>
pub fn overlay_group_names(&self) -> Vec<&str>
The names of the currently-loaded (non-empty) general overlay groups — a read accessor for tests / verification. An empty group is auto-removed on upsert, so a name present here always carries geometry.
Sourcepub fn datum_plane_names(&self) -> Vec<(&str, bool)>
pub fn datum_plane_names(&self) -> Vec<(&str, bool)>
The currently-fed datum PLANES as (name, emphasized) — a read accessor for
tests / verification (the datum planes replace their set wholesale each
set_datums_json, so this is exactly the current construction-datum feed).
emphasized is the selected/hovered hot flag (a selected datum reads true).
Sourcepub fn set_dimensions_json(&mut self, json: &str) -> Result<(), String>
pub fn set_dimensions_json(&mut self, json: &str) -> Result<(), String>
Replace the feature-dimension set. Shape: an array of
{id, type:"linear"|"angular"|"radial", ...} — linear: a,b,offsetDir, offset; angular: vertex,dirA,dirB,radius; radial: center,pointOnCircle.
Sourcepub fn set_transform_json(&mut self, json: &str) -> Result<(), String>
pub fn set_transform_json(&mut self, json: &str) -> Result<(), String>
Set (or clear, when json == "null") the transform gizmo. Shape:
{origin,x,y,z,showCenter?,showAxes?,showRings?} — the selected
feature’s frame (R28); the optional show flags (default true) carve the
translate-only / rotate-only variants the component Move toggle cycles.
pub fn set_viewcube_enabled(&mut self, enabled: bool)
Sourcepub fn set_view_frame(&mut self, frame: ViewFrame)
pub fn set_view_frame(&mut self, frame: ViewFrame)
Set the frame the ViewCube’s faces are named in. The engine sets it from whether a board is shown, the same test its standard views use.
pub fn view_frame(&self) -> ViewFrame
Sourcepub fn set_viewcube_size(&mut self, size_px: f32)
pub fn set_viewcube_size(&mut self, size_px: f32)
Set the ViewCube’s on-screen edge length (CSS px). ONE size field feeds both
the rendered mini-camera viewport (build_viewcube) and the hit-test corner
rect (viewcube_rect), so the drawn cube and its clickable region always
scale together. Driven from RenderSettings::viewcube_size_px on every
settings apply. Guarded to a >= 1px positive size so a bad feed can’t
collapse the rect.
Sourcepub fn build_main_overlay(&self, cam: &GizmoCamera) -> (Overlay, usize)
pub fn build_main_overlay(&self, cam: &GizmoCamera) -> (Overlay, usize)
Build the main-overlay geometry (everything but the ViewCube). Build the main overlay geometry AND the count of leading tri vertices that belong to the datum/construction PLANES (always emitted FIRST). The render core draws those with a NO-depth-write pipeline so a translucent plane can never occlude the gizmos/dimensions that follow.
Sourcepub fn dimension_anchors(&self, cam: &GizmoCamera) -> Vec<(String, [f32; 3])>
pub fn dimension_anchors(&self, cam: &GizmoCamera) -> Vec<(String, [f32; 3])>
(id, world label anchor) for every dimension — the host projects
each with world_to_screen to place its text label (R29).
Sourcepub fn any_visible(&self) -> bool
pub fn any_visible(&self) -> bool
Any overlay widget is present (main geometry or the ViewCube).
Sourcepub fn render_fingerprint(&self, cam: &GizmoCamera) -> u64
pub fn render_fingerprint(&self, cam: &GizmoCamera) -> u64
A hash of everything this registry would draw with cam: the main
overlay without the groups and the ViewCube, built as a frame builds
them, plus each group’s identity and stored fold_words hash. Used by
the app’s stale-frame check (automation builds) to notice a drawn
change that did not mark the frame dirty.
Sourcepub fn build_overlay(&self, cam: &GizmoCamera) -> WidgetOverlay
pub fn build_overlay(&self, cam: &GizmoCamera) -> WidgetOverlay
Build a whole frame’s overlay geometry from the live camera.
Sourcepub fn build_viewcube(&self, cam: &GizmoCamera) -> Option<ViewCubeFrame>
pub fn build_viewcube(&self, cam: &GizmoCamera) -> Option<ViewCubeFrame>
The ViewCube render frame (overlay + mini-camera + corner rect), or None when disabled.
Sourcepub fn viewcube_rect(&self, cam: &GizmoCamera) -> [f32; 4]
pub fn viewcube_rect(&self, cam: &GizmoCamera) -> [f32; 4]
The ViewCube corner rect [x, y, w, h] (CSS px) — the host decides
whether to forward a pointer event and offsets it into cube-local coords.
Sourcepub fn viewcube_hit(
&self,
cam: &GizmoCamera,
local_x: f32,
local_y: f32,
) -> Option<HandleId>
pub fn viewcube_hit( &self, cam: &GizmoCamera, local_x: f32, local_y: f32, ) -> Option<HandleId>
Hit-test the ViewCube at cube-local pixels; returns the region handle.
Sourcepub fn set_viewcube_hover(&mut self, handle: Option<HandleId>) -> bool
pub fn set_viewcube_hover(&mut self, handle: Option<HandleId>) -> bool
Set the ViewCube hover region (drives the highlight). Returns whether it changed.
Sourcepub fn viewcube_target(&self, handle: HandleId) -> ([f32; 3], [f32; 3])
pub fn viewcube_target(&self, handle: HandleId) -> ([f32; 3], [f32; 3])
The world eye→target look direction + up hint for a ViewCube region — the cube’s own (frame) direction carried into the world by the frame.
Sourcepub fn datum_plane_hits(
&self,
cam: &GizmoCamera,
x: f32,
y: f32,
) -> Vec<(String, [f32; 3])>
pub fn datum_plane_hits( &self, cam: &GizmoCamera, x: f32, y: f32, ) -> Vec<(String, [f32; 3])>
EVERY fed datum PLANE whose DRAWN card the pointer ray crosses, as
(name, world hit point) — the multi-hit sibling of datum_pick, which
stops at the first hit and also considers axes.
The bound is the rectangle the renderer draws, not the infinite plane:
DatumPlane::hit_point is the same half() extent build_main_overlay
draws with, evaluated against the LIVE camera on every call — so a
screen-constant card’s pickable region tracks its drawn size across a zoom
(nothing is baked). Either face of the card hits. Unnamed planes are
skipped (nothing could be selected by them).
The engine turns these into PickKind::Plane candidates so a construction
plane competes in the ordinary pick list instead of only on a geometry
miss (see EngineState::pick_candidates_at).
Sourcepub fn datum_pick(&self, cam: &GizmoCamera, x: f32, y: f32) -> Option<String>
pub fn datum_pick(&self, cam: &GizmoCamera, x: f32, y: f32) -> Option<String>
Pick the datum plane/axis under a screen pixel; returns its name.
pub fn has_transform(&self) -> bool
Sourcepub fn transform_origin(&self) -> Option<[f32; 3]>
pub fn transform_origin(&self) -> Option<[f32; 3]>
The VISIBLE transform gizmo’s current frame origin in world space, or None
when the gizmo is hidden. Reflects the last set_transform_json feed, so
it tracks the live-follow re-sync during a drag (Fix 3) — distinct from a
params-derived anchor, this proves the drawn widget actually moved.
Sourcepub fn transform_hit(&self, cam: &GizmoCamera, x: f32, y: f32) -> HandleId
pub fn transform_hit(&self, cam: &GizmoCamera, x: f32, y: f32) -> HandleId
Hit-test the transform gizmo; returns the handle (0 = none).
Sourcepub fn transform_axis_seg(
&self,
cam: &GizmoCamera,
i: usize,
) -> Option<(Vec3, Vec3)>
pub fn transform_axis_seg( &self, cam: &GizmoCamera, i: usize, ) -> Option<(Vec3, Vec3)>
The world-space (shaft-start, tip) endpoints of axis arrow i on the
LIVE transform gizmo — the SAME instance + axis_seg the hit test
(transform_hit → TransformGizmo::hit) measures against — so a debug
overlay can outline the exact pickable region without re-deriving it.
None when the gizmo is hidden.
Sourcepub fn transform_center_grab(&self) -> Option<Vec3>
pub fn transform_center_grab(&self) -> Option<Vec3>
The world-space center free-move / origin ball point of the LIVE transform
gizmo, or None when hidden / the center handle is off. For the debug
hit-area outline (radius brep_gizmos::transform::PX_CENTER_RAD).
Sourcepub fn transform_ring_grabs(&self, cam: &GizmoCamera) -> Option<[Vec3; 3]>
pub fn transform_ring_grabs(&self, cam: &GizmoCamera) -> Option<[Vec3; 3]>
The three rotation grab-sphere world points of the LIVE transform gizmo (in
ARCS order), or None when hidden. For the debug hit-area outline (radius
brep_gizmos::transform::PX_RING_GRAB_RAD).
Sourcepub fn transform_hit_regions(
&self,
cam: &GizmoCamera,
) -> Vec<(HandleId, HitShape)>
pub fn transform_hit_regions( &self, cam: &GizmoCamera, ) -> Vec<(HandleId, HitShape)>
The authoritative screen-space pickable regions of the LIVE transform gizmo
— the SAME hit_regions TransformGizmo::hit consumes — each paired with
its handle. [] when the gizmo is hidden. The debug-outline exposer
serializes these, so the drawn region IS exactly the pickable region.
pub fn set_transform_hover(&mut self, handle: HandleId) -> bool
pub fn set_transform_active(&mut self, handle: HandleId)
Sourcepub fn transform_drag_json(
&self,
cam: &GizmoCamera,
handle: HandleId,
sx: f32,
sy: f32,
cx: f32,
cy: f32,
) -> String
pub fn transform_drag_json( &self, cam: &GizmoCamera, handle: HandleId, sx: f32, sy: f32, cx: f32, cy: f32, ) -> String
Compute a transform drag: frame-space delta + its world resolution, as
JSON for the host’s feature-edit commit (R28). Resolved against the LIVE gizmo
frame (self.transform).
Sourcepub fn transform_drag_json_with_frame(
&self,
cam: &GizmoCamera,
frame_json: &str,
handle: HandleId,
sx: f32,
sy: f32,
cx: f32,
cy: f32,
) -> String
pub fn transform_drag_json_with_frame( &self, cam: &GizmoCamera, frame_json: &str, handle: HandleId, sx: f32, sy: f32, cx: f32, cy: f32, ) -> String
Like transform_drag_json but resolved against an EXPLICIT frozen frame
({origin,x,y,z}, the grab-time feature frame) instead of the live widget
gizmo. This lets the engine re-sync the VISIBLE gizmo to the moving feature
pose every drag frame (Fix 3 live-follow) while the delta stays anchored to
the grab frame, so the visual sync can’t feed back into the drag math.
Trait Implementations§
Auto Trait Implementations§
impl Forget for WidgetRegistry
impl Freeze for WidgetRegistry
impl Move for WidgetRegistry
impl RefUnwindSafe for WidgetRegistry
impl Send for WidgetRegistry
impl Sync for WidgetRegistry
impl Unpin for WidgetRegistry
impl UnsafeUnpin for WidgetRegistry
impl UnwindSafe for WidgetRegistry
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.