From 42146f6078669f9010b698de1e18a4025d748843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 12 Dec 2024 12:45:20 +0100 Subject: [PATCH 1/3] Factor out `NearClipPlane` from `VisualBounds2D` --- .../rerun/blueprint/archetypes.fbs | 1 + .../blueprint/archetypes/near_clip_plane.fbs | 12 ++ .../blueprint/archetypes/visual_bounds2d.fbs | 6 - .../src/blueprint/archetypes/.gitattributes | 1 + .../re_types/src/blueprint/archetypes/mod.rs | 2 + .../blueprint/archetypes/near_clip_plane.rs | 186 ++++++++++++++++++ .../blueprint/archetypes/visual_bounds2d.rs | 63 +----- crates/store/re_types/src/reflection/mod.rs | 20 +- crates/viewer/re_view_spatial/src/ui_2d.rs | 9 +- crates/viewer/re_view_spatial/src/view_2d.rs | 3 +- .../reference/types/views/graph_view.md | 3 - .../reference/types/views/spatial2d_view.md | 3 - rerun_cpp/src/rerun/blueprint/archetypes.hpp | 1 + .../rerun/blueprint/archetypes/.gitattributes | 2 + .../blueprint/archetypes/near_clip_plane.cpp | 41 ++++ .../blueprint/archetypes/near_clip_plane.hpp | 54 +++++ .../blueprint/archetypes/visual_bounds2d.cpp | 14 +- .../blueprint/archetypes/visual_bounds2d.hpp | 13 +- .../rerun/blueprint/archetypes/.gitattributes | 1 + .../rerun/blueprint/archetypes/__init__.py | 2 + .../blueprint/archetypes/near_clip_plane.py | 69 +++++++ .../blueprint/archetypes/visual_bounds2d.py | 11 -- 22 files changed, 407 insertions(+), 110 deletions(-) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs create mode 100644 crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.hpp create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/near_clip_plane.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index fbbed167ca0c..832d2487a112 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -11,6 +11,7 @@ include "./archetypes/force_position.fbs"; include "./archetypes/line_grid3d.fbs"; include "./archetypes/map_background.fbs"; include "./archetypes/map_zoom.fbs"; +include "./archetypes/near_clip_plane.fbs"; include "./archetypes/panel_blueprint.fbs"; include "./archetypes/plot_legend.fbs"; include "./archetypes/scalar_axis.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs new file mode 100644 index 000000000000..9875dfde1004 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs @@ -0,0 +1,12 @@ +namespace rerun.blueprint.archetypes; + +/// Controls the distance to the near clip plane in 3D scene units. +table NearClipPlane ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Copy" +) { + /// Controls the distance to the near clip plane in 3D scene units. + /// + /// Content closer than this distance will not be visible. + near_clip_plane: rerun.blueprint.components.NearClipPlane ("attr.rerun.component_optional", order: 1000); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs index 21b8599e5383..38c38541640c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs @@ -1,6 +1,5 @@ namespace rerun.blueprint.archetypes; - /// Controls the visual bounds of a 2D view. /// /// Everything within these bounds are guaranteed to be visible. @@ -16,9 +15,4 @@ table VisualBounds2D ( /// /// Use this to control pan & zoom of the view. range: rerun.blueprint.components.VisualBounds2D ("attr.rerun.component_required", order: 1000); - - /// Controls the distance to the near clip plane in 3D scene units. - /// - /// Content closer than this distance will not be visible. - near_clip_plane: rerun.blueprint.components.NearClipPlane ("attr.rerun.component_optional", order: 2000); } diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index e8331953aab0..bb60dc4d4d53 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -13,6 +13,7 @@ line_grid3d.rs linguist-generated=true map_background.rs linguist-generated=true map_zoom.rs linguist-generated=true mod.rs linguist-generated=true +near_clip_plane.rs linguist-generated=true panel_blueprint.rs linguist-generated=true plot_legend.rs linguist-generated=true scalar_axis.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index c0b54d19a91d..92d1c164ee4e 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -11,6 +11,7 @@ mod force_position; mod line_grid3d; mod map_background; mod map_zoom; +mod near_clip_plane; mod panel_blueprint; mod plot_legend; mod scalar_axis; @@ -35,6 +36,7 @@ pub use self::force_position::ForcePosition; pub use self::line_grid3d::LineGrid3D; pub use self::map_background::MapBackground; pub use self::map_zoom::MapZoom; +pub use self::near_clip_plane::NearClipPlane; pub use self::panel_blueprint::PanelBlueprint; pub use self::plot_legend::PlotLegend; pub use self::scalar_axis::ScalarAxis; diff --git a/crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs b/crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs new file mode 100644 index 000000000000..9714d55ddff1 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs @@ -0,0 +1,186 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Archetype**: Controls the distance to the near clip plane in 3D scene units. +#[derive(Clone, Debug, Copy)] +pub struct NearClipPlane { + /// Controls the distance to the near clip plane in 3D scene units. + /// + /// Content closer than this distance will not be visible. + pub near_clip_plane: crate::blueprint::components::NearClipPlane, +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = + once_cell::sync::Lazy::new(|| { + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + component_name: "rerun.blueprint.components.NearClipPlaneIndicator".into(), + archetype_field_name: None, + }] + }); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = + once_cell::sync::Lazy::new(|| { + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + component_name: "rerun.blueprint.components.NearClipPlane".into(), + archetype_field_name: Some("near_clip_plane".into()), + }] + }); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> = + once_cell::sync::Lazy::new(|| { + [ + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + component_name: "rerun.blueprint.components.NearClipPlaneIndicator".into(), + archetype_field_name: None, + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + component_name: "rerun.blueprint.components.NearClipPlane".into(), + archetype_field_name: Some("near_clip_plane".into()), + }, + ] + }); + +impl NearClipPlane { + /// The total number of components in the archetype: 0 required, 1 recommended, 1 optional + pub const NUM_COMPONENTS: usize = 2usize; +} + +/// Indicator component for the [`NearClipPlane`] [`::re_types_core::Archetype`] +pub type NearClipPlaneIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for NearClipPlane { + type Indicator = NearClipPlaneIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.NearClipPlane".into() + } + + #[inline] + fn display_name() -> &'static str { + "Near clip plane" + } + + #[inline] + fn indicator() -> ComponentBatchCowWithDescriptor<'static> { + static INDICATOR: NearClipPlaneIndicator = NearClipPlaneIndicator::DEFAULT; + ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let near_clip_plane = { + let array = arrays_by_name + .get("rerun.blueprint.components.NearClipPlane") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.NearClipPlane#near_clip_plane")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.NearClipPlane#near_clip_plane")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.NearClipPlane#near_clip_plane")? + }; + Ok(Self { near_clip_plane }) + } +} + +impl ::re_types_core::AsComponents for NearClipPlane { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + (Some(&self.near_clip_plane as &dyn ComponentBatch)).map(|batch| { + ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + archetype_field_name: Some(("near_clip_plane").into()), + component_name: ("rerun.blueprint.components.NearClipPlane").into(), + }), + } + }), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for NearClipPlane {} + +impl NearClipPlane { + /// Create a new `NearClipPlane`. + #[inline] + pub fn new(near_clip_plane: impl Into) -> Self { + Self { + near_clip_plane: near_clip_plane.into(), + } + } +} + +impl ::re_types_core::SizeBytes for NearClipPlane { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.near_clip_plane.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs index 48072b0eedf8..e409e5dbd94a 100644 --- a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs +++ b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs @@ -31,11 +31,6 @@ pub struct VisualBounds2D { /// /// Use this to control pan & zoom of the view. pub range: crate::blueprint::components::VisualBounds2D, - - /// Controls the distance to the near clip plane in 3D scene units. - /// - /// Content closer than this distance will not be visible. - pub near_clip_plane: crate::blueprint::components::NearClipPlane, } static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = @@ -56,16 +51,10 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usiz }] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = - once_cell::sync::Lazy::new(|| { - [ComponentDescriptor { - archetype_name: Some("rerun.blueprint.archetypes.VisualBounds2D".into()), - component_name: "rerun.blueprint.components.NearClipPlane".into(), - archetype_field_name: Some("near_clip_plane".into()), - }] - }); +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = + once_cell::sync::Lazy::new(|| []); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> = once_cell::sync::Lazy::new(|| { [ ComponentDescriptor { @@ -78,17 +67,12 @@ static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = component_name: "rerun.blueprint.components.VisualBounds2DIndicator".into(), archetype_field_name: None, }, - ComponentDescriptor { - archetype_name: Some("rerun.blueprint.archetypes.VisualBounds2D".into()), - component_name: "rerun.blueprint.components.NearClipPlane".into(), - archetype_field_name: Some("near_clip_plane".into()), - }, ] }); impl VisualBounds2D { - /// The total number of components in the archetype: 1 required, 1 recommended, 1 optional - pub const NUM_COMPONENTS: usize = 3usize; + /// The total number of components in the archetype: 1 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 2usize; } /// Indicator component for the [`VisualBounds2D`] [`::re_types_core::Archetype`] @@ -156,23 +140,7 @@ impl ::re_types_core::Archetype for VisualBounds2D { .ok_or_else(DeserializationError::missing_data) .with_context("rerun.blueprint.archetypes.VisualBounds2D#range")? }; - let near_clip_plane = { - let array = arrays_by_name - .get("rerun.blueprint.components.NearClipPlane") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")? - }; - Ok(Self { - range, - near_clip_plane, - }) + Ok(Self { range }) } } @@ -192,16 +160,6 @@ impl ::re_types_core::AsComponents for VisualBounds2D { }), } }), - (Some(&self.near_clip_plane as &dyn ComponentBatch)).map(|batch| { - ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(ComponentDescriptor { - archetype_name: Some("rerun.blueprint.archetypes.VisualBounds2D".into()), - archetype_field_name: Some(("near_clip_plane").into()), - component_name: ("rerun.blueprint.components.NearClipPlane").into(), - }), - } - }), ] .into_iter() .flatten() @@ -214,13 +172,9 @@ impl ::re_types_core::ArchetypeReflectionMarker for VisualBounds2D {} impl VisualBounds2D { /// Create a new `VisualBounds2D`. #[inline] - pub fn new( - range: impl Into, - near_clip_plane: impl Into, - ) -> Self { + pub fn new(range: impl Into) -> Self { Self { range: range.into(), - near_clip_plane: near_clip_plane.into(), } } } @@ -228,12 +182,11 @@ impl VisualBounds2D { impl ::re_types_core::SizeBytes for VisualBounds2D { #[inline] fn heap_size_bytes(&self) -> u64 { - self.range.heap_size_bytes() + self.near_clip_plane.heap_size_bytes() + self.range.heap_size_bytes() } #[inline] fn is_pod() -> bool { ::is_pod() - && ::is_pod() } } diff --git a/crates/store/re_types/src/reflection/mod.rs b/crates/store/re_types/src/reflection/mod.rs index ee95b1db1c8f..4ccdcc6c784b 100644 --- a/crates/store/re_types/src/reflection/mod.rs +++ b/crates/store/re_types/src/reflection/mod.rs @@ -2136,6 +2136,20 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.NearClipPlane"), + ArchetypeReflection { + display_name: "Near clip plane", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.NearClipPlane".into(), display_name : + "Near clip plane", docstring_md : + "Controls the distance to the near clip plane in 3D scene units.\n\nContent closer than this distance will not be visible.", + is_required : false, }, + ], + }, + ), ( ArchetypeName::new("rerun.blueprint.archetypes.PanelBlueprint"), ArchetypeReflection { @@ -2335,11 +2349,7 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { "rerun.blueprint.components.VisualBounds2D".into(), display_name : "Range", docstring_md : "Controls the visible range of a 2D view.\n\nUse this to control pan & zoom of the view.", - is_required : true, }, ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.NearClipPlane".into(), display_name : - "Near clip plane", docstring_md : - "Controls the distance to the near clip plane in 3D scene units.\n\nContent closer than this distance will not be visible.", - is_required : false, }, + is_required : true, }, ], }, ), diff --git a/crates/viewer/re_view_spatial/src/ui_2d.rs b/crates/viewer/re_view_spatial/src/ui_2d.rs index bf557b8a6a07..d58897e90ac5 100644 --- a/crates/viewer/re_view_spatial/src/ui_2d.rs +++ b/crates/viewer/re_view_spatial/src/ui_2d.rs @@ -7,7 +7,7 @@ use re_renderer::view_builder::{TargetConfiguration, ViewBuilder}; use re_types::{ archetypes::Pinhole, blueprint::{ - archetypes::{Background, VisualBounds2D}, + archetypes::{Background, NearClipPlane, VisualBounds2D}, components as blueprint_components, }, components::ViewCoordinates, @@ -168,12 +168,17 @@ impl SpatialView2D { ctx.blueprint_query, query.view_id, ); + let clip_property = ViewProperty::from_archetype::( + ctx.blueprint_db(), + ctx.blueprint_query, + query.view_id, + ); // Convert ui coordinates to/from scene coordinates. let ui_from_scene = ui_from_scene(ctx, &response, self, state, &bounds_property); let scene_from_ui = ui_from_scene.inverse(); - let near_clip_plane: blueprint_components::NearClipPlane = bounds_property + let near_clip_plane: blueprint_components::NearClipPlane = clip_property .component_or_fallback(ctx, self, state) .ok_or_log_error() .unwrap_or_default(); diff --git a/crates/viewer/re_view_spatial/src/view_2d.rs b/crates/viewer/re_view_spatial/src/view_2d.rs index 89fb14ea39a3..724118f27275 100644 --- a/crates/viewer/re_view_spatial/src/view_2d.rs +++ b/crates/viewer/re_view_spatial/src/view_2d.rs @@ -6,7 +6,7 @@ use re_log_types::EntityPath; use re_types::View; use re_types::{ archetypes::{DepthImage, Image}, - blueprint::archetypes::{Background, VisualBounds2D}, + blueprint::archetypes::{Background, NearClipPlane, VisualBounds2D}, Archetype, ComponentName, ViewClassIdentifier, }; use re_ui::UiExt as _; @@ -246,6 +246,7 @@ impl ViewClass for SpatialView2D { re_ui::list_item::list_item_scope(ui, "spatial_view2d_selection_ui", |ui| { view_property_ui::(ctx, ui, view_id, self, state); + view_property_ui::(ctx, ui, view_id, self, state); view_property_ui::(ctx, ui, view_id, self, state); }); diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 90a12b048c15..7e39cfc769e4 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -11,9 +11,6 @@ A graph view to display time-variying, directed or undirected graph visualizatio Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. - -* `range`: Controls the visible range of a 2D view. -* `near_clip_plane`: Controls the distance to the near clip plane in 3D scene units. ### `force_link` Allows to control the interaction between two nodes connected by an edge. diff --git a/docs/content/reference/types/views/spatial2d_view.md b/docs/content/reference/types/views/spatial2d_view.md index afcc55b75980..5bb3a50596e9 100644 --- a/docs/content/reference/types/views/spatial2d_view.md +++ b/docs/content/reference/types/views/spatial2d_view.md @@ -17,9 +17,6 @@ The visible parts of the scene, in the coordinate space of the scene. Everything within these bounds are guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. - -* `range`: Controls the visible range of a 2D view. -* `near_clip_plane`: Controls the distance to the near clip plane in 3D scene units. ### `time_ranges` Configures which range on each timeline is shown by this view (unless specified differently per entity). diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index f29777108ae4..83bfdf51b7bd 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -13,6 +13,7 @@ #include "blueprint/archetypes/line_grid3d.hpp" #include "blueprint/archetypes/map_background.hpp" #include "blueprint/archetypes/map_zoom.hpp" +#include "blueprint/archetypes/near_clip_plane.hpp" #include "blueprint/archetypes/panel_blueprint.hpp" #include "blueprint/archetypes/plot_legend.hpp" #include "blueprint/archetypes/scalar_axis.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes index 4f4c826ff1bd..eb9e19447493 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -23,6 +23,8 @@ map_background.cpp linguist-generated=true map_background.hpp linguist-generated=true map_zoom.cpp linguist-generated=true map_zoom.hpp linguist-generated=true +near_clip_plane.cpp linguist-generated=true +near_clip_plane.hpp linguist-generated=true panel_blueprint.cpp linguist-generated=true panel_blueprint.hpp linguist-generated=true plot_legend.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.cpp new file mode 100644 index 000000000000..2e16afb302ab --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.cpp @@ -0,0 +1,41 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs". + +#include "near_clip_plane.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::NearClipPlane& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable( + archetype.near_clip_plane, + ComponentDescriptor( + "rerun.blueprint.archetypes.NearClipPlane", + "near_clip_plane", + "rerun.blueprint.components.NearClipPlane" + ) + ); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = NearClipPlane::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.hpp new file mode 100644 index 000000000000..b01dee338d3c --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.hpp @@ -0,0 +1,54 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs". + +#pragma once + +#include "../../blueprint/components/near_clip_plane.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + /// **Archetype**: Controls the distance to the near clip plane in 3D scene units. + struct NearClipPlane { + /// Controls the distance to the near clip plane in 3D scene units. + /// + /// Content closer than this distance will not be visible. + rerun::blueprint::components::NearClipPlane near_clip_plane; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.NearClipPlaneIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + NearClipPlane() = default; + NearClipPlane(NearClipPlane&& other) = default; + + explicit NearClipPlane(rerun::blueprint::components::NearClipPlane _near_clip_plane) + : near_clip_plane(std::move(_near_clip_plane)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::NearClipPlane& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp index d5756b46e0ef..9326c22b3548 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp @@ -15,7 +15,7 @@ namespace rerun { ) { using namespace blueprint::archetypes; std::vector cells; - cells.reserve(3); + cells.reserve(2); { auto result = ComponentBatch::from_loggable( @@ -29,18 +29,6 @@ namespace rerun { RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } - { - auto result = ComponentBatch::from_loggable( - archetype.near_clip_plane, - ComponentDescriptor( - "rerun.blueprint.archetypes.VisualBounds2D", - "near_clip_plane", - "rerun.blueprint.components.NearClipPlane" - ) - ); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } { auto indicator = VisualBounds2D::IndicatorComponent(); auto result = ComponentBatch::from_loggable(indicator); diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp index 0cf72032e464..fc0f11e560f1 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp @@ -3,7 +3,6 @@ #pragma once -#include "../../blueprint/components/near_clip_plane.hpp" #include "../../blueprint/components/visual_bounds2d.hpp" #include "../../collection.hpp" #include "../../component_batch.hpp" @@ -28,11 +27,6 @@ namespace rerun::blueprint::archetypes { /// Use this to control pan & zoom of the view. rerun::blueprint::components::VisualBounds2D range; - /// Controls the distance to the near clip plane in 3D scene units. - /// - /// Content closer than this distance will not be visible. - rerun::blueprint::components::NearClipPlane near_clip_plane; - public: static constexpr const char IndicatorComponentName[] = "rerun.blueprint.components.VisualBounds2DIndicator"; @@ -44,11 +38,8 @@ namespace rerun::blueprint::archetypes { VisualBounds2D() = default; VisualBounds2D(VisualBounds2D&& other) = default; - explicit VisualBounds2D( - rerun::blueprint::components::VisualBounds2D _range, - rerun::blueprint::components::NearClipPlane _near_clip_plane - ) - : range(std::move(_range)), near_clip_plane(std::move(_near_clip_plane)) {} + explicit VisualBounds2D(rerun::blueprint::components::VisualBounds2D _range) + : range(std::move(_range)) {} }; } // namespace rerun::blueprint::archetypes diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index 7c61132e3f62..1d0779e1ac40 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -13,6 +13,7 @@ force_position.py linguist-generated=true line_grid3d.py linguist-generated=true map_background.py linguist-generated=true map_zoom.py linguist-generated=true +near_clip_plane.py linguist-generated=true panel_blueprint.py linguist-generated=true plot_legend.py linguist-generated=true scalar_axis.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py index 897b98f6da68..45d0221ebd08 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -13,6 +13,7 @@ from .line_grid3d import LineGrid3D from .map_background import MapBackground from .map_zoom import MapZoom +from .near_clip_plane import NearClipPlane from .panel_blueprint import PanelBlueprint from .plot_legend import PlotLegend from .scalar_axis import ScalarAxis @@ -37,6 +38,7 @@ "LineGrid3D", "MapBackground", "MapZoom", + "NearClipPlane", "PanelBlueprint", "PlotLegend", "ScalarAxis", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/near_clip_plane.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/near_clip_plane.py new file mode 100644 index 000000000000..dee3bdaccadb --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/near_clip_plane.py @@ -0,0 +1,69 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs". + +# You can extend this class by creating a "NearClipPlaneExt" class in "near_clip_plane_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ... import datatypes +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components +from ...error_utils import catch_and_log_exceptions + +__all__ = ["NearClipPlane"] + + +@define(str=False, repr=False, init=False) +class NearClipPlane(Archetype): + """**Archetype**: Controls the distance to the near clip plane in 3D scene units.""" + + def __init__(self: Any, near_clip_plane: datatypes.Float32Like): + """ + Create a new instance of the NearClipPlane archetype. + + Parameters + ---------- + near_clip_plane: + Controls the distance to the near clip plane in 3D scene units. + + Content closer than this distance will not be visible. + + """ + + # You can define your own __init__ function as a member of NearClipPlaneExt in near_clip_plane_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(near_clip_plane=near_clip_plane) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + near_clip_plane=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> NearClipPlane: + """Produce an empty NearClipPlane, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + near_clip_plane: blueprint_components.NearClipPlaneBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.NearClipPlaneBatch._required, # type: ignore[misc] + ) + # Controls the distance to the near clip plane in 3D scene units. + # + # Content closer than this distance will not be visible. + # + # (Docstring intentionally commented out to hide this field from the docs) + + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py index 110ebd5c2d69..7a6a5159dc0b 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py @@ -34,7 +34,6 @@ def __attrs_clear__(self) -> None: """Convenience method for calling `__attrs_init__` with all `None`s.""" self.__attrs_init__( range=None, # type: ignore[arg-type] - near_clip_plane=None, # type: ignore[arg-type] ) @classmethod @@ -54,15 +53,5 @@ def _clear(cls) -> VisualBounds2D: # # (Docstring intentionally commented out to hide this field from the docs) - near_clip_plane: blueprint_components.NearClipPlaneBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.NearClipPlaneBatch._required, # type: ignore[misc] - ) - # Controls the distance to the near clip plane in 3D scene units. - # - # Content closer than this distance will not be visible. - # - # (Docstring intentionally commented out to hide this field from the docs) - __str__ = Archetype.__str__ __repr__ = Archetype.__repr__ # type: ignore[assignment] From a1b6fb9194fca78137348cd556971c510ed116ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 12 Dec 2024 13:28:18 +0100 Subject: [PATCH 2/3] Add `unreleased` --- .../definitions/rerun/blueprint/archetypes/near_clip_plane.fbs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs index 9875dfde1004..a157d67a2982 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs @@ -2,6 +2,7 @@ namespace rerun.blueprint.archetypes; /// Controls the distance to the near clip plane in 3D scene units. table NearClipPlane ( + "attr.docs.unreleased", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Copy" ) { From 59adbac5b5a27318791a554bf403c287f469b8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 13 Dec 2024 11:26:36 +0100 Subject: [PATCH 3/3] Fix --- .../rerun/blueprint/archetypes/visual_bounds2d_ext.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py index f28c2ae1f359..05a427e30cfe 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py @@ -15,7 +15,6 @@ def __init__( *, x_range: datatypes.Range1DLike | None = None, y_range: datatypes.Range1DLike | None = None, - near_clip_plane: datatypes.Float32Like | None = None, ): """ Create a new instance of the VisualBounds2D archetype. @@ -26,8 +25,6 @@ def __init__( The minimum visible range of the X-axis (usually left and right bounds). y_range: The minimum visible range of the Y-axis (usually left and right bounds). - near_clip_plane: - The distance to the near clipping plane. """ @@ -41,7 +38,6 @@ def __init__( with catch_and_log_exceptions(context=self.__class__.__name__): self.__attrs_init__( range=range, - near_clip_plane=near_clip_plane, ) return self.__attrs_clear__()