From 9aaac3432c1d0e923625a2947a9404c49d685c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 17:44:03 +0100 Subject: [PATCH 1/8] Add missing screenshots of graph view archetypes --- .../rerun/archetypes/graph_edges.fbs | 6 ++-- .../rerun/archetypes/graph_nodes.fbs | 6 ++-- examples/rust/graph_lattice/README.md | 29 +++++++++++++++++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs b/crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs index f4e6a7a5988d..d7274e854a99 100644 --- a/crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs +++ b/crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs @@ -2,14 +2,12 @@ namespace rerun.archetypes; // --- -// TODO(ab): Add images to snippets. - /// A list of edges in a graph. /// /// By default, edges are undirected. /// -/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="" -/// \example archetypes/graph_directed !api title="Simple directed graph" image="" +/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/469695b3038cc74d67d881ba318415c31de2dffb/1200w.png" +/// \example archetypes/graph_directed !api title="Simple directed graph" image="https://static.rerun.io/graph_directed/e04ef6a2a959517c70c3633c88988a2f1af75a59/1200w.png" table GraphEdges ( "attr.docs.category": "Graph", "attr.docs.unreleased", diff --git a/crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs b/crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs index bf31f6fe5efa..e863d2ff76b3 100644 --- a/crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs +++ b/crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs @@ -2,12 +2,10 @@ namespace rerun.archetypes; // --- -// TODO(ab): Add images to snippets. - /// A list of nodes in a graph with optional labels, colors, etc. /// -/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="" -/// \example archetypes/graph_directed !api title="Simple directed graph" image="" +/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/469695b3038cc74d67d881ba318415c31de2dffb/1200w.png" +/// \example archetypes/graph_directed !api title="Simple directed graph" image="https://static.rerun.io/graph_directed/e04ef6a2a959517c70c3633c88988a2f1af75a59/1200w.png" table GraphNodes ( "attr.docs.category": "Graph", "attr.docs.unreleased", diff --git a/examples/rust/graph_lattice/README.md b/examples/rust/graph_lattice/README.md index c714a94be6e1..a4ebaa3a477f 100644 --- a/examples/rust/graph_lattice/README.md +++ b/examples/rust/graph_lattice/README.md @@ -1,3 +1,28 @@ -# graph_lattice + -Demonstrates graph layout of a lattice without explicit positions. +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. + + + + + + + + + +## 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 +cargo run --release +``` From 4341cdcd9106fa29cb1d929c807152c4372cc79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 17:50:11 +0100 Subject: [PATCH 2/8] Run `pixi run codegen` --- .../reference/types/archetypes/graph_edges.md | 16 ++++++++++++++-- .../reference/types/archetypes/graph_nodes.md | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/content/reference/types/archetypes/graph_edges.md b/docs/content/reference/types/archetypes/graph_edges.md index 626954039656..d2846ae83543 100644 --- a/docs/content/reference/types/archetypes/graph_edges.md +++ b/docs/content/reference/types/archetypes/graph_edges.md @@ -31,11 +31,23 @@ By default, edges are undirected. snippet: archetypes/graph_undirected - + + + + + + + ### Simple directed graph snippet: archetypes/graph_directed - + + + + + + + diff --git a/docs/content/reference/types/archetypes/graph_nodes.md b/docs/content/reference/types/archetypes/graph_nodes.md index 694708eaa5be..e6eefb42bd30 100644 --- a/docs/content/reference/types/archetypes/graph_nodes.md +++ b/docs/content/reference/types/archetypes/graph_nodes.md @@ -29,11 +29,23 @@ A list of nodes in a graph with optional labels, colors, etc. snippet: archetypes/graph_undirected - + + + + + + + ### Simple directed graph snippet: archetypes/graph_directed - + + + + + + + From 6154fab6c41d0bbfddc5e47e9172503fba9b91a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 10 Dec 2024 09:36:54 +0100 Subject: [PATCH 3/8] Improve transformation handling --- crates/viewer/re_space_view_graph/src/properties.rs | 10 +++++++++- crates/viewer/re_space_view_graph/src/ui/state.rs | 4 +++- crates/viewer/re_space_view_graph/src/view.rs | 9 ++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/crates/viewer/re_space_view_graph/src/properties.rs b/crates/viewer/re_space_view_graph/src/properties.rs index de6b0255f0ca..68bfb782bf4c 100644 --- a/crates/viewer/re_space_view_graph/src/properties.rs +++ b/crates/viewer/re_space_view_graph/src/properties.rs @@ -1,4 +1,5 @@ use re_types::blueprint::components::VisualBounds2D; +use re_ui::zoom_pan_area::fit_to_rect_in_scene; use re_viewer_context::{SpaceViewStateExt as _, TypedComponentFallbackProvider}; use crate::{ui::GraphSpaceViewState, GraphSpaceView}; @@ -14,7 +15,14 @@ impl TypedComponentFallbackProvider for GraphSpaceView { }; match state.layout_state.bounding_rect() { - Some(rect) if valid_bound(&rect) => rect.into(), + Some(rect) if valid_bound(&rect) => { + if let Some(rect_in_ui) = state.rect_in_ui { + let ui_from_world = fit_to_rect_in_scene(rect_in_ui, rect); + (ui_from_world.inverse() * rect_in_ui).into() + } else { + rect.into() + } + } _ => VisualBounds2D::default(), } } diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index 4f22ca995c53..bbbee252340c 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -1,4 +1,4 @@ -use egui::Rect; +use egui::{emath::TSTransform, Rect}; use re_format::format_f32; use re_types::blueprint::components::VisualBounds2D; use re_ui::UiExt; @@ -16,6 +16,8 @@ pub struct GraphSpaceViewState { pub show_debug: bool, pub visual_bounds: Option, + pub ui_from_world: Option, + pub rect_in_ui: Option, } impl GraphSpaceViewState { diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index 6539892a1447..19f2dab7cd2e 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -164,15 +164,17 @@ Display a graph of nodes and edges. let rect_in_scene: blueprint::components::VisualBounds2D = bounds_property.component_or_fallback(ctx, self, state)?; - let rect_in_ui = ui.max_rect(); + let rect_in_ui = *state.rect_in_ui.insert(ui.max_rect()); let request = LayoutRequest::from_graphs(graphs.iter()); let layout_was_empty = state.layout_state.is_none(); let layout = state.layout_state.get(request); - let mut ui_from_world = fit_to_rect_in_scene(rect_in_ui, rect_in_scene.into()); + let ui_from_world = state + .ui_from_world + .get_or_insert_with(|| fit_to_rect_in_scene(rect_in_ui, rect_in_scene.into())); - let resp = zoom_pan_area(ui, rect_in_ui, &mut ui_from_world, |ui| { + let resp = zoom_pan_area(ui, rect_in_ui, ui_from_world, |ui| { let mut world_bounding_rect = egui::Rect::NOTHING; for graph in &graphs { @@ -191,6 +193,7 @@ Display a graph of nodes and edges. blueprint::components::VisualBounds2D::from(ui_from_world.inverse() * rect_in_ui); if resp.double_clicked() || layout_was_empty { bounds_property.reset_blueprint_component::(ctx); + state.ui_from_world = None; } else if rect_in_scene != updated_rect_in_scene { bounds_property.save_blueprint_component(ctx, &updated_rect_in_scene); } From cb2da21b94e8ceb09e3f8b07af6b8e435c8d2a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 10 Dec 2024 09:37:03 +0100 Subject: [PATCH 4/8] Update screenshots --- .../rerun/archetypes/graph_edges.fbs | 4 ++-- .../rerun/archetypes/graph_nodes.fbs | 4 ++-- .../reference/types/archetypes/graph_edges.md | 20 +++++++++---------- .../reference/types/archetypes/graph_nodes.md | 20 +++++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs b/crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs index d7274e854a99..a20ea2d39fa1 100644 --- a/crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs +++ b/crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs @@ -6,8 +6,8 @@ namespace rerun.archetypes; /// /// By default, edges are undirected. /// -/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/469695b3038cc74d67d881ba318415c31de2dffb/1200w.png" -/// \example archetypes/graph_directed !api title="Simple directed graph" image="https://static.rerun.io/graph_directed/e04ef6a2a959517c70c3633c88988a2f1af75a59/1200w.png" +/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/15f46bec77452a8c6220558e4403b99cac188e2e/1200w.png" +/// \example archetypes/graph_directed !api title="Simple directed graph" image="https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/1200w.png" table GraphEdges ( "attr.docs.category": "Graph", "attr.docs.unreleased", diff --git a/crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs b/crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs index e863d2ff76b3..7e7ddb535164 100644 --- a/crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs +++ b/crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs @@ -4,8 +4,8 @@ namespace rerun.archetypes; /// A list of nodes in a graph with optional labels, colors, etc. /// -/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/469695b3038cc74d67d881ba318415c31de2dffb/1200w.png" -/// \example archetypes/graph_directed !api title="Simple directed graph" image="https://static.rerun.io/graph_directed/e04ef6a2a959517c70c3633c88988a2f1af75a59/1200w.png" +/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/15f46bec77452a8c6220558e4403b99cac188e2e/1200w.png" +/// \example archetypes/graph_directed !api title="Simple directed graph" image="https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/1200w.png" table GraphNodes ( "attr.docs.category": "Graph", "attr.docs.unreleased", diff --git a/docs/content/reference/types/archetypes/graph_edges.md b/docs/content/reference/types/archetypes/graph_edges.md index d2846ae83543..04d911eaa0c5 100644 --- a/docs/content/reference/types/archetypes/graph_edges.md +++ b/docs/content/reference/types/archetypes/graph_edges.md @@ -32,11 +32,11 @@ By default, edges are undirected. snippet: archetypes/graph_undirected - - - - - + + + + + ### Simple directed graph @@ -44,10 +44,10 @@ snippet: archetypes/graph_undirected snippet: archetypes/graph_directed - - - - - + + + + + diff --git a/docs/content/reference/types/archetypes/graph_nodes.md b/docs/content/reference/types/archetypes/graph_nodes.md index e6eefb42bd30..739e3afcaf7c 100644 --- a/docs/content/reference/types/archetypes/graph_nodes.md +++ b/docs/content/reference/types/archetypes/graph_nodes.md @@ -30,11 +30,11 @@ A list of nodes in a graph with optional labels, colors, etc. snippet: archetypes/graph_undirected - - - - - + + + + + ### Simple directed graph @@ -42,10 +42,10 @@ snippet: archetypes/graph_undirected snippet: archetypes/graph_directed - - - - - + + + + + From 75aedcd93b71da012edf7a69ea7ba4d9578c2539 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Wed, 11 Dec 2024 10:18:11 +0100 Subject: [PATCH 5/8] Fix python blueprint logging to wrong path --- rerun_py/rerun_sdk/rerun/blueprint/api.py | 2 +- rerun_py/tests/unit/test_container_blueprint.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/api.py b/rerun_py/rerun_sdk/rerun/blueprint/api.py index 9727a50b19df..c40b442ef1d2 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/api.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/api.py @@ -98,7 +98,7 @@ def blueprint_path(self) -> str: Note that although this is an `EntityPath`, is scoped to the blueprint tree and not a part of the regular data hierarchy. """ - return f"space_view/{self.id}" + return f"view/{self.id}" def to_container(self) -> Container: """Convert this view to a container.""" diff --git a/rerun_py/tests/unit/test_container_blueprint.py b/rerun_py/tests/unit/test_container_blueprint.py index c034ce7b5a99..494644d7e970 100644 --- a/rerun_py/tests/unit/test_container_blueprint.py +++ b/rerun_py/tests/unit/test_container_blueprint.py @@ -36,8 +36,8 @@ def test_container_blueprint() -> None: contents_arrays: Sequence[Any] = [ None, [], - ["space_view/1234", "container/5678"], - [EntityPath("space_view/1234"), EntityPath("container/5678")], + ["view/1234", "container/5678"], + [EntityPath("view/1234"), EntityPath("container/5678")], ] col_shares_arrays = [ @@ -54,9 +54,9 @@ def test_container_blueprint() -> None: active_tab_arrays = [ None, - "space_view/1234", - ActiveTab("space_view/1234"), - ActiveTab(EntityPath("space_view/1234")), + "view/1234", + ActiveTab("view/1234"), + ActiveTab(EntityPath("view/1234")), ] visible_arrays = [ From cefc3f8777b91e1663ee6cc77480419465110da7 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Wed, 11 Dec 2024 10:18:22 +0100 Subject: [PATCH 6/8] fix dead code --- rerun_cpp/src/rerun/blueprint.hpp | 11 ----------- rerun_py/docs/gen_common_index.py | 20 +++++++++----------- 2 files changed, 9 insertions(+), 22 deletions(-) delete mode 100644 rerun_cpp/src/rerun/blueprint.hpp diff --git a/rerun_cpp/src/rerun/blueprint.hpp b/rerun_cpp/src/rerun/blueprint.hpp deleted file mode 100644 index 6bcce6fd744d..000000000000 --- a/rerun_cpp/src/rerun/blueprint.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs - -#pragma once - -#include "blueprint/auto_views.hpp" -#include "blueprint/entity_properties_component.hpp" -#include "blueprint/panel_view.hpp" -#include "blueprint/query_expressions.hpp" -#include "blueprint/space_view_component.hpp" -#include "blueprint/space_view_maximized.hpp" -#include "blueprint/viewport_layout.hpp" diff --git a/rerun_py/docs/gen_common_index.py b/rerun_py/docs/gen_common_index.py index da8d9dc6c073..4c106a2e6ce4 100755 --- a/rerun_py/docs/gen_common_index.py +++ b/rerun_py/docs/gen_common_index.py @@ -380,17 +380,15 @@ class Section: mod_path="rerun.utilities", show_submodules=True, ), - Section( - title="Experimental", - func_list=[ - "add_space_view", - "new_blueprint", - "set_auto_views", - "set_panels", - ], - show_tables=False, - mod_path="rerun.experimental", - ), + # We don't have any experimental apis right now, but when you add one again, you should add this here: + # Section( + # title="Experimental", + # func_list=[ + # "my_experimental_function", + # ], + # show_tables=False, + # mod_path="rerun.experimental", + # ), ] From 51d3d762e3eea9f90f465e194efd36fb0689167d Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Wed, 11 Dec 2024 10:18:49 +0100 Subject: [PATCH 7/8] fix some more cosmetic lack of rename --- examples/rust/chess_robby_fischer/README.md | 6 +++--- rerun_py/tests/unit/test_view_contents.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/rust/chess_robby_fischer/README.md b/examples/rust/chess_robby_fischer/README.md index a1309eae90fd..cdefec85040c 100644 --- a/examples/rust/chess_robby_fischer/README.md +++ b/examples/rust/chess_robby_fischer/README.md @@ -279,7 +279,7 @@ import rerun as rr import rerun.blueprint as rrb import argparse -space_view_defaults = [ +view_defaults = [ rr.components.AxisLength(0.0), # To hide the axes of all the transformations. rr.components.ImagePlaneDistance(0.3), ] @@ -305,11 +305,11 @@ blueprint = rrb.Blueprint( rrb.Spatial3DView( origin="/arm.urdf/base_link/glid_platta_1/bas_1/gemensam_vagg_1/botten_snurr_1/kortarm_kopia_1/led_1/led_axel_1/lang_arm_1/mount_1/ram_1", contents="/**", - defaults=space_view_defaults + defaults=view_defaults ) ), rrb.Spatial3DView( - defaults=space_view_defaults + defaults=view_defaults ), column_shares=[2,2,3] ), diff --git a/rerun_py/tests/unit/test_view_contents.py b/rerun_py/tests/unit/test_view_contents.py index 93aa0e4ba5c2..ee54d77b4d1a 100644 --- a/rerun_py/tests/unit/test_view_contents.py +++ b/rerun_py/tests/unit/test_view_contents.py @@ -8,7 +8,7 @@ from rerun.datatypes.utf8 import Utf8ArrayLike -def test_space_view_contents() -> None: +def test_view_contents() -> None: query_array = [ [ "+ /**", From 622c66651905287437888e0b15fe74462f218e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Wed, 11 Dec 2024 10:54:04 +0100 Subject: [PATCH 8/8] Keep center during resizing --- crates/viewer/re_view_graph/src/view.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/viewer/re_view_graph/src/view.rs b/crates/viewer/re_view_graph/src/view.rs index 72c2e74f9fd2..eaf2068663ee 100644 --- a/crates/viewer/re_view_graph/src/view.rs +++ b/crates/viewer/re_view_graph/src/view.rs @@ -168,6 +168,8 @@ Display a graph of nodes and edges. let state = state.downcast_mut::()?; + let params = ForceLayoutParams::get(ctx, query, self, state)?; + let bounds_property = ViewProperty::from_archetype::( ctx.blueprint_db(), ctx.blueprint_query, @@ -176,18 +178,27 @@ Display a graph of nodes and edges. let rect_in_scene: blueprint::components::VisualBounds2D = bounds_property.component_or_fallback(ctx, self, state)?; - let rect_in_ui = *state.rect_in_ui.insert(ui.max_rect()); - - let params = ForceLayoutParams::get(ctx, query, self, state)?; - + // 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. + let prev_rect_in_ui = state.rect_in_ui; + let rect_in_ui = *state.rect_in_ui.insert(ui.max_rect()); + let ui_from_world = state .ui_from_world .get_or_insert_with(|| fit_to_rect_in_scene(rect_in_ui, rect_in_scene.into())); + // We ensure that the view's center is kept during resizing. + if let Some(prev) = prev_rect_in_ui { + if prev != rect_in_ui { + let delta = rect_in_ui.center() - prev.center(); + ui_from_world.translation += delta; + } + } + let resp = zoom_pan_area(ui, rect_in_ui, ui_from_world, |ui| { let mut world_bounding_rect = egui::Rect::NOTHING;