From bd21f004abd144d1e57e7f12a7dd9f0bbfc57bf5 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Fri, 8 Mar 2024 09:29:15 +0100 Subject: [PATCH] unify auto False-on-user-blueprint True-on-no-blueprint for `auto_layout` and `auto_space_views` --- .../archetypes/viewport_blueprint.fbs | 18 ++++++------ .../archetypes/viewport_blueprint.rs | 14 +++++----- crates/re_viewport/src/viewport_blueprint.rs | 23 +++++++-------- .../archetypes/viewport_blueprint.hpp | 28 +++++++++---------- .../archetypes/viewport_blueprint.py | 28 +++++++++---------- 5 files changed, 56 insertions(+), 55 deletions(-) diff --git a/crates/re_types/definitions/rerun/blueprint/archetypes/viewport_blueprint.fbs b/crates/re_types/definitions/rerun/blueprint/archetypes/viewport_blueprint.fbs index a2d5ebe8a40d..8a00279674e7 100644 --- a/crates/re_types/definitions/rerun/blueprint/archetypes/viewport_blueprint.fbs +++ b/crates/re_types/definitions/rerun/blueprint/archetypes/viewport_blueprint.fbs @@ -26,7 +26,7 @@ table ViewportBlueprint ( /// Show one tab as maximized? maximized: rerun.blueprint.components.SpaceViewMaximized ("attr.rerun.component_optional", nullable, order: 3000); - // TODO(andreas): This is to be removed in the future, all new space views without an explicit container + // TODO(andreas): This is to be removed in the future, all new Space Views without an explicit container // should always insert themselves using a heuristic. /// Whether the viewport layout is determined automatically. /// @@ -34,19 +34,19 @@ table ViewportBlueprint ( /// This defaults to `false` and is automatically set to `false` when there is user determined layout. auto_layout: rerun.blueprint.components.AutoLayout ("attr.rerun.component_optional", nullable, order: 4000); - // TODO(jleibs): This should come with an optional container id that specifies where to insert new space views. - /// Whether or not space views should be created automatically. + // TODO(jleibs): This should come with an optional container id that specifies where to insert new Space Views. + /// Whether or not Space Views should be created automatically. /// - /// True if not specified, meaning that if the Viewer deems it necessary to add new Space Views to cover - /// all logged entities appropriately, it will do so unless they were added previously - /// (as identified by `past_viewer_recommendations`). + /// If `true`, the viewer will only add Space Views that it hasn't considered previously (as identified by `past_viewer_recommendations`) + /// and which aren't deemed redundant to existing Space Views. + /// This defaults to `false` and is automatically set to `false` when the user adds Space Views manually in the viewer. auto_space_views: rerun.blueprint.components.AutoSpaceViews ("attr.rerun.component_optional", nullable, order: 5000); - /// Hashes of all recommended space views the viewer has already added and that should not be added again. + /// Hashes of all recommended Space Views the viewer has already added and that should not be added again. /// /// This is an internal field and should not be set usually. - /// If you want the viewer from stopping to add space views, you should set `auto_space_views` to `false`. + /// If you want the viewer from stopping to add Space Views, you should set `auto_space_views` to `false`. /// - /// The viewer uses this to determine whether it should keep adding space views. + /// The viewer uses this to determine whether it should keep adding Space Views. past_viewer_recommendations: [rerun.blueprint.components.ViewerRecommendationHash] ("attr.rerun.component_optional", nullable, order: 6000); } diff --git a/crates/re_viewport/src/blueprint/archetypes/viewport_blueprint.rs b/crates/re_viewport/src/blueprint/archetypes/viewport_blueprint.rs index 7df5fbc6cf5e..b902fbe52da0 100644 --- a/crates/re_viewport/src/blueprint/archetypes/viewport_blueprint.rs +++ b/crates/re_viewport/src/blueprint/archetypes/viewport_blueprint.rs @@ -39,19 +39,19 @@ pub struct ViewportBlueprint { /// This defaults to `false` and is automatically set to `false` when there is user determined layout. pub auto_layout: Option, - /// Whether or not space views should be created automatically. + /// Whether or not Space Views should be created automatically. /// - /// True if not specified, meaning that if the Viewer deems it necessary to add new Space Views to cover - /// all logged entities appropriately, it will do so unless they were added previously - /// (as identified by `past_viewer_recommendations`). + /// If `true`, the viewer will only add Space Views that it hasn't considered previously (as identified by `past_viewer_recommendations`) + /// and which aren't deemed redundant to existing Space Views. + /// This defaults to `false` and is automatically set to `false` when the user adds Space Views manually in the viewer. pub auto_space_views: Option, - /// Hashes of all recommended space views the viewer has already added and that should not be added again. + /// Hashes of all recommended Space Views the viewer has already added and that should not be added again. /// /// This is an internal field and should not be set usually. - /// If you want the viewer from stopping to add space views, you should set `auto_space_views` to `false`. + /// If you want the viewer from stopping to add Space Views, you should set `auto_space_views` to `false`. /// - /// The viewer uses this to determine whether it should keep adding space views. + /// The viewer uses this to determine whether it should keep adding Space Views. pub past_viewer_recommendations: Option>, } diff --git a/crates/re_viewport/src/viewport_blueprint.rs b/crates/re_viewport/src/viewport_blueprint.rs index b06078d60f69..428a7979a90b 100644 --- a/crates/re_viewport/src/viewport_blueprint.rs +++ b/crates/re_viewport/src/viewport_blueprint.rs @@ -128,15 +128,16 @@ impl ViewportBlueprint { .collect(); let root_container = root_container.map(|id| id.0.into()); - let auto_space_views = auto_space_views.map_or_else( - || { - // Only enable auto-space-views if this is the app-default blueprint - blueprint_db - .store_info() - .map_or(false, |ri| ri.is_app_default_blueprint()) - }, - |auto| auto.0, - ); + + // Auto layouting and auto space view are only enabled if no blueprint has been provided by the user. + // Only enable auto-space-views if this is the app-default blueprint + let is_app_default_blueprint = blueprint_db + .store_info() + .map_or(false, |ri| ri.is_app_default_blueprint()); + let auto_layout = + AtomicBool::new(auto_layout.map_or(is_app_default_blueprint, |auto| auto.0)); + let auto_space_views = + AtomicBool::new(auto_space_views.map_or(is_app_default_blueprint, |auto| auto.0)); let tree = build_tree_from_space_views_and_containers( space_views.values(), @@ -156,8 +157,8 @@ impl ViewportBlueprint { root_container, tree, maximized: maximized.map(|id| id.0.into()), - auto_layout: auto_layout.unwrap_or_default().0.into(), - auto_space_views: auto_space_views.into(), + auto_layout, + auto_space_views, past_viewer_recommendation_hashes, tree_action_sender, } diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/viewport_blueprint.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/viewport_blueprint.hpp index 8ab6cd43ee9a..31458d45b3f4 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/viewport_blueprint.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/viewport_blueprint.hpp @@ -38,19 +38,19 @@ namespace rerun::blueprint::archetypes { /// This defaults to `false` and is automatically set to `false` when there is user determined layout. std::optional auto_layout; - /// Whether or not space views should be created automatically. + /// Whether or not Space Views should be created automatically. /// - /// True if not specified, meaning that if the Viewer deems it necessary to add new Space Views to cover - /// all logged entities appropriately, it will do so unless they were added previously - /// (as identified by `past_viewer_recommendations`). + /// If `true`, the viewer will only add Space Views that it hasn't considered previously (as identified by `past_viewer_recommendations`) + /// and which aren't deemed redundant to existing Space Views. + /// This defaults to `false` and is automatically set to `false` when the user adds Space Views manually in the viewer. std::optional auto_space_views; - /// Hashes of all recommended space views the viewer has already added and that should not be added again. + /// Hashes of all recommended Space Views the viewer has already added and that should not be added again. /// /// This is an internal field and should not be set usually. - /// If you want the viewer from stopping to add space views, you should set `auto_space_views` to `false`. + /// If you want the viewer from stopping to add Space Views, you should set `auto_space_views` to `false`. /// - /// The viewer uses this to determine whether it should keep adding space views. + /// The viewer uses this to determine whether it should keep adding Space Views. std::optional> past_viewer_recommendations; @@ -98,11 +98,11 @@ namespace rerun::blueprint::archetypes { RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) } - /// Whether or not space views should be created automatically. + /// Whether or not Space Views should be created automatically. /// - /// True if not specified, meaning that if the Viewer deems it necessary to add new Space Views to cover - /// all logged entities appropriately, it will do so unless they were added previously - /// (as identified by `past_viewer_recommendations`). + /// If `true`, the viewer will only add Space Views that it hasn't considered previously (as identified by `past_viewer_recommendations`) + /// and which aren't deemed redundant to existing Space Views. + /// This defaults to `false` and is automatically set to `false` when the user adds Space Views manually in the viewer. ViewportBlueprint with_auto_space_views( rerun::blueprint::components::AutoSpaceViews _auto_space_views ) && { @@ -111,12 +111,12 @@ namespace rerun::blueprint::archetypes { RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) } - /// Hashes of all recommended space views the viewer has already added and that should not be added again. + /// Hashes of all recommended Space Views the viewer has already added and that should not be added again. /// /// This is an internal field and should not be set usually. - /// If you want the viewer from stopping to add space views, you should set `auto_space_views` to `false`. + /// If you want the viewer from stopping to add Space Views, you should set `auto_space_views` to `false`. /// - /// The viewer uses this to determine whether it should keep adding space views. + /// The viewer uses this to determine whether it should keep adding Space Views. ViewportBlueprint with_past_viewer_recommendations( Collection _past_viewer_recommendations diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py index 4fb9aa248493..fcace42edb95 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py @@ -48,18 +48,18 @@ def __init__( If `true`, the container layout will be reset whenever a new space view is added or removed. This defaults to `false` and is automatically set to `false` when there is user determined layout. auto_space_views: - Whether or not space views should be created automatically. + Whether or not Space Views should be created automatically. - True if not specified, meaning that if the Viewer deems it necessary to add new Space Views to cover - all logged entities appropriately, it will do so unless they were added previously - (as identified by `past_viewer_recommendations`). + If `true`, the viewer will only add Space Views that it hasn't considered previously (as identified by `past_viewer_recommendations`) + and which aren't deemed redundant to existing Space Views. + This defaults to `false` and is automatically set to `false` when the user adds Space Views manually in the viewer. past_viewer_recommendations: - Hashes of all recommended space views the viewer has already added and that should not be added again. + Hashes of all recommended Space Views the viewer has already added and that should not be added again. This is an internal field and should not be set usually. - If you want the viewer from stopping to add space views, you should set `auto_space_views` to `false`. + If you want the viewer from stopping to add Space Views, you should set `auto_space_views` to `false`. - The viewer uses this to determine whether it should keep adding space views. + The viewer uses this to determine whether it should keep adding Space Views. """ @@ -137,11 +137,11 @@ def _clear(cls) -> ViewportBlueprint: default=None, converter=blueprint_components.AutoSpaceViewsBatch._optional, # type: ignore[misc] ) - # Whether or not space views should be created automatically. + # Whether or not Space Views should be created automatically. # - # True if not specified, meaning that if the Viewer deems it necessary to add new Space Views to cover - # all logged entities appropriately, it will do so unless they were added previously - # (as identified by `past_viewer_recommendations`). + # If `true`, the viewer will only add Space Views that it hasn't considered previously (as identified by `past_viewer_recommendations`) + # and which aren't deemed redundant to existing Space Views. + # This defaults to `false` and is automatically set to `false` when the user adds Space Views manually in the viewer. # # (Docstring intentionally commented out to hide this field from the docs) @@ -150,12 +150,12 @@ def _clear(cls) -> ViewportBlueprint: default=None, converter=blueprint_components.ViewerRecommendationHashBatch._optional, # type: ignore[misc] ) - # Hashes of all recommended space views the viewer has already added and that should not be added again. + # Hashes of all recommended Space Views the viewer has already added and that should not be added again. # # This is an internal field and should not be set usually. - # If you want the viewer from stopping to add space views, you should set `auto_space_views` to `false`. + # If you want the viewer from stopping to add Space Views, you should set `auto_space_views` to `false`. # - # The viewer uses this to determine whether it should keep adding space views. + # The viewer uses this to determine whether it should keep adding Space Views. # # (Docstring intentionally commented out to hide this field from the docs)