Skip to content

Commit

Permalink
Move {Viewport, SpaceView, Container}Blueprint to new `re_viewport_…
Browse files Browse the repository at this point in the history
…blueprint` crate (rerun-io#6405)

### What

- Closes rerun-io#5421
- Unlocks rerun-io#6414 
- Unlocks  rerun-io#6415

This enable more general access to manipulating the blueprint and unlock
further crate splitting.


![](https://static.rerun.io/crates/f0024a424aa35efab710ae88ba6a1ed741e7c248/1200w.png)

### TODO

- [x] delete the traits in `data_query.rs` and use concrete types
instead
- [x] move the UI function introduced by Andreas back to `re_space_view`

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6405?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6405?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6405)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
abey79 authored May 23, 2024
1 parent 0270109 commit be84090
Show file tree
Hide file tree
Showing 47 changed files with 323 additions and 292 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ _deps
__pycache__
*.pyc
*.so
**/.pytest_cache

# Pixi environment
.pixi
Expand Down
11 changes: 6 additions & 5 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ Of course, this will only take us so far. In the future we plan on caching queri
Here is an overview of the crates included in the project:

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

<!-- !!! IMPORTANT!!!
Expand Down Expand Up @@ -128,6 +128,7 @@ Update instructions:
|-----------------------------|----------------------------------------------------------------------------------------|
| re_viewer | The Rerun Viewer |
| re_viewport | The central viewport panel of the Rerun viewer. |
| re_viewport_blueprint | The data model description of the viewport panel. |
| re_time_panel | The time panel of the Rerun Viewer, allowing to control the displayed timeline & time. |
| re_data_ui | Provides ui elements for Rerun component data for the Rerun Viewer. |
| re_viewer_context | Rerun Viewer state that is shared with the viewer's code components. |
Expand Down
40 changes: 29 additions & 11 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4644,19 +4644,14 @@ name = "re_space_view"
version = "0.17.0-alpha.2"
dependencies = [
"egui",
"itertools 0.12.0",
"nohash-hasher",
"re_data_store",
"re_entity_db",
"re_log",
"re_log_types",
"re_query",
"re_tracing",
"re_types",
"re_types_core",
"re_ui",
"re_viewer_context",
"slotmap",
"smallvec",
"re_viewport_blueprint",
]

[[package]]
Expand Down Expand Up @@ -4724,6 +4719,7 @@ dependencies = [
"re_types",
"re_ui",
"re_viewer_context",
"re_viewport_blueprint",
"serde",
"smallvec",
"web-time",
Expand Down Expand Up @@ -4777,7 +4773,6 @@ version = "0.17.0-alpha.2"
dependencies = [
"egui",
"egui_extras",
"itertools 0.12.0",
"re_data_store",
"re_data_ui",
"re_entity_db",
Expand Down Expand Up @@ -4810,6 +4805,7 @@ dependencies = [
"re_types",
"re_ui",
"re_viewer_context",
"re_viewport_blueprint",
]

[[package]]
Expand Down Expand Up @@ -4840,6 +4836,7 @@ dependencies = [
"re_ui",
"re_viewer_context",
"re_viewport",
"re_viewport_blueprint",
"serde",
"vec1",
]
Expand Down Expand Up @@ -4998,7 +4995,6 @@ dependencies = [
"eframe",
"egui",
"egui-wgpu",
"egui_extras",
"egui_plot",
"egui_tiles",
"ehttp",
Expand Down Expand Up @@ -5041,6 +5037,7 @@ dependencies = [
"re_ui",
"re_viewer_context",
"re_viewport",
"re_viewport_blueprint",
"re_ws_comms",
"rfd",
"ron",
Expand Down Expand Up @@ -5110,7 +5107,6 @@ dependencies = [
"nohash-hasher",
"once_cell",
"rayon",
"re_data_store",
"re_data_ui",
"re_entity_db",
"re_log",
Expand All @@ -5121,13 +5117,35 @@ dependencies = [
"re_tracing",
"re_types",
"re_types_blueprint",
"re_types_core",
"re_ui",
"re_viewer_context",
"re_viewport_blueprint",
"smallvec",
"static_assertions",
]

[[package]]
name = "re_viewport_blueprint"
version = "0.17.0-alpha.2"
dependencies = [
"ahash",
"egui",
"egui_tiles",
"itertools 0.12.0",
"nohash-hasher",
"re_data_store",
"re_entity_db",
"re_log",
"re_log_types",
"re_tracing",
"re_types",
"re_types_blueprint",
"re_types_core",
"re_viewer_context",
"slotmap",
"smallvec",
]

[[package]]
name = "re_web_viewer_server"
version = "0.17.0-alpha.2"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ re_ui = { path = "crates/re_ui", version = "=0.17.0-alpha.2", default-features =
re_viewer = { path = "crates/re_viewer", version = "=0.17.0-alpha.2", default-features = false }
re_viewer_context = { path = "crates/re_viewer_context", version = "=0.17.0-alpha.2", default-features = false }
re_viewport = { path = "crates/re_viewport", version = "=0.17.0-alpha.2", default-features = false }
re_viewport_blueprint = { path = "crates/re_viewport_blueprint", version = "=0.17.0-alpha.2", default-features = false }
re_web_viewer_server = { path = "crates/re_web_viewer_server", version = "=0.17.0-alpha.2", default-features = false }
re_ws_comms = { path = "crates/re_ws_comms", version = "=0.17.0-alpha.2", default-features = false }
rerun = { path = "crates/rerun", version = "=0.17.0-alpha.2", default-features = false }
Expand Down
9 changes: 2 additions & 7 deletions crates/re_space_view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@ all-features = true
default = []

[dependencies]
re_log.workspace = true
re_log_types.workspace = true
re_data_store.workspace = true
re_entity_db.workspace = true
re_query.workspace = true
re_tracing.workspace = true
re_types_core.workspace = true
re_types.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true
re_viewport_blueprint.workspace = true

egui.workspace = true
itertools.workspace = true
nohash-hasher.workspace = true
slotmap.workspace = true
smallvec = { workspace = true, features = ["serde"] }
49 changes: 0 additions & 49 deletions crates/re_space_view/src/data_query.rs

This file was deleted.

14 changes: 3 additions & 11 deletions crates/re_space_view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@
//! Types & utilities for defining Space View classes and communicating with the Viewport.
pub mod controls;
mod data_query;

mod heuristics;
mod screenshot;
mod space_view;
mod space_view_contents;
mod view_properties; // TODO(andreas): better name before `sub_archetype` sticks around?
mod view_property_ui;
mod visualizable;

pub use data_query::{DataQuery, EntityOverrideContext, PropertyResolver};
pub use heuristics::suggest_space_view_for_each_entity;
pub use screenshot::ScreenshotMode;
pub use space_view::SpaceViewBlueprint;
pub use space_view_contents::SpaceViewContents;
pub use view_properties::{
edit_blueprint_component, entity_path_for_view_property, get_blueprint_component,
query_view_property, query_view_property_or_default, view_property, view_property_ui,
};
pub use view_property_ui::view_property_ui;
pub use visualizable::determine_visualizable_entities;

pub mod external {
Expand Down
65 changes: 65 additions & 0 deletions crates/re_space_view/src/view_property_ui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use re_types_core::Archetype;
use re_ui::list_item;
use re_viewer_context::{SpaceViewId, ViewerContext};
use re_viewport_blueprint::entity_path_for_view_property;

/// Display the UI for editing all components of a blueprint archetype.
///
/// Note that this will show default values for components that are null.
pub fn view_property_ui<A: Archetype>(
ctx: &ViewerContext<'_>,
space_view_id: SpaceViewId,
ui: &mut egui::Ui,
) {
let blueprint_db = ctx.store_context.blueprint;
let blueprint_query = ctx.blueprint_query;
let blueprint_path = entity_path_for_view_property::<A>(space_view_id, blueprint_db.tree());

let component_names = A::all_components();
let component_results = blueprint_db.latest_at(
blueprint_query,
&blueprint_path,
component_names.iter().copied(),
);

let sub_prop_ui = |re_ui: &re_ui::ReUi, ui: &mut egui::Ui| {
for component_name in component_names.as_ref() {
if component_name.is_indicator_component() {
continue;
}

list_item::ListItem::new(re_ui)
.interactive(false)
.show_flat(
ui,
// TODO(andreas): Note that we loose the archetype's field name here, instead we label the item with the component name.
list_item::PropertyContent::new(component_name.short_name()).value_fn(
|_, ui, _| {
ctx.component_ui_registry.edit_ui(
ctx,
ui,
re_viewer_context::UiLayout::List,
blueprint_query,
blueprint_db,
&blueprint_path,
&blueprint_path,
component_results.get_or_empty(*component_name),
component_name,
&0.into(),
);
},
),
);
}
};

list_item::ListItem::new(ctx.re_ui)
.interactive(false)
.show_hierarchical_with_children(
ui,
A::name().full_name(),
true,
list_item::LabelContent::new(A::name().short_name()),
sub_prop_ui,
);
}
1 change: 1 addition & 0 deletions crates/re_space_view_spatial/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ re_types = { workspace = true, features = ["ecolor", "glam", "image"] }
re_tracing.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true
re_viewport_blueprint.workspace = true
re_space_view.workspace = true

ahash.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/space_view_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl SpaceViewClass for SpatialSpaceView2D {
fn visual_bounds_ui(ctx: &ViewerContext<'_>, space_view_id: SpaceViewId, ui: &mut egui::Ui) {
let tooltip = "The area guaranteed to be visible.\n\
Depending on the view's current aspect ratio the actually visible area might be larger either horizontally or vertically.";
re_space_view::edit_blueprint_component::<
re_viewport_blueprint::edit_blueprint_component::<
VisualBounds2D,
blueprint_components::VisualBounds2D,
(),
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ pub fn background_ui(
let blueprint_db = ctx.store_context.blueprint;
let blueprint_query = ctx.blueprint_query;
let (archetype, blueprint_path) =
re_space_view::query_view_property(space_view_id, blueprint_db, blueprint_query);
re_viewport_blueprint::query_view_property(space_view_id, blueprint_db, blueprint_query);

let Background { color, mut kind } = archetype.ok().flatten().unwrap_or(default_background);

Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view_spatial/src/ui_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn ui_from_scene(
RectTransform::from_to(letterboxed_bounds, response.rect)
}

re_space_view::edit_blueprint_component::<
re_viewport_blueprint::edit_blueprint_component::<
VisualBounds2D,
blueprint_components::VisualBounds2D,
RectTransform,
Expand Down Expand Up @@ -285,7 +285,7 @@ pub fn view_2d(
view_builder.queue_draw(draw_data);
}

let background = re_space_view::view_property::<Background>(ctx, query.space_view_id)
let background = re_viewport_blueprint::view_property::<Background>(ctx, query.space_view_id)
.unwrap_or(Background::DEFAULT_2D);
let (background_drawable, clear_color) = crate::configure_background(
ctx,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/ui_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ pub fn view_3d(
// Commit ui induced lines.
view_builder.queue_draw(line_builder.into_draw_data()?);

let background = re_space_view::view_property::<Background>(ctx, query.space_view_id)
let background = re_viewport_blueprint::view_property::<Background>(ctx, query.space_view_id)
.unwrap_or(Background::DEFAULT_3D);
let (background_drawable, clear_color) = crate::configure_background(
ctx,
Expand Down
1 change: 0 additions & 1 deletion crates/re_space_view_text_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ re_viewer_context.workspace = true

egui_extras.workspace = true
egui.workspace = true
itertools.workspace = true
1 change: 1 addition & 0 deletions crates/re_space_view_time_series/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ re_tracing.workspace = true
re_types = { workspace = true, features = ["egui_plot"] }
re_ui.workspace = true
re_viewer_context.workspace = true
re_viewport_blueprint.workspace = true

egui.workspace = true
egui_plot.workspace = true
Expand Down
Loading

0 comments on commit be84090

Please sign in to comment.