Skip to main content

GeometryCache

Struct GeometryCache 

Source
pub struct GeometryCache<N = SimpleNodeGeometry> {
    pub node_rects: HashMap<i32, N>,
    pub pin_positions: HashMap<i32, StoredPin>,
    pub group_rects: HashMap<i32, SimpleNodeGeometry>,
    /* private fields */
}
Expand description

Helper struct to manage spatial state of the editor (node rects and pin positions)

Generic over N to allow using specialized node types that implement NodeGeometry.

Fields§

§node_rects: HashMap<i32, N>§pin_positions: HashMap<i32, StoredPin>§group_rects: HashMap<i32, SimpleNodeGeometry>

Displayed rectangles of group sheets, keyed by group id. A collapsed sheet reports its header band, so this is what a marquee sees.

Implementations§

Source§

impl<N> GeometryCache<N>

Source

pub fn new() -> Self

Source

pub fn remove_pin(&mut self, pin_id: i32) -> bool

Remove one pin from the disposable geometry projection.

Source

pub fn remove_node(&mut self, node_id: i32) -> Vec<i32>

Remove a node and every pin currently owned by it.

The returned pin IDs let higher layers retire topology that refers to those pins without deriving ownership from an application-specific ID.

Source

pub fn clear(&mut self)

Clear all projected node, pin and group geometry.

Source

pub fn set_node_hidden(&mut self, node_id: i32, hidden: bool)

Mark a node hidden or visible. Hidden nodes keep their rectangle and pins but take part in no hit testing, and links touching them have no route. BaseNode reports this when a collapsed group hides it.

Source

pub fn is_node_hidden(&self, node_id: i32) -> bool

Whether a node is currently hidden.

Source

pub fn update_group_rect( &mut self, id: i32, x: f32, y: f32, width: f32, height: f32, )

Update a group sheet’s displayed rectangle (world coordinates).

Source

pub fn remove_group(&mut self, group_id: i32) -> bool

Remove a group sheet’s rectangle.

Source

pub fn groups_in_selection_box( &self, x: f32, y: f32, width: f32, height: f32, ) -> Vec<i32>

Groups whose displayed rectangle intersects the selection box, by the same intersection rule as nodes.

Source§

impl<N> GeometryCache<N>
where N: NodeGeometry + Copy,

Source

pub fn get_absolute_pins(&self) -> impl Iterator<Item = SimplePinGeometry> + '_

Iterator over absolute pin positions for hit testing

Iterator over absolute link geometries for hit testing

Source

pub fn find_pin_at(&self, x: f32, y: f32, hit_radius: f32) -> i32

Find the nearest hit-testable pin at a world-space position. Exact distance ties choose the lowest pin ID.

Find link at position

Find a default rendered Bézier route in world coordinates.

The mouse position and world_hover_distance are both world-space. Routes use the same zoom-independent curve as Self::link_curve_world.

Source

pub fn nodes_in_selection_box( &self, x: f32, y: f32, width: f32, height: f32, ) -> Vec<i32>

Compute nodes in selection box. Hidden nodes are never hit.

Compute links in selection box

Resolve absolute world-space positions for a link’s start and end pins. Returns (start_x, start_y, end_x, end_y), or None if pins or nodes are missing or either node is hidden — a link into a collapsed group has no route and is not drawn.

Compute bezier path in world coordinates with explicit zoom for bezier offset scaling.

Compute bezier path in screen space from world-space cache data.

Transforms world positions to screen: screen = world * zoom + pan

The curve of a link in pure world coordinates (zoom = 1.0).

Used when links are rendered inside a transform-scale container that handles zoom visually. Bezier offset is unscaled.

Compute bezier path in pure world coordinates (zoom=1.0).

Source

pub fn handle_pin_report( &mut self, pin_id: i32, node_id: i32, pin_type: i32, rel_x: f32, rel_y: f32, )

Standard handler for pin position reports from Slint

Source

pub fn handle_pin_report_with_hit_testable( &mut self, pin_id: i32, node_id: i32, pin_type: i32, rel_x: f32, rel_y: f32, hit_testable: bool, )

Update a pin and whether it participates in pin hit testing.

Non-hit-testable pins remain available for existing link routing and validation. This lets a level-of-detail view hide a pin without making its logical connections disappear.

Source§

impl GeometryCache<SimpleNodeGeometry>

Convenience implementation for the default SimpleNodeGeometry

Source

pub fn update_node_rect( &mut self, id: i32, x: f32, y: f32, width: f32, height: f32, )

Update a node’s rectangle (shorthand for SimpleNodeGeometry)

Source

pub fn handle_node_rect_report( &mut self, id: i32, x: f32, y: f32, w: f32, h: f32, )

Standard handler for node rect reports from Slint (for SimpleNodeGeometry)

Trait Implementations§

Source§

impl<N> Default for GeometryCache<N>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<N> Freeze for GeometryCache<N>
where HashMap<i32, N>: Freeze,

§

impl<N> RefUnwindSafe for GeometryCache<N>

§

impl<N> Send for GeometryCache<N>
where HashMap<i32, N>: Send,

§

impl<N> Sync for GeometryCache<N>
where HashMap<i32, N>: Sync,

§

impl<N> Unpin for GeometryCache<N>
where HashMap<i32, N>: Unpin,

§

impl<N> UnsafeUnpin for GeometryCache<N>
where HashMap<i32, N>: UnsafeUnpin,

§

impl<N> UnwindSafe for GeometryCache<N>
where HashMap<i32, N>: UnwindSafe,

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<T> ErasedDestructor for T
where T: 'static,

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