pub struct Graph {
pub ports: HashMap<PortId, Port>,
pub edges: HashMap<EdgeId, Edge>,
pub selected_edge: HashSet<EdgeId>,
pub selected_node: HashSet<NodeId>,
/* private fields */
}Fields§
§ports: HashMap<PortId, Port>§edges: HashMap<EdgeId, Edge>§selected_edge: HashSet<EdgeId>§selected_node: HashSet<NodeId>Implementations§
Source§impl Graph
impl Graph
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/extension.rs (line 9)
7fn main() {
8 Application::new().run(|cx| {
9 let mut graph = Graph::new();
10
11 graph
12 .create_node("number")
13 .position(100.0, 100.0)
14 .size(300.0, 150.0)
15 .output()
16 .build(&mut graph);
17
18 graph
19 .create_node("")
20 .position(300.0, 400.0)
21 .input()
22 .build(&mut graph);
23
24 cx.open_window(WindowOptions::default(), |_, cx| {
25 cx.new(|fc| {
26 let mut flow = FlowCanvas::new(graph, fc)
27 .plugin(SelectionPlugin::new())
28 .plugin(NodeInteractionPlugin::new())
29 .plugin(ViewportPlugin::new())
30 .plugin(Background::new())
31 .plugin(NodePlugin::new().register_node("number", NumberNode {}));
32 flow.init_plugins();
33 flow
34 })
35 })
36 .unwrap();
37 });
38}More examples
examples/bench.rs (line 6)
4fn main() {
5 Application::new().run(|cx| {
6 let mut graph = Graph::new();
7
8 for j in 0..100 {
9 for i in 0..100 {
10 graph
11 .create_node("")
12 .position(200.0 * i as f32, 200.0 * j as f32)
13 .input()
14 .output()
15 .build(&mut graph);
16 }
17 }
18
19 cx.open_window(WindowOptions::default(), |_, cx| {
20 cx.new(|fc| {
21 let mut flow = FlowCanvas::new(graph, fc)
22 .plugin(SelectionPlugin::new())
23 .plugin(NodeInteractionPlugin::new())
24 .plugin(ViewportPlugin::new())
25 .plugin(Background::new())
26 .plugin(NodePlugin::new())
27 .plugin(PortInteractionPlugin::new())
28 .plugin(EdgePlugin::new())
29 .plugin(DeletePlugin::new())
30 .plugin(HistoryPlugin::new());
31 flow.init_plugins();
32 flow
33 })
34 })
35 .unwrap();
36 });
37}examples/basic.rs (line 6)
4fn main() {
5 Application::new().run(|cx| {
6 let mut graph = Graph::new();
7
8 graph
9 .create_node("")
10 .position(100.0, 100.0)
11 .output()
12 .build(&mut graph);
13
14 graph
15 .create_node("")
16 .position(300.0, 400.0)
17 .input()
18 .output()
19 .build(&mut graph);
20
21 graph
22 .create_node("")
23 .position(500.0, 500.0)
24 .input()
25 .output()
26 .build(&mut graph);
27
28 cx.open_window(WindowOptions::default(), |_, cx| {
29 cx.new(|fc| {
30 let mut flow = FlowCanvas::new(graph, fc)
31 .plugin(SelectionPlugin::new())
32 .plugin(NodeInteractionPlugin::new())
33 .plugin(ViewportPlugin::new())
34 .plugin(Background::new())
35 .plugin(NodePlugin::new())
36 .plugin(PortInteractionPlugin::new())
37 .plugin(EdgePlugin::new())
38 .plugin(DeletePlugin::new())
39 .plugin(HistoryPlugin::new());
40 flow.init_plugins();
41 flow
42 })
43 })
44 .unwrap();
45 });
46}Sourcepub fn create_node(&self, node_type: &str) -> NodeBuilder
pub fn create_node(&self, node_type: &str) -> NodeBuilder
Examples found in repository?
examples/extension.rs (line 12)
7fn main() {
8 Application::new().run(|cx| {
9 let mut graph = Graph::new();
10
11 graph
12 .create_node("number")
13 .position(100.0, 100.0)
14 .size(300.0, 150.0)
15 .output()
16 .build(&mut graph);
17
18 graph
19 .create_node("")
20 .position(300.0, 400.0)
21 .input()
22 .build(&mut graph);
23
24 cx.open_window(WindowOptions::default(), |_, cx| {
25 cx.new(|fc| {
26 let mut flow = FlowCanvas::new(graph, fc)
27 .plugin(SelectionPlugin::new())
28 .plugin(NodeInteractionPlugin::new())
29 .plugin(ViewportPlugin::new())
30 .plugin(Background::new())
31 .plugin(NodePlugin::new().register_node("number", NumberNode {}));
32 flow.init_plugins();
33 flow
34 })
35 })
36 .unwrap();
37 });
38}More examples
examples/bench.rs (line 11)
4fn main() {
5 Application::new().run(|cx| {
6 let mut graph = Graph::new();
7
8 for j in 0..100 {
9 for i in 0..100 {
10 graph
11 .create_node("")
12 .position(200.0 * i as f32, 200.0 * j as f32)
13 .input()
14 .output()
15 .build(&mut graph);
16 }
17 }
18
19 cx.open_window(WindowOptions::default(), |_, cx| {
20 cx.new(|fc| {
21 let mut flow = FlowCanvas::new(graph, fc)
22 .plugin(SelectionPlugin::new())
23 .plugin(NodeInteractionPlugin::new())
24 .plugin(ViewportPlugin::new())
25 .plugin(Background::new())
26 .plugin(NodePlugin::new())
27 .plugin(PortInteractionPlugin::new())
28 .plugin(EdgePlugin::new())
29 .plugin(DeletePlugin::new())
30 .plugin(HistoryPlugin::new());
31 flow.init_plugins();
32 flow
33 })
34 })
35 .unwrap();
36 });
37}examples/basic.rs (line 9)
4fn main() {
5 Application::new().run(|cx| {
6 let mut graph = Graph::new();
7
8 graph
9 .create_node("")
10 .position(100.0, 100.0)
11 .output()
12 .build(&mut graph);
13
14 graph
15 .create_node("")
16 .position(300.0, 400.0)
17 .input()
18 .output()
19 .build(&mut graph);
20
21 graph
22 .create_node("")
23 .position(500.0, 500.0)
24 .input()
25 .output()
26 .build(&mut graph);
27
28 cx.open_window(WindowOptions::default(), |_, cx| {
29 cx.new(|fc| {
30 let mut flow = FlowCanvas::new(graph, fc)
31 .plugin(SelectionPlugin::new())
32 .plugin(NodeInteractionPlugin::new())
33 .plugin(ViewportPlugin::new())
34 .plugin(Background::new())
35 .plugin(NodePlugin::new())
36 .plugin(PortInteractionPlugin::new())
37 .plugin(EdgePlugin::new())
38 .plugin(DeletePlugin::new())
39 .plugin(HistoryPlugin::new());
40 flow.init_plugins();
41 flow
42 })
43 })
44 .unwrap();
45 });
46}pub fn next_node_id(&self) -> NodeId
pub fn next_port_id(&self) -> PortId
pub fn next_edge_id(&self) -> EdgeId
pub fn add_node(&mut self, node: Node)
pub fn add_point(&mut self, port: Port)
pub fn nodes(&self) -> &HashMap<NodeId, Node>
pub fn node_order(&self) -> &Vec<NodeId>
pub fn node_order_mut(&mut self) -> &mut Vec<NodeId>
pub fn new_edge(&self) -> Edge
pub fn add_edge(&mut self, edge: Edge)
pub fn remove_edge(&mut self, edge_id: EdgeId)
pub fn get_node(&self, id: &NodeId) -> Option<&Node>
pub fn get_node_mut(&mut self, id: &NodeId) -> Option<&mut Node>
pub fn remove_node(&mut self, id: &NodeId)
pub fn add_selected_node(&mut self, id: NodeId, shift: bool)
pub fn clear_selected_node(&mut self)
pub fn remove_selected_node(&mut self) -> bool
pub fn add_selected_edge(&mut self, id: EdgeId, shift: bool)
pub fn clear_selected_edge(&mut self)
pub fn remove_selected_edge(&mut self) -> bool
pub fn selection_bounds(&self) -> Option<Bounds<Pixels>>
pub fn selected_nodes_with_positions(&self) -> HashMap<NodeId, Point<Pixels>>
pub fn hit_node(&self, mouse: Point<Pixels>) -> Option<NodeId>
pub fn bring_node_to_front(&mut self, node_id: NodeId)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 more