Skip to content

Commit c739dd8

Browse files
grtlrWumpf
andauthored
Add missing screenshots of graph view archetypes (#8371)
### Related <!-- Include links to any related issues/PRs in a bulleted list, for example: * Closes #1234 * Part of #1337 --> * Closes #8277 * Closes #8327 * Closes #8237 ### What This fixes many problems around the state of the graph view. Turns out the scene rect alone is not sufficient to store all of the viewer state (who would have thought 😇). <!-- Make sure the PR title and labels are set to maximize their usefulness for the CHANGELOG, and our `git log`. If you have noticed any breaking changes, include them in the migration guide. We track various metrics at <https://build.rerun.io>. For maintainers: * To run all checks from `main`, comment on the PR with `@rerun-bot full-check`. * To deploy documentation changes immediately after merging this PR, add the `deploy docs` label. --> --------- Co-authored-by: Andreas Reich <r_andreas2@web.de>
1 parent 6972345 commit c739dd8

File tree

14 files changed

+110
-54
lines changed

14 files changed

+110
-54
lines changed

crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ namespace rerun.archetypes;
22

33
// ---
44

5-
// TODO(ab): Add images to snippets.
6-
75
/// A list of edges in a graph.
86
///
97
/// By default, edges are undirected.
108
///
11-
/// \example archetypes/graph_undirected !api title="Simple undirected graph" image=""
12-
/// \example archetypes/graph_directed !api title="Simple directed graph" image=""
9+
/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/15f46bec77452a8c6220558e4403b99cac188e2e/1200w.png"
10+
/// \example archetypes/graph_directed !api title="Simple directed graph" image="https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/1200w.png"
1311
table GraphEdges (
1412
"attr.docs.category": "Graph",
1513
"attr.docs.unreleased",

crates/store/re_types/definitions/rerun/archetypes/graph_nodes.fbs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ namespace rerun.archetypes;
22

33
// ---
44

5-
// TODO(ab): Add images to snippets.
6-
75
/// A list of nodes in a graph with optional labels, colors, etc.
86
///
9-
/// \example archetypes/graph_undirected !api title="Simple undirected graph" image=""
10-
/// \example archetypes/graph_directed !api title="Simple directed graph" image=""
7+
/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/15f46bec77452a8c6220558e4403b99cac188e2e/1200w.png"
8+
/// \example archetypes/graph_directed !api title="Simple directed graph" image="https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/1200w.png"
119
table GraphNodes (
1210
"attr.docs.category": "Graph",
1311
"attr.docs.unreleased",

crates/viewer/re_view_graph/src/properties.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use re_types::{
66
components::Position2D,
77
Archetype as _,
88
};
9+
use re_ui::zoom_pan_area::fit_to_rect_in_scene;
910
use re_viewer_context::{TypedComponentFallbackProvider, ViewStateExt as _};
1011

1112
use crate::{ui::GraphViewState, GraphView};
@@ -21,7 +22,14 @@ impl TypedComponentFallbackProvider<VisualBounds2D> for GraphView {
2122
};
2223

2324
match state.layout_state.bounding_rect() {
24-
Some(rect) if valid_bound(&rect) => rect.into(),
25+
Some(rect) if valid_bound(&rect) => {
26+
if let Some(rect_in_ui) = state.rect_in_ui {
27+
let ui_from_world = fit_to_rect_in_scene(rect_in_ui, rect);
28+
(ui_from_world.inverse() * rect_in_ui).into()
29+
} else {
30+
rect.into()
31+
}
32+
}
2533
_ => VisualBounds2D::default(),
2634
}
2735
}

crates/viewer/re_view_graph/src/ui/state.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use egui::Rect;
1+
use egui::{emath::TSTransform, Rect};
22
use re_format::format_f32;
33
use re_types::blueprint::components::VisualBounds2D;
44
use re_ui::UiExt;
@@ -16,6 +16,8 @@ pub struct GraphViewState {
1616
pub show_debug: bool,
1717

1818
pub visual_bounds: Option<VisualBounds2D>,
19+
pub ui_from_world: Option<TSTransform>,
20+
pub rect_in_ui: Option<Rect>,
1921
}
2022

2123
impl GraphViewState {

crates/viewer/re_view_graph/src/view.rs

+20-6
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ Display a graph of nodes and edges.
168168

169169
let state = state.downcast_mut::<GraphViewState>()?;
170170

171+
let params = ForceLayoutParams::get(ctx, query, self, state)?;
172+
171173
let bounds_property = ViewProperty::from_archetype::<VisualBounds2D>(
172174
ctx.blueprint_db(),
173175
ctx.blueprint_query,
@@ -176,17 +178,28 @@ Display a graph of nodes and edges.
176178
let rect_in_scene: blueprint::components::VisualBounds2D =
177179
bounds_property.component_or_fallback(ctx, self, state)?;
178180

179-
let params = ForceLayoutParams::get(ctx, query, self, state)?;
180-
181-
let rect_in_ui = ui.max_rect();
182-
181+
// Perform all layout-related tasks.
183182
let request = LayoutRequest::from_graphs(graphs.iter());
184183
let layout_was_empty = state.layout_state.is_none();
185184
let layout = state.layout_state.get(request, params);
186185

187-
let mut ui_from_world = fit_to_rect_in_scene(rect_in_ui, rect_in_scene.into());
186+
// Prepare the view and the transformations.
187+
let prev_rect_in_ui = state.rect_in_ui;
188+
let rect_in_ui = *state.rect_in_ui.insert(ui.max_rect());
189+
190+
let ui_from_world = state
191+
.ui_from_world
192+
.get_or_insert_with(|| fit_to_rect_in_scene(rect_in_ui, rect_in_scene.into()));
193+
194+
// We ensure that the view's center is kept during resizing.
195+
if let Some(prev) = prev_rect_in_ui {
196+
if prev != rect_in_ui {
197+
let delta = rect_in_ui.center() - prev.center();
198+
ui_from_world.translation += delta;
199+
}
200+
}
188201

189-
let resp = zoom_pan_area(ui, rect_in_ui, &mut ui_from_world, |ui| {
202+
let resp = zoom_pan_area(ui, rect_in_ui, ui_from_world, |ui| {
190203
let mut world_bounding_rect = egui::Rect::NOTHING;
191204

192205
for graph in &graphs {
@@ -205,6 +218,7 @@ Display a graph of nodes and edges.
205218
blueprint::components::VisualBounds2D::from(ui_from_world.inverse() * rect_in_ui);
206219
if resp.double_clicked() || layout_was_empty {
207220
bounds_property.reset_blueprint_component::<blueprint::components::VisualBounds2D>(ctx);
221+
state.ui_from_world = None;
208222
} else if rect_in_scene != updated_rect_in_scene {
209223
bounds_property.save_blueprint_component(ctx, &updated_rect_in_scene);
210224
}

docs/content/reference/types/archetypes/graph_edges.md

+14-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/content/reference/types/archetypes/graph_nodes.md

+14-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/rust/chess_robby_fischer/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ import rerun as rr
279279
import rerun.blueprint as rrb
280280
import argparse
281281

282-
space_view_defaults = [
282+
view_defaults = [
283283
rr.components.AxisLength(0.0), # To hide the axes of all the transformations.
284284
rr.components.ImagePlaneDistance(0.3),
285285
]
@@ -305,11 +305,11 @@ blueprint = rrb.Blueprint(
305305
rrb.Spatial3DView(
306306
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",
307307
contents="/**",
308-
defaults=space_view_defaults
308+
defaults=view_defaults
309309
)
310310
),
311311
rrb.Spatial3DView(
312-
defaults=space_view_defaults
312+
defaults=view_defaults
313313
),
314314
column_shares=[2,2,3]
315315
),

examples/rust/graph_lattice/README.md

+27-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1-
# graph_lattice
1+
<!--[metadata]
2+
title = "Graph lattice"
3+
tags = ["Graph", "Layout"]
4+
thumbnail = "https://static.rerun.io/graph_lattice/f9169da9c3f35b7260c9d74cd5be5fe710aec6a8/480w.png"
5+
thumbnail_dimensions = [480, 269]
6+
channel = "main"
7+
-->
28

3-
Demonstrates graph layout of a lattice without explicit positions.
9+
This example shows different attributes that you can associate with nodes in a graph.
10+
Since no explicit positions are passed for the nodes, Rerun will layout the graph automatically.
11+
12+
<picture>
13+
<img src="https://static.rerun.io/graph_lattice/f9169da9c3f35b7260c9d74cd5be5fe710aec6a8/full.png" alt="">
14+
<source media="(max-width: 480px)" srcset="https://static.rerun.io/graph_lattice/f9169da9c3f35b7260c9d74cd5be5fe710aec6a8/480w.png">
15+
<source media="(max-width: 768px)" srcset="https://static.rerun.io/graph_lattice/f9169da9c3f35b7260c9d74cd5be5fe710aec6a8/768w.png">
16+
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/graph_lattice/f9169da9c3f35b7260c9d74cd5be5fe710aec6a8/1024w.png">
17+
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/graph_lattice/f9169da9c3f35b7260c9d74cd5be5fe710aec6a8/1200w.png">
18+
</picture>
19+
20+
## Used Rerun types
21+
[`GraphNodes`](https://www.rerun.io/docs/reference/types/archetypes/graph_nodes?speculative-link),
22+
[`GraphEdges`](https://www.rerun.io/docs/reference/types/archetypes/graph_edges?speculative-link)
23+
24+
## Run the code
25+
26+
```bash
27+
cargo run --release
28+
```

rerun_cpp/src/rerun/blueprint.hpp

-11
This file was deleted.

rerun_py/docs/gen_common_index.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -380,17 +380,15 @@ class Section:
380380
mod_path="rerun.utilities",
381381
show_submodules=True,
382382
),
383-
Section(
384-
title="Experimental",
385-
func_list=[
386-
"add_space_view",
387-
"new_blueprint",
388-
"set_auto_views",
389-
"set_panels",
390-
],
391-
show_tables=False,
392-
mod_path="rerun.experimental",
393-
),
383+
# We don't have any experimental apis right now, but when you add one again, you should add this here:
384+
# Section(
385+
# title="Experimental",
386+
# func_list=[
387+
# "my_experimental_function",
388+
# ],
389+
# show_tables=False,
390+
# mod_path="rerun.experimental",
391+
# ),
394392
]
395393

396394

rerun_py/rerun_sdk/rerun/blueprint/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def blueprint_path(self) -> str:
9898
Note that although this is an `EntityPath`, is scoped to the blueprint tree and
9999
not a part of the regular data hierarchy.
100100
"""
101-
return f"space_view/{self.id}"
101+
return f"view/{self.id}"
102102

103103
def to_container(self) -> Container:
104104
"""Convert this view to a container."""

rerun_py/tests/unit/test_container_blueprint.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def test_container_blueprint() -> None:
3636
contents_arrays: Sequence[Any] = [
3737
None,
3838
[],
39-
["space_view/1234", "container/5678"],
40-
[EntityPath("space_view/1234"), EntityPath("container/5678")],
39+
["view/1234", "container/5678"],
40+
[EntityPath("view/1234"), EntityPath("container/5678")],
4141
]
4242

4343
col_shares_arrays = [
@@ -54,9 +54,9 @@ def test_container_blueprint() -> None:
5454

5555
active_tab_arrays = [
5656
None,
57-
"space_view/1234",
58-
ActiveTab("space_view/1234"),
59-
ActiveTab(EntityPath("space_view/1234")),
57+
"view/1234",
58+
ActiveTab("view/1234"),
59+
ActiveTab(EntityPath("view/1234")),
6060
]
6161

6262
visible_arrays = [

rerun_py/tests/unit/test_view_contents.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from rerun.datatypes.utf8 import Utf8ArrayLike
99

1010

11-
def test_space_view_contents() -> None:
11+
def test_view_contents() -> None:
1212
query_array = [
1313
[
1414
"+ /**",

0 commit comments

Comments
 (0)