DisplayNode

Trait DisplayNode 

Source
pub trait DisplayNode<N, E, Ty, Ix>: Clone + From<NodeProps<N>>
where N: Clone, E: Clone, Ty: EdgeType, Ix: IndexType,
{ // Required methods fn closest_boundary_point(&self, dir: Vec2) -> Pos2; fn shapes(&mut self, ctx: &DrawContext<'_>) -> Vec<Shape>; fn update(&mut self, state: &NodeProps<N>); fn is_inside(&self, pos: Pos2) -> bool; }

Required Methods§

Source

fn closest_boundary_point(&self, dir: Vec2) -> Pos2

Returns the closest point on the shape boundary in the direction of dir.

  • dir - direction pointing from the shape center to the required boundary point.

Could be used to snap the edge ends to the node.

Source

fn shapes(&mut self, ctx: &DrawContext<'_>) -> Vec<Shape>

Draws shapes of the node. If the node is interacted these shapes will be used for drawing on foreground layer, otherwise on background layer. Has mutable reference to itself for possibility to change internal state for the visualizations where this is important.

Use ctx.meta to properly scale and translate the shape. Use ctx.painter to have low level access to egui painting process.

Source

fn update(&mut self, state: &NodeProps<N>)

Is called on every frame. Can be used for updating state of the implementation of DisplayNode

Source

fn is_inside(&self, pos: Pos2) -> bool

Checks if the provided pos is inside the shape.

  • pos - position is in the canvas coordinates.

Could be used to bind mouse events to the custom drawn nodes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<N: Clone, E: Clone, Ty: EdgeType, Ix: IndexType> DisplayNode<N, E, Ty, Ix> for DefaultNodeShape