Struct egui_graphs::GraphView

source ·
pub struct GraphView<'a, N: Clone, E: Clone, Ty: EdgeType> { /* private fields */ }
Expand description

Widget for visualizing and interacting with graphs.

It implements egui::Widget and can be used like any other widget.

The widget uses a mutable reference to the [StableGraph<egui_graphs::Node, egui_graphs::Edge>] struct to visualize and interact with the graph. N and E is arbitrary client data associated with nodes and edges. You can customize the visualization and interaction behavior using SettingsInteraction, SettingsNavigation and SettingsStyle structs.

When any interaction or node property change occurs, the widget sends Change struct to the provided [Sender] channel, which can be set via the with_interactions method. The Change struct contains information about a change that occurred in the graph. Client can use this information to modify external state of his application if needed.

When the user performs navigation actions (zoom & pan, fit to screen), they do not produce changes. This is because these actions are performed on the global coordinates and do not change any properties of the nodes or edges.

Implementations§

source§

impl<'a, N: Clone, E: Clone, Ty: EdgeType> GraphView<'a, N, E, Ty>

source

pub fn new(g: &'a mut Graph<N, E, Ty>) -> Self

Creates a new GraphView widget with default navigation and interactions settings. To customize navigation and interactions use with_interactions and with_navigations methods.

source

pub fn with_interactions( self, settings_interaction: &SettingsInteraction ) -> Self

Makes widget interactive according to the provided settings.

source

pub fn with_changes(self, changes_sender: &'a Sender<Change>) -> Self

Make every interaction send Change to the provided [crossbeam::channel::Sender] as soon as interaction happens.

Change events can be used to handle interactions on the application side.

source

pub fn with_navigations(self, settings_navigation: &SettingsNavigation) -> Self

Modifies default behaviour of navigation settings.

source

pub fn with_styles(self, settings_style: &SettingsStyle) -> Self

Modifies default style settings.

source

pub fn reset_metadata(ui: &mut Ui)

Resets navigation metadata

Trait Implementations§

source§

impl<'a, N: Clone, E: Clone, Ty: EdgeType> Widget for &mut GraphView<'a, N, E, Ty>

source§

fn ui(self, ui: &mut Ui) -> Response

Allocate space, interact, paint, and return a Response. Read more

Auto Trait Implementations§

§

impl<'a, N, E, Ty> RefUnwindSafe for GraphView<'a, N, E, Ty>where E: RefUnwindSafe, N: RefUnwindSafe, Ty: RefUnwindSafe,

§

impl<'a, N, E, Ty> Send for GraphView<'a, N, E, Ty>where E: Send, N: Send, Ty: Send,

§

impl<'a, N, E, Ty> Sync for GraphView<'a, N, E, Ty>where E: Sync, N: Sync, Ty: Sync,

§

impl<'a, N, E, Ty> Unpin for GraphView<'a, N, E, Ty>

§

impl<'a, N, E, Ty> !UnwindSafe for GraphView<'a, N, E, Ty>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V