-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Default random layout * Possibility to provide custom layout * Hierarchical layout * User set positions prioritization Possibly fixes #219
- Loading branch information
Showing
36 changed files
with
871 additions
and
311 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "basic_custom" | ||
version = "0.1.0" | ||
authors = ["Dmitrii Samsonov <[email protected]>"] | ||
license = "MIT" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
egui_graphs = { path = "../../" } | ||
egui = "0.29" | ||
eframe = "0.29" | ||
petgraph = "0.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Basic | ||
Basic example which demonstrates the usage of `GraphView` widget with helper functions. | ||
|
||
## run | ||
```bash | ||
cargo run --release -p basic_custom | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use eframe::{run_native, App, CreationContext, NativeOptions}; | ||
use egui::{Context, Pos2}; | ||
use egui_graphs::{DefaultGraphView, Graph, SettingsStyle}; | ||
use petgraph::stable_graph::StableGraph; | ||
|
||
pub struct BasicCustomApp { | ||
g: Graph, | ||
} | ||
|
||
impl BasicCustomApp { | ||
fn new(_: &CreationContext<'_>) -> Self { | ||
let mut g = Graph::new(StableGraph::default()); | ||
|
||
let positions = vec![Pos2::new(0., 0.), Pos2::new(50., 0.), Pos2::new(0., 50.)]; | ||
let mut idxs = Vec::with_capacity(positions.len()); | ||
for position in positions { | ||
let idx = g.add_node_with_label_and_location((), position.to_string(), position); | ||
|
||
idxs.push(idx); | ||
} | ||
|
||
g.add_edge(idxs[0], idxs[1], ()); | ||
g.add_edge(idxs[1], idxs[2], ()); | ||
g.add_edge(idxs[2], idxs[0], ()); | ||
|
||
Self { g } | ||
} | ||
} | ||
|
||
impl App for BasicCustomApp { | ||
fn update(&mut self, ctx: &Context, _: &mut eframe::Frame) { | ||
egui::CentralPanel::default().show(ctx, |ui| { | ||
ui.add( | ||
&mut DefaultGraphView::new(&mut self.g) | ||
.with_styles(&SettingsStyle::default().with_labels_always(true)), | ||
); | ||
}); | ||
} | ||
} | ||
|
||
fn main() { | ||
let native_options = NativeOptions::default(); | ||
run_native( | ||
"egui_graphs_basic_custom_demo", | ||
native_options, | ||
Box::new(|cc| Ok(Box::new(BasicCustomApp::new(cc)))), | ||
) | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.