From 651527317195301288a1fa435b62116fc01de3eb Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Wed, 22 May 2024 14:41:18 +0200 Subject: [PATCH 01/10] Moved `SpaceViewBlueprint` (and friend) to new `re_viewport_blueprint` --- Cargo.lock | 32 +++++++-- Cargo.toml | 1 + crates/re_space_view/Cargo.toml | 9 +-- crates/re_space_view/src/lib.rs | 14 +--- crates/re_space_view/src/view_property_ui.rs | 65 +++++++++++++++++ crates/re_space_view_spatial/Cargo.toml | 1 + .../src/space_view_2d.rs | 2 +- crates/re_space_view_spatial/src/ui.rs | 2 +- crates/re_space_view_spatial/src/ui_2d.rs | 4 +- crates/re_space_view_spatial/src/ui_3d.rs | 2 +- crates/re_space_view_time_series/Cargo.toml | 1 + .../src/space_view_class.rs | 3 +- crates/re_viewer/Cargo.toml | 1 + crates/re_viewer/src/app_state.rs | 3 +- crates/re_viewer/src/ui/override_ui.rs | 3 +- crates/re_viewer/src/ui/query_range_ui.rs | 2 +- crates/re_viewer/src/ui/selection_panel.rs | 2 +- .../src/ui/space_view_space_origin_ui.rs | 2 +- crates/re_viewport/Cargo.toml | 1 + .../src/add_space_view_or_container_modal.rs | 2 +- crates/re_viewport/src/auto_layout.rs | 2 +- .../actions/add_entities_to_new_space_view.rs | 3 +- .../context_menu/actions/add_space_view.rs | 2 +- crates/re_viewport/src/screenshot.rs | 3 +- .../src/space_view_entity_picker.rs | 3 +- .../re_viewport/src/space_view_heuristics.rs | 2 +- crates/re_viewport/src/system_execution.rs | 2 +- crates/re_viewport/src/viewport_blueprint.rs | 2 +- .../re_viewport/src/viewport_blueprint_ui.rs | 2 +- crates/re_viewport_blueprint/Cargo.toml | 35 +++++++++ crates/re_viewport_blueprint/README.md | 10 +++ .../src/data_query.rs | 0 crates/re_viewport_blueprint/src/lib.rs | 12 ++++ .../src/space_view.rs | 0 .../src/space_view_contents.rs | 0 .../src/view_properties.rs | 71 +------------------ 36 files changed, 186 insertions(+), 115 deletions(-) create mode 100644 crates/re_space_view/src/view_property_ui.rs create mode 100644 crates/re_viewport_blueprint/Cargo.toml create mode 100644 crates/re_viewport_blueprint/README.md rename crates/{re_space_view => re_viewport_blueprint}/src/data_query.rs (100%) create mode 100644 crates/re_viewport_blueprint/src/lib.rs rename crates/{re_space_view => re_viewport_blueprint}/src/space_view.rs (100%) rename crates/{re_space_view => re_viewport_blueprint}/src/space_view_contents.rs (100%) rename crates/{re_space_view => re_viewport_blueprint}/src/view_properties.rs (65%) diff --git a/Cargo.lock b/Cargo.lock index 62e7b04b302c..f09c4773b577 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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]] @@ -4724,6 +4719,7 @@ dependencies = [ "re_types", "re_ui", "re_viewer_context", + "re_viewport_blueprint", "serde", "smallvec", "web-time", @@ -4810,6 +4806,7 @@ dependencies = [ "re_types", "re_ui", "re_viewer_context", + "re_viewport_blueprint", ] [[package]] @@ -5041,6 +5038,7 @@ dependencies = [ "re_ui", "re_viewer_context", "re_viewport", + "re_viewport_blueprint", "re_ws_comms", "rfd", "ron", @@ -5124,10 +5122,30 @@ dependencies = [ "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 = [ + "egui", + "itertools 0.12.0", + "nohash-hasher", + "re_data_store", + "re_entity_db", + "re_log", + "re_log_types", + "re_tracing", + "re_types", + "re_types_core", + "re_viewer_context", + "slotmap", + "smallvec", +] + [[package]] name = "re_web_viewer_server" version = "0.17.0-alpha.2" diff --git a/Cargo.toml b/Cargo.toml index 323764632d52..e7eabe8ae98c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/crates/re_space_view/Cargo.toml b/crates/re_space_view/Cargo.toml index 36b53d591f51..a54759094ef5 100644 --- a/crates/re_space_view/Cargo.toml +++ b/crates/re_space_view/Cargo.toml @@ -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"] } diff --git a/crates/re_space_view/src/lib.rs b/crates/re_space_view/src/lib.rs index a9132a0286e9..500f9e242c2b 100644 --- a/crates/re_space_view/src/lib.rs +++ b/crates/re_space_view/src/lib.rs @@ -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 { diff --git a/crates/re_space_view/src/view_property_ui.rs b/crates/re_space_view/src/view_property_ui.rs new file mode 100644 index 000000000000..b11e5fea970b --- /dev/null +++ b/crates/re_space_view/src/view_property_ui.rs @@ -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( + 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::(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, + ); +} diff --git a/crates/re_space_view_spatial/Cargo.toml b/crates/re_space_view_spatial/Cargo.toml index bc0c28779e2b..23fa04af6b6e 100644 --- a/crates/re_space_view_spatial/Cargo.toml +++ b/crates/re_space_view_spatial/Cargo.toml @@ -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 diff --git a/crates/re_space_view_spatial/src/space_view_2d.rs b/crates/re_space_view_spatial/src/space_view_2d.rs index d262e1b1e7f0..778f663dd2a5 100644 --- a/crates/re_space_view_spatial/src/space_view_2d.rs +++ b/crates/re_space_view_spatial/src/space_view_2d.rs @@ -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, (), diff --git a/crates/re_space_view_spatial/src/ui.rs b/crates/re_space_view_spatial/src/ui.rs index b082161723f9..fb51cbeb89d4 100644 --- a/crates/re_space_view_spatial/src/ui.rs +++ b/crates/re_space_view_spatial/src/ui.rs @@ -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); diff --git a/crates/re_space_view_spatial/src/ui_2d.rs b/crates/re_space_view_spatial/src/ui_2d.rs index dcce82da23d9..e406167b3e1a 100644 --- a/crates/re_space_view_spatial/src/ui_2d.rs +++ b/crates/re_space_view_spatial/src/ui_2d.rs @@ -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, @@ -285,7 +285,7 @@ pub fn view_2d( view_builder.queue_draw(draw_data); } - let background = re_space_view::view_property::(ctx, query.space_view_id) + let background = re_viewport_blueprint::view_property::(ctx, query.space_view_id) .unwrap_or(Background::DEFAULT_2D); let (background_drawable, clear_color) = crate::configure_background( ctx, diff --git a/crates/re_space_view_spatial/src/ui_3d.rs b/crates/re_space_view_spatial/src/ui_3d.rs index f90a8e25e4ff..80d8ec77cafc 100644 --- a/crates/re_space_view_spatial/src/ui_3d.rs +++ b/crates/re_space_view_spatial/src/ui_3d.rs @@ -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::(ctx, query.space_view_id) + let background = re_viewport_blueprint::view_property::(ctx, query.space_view_id) .unwrap_or(Background::DEFAULT_3D); let (background_drawable, clear_color) = crate::configure_background( ctx, diff --git a/crates/re_space_view_time_series/Cargo.toml b/crates/re_space_view_time_series/Cargo.toml index bcbfc845c815..d679e5b54f1f 100644 --- a/crates/re_space_view_time_series/Cargo.toml +++ b/crates/re_space_view_time_series/Cargo.toml @@ -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 diff --git a/crates/re_space_view_time_series/src/space_view_class.rs b/crates/re_space_view_time_series/src/space_view_class.rs index 4f7b1ed47819..e7c0bba54e3a 100644 --- a/crates/re_space_view_time_series/src/space_view_class.rs +++ b/crates/re_space_view_time_series/src/space_view_class.rs @@ -5,7 +5,7 @@ use egui_plot::{Legend, Line, Plot, PlotPoint, Points}; use re_data_store::TimeType; use re_format::next_grid_tick_magnitude_ns; use re_log_types::{EntityPath, TimeInt, TimeZone}; -use re_space_view::{controls, query_view_property_or_default, view_property_ui}; +use re_space_view::{controls, view_property_ui}; use re_types::blueprint::archetypes::PlotLegend; use re_types::{components::Range1D, datatypes::TimeRange, SpaceViewClassIdentifier, View}; use re_ui::list_item; @@ -19,6 +19,7 @@ use re_viewer_context::{ SpaceViewSystemExecutionError, SystemExecutionOutput, ViewQuery, ViewSystemIdentifier, ViewerContext, VisualizableEntities, }; +use re_viewport_blueprint::query_view_property_or_default; use crate::line_visualizer_system::SeriesLineSystem; use crate::point_visualizer_system::SeriesPointSystem; diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index a039133d20c4..ce1cc5a5ec82 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -74,6 +74,7 @@ re_types_core.workspace = true re_ui.workspace = true re_viewer_context.workspace = true re_viewport.workspace = true +re_viewport_blueprint.workspace = true re_ws_comms = { workspace = true, features = ["client"] } # Internal (optional): diff --git a/crates/re_viewer/src/app_state.rs b/crates/re_viewer/src/app_state.rs index 4546100cebdc..77ac101508a0 100644 --- a/crates/re_viewer/src/app_state.rs +++ b/crates/re_viewer/src/app_state.rs @@ -4,7 +4,7 @@ use re_data_store::LatestAtQuery; use re_entity_db::EntityDb; use re_log_types::{LogMsg, ResolvedTimeRangeF, StoreId}; use re_smart_channel::ReceiveSet; -use re_space_view::{determine_visualizable_entities, DataQuery as _, PropertyResolver as _}; +use re_space_view::determine_visualizable_entities; use re_types::blueprint::components::PanelState; use re_viewer_context::{ blueprint_timeline, AppOptions, ApplicationSelectionState, Caches, CommandSender, @@ -12,6 +12,7 @@ use re_viewer_context::{ StoreHub, SystemCommandSender as _, ViewerContext, }; use re_viewport::{Viewport, ViewportBlueprint, ViewportState}; +use re_viewport_blueprint::{DataQuery as _, PropertyResolver as _}; use crate::ui::recordings_panel_ui; use crate::{app_blueprint::AppBlueprint, ui::blueprint_panel_ui}; diff --git a/crates/re_viewer/src/ui/override_ui.rs b/crates/re_viewer/src/ui/override_ui.rs index 0c5fe3bf74dd..ba9ddbcc436a 100644 --- a/crates/re_viewer/src/ui/override_ui.rs +++ b/crates/re_viewer/src/ui/override_ui.rs @@ -5,12 +5,13 @@ use itertools::Itertools; use re_data_store::LatestAtQuery; use re_entity_db::{EntityDb, InstancePath}; use re_log_types::{DataRow, RowId, StoreKind}; -use re_space_view::{determine_visualizable_entities, SpaceViewBlueprint}; +use re_space_view::determine_visualizable_entities; use re_types_core::{components::VisualizerOverrides, ComponentName}; use re_viewer_context::{ DataResult, OverridePath, SystemCommand, SystemCommandSender as _, UiLayout, ViewSystemIdentifier, ViewerContext, }; +use re_viewport_blueprint::SpaceViewBlueprint; pub fn override_ui( ctx: &ViewerContext<'_>, diff --git a/crates/re_viewer/src/ui/query_range_ui.rs b/crates/re_viewer/src/ui/query_range_ui.rs index bed720e40f94..d99d35f75a6d 100644 --- a/crates/re_viewer/src/ui/query_range_ui.rs +++ b/crates/re_viewer/src/ui/query_range_ui.rs @@ -5,7 +5,6 @@ use egui::{NumExt as _, Response, Ui}; use re_entity_db::TimeHistogram; use re_log_types::{EntityPath, ResolvedTimeRange, TimeType, TimeZone, TimelineName}; -use re_space_view::{entity_path_for_view_property, SpaceViewBlueprint}; use re_space_view_spatial::{SpatialSpaceView2D, SpatialSpaceView3D}; use re_space_view_time_series::TimeSeriesSpaceView; use re_types::{ @@ -14,6 +13,7 @@ use re_types::{ }; use re_ui::{markdown_ui, ReUi}; use re_viewer_context::{QueryRange, SpaceViewClass, ViewerContext}; +use re_viewport_blueprint::{entity_path_for_view_property, SpaceViewBlueprint}; /// These space views support the Visible History feature. static VISIBLE_HISTORY_SUPPORTED_SPACE_VIEWS: once_cell::sync::Lazy< diff --git a/crates/re_viewer/src/ui/selection_panel.rs b/crates/re_viewer/src/ui/selection_panel.rs index 50af8049657c..cc0e0126a846 100644 --- a/crates/re_viewer/src/ui/selection_panel.rs +++ b/crates/re_viewer/src/ui/selection_panel.rs @@ -268,7 +268,7 @@ fn data_section_ui(item: &Item) -> Option> { fn space_view_button( ctx: &ViewerContext<'_>, ui: &mut egui::Ui, - space_view: &re_space_view::SpaceViewBlueprint, + space_view: &re_viewport_blueprint::SpaceViewBlueprint, ) -> egui::Response { let item = Item::SpaceView(space_view.id); let is_selected = ctx.selection().contains_item(&item); diff --git a/crates/re_viewer/src/ui/space_view_space_origin_ui.rs b/crates/re_viewer/src/ui/space_view_space_origin_ui.rs index d2a1239d1998..6830c3e83199 100644 --- a/crates/re_viewer/src/ui/space_view_space_origin_ui.rs +++ b/crates/re_viewer/src/ui/space_view_space_origin_ui.rs @@ -4,9 +4,9 @@ use eframe::emath::NumExt; use egui::{Key, Ui}; use re_log_types::EntityPath; -use re_space_view::SpaceViewBlueprint; use re_ui::{list_item, ReUi, SyntaxHighlighting}; use re_viewer_context::ViewerContext; +use re_viewport_blueprint::SpaceViewBlueprint; /// State of the space origin widget. #[derive(Default, Clone)] diff --git a/crates/re_viewport/Cargo.toml b/crates/re_viewport/Cargo.toml index 87d211893b2e..8d26ae06943a 100644 --- a/crates/re_viewport/Cargo.toml +++ b/crates/re_viewport/Cargo.toml @@ -38,6 +38,7 @@ re_types_blueprint.workspace = true re_types_core.workspace = true re_ui.workspace = true re_viewer_context.workspace = true +re_viewport_blueprint.workspace = true ahash.workspace = true egui_tiles.workspace = true diff --git a/crates/re_viewport/src/add_space_view_or_container_modal.rs b/crates/re_viewport/src/add_space_view_or_container_modal.rs index 259733523d8f..1c53b2fa3535 100644 --- a/crates/re_viewport/src/add_space_view_or_container_modal.rs +++ b/crates/re_viewport/src/add_space_view_or_container_modal.rs @@ -1,10 +1,10 @@ //! Modal for adding a new space view of container to an existing target container. -use re_space_view::SpaceViewBlueprint; use re_ui::ReUi; use re_viewer_context::{ blueprint_id_to_tile_id, ContainerId, RecommendedSpaceView, ViewerContext, }; +use re_viewport_blueprint::SpaceViewBlueprint; use crate::{icon_for_container_kind, ViewportBlueprint}; diff --git a/crates/re_viewport/src/auto_layout.rs b/crates/re_viewport/src/auto_layout.rs index 8252d57f1b1e..51006d866014 100644 --- a/crates/re_viewport/src/auto_layout.rs +++ b/crates/re_viewport/src/auto_layout.rs @@ -9,7 +9,7 @@ use itertools::Itertools as _; use re_types::SpaceViewClassIdentifier; use re_viewer_context::SpaceViewId; -use re_space_view::SpaceViewBlueprint; +use re_viewport_blueprint::SpaceViewBlueprint; #[derive(Clone, Debug)] struct SpaceMakeInfo { diff --git a/crates/re_viewport/src/context_menu/actions/add_entities_to_new_space_view.rs b/crates/re_viewport/src/context_menu/actions/add_entities_to_new_space_view.rs index ba9e2569fd06..f2f052626b34 100644 --- a/crates/re_viewport/src/context_menu/actions/add_entities_to_new_space_view.rs +++ b/crates/re_viewport/src/context_menu/actions/add_entities_to_new_space_view.rs @@ -3,9 +3,10 @@ use itertools::Itertools; use nohash_hasher::IntSet; use re_log_types::{EntityPath, EntityPathFilter, EntityPathRule, RuleEffect}; -use re_space_view::{determine_visualizable_entities, SpaceViewBlueprint}; +use re_space_view::determine_visualizable_entities; use re_types::SpaceViewClassIdentifier; use re_viewer_context::{Item, RecommendedSpaceView}; +use re_viewport_blueprint::SpaceViewBlueprint; use crate::context_menu::{ContextMenuAction, ContextMenuContext}; diff --git a/crates/re_viewport/src/context_menu/actions/add_space_view.rs b/crates/re_viewport/src/context_menu/actions/add_space_view.rs index aaef44fe40ea..238a22004ab8 100644 --- a/crates/re_viewport/src/context_menu/actions/add_space_view.rs +++ b/crates/re_viewport/src/context_menu/actions/add_space_view.rs @@ -1,7 +1,7 @@ -use re_space_view::SpaceViewBlueprint; use re_types::SpaceViewClassIdentifier; use re_ui::Icon; use re_viewer_context::{ContainerId, Item, RecommendedSpaceView}; +use re_viewport_blueprint::SpaceViewBlueprint; use crate::context_menu::{ContextMenuAction, ContextMenuContext}; diff --git a/crates/re_viewport/src/screenshot.rs b/crates/re_viewport/src/screenshot.rs index dec438f1fd45..83f650da4452 100644 --- a/crates/re_viewport/src/screenshot.rs +++ b/crates/re_viewport/src/screenshot.rs @@ -1,4 +1,5 @@ -use re_space_view::{ScreenshotMode, SpaceViewBlueprint}; +use re_space_view::ScreenshotMode; +use re_viewport_blueprint::SpaceViewBlueprint; pub fn handle_pending_space_view_screenshots( space_view: &SpaceViewBlueprint, diff --git a/crates/re_viewport/src/space_view_entity_picker.rs b/crates/re_viewport/src/space_view_entity_picker.rs index fe9b9069c969..b5aa976147d9 100644 --- a/crates/re_viewport/src/space_view_entity_picker.rs +++ b/crates/re_viewport/src/space_view_entity_picker.rs @@ -4,8 +4,9 @@ use nohash_hasher::IntMap; use re_data_ui::item_ui; use re_entity_db::{EntityPath, EntityTree, InstancePath}; use re_log_types::{EntityPathFilter, EntityPathRule}; -use re_space_view::{determine_visualizable_entities, SpaceViewBlueprint}; +use re_space_view::determine_visualizable_entities; use re_viewer_context::{DataQueryResult, SpaceViewId, ViewerContext}; +use re_viewport_blueprint::SpaceViewBlueprint; use crate::ViewportBlueprint; diff --git a/crates/re_viewport/src/space_view_heuristics.rs b/crates/re_viewport/src/space_view_heuristics.rs index 15c79faf7c6d..5185143e0ce9 100644 --- a/crates/re_viewport/src/space_view_heuristics.rs +++ b/crates/re_viewport/src/space_view_heuristics.rs @@ -1,6 +1,6 @@ use re_viewer_context::ViewerContext; -use re_space_view::SpaceViewBlueprint; +use re_viewport_blueprint::SpaceViewBlueprint; /// List out all space views we generate by default for the available data. /// diff --git a/crates/re_viewport/src/system_execution.rs b/crates/re_viewport/src/system_execution.rs index 5fbaf9b3ff9f..89d35a1878ed 100644 --- a/crates/re_viewport/src/system_execution.rs +++ b/crates/re_viewport/src/system_execution.rs @@ -11,7 +11,7 @@ use re_viewer_context::{ }; use crate::space_view_highlights::highlights_for_space_view; -use re_space_view::SpaceViewBlueprint; +use re_viewport_blueprint::SpaceViewBlueprint; pub fn create_and_run_space_view_systems( ctx: &ViewerContext<'_>, diff --git a/crates/re_viewport/src/viewport_blueprint.rs b/crates/re_viewport/src/viewport_blueprint.rs index cca809bd8997..33d84bf42f6c 100644 --- a/crates/re_viewport/src/viewport_blueprint.rs +++ b/crates/re_viewport/src/viewport_blueprint.rs @@ -10,7 +10,6 @@ use smallvec::SmallVec; use re_data_store::LatestAtQuery; use re_entity_db::external::re_query::PromiseResult; use re_entity_db::EntityPath; -use re_space_view::SpaceViewBlueprint; use re_types::blueprint::components::ViewerRecommendationHash; use re_types_blueprint::blueprint::components::{ AutoLayout, AutoSpaceViews, IncludedSpaceView, RootContainer, SpaceViewMaximized, @@ -18,6 +17,7 @@ use re_types_blueprint::blueprint::components::{ use re_viewer_context::{ blueprint_id_to_tile_id, ContainerId, Contents, Item, SpaceViewId, ViewerContext, }; +use re_viewport_blueprint::SpaceViewBlueprint; use crate::{container::ContainerBlueprint, viewport::TreeAction, VIEWPORT_PATH}; diff --git a/crates/re_viewport/src/viewport_blueprint_ui.rs b/crates/re_viewport/src/viewport_blueprint_ui.rs index e2a62321049a..6310bc5ccd80 100644 --- a/crates/re_viewport/src/viewport_blueprint_ui.rs +++ b/crates/re_viewport/src/viewport_blueprint_ui.rs @@ -5,13 +5,13 @@ use smallvec::SmallVec; use re_entity_db::InstancePath; use re_log_types::EntityPath; -use re_space_view::SpaceViewBlueprint; use re_types::blueprint::components::Visible; use re_ui::{drag_and_drop::DropTarget, list_item, ReUi}; use re_viewer_context::{CollapseScope, Contents, ContentsName, DataResultTree}; use re_viewer_context::{ ContainerId, DataQueryResult, DataResultNode, HoverHighlight, Item, SpaceViewId, ViewerContext, }; +use re_viewport_blueprint::SpaceViewBlueprint; use crate::context_menu::context_menu_ui_for_item; use crate::{SelectionUpdateBehavior, Viewport}; diff --git a/crates/re_viewport_blueprint/Cargo.toml b/crates/re_viewport_blueprint/Cargo.toml new file mode 100644 index 000000000000..e964ac25fefa --- /dev/null +++ b/crates/re_viewport_blueprint/Cargo.toml @@ -0,0 +1,35 @@ +[package] +authors.workspace = true +description = "The central viewport panel of the Rerun viewer." +edition.workspace = true +homepage.workspace = true +license.workspace = true +name = "re_viewport_blueprint" +publish = true +readme = "README.md" +repository.workspace = true +rust-version.workspace = true +version.workspace = true +include = ["../../LICENSE-APACHE", "../../LICENSE-MIT", "**/*.rs", "Cargo.toml"] + +[lints] +workspace = true + +[package.metadata.docs.rs] +all-features = true + +[dependencies] +re_data_store.workspace = true +re_entity_db = { workspace = true, features = ["serde"] } +re_log_types.workspace = true +re_log.workspace = true +re_tracing.workspace = true +re_types.workspace = true +re_types_core.workspace = true +re_viewer_context.workspace = true + +egui.workspace = true +itertools.workspace = true +nohash-hasher.workspace = true +slotmap.workspace = true +smallvec.workspace = true diff --git a/crates/re_viewport_blueprint/README.md b/crates/re_viewport_blueprint/README.md new file mode 100644 index 000000000000..8a2527e88a20 --- /dev/null +++ b/crates/re_viewport_blueprint/README.md @@ -0,0 +1,10 @@ +# re_viewport_blueprint + +Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates. + +[![Latest version](https://img.shields.io/crates/v/re_viewport_blueprint.svg)](https://crates.io/crates/re_viewport_blueprint) +[![Documentation](https://docs.rs/re_viewport_blueprint/badge.svg)](https://docs.rs/re_viewport_blueprint) +![MIT](https://img.shields.io/badge/license-MIT-blue.svg) +![Apache](https://img.shields.io/badge/license-Apache-blue.svg) + +The data model describing the layout of the viewport. diff --git a/crates/re_space_view/src/data_query.rs b/crates/re_viewport_blueprint/src/data_query.rs similarity index 100% rename from crates/re_space_view/src/data_query.rs rename to crates/re_viewport_blueprint/src/data_query.rs diff --git a/crates/re_viewport_blueprint/src/lib.rs b/crates/re_viewport_blueprint/src/lib.rs new file mode 100644 index 000000000000..cecb11b2f985 --- /dev/null +++ b/crates/re_viewport_blueprint/src/lib.rs @@ -0,0 +1,12 @@ +mod data_query; +mod space_view; +mod space_view_contents; +mod view_properties; // TODO(andreas): better name before `sub_archetype` sticks around? + +pub use data_query::{DataQuery, EntityOverrideContext, PropertyResolver}; +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, +}; diff --git a/crates/re_space_view/src/space_view.rs b/crates/re_viewport_blueprint/src/space_view.rs similarity index 100% rename from crates/re_space_view/src/space_view.rs rename to crates/re_viewport_blueprint/src/space_view.rs diff --git a/crates/re_space_view/src/space_view_contents.rs b/crates/re_viewport_blueprint/src/space_view_contents.rs similarity index 100% rename from crates/re_space_view/src/space_view_contents.rs rename to crates/re_viewport_blueprint/src/space_view_contents.rs diff --git a/crates/re_space_view/src/view_properties.rs b/crates/re_viewport_blueprint/src/view_properties.rs similarity index 65% rename from crates/re_space_view/src/view_properties.rs rename to crates/re_viewport_blueprint/src/view_properties.rs index 836dd8fcfa6b..6ed3e6fdae17 100644 --- a/crates/re_space_view/src/view_properties.rs +++ b/crates/re_viewport_blueprint/src/view_properties.rs @@ -1,17 +1,11 @@ use re_data_store::LatestAtQuery; use re_entity_db::{ external::re_query::{LatestAtResults, PromiseResult, ToArchetype}, - EntityDb, + EntityDb, EntityTree, }; use re_log_types::EntityPath; use re_types::Archetype; -use re_viewer_context::{ - external::{ - re_entity_db::EntityTree, - re_ui::{self, list_item}, - }, - SpaceViewId, ViewerContext, -}; +use re_viewer_context::{SpaceViewId, ViewerContext}; pub fn entity_path_for_view_property( space_view_id: SpaceViewId, @@ -128,64 +122,3 @@ pub fn edit_blueprint_component( - 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::(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, - ); -} From e1d48e2aa5e429b86f08fd986ef30e2b595d4670 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Thu, 23 May 2024 10:00:33 +0200 Subject: [PATCH 02/10] Updated ARCHITECTURE.md --- ARCHITECTURE.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 37df6cfd38b6..665144876cc5 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -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: - - - - - + + + + +