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>
impl<N> GeometryCache<N>
pub fn new() -> Self
Sourcepub fn remove_pin(&mut self, pin_id: i32) -> bool
pub fn remove_pin(&mut self, pin_id: i32) -> bool
Remove one pin from the disposable geometry projection.
Sourcepub fn remove_node(&mut self, node_id: i32) -> Vec<i32>
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.
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.
Whether a node is currently hidden.
Sourcepub fn update_group_rect(
&mut self,
id: i32,
x: f32,
y: f32,
width: f32,
height: f32,
)
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).
Sourcepub fn remove_group(&mut self, group_id: i32) -> bool
pub fn remove_group(&mut self, group_id: i32) -> bool
Remove a group sheet’s rectangle.
Source§impl<N> GeometryCache<N>where
N: NodeGeometry + Copy,
impl<N> GeometryCache<N>where
N: NodeGeometry + Copy,
Sourcepub fn get_absolute_pins(&self) -> impl Iterator<Item = SimplePinGeometry> + '_
pub fn get_absolute_pins(&self) -> impl Iterator<Item = SimplePinGeometry> + '_
Iterator over absolute pin positions for hit testing
Sourcepub fn get_absolute_links<'a, I>(
&'a self,
links: I,
) -> impl Iterator<Item = SimpleLinkGeometry> + 'a
pub fn get_absolute_links<'a, I>( &'a self, links: I, ) -> impl Iterator<Item = SimpleLinkGeometry> + 'a
Iterator over absolute link geometries for hit testing
Sourcepub fn find_pin_at(&self, x: f32, y: f32, hit_radius: f32) -> i32
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.
Sourcepub fn find_link_at<'a, I>(
&'a self,
x: f32,
y: f32,
links: I,
hover_distance: f32,
zoom: f32,
bezier_min_offset: f32,
hit_samples: usize,
) -> i32
pub fn find_link_at<'a, I>( &'a self, x: f32, y: f32, links: I, hover_distance: f32, zoom: f32, bezier_min_offset: f32, hit_samples: usize, ) -> i32
Find link at position
Sourcepub fn find_bezier_link_at_world<'a, I>(
&'a self,
world_x: f32,
world_y: f32,
links: I,
world_hover_distance: f32,
bezier_min_offset: f32,
hit_samples: usize,
) -> i32
pub fn find_bezier_link_at_world<'a, I>( &'a self, world_x: f32, world_y: f32, links: I, world_hover_distance: f32, bezier_min_offset: f32, hit_samples: usize, ) -> i32
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.
Sourcepub fn nodes_in_selection_box(
&self,
x: f32,
y: f32,
width: f32,
height: f32,
) -> Vec<i32>
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.
Sourcepub fn links_in_selection_box<'a, I>(
&'a self,
x: f32,
y: f32,
width: f32,
height: f32,
links: I,
) -> Vec<i32>
pub fn links_in_selection_box<'a, I>( &'a self, x: f32, y: f32, width: f32, height: f32, links: I, ) -> Vec<i32>
Compute links in selection box
Sourcepub fn resolve_link_endpoints_world(
&self,
start_pin: i32,
end_pin: i32,
) -> Option<(f32, f32, f32, f32)>
pub fn resolve_link_endpoints_world( &self, start_pin: i32, end_pin: i32, ) -> Option<(f32, f32, f32, f32)>
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.
Sourcepub fn compute_link_path(
&self,
start_pin: i32,
end_pin: i32,
zoom: f32,
bezier_min_offset: f32,
) -> Option<String>
pub fn compute_link_path( &self, start_pin: i32, end_pin: i32, zoom: f32, bezier_min_offset: f32, ) -> Option<String>
Compute bezier path in world coordinates with explicit zoom for bezier offset scaling.
Sourcepub fn compute_link_path_screen(
&self,
start_pin: i32,
end_pin: i32,
zoom: f32,
pan_x: f32,
pan_y: f32,
bezier_min_offset: f32,
) -> Option<String>
pub fn compute_link_path_screen( &self, start_pin: i32, end_pin: i32, zoom: f32, pan_x: f32, pan_y: f32, bezier_min_offset: f32, ) -> Option<String>
Compute bezier path in screen space from world-space cache data.
Transforms world positions to screen: screen = world * zoom + pan
Sourcepub fn link_curve_world(
&self,
start_pin: i32,
end_pin: i32,
bezier_min_offset: f32,
) -> Option<CubicBezier>
pub fn link_curve_world( &self, start_pin: i32, end_pin: i32, bezier_min_offset: f32, ) -> Option<CubicBezier>
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.
Sourcepub fn compute_link_path_world(
&self,
start_pin: i32,
end_pin: i32,
bezier_min_offset: f32,
) -> Option<String>
pub fn compute_link_path_world( &self, start_pin: i32, end_pin: i32, bezier_min_offset: f32, ) -> Option<String>
Compute bezier path in pure world coordinates (zoom=1.0).
Sourcepub fn handle_pin_report(
&mut self,
pin_id: i32,
node_id: i32,
pin_type: i32,
rel_x: f32,
rel_y: f32,
)
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
Sourcepub 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,
)
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
impl GeometryCache<SimpleNodeGeometry>
Convenience implementation for the default SimpleNodeGeometry