Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement complete Graph View example #8421

Merged
merged 13 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2915,15 +2915,6 @@ dependencies = [
"bitflags 2.6.0",
]

[[package]]
name = "graph_binary_tree"
version = "0.21.0-alpha.1+dev"
dependencies = [
"anyhow",
"clap",
"rerun",
]

[[package]]
name = "graph_lattice"
version = "0.21.0-alpha.1+dev"
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_view_graph/src/layout/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl ForceLayoutProvider {
let c1_base = source_pos + delta * 0.25;
let c2_base = source_pos + delta * 0.75;

let base_n = Vec2::new(-c1_base.y, c1_base.x).normalized();
let base_n = Vec2::new(-delta.y, delta.x).normalized();

let c1_left = c1_base + base_n * (fan_amount / 2.);
let c2_left = c2_base + base_n * (fan_amount / 2.);
Expand Down
3 changes: 1 addition & 2 deletions crates/viewer/re_view_graph/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ Display a graph of nodes and edges.

// Perform all layout-related tasks.
let request = LayoutRequest::from_graphs(graphs.iter());
let layout_was_empty = state.layout_state.is_none();
let layout = state.layout_state.get(request, params);

// Prepare the view and the transformations.
Expand Down Expand Up @@ -216,7 +215,7 @@ Display a graph of nodes and edges.
// Update blueprint if changed
let updated_rect_in_scene =
blueprint::components::VisualBounds2D::from(ui_from_world.inverse() * rect_in_ui);
if resp.double_clicked() || layout_was_empty {
if resp.double_clicked() {
bounds_property.reset_blueprint_component::<blueprint::components::VisualBounds2D>(ctx);
state.ui_from_world = None;
} else if rect_in_scene != updated_rect_in_scene {
Expand Down
5 changes: 3 additions & 2 deletions examples/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ examples = [
"notebook",
"clock",
"dna",
"graphs",
"log_file",
"openstreetmap_data",
"minimal",
Expand All @@ -150,8 +151,6 @@ examples = [
"plots",
"live_scrolling_plot",
"raw_mesh",
"graph_lattice",
"graph_binary_tree",
"air_traffic_data",
]

Expand All @@ -169,6 +168,8 @@ examples = [
"drone_lidar",
"extend_viewer_ui",
"external_data_loader",
"graph_binary_tree",
"graph_lattice",
"incremental_logging",
"minimal_serve",
"shared_recording",
Expand Down
28 changes: 0 additions & 28 deletions examples/python/graph_binary_tree/README.md

This file was deleted.

108 changes: 0 additions & 108 deletions examples/python/graph_binary_tree/graph_binary_tree.py

This file was deleted.

8 changes: 4 additions & 4 deletions examples/python/graph_lattice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Since no explicit positions are passed for the nodes, Rerun will layout the grap

## Run the code

```bash
pip install -e examples/python/graph_lattice
python -m graph_lattice
```
```bash
pip install -e examples/python/graph_lattice
python -m graph_lattice
```
29 changes: 29 additions & 0 deletions examples/python/graphs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--[metadata]
title = "Graphs"
tags = ["Graph", "Layout"]
thumbnail = "https://static.rerun.io/graphs/19e6ca2e0752cdc7107c10b0cb79a4b7192d9e0b/480w.png"
thumbnail_dimensions = [480, 399]
channel = "main"
-->

This example shows different attributes that you can associate with nodes in a graph.
Since no explicit positions are passed for the nodes, Rerun will layout the graph automatically.

<picture>
<img src="https://static.rerun.io/graphs/19e6ca2e0752cdc7107c10b0cb79a4b7192d9e0b/full.png" alt="">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/graphs/19e6ca2e0752cdc7107c10b0cb79a4b7192d9e0b/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/graphs/19e6ca2e0752cdc7107c10b0cb79a4b7192d9e0b/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/graphs/19e6ca2e0752cdc7107c10b0cb79a4b7192d9e0b/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/graphs/19e6ca2e0752cdc7107c10b0cb79a4b7192d9e0b/1200w.png">
</picture>

## Used Rerun types
[`GraphNodes`](https://www.rerun.io/docs/reference/types/archetypes/graph_nodes?speculative-link),
[`GraphEdges`](https://www.rerun.io/docs/reference/types/archetypes/graph_edges?speculative-link)

## Run the code

```bash
pip install -e examples/python/graphs
python -m graphs
```
Loading
Loading