diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/dataframe_query.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/dataframe_query.fbs index 5cdda33c14a4..03cd66ec9a49 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/dataframe_query.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/dataframe_query.fbs @@ -3,6 +3,7 @@ namespace rerun.blueprint.archetypes; /// The query for the dataframe view. table DataframeQuery ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint" ) { // --- Optional --- diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs index a574b9c696c0..a84cb467afa4 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs @@ -2,6 +2,7 @@ namespace rerun.blueprint.archetypes; /// Tries to move the center of mass of the graph to the origin. struct ForceCenter ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint" ) { /// Whether the center force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs index f4a4e760b59a..e234cd05b08a 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs @@ -2,6 +2,7 @@ namespace rerun.blueprint.archetypes; /// Resolves collisions between the bounding circles, according to the radius of the nodes. struct ForceCollisionRadius ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint" ) { /// Whether the collision force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs index 2d34b1c936ae..addd9d3a2632 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs @@ -2,6 +2,7 @@ namespace rerun.blueprint.archetypes; /// Aims to achieve a target distance between two nodes that are connected by an edge. struct ForceLink ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint" ) { /// Whether the link force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs index abc576912fca..3507c736c588 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs @@ -4,6 +4,7 @@ namespace rerun.blueprint.archetypes; /// /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. struct ForceManyBody ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint" ) { /// Whether the many body force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs index 6689b95b48d7..2456ba44e5a7 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs @@ -2,6 +2,7 @@ namespace rerun.blueprint.archetypes; /// Similar to gravity, this force pulls nodes towards a specific position. struct ForcePosition ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint" ) { /// Whether the position force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/line_grid3d.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/line_grid3d.fbs index 3143471766f1..e974d87430b7 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/line_grid3d.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/line_grid3d.fbs @@ -2,6 +2,7 @@ namespace rerun.blueprint.archetypes; /// Configuration for the 3D line grid. table LineGrid3D ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint" ) { /// Whether the grid is visible. diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/map_background.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/map_background.fbs index 1a8184ff6b13..0a2b93e965b8 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/map_background.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/map_background.fbs @@ -3,6 +3,7 @@ namespace rerun.blueprint.archetypes; /// Configuration for the background map of the map view. table MapBackground ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.python.aliases": "blueprint_components.MapProviderLike" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/map_zoom.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/map_zoom.fbs index 28acc6252c32..40cba26edf83 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/map_zoom.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/map_zoom.fbs @@ -4,6 +4,7 @@ namespace rerun.blueprint.archetypes; /// Configuration of the map view zoom level. //TODO(ab): Turn this archetype into `MapArea` and include a `center: LatLon` componnent or similar table MapZoom ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.python.aliases": "datatypes.Float64Like" ) { 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..5e77fc9006d5 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,8 +2,8 @@ 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" + "attr.rust.archetype_eager", + "attr.rerun.scope": "blueprint" ) { /// Controls the distance to the near clip plane in 3D scene units. /// diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/panel_blueprint.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/panel_blueprint.fbs index 28660dc25330..fe6ba781aebb 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/panel_blueprint.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/panel_blueprint.fbs @@ -4,6 +4,7 @@ namespace rerun.blueprint.archetypes; /// Shared state for the 3 collapsible panels. table PanelBlueprint ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Default" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/plot_legend.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/plot_legend.fbs index e9f409e1fd31..30c60b3c07ee 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/plot_legend.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/plot_legend.fbs @@ -5,6 +5,7 @@ namespace rerun.blueprint.archetypes; /// Configuration for the legend of a plot. table PlotLegend ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Default", "attr.python.aliases": "blueprint_components.Corner2D" diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/scalar_axis.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/scalar_axis.fbs index 0d3f5e645978..d7a3657ed9c4 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/scalar_axis.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/scalar_axis.fbs @@ -5,6 +5,7 @@ namespace rerun.blueprint.archetypes; /// Configuration for the scalar axis of a plot. table ScalarAxis ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Default" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_scalar_mapping.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_scalar_mapping.fbs index ff772e6abdfc..0195e2b9bc2c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_scalar_mapping.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_scalar_mapping.fbs @@ -2,6 +2,7 @@ namespace rerun.blueprint.archetypes; /// Configures how tensor scalars are mapped to color. table TensorScalarMapping ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Default" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_slice_selection.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_slice_selection.fbs index 0928b5fe28fb..8619811df846 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_slice_selection.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_slice_selection.fbs @@ -2,8 +2,8 @@ namespace rerun.blueprint.archetypes; /// Specifies a 2D slice of a tensor. table TensorSliceSelection ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Hash, PartialEq, Eq" + "attr.rust.archetype_eager", + "attr.rerun.scope": "blueprint" ) { /// Which dimension to map to width. /// diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_view_fit.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_view_fit.fbs index 1848284ee426..ca2591d487a6 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_view_fit.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/tensor_view_fit.fbs @@ -2,6 +2,7 @@ namespace rerun.blueprint.archetypes; /// Configures how a selected tensor slice is shown on screen. table TensorViewFit ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Default", "attr.python.aliases": "blueprint_components.ViewFitLike" diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/view_blueprint.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/view_blueprint.fbs index 87b258633e94..6eba591e3fc6 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/view_blueprint.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/view_blueprint.fbs @@ -4,6 +4,7 @@ namespace rerun.blueprint.archetypes; /// The description of a single view. table ViewBlueprint ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint" ) { // --- Required --- diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/view_contents.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/view_contents.fbs index 2c9509dee26b..091bb68798b0 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/view_contents.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/view_contents.fbs @@ -41,6 +41,7 @@ namespace rerun.blueprint.archetypes; /// The last rule matching `/world` is `- /world`, so it is excluded. /// The last rule matching `/world/house` is `+ /world/**`, so it is included. table ViewContents ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Default" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/viewport_blueprint.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/viewport_blueprint.fbs index dc0cfff65e0f..e8a1f9753906 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/viewport_blueprint.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/viewport_blueprint.fbs @@ -4,6 +4,7 @@ namespace rerun.blueprint.archetypes; /// The top-level description of the viewport. table ViewportBlueprint ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Default" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visible_time_ranges.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visible_time_ranges.fbs index afc050fadae1..3706c4b5d9fe 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visible_time_ranges.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visible_time_ranges.fbs @@ -12,6 +12,7 @@ namespace rerun.blueprint.archetypes; /// - For time series views, the default is to show the entire timeline. /// - For any other view, the default is to apply latest-at semantics. table VisibleTimeRanges ( + "attr.rust.archetype_eager", "attr.rerun.scope": "blueprint", "attr.rust.derive": "Default", "attr.python.aliases": "datatypes.VisibleTimeRangeLike, Sequence[datatypes.VisibleTimeRangeLike]" 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 ea210ab47b96..b9ba3e9e5d7b 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 @@ -8,8 +8,8 @@ namespace rerun.blueprint.archetypes; /// If no visual bounds are set, it will be determined automatically, /// based on the bounding-box of the data or other camera information present in the view. table VisualBounds2D ( - "attr.rerun.scope": "blueprint", - "attr.rust.archetype_eager": "" + "attr.rust.archetype_eager", + "attr.rerun.scope": "blueprint" ) { /// Controls the visible range of a 2D view. /// diff --git a/crates/store/re_types/src/blueprint/archetypes/dataframe_query.rs b/crates/store/re_types/src/blueprint/archetypes/dataframe_query.rs index 271e7e0e7936..ec77a32087d3 100644 --- a/crates/store/re_types/src/blueprint/archetypes/dataframe_query.rs +++ b/crates/store/re_types/src/blueprint/archetypes/dataframe_query.rs @@ -19,26 +19,26 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: The query for the dataframe view. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct DataframeQuery { /// The timeline for this query. /// /// If unset, the timeline currently active on the time panel is used. - pub timeline: Option, + pub timeline: Option, /// If provided, only rows whose timestamp is within this range will be shown. /// /// Note: will be unset as soon as `timeline` is changed. - pub filter_by_range: Option, + pub filter_by_range: Option, /// If provided, only show rows which contains a logged event for the specified component. - pub filter_is_not_null: Option, + pub filter_is_not_null: Option, /// Should empty cells be filled with latest-at queries? - pub apply_latest_at: Option, + pub apply_latest_at: Option, /// Selected columns. If unset, all columns are selected. - pub select: Option, + pub select: Option, } impl DataframeQuery { @@ -186,54 +186,27 @@ impl ::re_types_core::Archetype for DataframeQuery { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let timeline = if let Some(array) = arrays_by_descr.get(&Self::descriptor_timeline()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.DataframeQuery#timeline")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let filter_by_range = - if let Some(array) = arrays_by_descr.get(&Self::descriptor_filter_by_range()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.DataframeQuery#filter_by_range")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let filter_is_not_null = - if let Some(array) = arrays_by_descr.get(&Self::descriptor_filter_is_not_null()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.DataframeQuery#filter_is_not_null")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let apply_latest_at = - if let Some(array) = arrays_by_descr.get(&Self::descriptor_apply_latest_at()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.DataframeQuery#apply_latest_at")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let select = if let Some(array) = arrays_by_descr.get(&Self::descriptor_select()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.DataframeQuery#select")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let timeline = arrays_by_descr + .get(&Self::descriptor_timeline()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_timeline())); + let filter_by_range = arrays_by_descr + .get(&Self::descriptor_filter_by_range()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_filter_by_range()) + }); + let filter_is_not_null = arrays_by_descr + .get(&Self::descriptor_filter_is_not_null()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_filter_is_not_null()) + }); + let apply_latest_at = arrays_by_descr + .get(&Self::descriptor_apply_latest_at()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_apply_latest_at()) + }); + let select = arrays_by_descr + .get(&Self::descriptor_select()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_select())); Ok(Self { timeline, filter_by_range, @@ -245,51 +218,16 @@ impl ::re_types_core::Archetype for DataframeQuery { } impl ::re_types_core::AsComponents for DataframeQuery { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .timeline - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_timeline()), - }), - (self - .filter_by_range - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_filter_by_range()), - }), - (self - .filter_is_not_null - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_filter_is_not_null()), - }), - (self - .apply_latest_at - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_apply_latest_at()), - }), - (self - .select - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_select()), - }), + Self::indicator().serialized(), + self.timeline.clone(), + self.filter_by_range.clone(), + self.filter_is_not_null.clone(), + self.apply_latest_at.clone(), + self.select.clone(), ] .into_iter() .flatten() @@ -312,6 +250,40 @@ impl DataframeQuery { } } + /// Update only some specific fields of a `DataframeQuery`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `DataframeQuery`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + timeline: Some(SerializedComponentBatch::new( + crate::blueprint::components::TimelineName::arrow_empty(), + Self::descriptor_timeline(), + )), + filter_by_range: Some(SerializedComponentBatch::new( + crate::blueprint::components::FilterByRange::arrow_empty(), + Self::descriptor_filter_by_range(), + )), + filter_is_not_null: Some(SerializedComponentBatch::new( + crate::blueprint::components::FilterIsNotNull::arrow_empty(), + Self::descriptor_filter_is_not_null(), + )), + apply_latest_at: Some(SerializedComponentBatch::new( + crate::blueprint::components::ApplyLatestAt::arrow_empty(), + Self::descriptor_apply_latest_at(), + )), + select: Some(SerializedComponentBatch::new( + crate::blueprint::components::SelectedColumns::arrow_empty(), + Self::descriptor_select(), + )), + } + } + /// The timeline for this query. /// /// If unset, the timeline currently active on the time panel is used. @@ -320,7 +292,7 @@ impl DataframeQuery { mut self, timeline: impl Into, ) -> Self { - self.timeline = Some(timeline.into()); + self.timeline = try_serialize_field(Self::descriptor_timeline(), [timeline]); self } @@ -332,7 +304,8 @@ impl DataframeQuery { mut self, filter_by_range: impl Into, ) -> Self { - self.filter_by_range = Some(filter_by_range.into()); + self.filter_by_range = + try_serialize_field(Self::descriptor_filter_by_range(), [filter_by_range]); self } @@ -342,7 +315,8 @@ impl DataframeQuery { mut self, filter_is_not_null: impl Into, ) -> Self { - self.filter_is_not_null = Some(filter_is_not_null.into()); + self.filter_is_not_null = + try_serialize_field(Self::descriptor_filter_is_not_null(), [filter_is_not_null]); self } @@ -352,7 +326,8 @@ impl DataframeQuery { mut self, apply_latest_at: impl Into, ) -> Self { - self.apply_latest_at = Some(apply_latest_at.into()); + self.apply_latest_at = + try_serialize_field(Self::descriptor_apply_latest_at(), [apply_latest_at]); self } @@ -362,7 +337,7 @@ impl DataframeQuery { mut self, select: impl Into, ) -> Self { - self.select = Some(select.into()); + self.select = try_serialize_field(Self::descriptor_select(), [select]); self } } @@ -376,13 +351,4 @@ impl ::re_byte_size::SizeBytes for DataframeQuery { + self.apply_latest_at.heap_size_bytes() + self.select.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - && >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_center.rs b/crates/store/re_types/src/blueprint/archetypes/force_center.rs index 79a0bbbe17bb..7b59245112c9 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_center.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_center.rs @@ -19,15 +19,15 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: Tries to move the center of mass of the graph to the origin. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct ForceCenter { /// Whether the center force is enabled. /// /// The center force tries to move the center of mass of the graph towards the origin. - pub enabled: Option, + pub enabled: Option, /// The strength of the force. - pub strength: Option, + pub strength: Option, } impl ForceCenter { @@ -139,50 +139,24 @@ impl ::re_types_core::Archetype for ForceCenter { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let enabled = if let Some(array) = arrays_by_descr.get(&Self::descriptor_enabled()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceCenter#enabled")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let strength = if let Some(array) = arrays_by_descr.get(&Self::descriptor_strength()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceCenter#strength")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let enabled = arrays_by_descr + .get(&Self::descriptor_enabled()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_enabled())); + let strength = arrays_by_descr + .get(&Self::descriptor_strength()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_strength())); Ok(Self { enabled, strength }) } } impl ::re_types_core::AsComponents for ForceCenter { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .enabled - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_enabled()), - }), - (self - .strength - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_strength()), - }), + Self::indicator().serialized(), + self.enabled.clone(), + self.strength.clone(), ] .into_iter() .flatten() @@ -202,6 +176,28 @@ impl ForceCenter { } } + /// Update only some specific fields of a `ForceCenter`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ForceCenter`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + enabled: Some(SerializedComponentBatch::new( + crate::blueprint::components::Enabled::arrow_empty(), + Self::descriptor_enabled(), + )), + strength: Some(SerializedComponentBatch::new( + crate::blueprint::components::ForceStrength::arrow_empty(), + Self::descriptor_strength(), + )), + } + } + /// Whether the center force is enabled. /// /// The center force tries to move the center of mass of the graph towards the origin. @@ -210,7 +206,7 @@ impl ForceCenter { mut self, enabled: impl Into, ) -> Self { - self.enabled = Some(enabled.into()); + self.enabled = try_serialize_field(Self::descriptor_enabled(), [enabled]); self } @@ -220,7 +216,7 @@ impl ForceCenter { mut self, strength: impl Into, ) -> Self { - self.strength = Some(strength.into()); + self.strength = try_serialize_field(Self::descriptor_strength(), [strength]); self } } @@ -230,10 +226,4 @@ impl ::re_byte_size::SizeBytes for ForceCenter { fn heap_size_bytes(&self) -> u64 { self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs index 809f2c4ab50b..227da89c2eca 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs @@ -19,20 +19,20 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: Resolves collisions between the bounding circles, according to the radius of the nodes. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct ForceCollisionRadius { /// Whether the collision force is enabled. /// /// The collision force resolves collisions between nodes based on the bounding circle defined by their radius. - pub enabled: Option, + pub enabled: Option, /// The strength of the force. - pub strength: Option, + pub strength: Option, /// Specifies how often this force should be applied per iteration. /// /// Increasing this parameter can lead to better results at the cost of longer computation time. - pub iterations: Option, + pub iterations: Option, } impl ForceCollisionRadius { @@ -157,33 +157,17 @@ impl ::re_types_core::Archetype for ForceCollisionRadius { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let enabled = if let Some(array) = arrays_by_descr.get(&Self::descriptor_enabled()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceCollisionRadius#enabled")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let strength = if let Some(array) = arrays_by_descr.get(&Self::descriptor_strength()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceCollisionRadius#strength")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let iterations = if let Some(array) = arrays_by_descr.get(&Self::descriptor_iterations()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceCollisionRadius#iterations")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let enabled = arrays_by_descr + .get(&Self::descriptor_enabled()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_enabled())); + let strength = arrays_by_descr + .get(&Self::descriptor_strength()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_strength())); + let iterations = arrays_by_descr + .get(&Self::descriptor_iterations()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_iterations()) + }); Ok(Self { enabled, strength, @@ -193,35 +177,14 @@ impl ::re_types_core::Archetype for ForceCollisionRadius { } impl ::re_types_core::AsComponents for ForceCollisionRadius { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .enabled - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_enabled()), - }), - (self - .strength - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_strength()), - }), - (self - .iterations - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_iterations()), - }), + Self::indicator().serialized(), + self.enabled.clone(), + self.strength.clone(), + self.iterations.clone(), ] .into_iter() .flatten() @@ -242,6 +205,32 @@ impl ForceCollisionRadius { } } + /// Update only some specific fields of a `ForceCollisionRadius`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ForceCollisionRadius`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + enabled: Some(SerializedComponentBatch::new( + crate::blueprint::components::Enabled::arrow_empty(), + Self::descriptor_enabled(), + )), + strength: Some(SerializedComponentBatch::new( + crate::blueprint::components::ForceStrength::arrow_empty(), + Self::descriptor_strength(), + )), + iterations: Some(SerializedComponentBatch::new( + crate::blueprint::components::ForceIterations::arrow_empty(), + Self::descriptor_iterations(), + )), + } + } + /// Whether the collision force is enabled. /// /// The collision force resolves collisions between nodes based on the bounding circle defined by their radius. @@ -250,7 +239,7 @@ impl ForceCollisionRadius { mut self, enabled: impl Into, ) -> Self { - self.enabled = Some(enabled.into()); + self.enabled = try_serialize_field(Self::descriptor_enabled(), [enabled]); self } @@ -260,7 +249,7 @@ impl ForceCollisionRadius { mut self, strength: impl Into, ) -> Self { - self.strength = Some(strength.into()); + self.strength = try_serialize_field(Self::descriptor_strength(), [strength]); self } @@ -272,7 +261,7 @@ impl ForceCollisionRadius { mut self, iterations: impl Into, ) -> Self { - self.iterations = Some(iterations.into()); + self.iterations = try_serialize_field(Self::descriptor_iterations(), [iterations]); self } } @@ -284,11 +273,4 @@ impl ::re_byte_size::SizeBytes for ForceCollisionRadius { + self.strength.heap_size_bytes() + self.iterations.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs index ed81ba18c7cf..b2b5dd1d045e 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_link.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -19,20 +19,20 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: Aims to achieve a target distance between two nodes that are connected by an edge. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct ForceLink { /// Whether the link force is enabled. /// /// The link force aims to achieve a target distance between two nodes that are connected by one ore more edges. - pub enabled: Option, + pub enabled: Option, /// The target distance between two nodes. - pub distance: Option, + pub distance: Option, /// Specifies how often this force should be applied per iteration. /// /// Increasing this parameter can lead to better results at the cost of longer computation time. - pub iterations: Option, + pub iterations: Option, } impl ForceLink { @@ -156,33 +156,17 @@ impl ::re_types_core::Archetype for ForceLink { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let enabled = if let Some(array) = arrays_by_descr.get(&Self::descriptor_enabled()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceLink#enabled")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let distance = if let Some(array) = arrays_by_descr.get(&Self::descriptor_distance()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceLink#distance")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let iterations = if let Some(array) = arrays_by_descr.get(&Self::descriptor_iterations()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceLink#iterations")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let enabled = arrays_by_descr + .get(&Self::descriptor_enabled()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_enabled())); + let distance = arrays_by_descr + .get(&Self::descriptor_distance()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_distance())); + let iterations = arrays_by_descr + .get(&Self::descriptor_iterations()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_iterations()) + }); Ok(Self { enabled, distance, @@ -192,35 +176,14 @@ impl ::re_types_core::Archetype for ForceLink { } impl ::re_types_core::AsComponents for ForceLink { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .enabled - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_enabled()), - }), - (self - .distance - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_distance()), - }), - (self - .iterations - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_iterations()), - }), + Self::indicator().serialized(), + self.enabled.clone(), + self.distance.clone(), + self.iterations.clone(), ] .into_iter() .flatten() @@ -241,6 +204,32 @@ impl ForceLink { } } + /// Update only some specific fields of a `ForceLink`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ForceLink`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + enabled: Some(SerializedComponentBatch::new( + crate::blueprint::components::Enabled::arrow_empty(), + Self::descriptor_enabled(), + )), + distance: Some(SerializedComponentBatch::new( + crate::blueprint::components::ForceDistance::arrow_empty(), + Self::descriptor_distance(), + )), + iterations: Some(SerializedComponentBatch::new( + crate::blueprint::components::ForceIterations::arrow_empty(), + Self::descriptor_iterations(), + )), + } + } + /// Whether the link force is enabled. /// /// The link force aims to achieve a target distance between two nodes that are connected by one ore more edges. @@ -249,7 +238,7 @@ impl ForceLink { mut self, enabled: impl Into, ) -> Self { - self.enabled = Some(enabled.into()); + self.enabled = try_serialize_field(Self::descriptor_enabled(), [enabled]); self } @@ -259,7 +248,7 @@ impl ForceLink { mut self, distance: impl Into, ) -> Self { - self.distance = Some(distance.into()); + self.distance = try_serialize_field(Self::descriptor_distance(), [distance]); self } @@ -271,7 +260,7 @@ impl ForceLink { mut self, iterations: impl Into, ) -> Self { - self.iterations = Some(iterations.into()); + self.iterations = try_serialize_field(Self::descriptor_iterations(), [iterations]); self } } @@ -283,11 +272,4 @@ impl ::re_byte_size::SizeBytes for ForceLink { + self.distance.heap_size_bytes() + self.iterations.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs index 12a4f7f61971..399a1e0c98e4 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs @@ -21,18 +21,18 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: A force between each pair of nodes that ressembles an electrical charge. /// /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct ForceManyBody { /// Whether the many body force is enabled. /// /// The many body force is applied on each pair of nodes in a way that ressembles an electrical charge. If the /// strength is smaller than 0, it pushes nodes apart; if it is larger than 0, it pulls them together. - pub enabled: Option, + pub enabled: Option, /// The strength of the force. /// /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. - pub strength: Option, + pub strength: Option, } impl ForceManyBody { @@ -144,50 +144,24 @@ impl ::re_types_core::Archetype for ForceManyBody { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let enabled = if let Some(array) = arrays_by_descr.get(&Self::descriptor_enabled()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceManyBody#enabled")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let strength = if let Some(array) = arrays_by_descr.get(&Self::descriptor_strength()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceManyBody#strength")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let enabled = arrays_by_descr + .get(&Self::descriptor_enabled()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_enabled())); + let strength = arrays_by_descr + .get(&Self::descriptor_strength()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_strength())); Ok(Self { enabled, strength }) } } impl ::re_types_core::AsComponents for ForceManyBody { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .enabled - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_enabled()), - }), - (self - .strength - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_strength()), - }), + Self::indicator().serialized(), + self.enabled.clone(), + self.strength.clone(), ] .into_iter() .flatten() @@ -207,6 +181,28 @@ impl ForceManyBody { } } + /// Update only some specific fields of a `ForceManyBody`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ForceManyBody`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + enabled: Some(SerializedComponentBatch::new( + crate::blueprint::components::Enabled::arrow_empty(), + Self::descriptor_enabled(), + )), + strength: Some(SerializedComponentBatch::new( + crate::blueprint::components::ForceStrength::arrow_empty(), + Self::descriptor_strength(), + )), + } + } + /// Whether the many body force is enabled. /// /// The many body force is applied on each pair of nodes in a way that ressembles an electrical charge. If the @@ -216,7 +212,7 @@ impl ForceManyBody { mut self, enabled: impl Into, ) -> Self { - self.enabled = Some(enabled.into()); + self.enabled = try_serialize_field(Self::descriptor_enabled(), [enabled]); self } @@ -228,7 +224,7 @@ impl ForceManyBody { mut self, strength: impl Into, ) -> Self { - self.strength = Some(strength.into()); + self.strength = try_serialize_field(Self::descriptor_strength(), [strength]); self } } @@ -238,10 +234,4 @@ impl ::re_byte_size::SizeBytes for ForceManyBody { fn heap_size_bytes(&self) -> u64 { self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position.rs b/crates/store/re_types/src/blueprint/archetypes/force_position.rs index ca3cbcec4559..ad4a4d3360f0 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_position.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_position.rs @@ -19,18 +19,18 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: Similar to gravity, this force pulls nodes towards a specific position. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct ForcePosition { /// Whether the position force is enabled. /// /// The position force pulls nodes towards a specific position, similar to gravity. - pub enabled: Option, + pub enabled: Option, /// The strength of the force. - pub strength: Option, + pub strength: Option, /// The position where the nodes should be pulled towards. - pub position: Option, + pub position: Option, } impl ForcePosition { @@ -154,33 +154,15 @@ impl ::re_types_core::Archetype for ForcePosition { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let enabled = if let Some(array) = arrays_by_descr.get(&Self::descriptor_enabled()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForcePosition#enabled")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let strength = if let Some(array) = arrays_by_descr.get(&Self::descriptor_strength()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForcePosition#strength")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let position = if let Some(array) = arrays_by_descr.get(&Self::descriptor_position()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForcePosition#position")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let enabled = arrays_by_descr + .get(&Self::descriptor_enabled()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_enabled())); + let strength = arrays_by_descr + .get(&Self::descriptor_strength()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_strength())); + let position = arrays_by_descr + .get(&Self::descriptor_position()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_position())); Ok(Self { enabled, strength, @@ -190,35 +172,14 @@ impl ::re_types_core::Archetype for ForcePosition { } impl ::re_types_core::AsComponents for ForcePosition { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .enabled - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_enabled()), - }), - (self - .strength - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_strength()), - }), - (self - .position - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_position()), - }), + Self::indicator().serialized(), + self.enabled.clone(), + self.strength.clone(), + self.position.clone(), ] .into_iter() .flatten() @@ -239,6 +200,32 @@ impl ForcePosition { } } + /// Update only some specific fields of a `ForcePosition`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ForcePosition`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + enabled: Some(SerializedComponentBatch::new( + crate::blueprint::components::Enabled::arrow_empty(), + Self::descriptor_enabled(), + )), + strength: Some(SerializedComponentBatch::new( + crate::blueprint::components::ForceStrength::arrow_empty(), + Self::descriptor_strength(), + )), + position: Some(SerializedComponentBatch::new( + crate::components::Position2D::arrow_empty(), + Self::descriptor_position(), + )), + } + } + /// Whether the position force is enabled. /// /// The position force pulls nodes towards a specific position, similar to gravity. @@ -247,7 +234,7 @@ impl ForcePosition { mut self, enabled: impl Into, ) -> Self { - self.enabled = Some(enabled.into()); + self.enabled = try_serialize_field(Self::descriptor_enabled(), [enabled]); self } @@ -257,14 +244,14 @@ impl ForcePosition { mut self, strength: impl Into, ) -> Self { - self.strength = Some(strength.into()); + self.strength = try_serialize_field(Self::descriptor_strength(), [strength]); self } /// The position where the nodes should be pulled towards. #[inline] pub fn with_position(mut self, position: impl Into) -> Self { - self.position = Some(position.into()); + self.position = try_serialize_field(Self::descriptor_position(), [position]); self } } @@ -276,11 +263,4 @@ impl ::re_byte_size::SizeBytes for ForcePosition { + self.strength.heap_size_bytes() + self.position.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/line_grid3d.rs b/crates/store/re_types/src/blueprint/archetypes/line_grid3d.rs index 7c68426495bb..e9d5a7582e8a 100644 --- a/crates/store/re_types/src/blueprint/archetypes/line_grid3d.rs +++ b/crates/store/re_types/src/blueprint/archetypes/line_grid3d.rs @@ -19,34 +19,34 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: Configuration for the 3D line grid. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct LineGrid3D { /// Whether the grid is visible. /// /// Defaults to true. - pub visible: Option, + pub visible: Option, /// Space between grid lines spacing of one line to the next in scene units. /// /// As you zoom out, successively only every tenth line is shown. /// This controls the closest zoom level. - pub spacing: Option, + pub spacing: Option, /// In what plane the grid is drawn. /// /// Defaults to whatever plane is determined as the plane at zero units up/down as defined by [`components::ViewCoordinates`][crate::components::ViewCoordinates] if present. - pub plane: Option, + pub plane: Option, /// How thick the lines should be in ui units. /// /// Default is 1.0 ui unit. - pub stroke_width: Option, + pub stroke_width: Option, /// Color used for the grid. /// /// Transparency via alpha channel is supported. /// Defaults to a slightly transparent light gray. - pub color: Option, + pub color: Option, } impl LineGrid3D { @@ -194,52 +194,23 @@ impl ::re_types_core::Archetype for LineGrid3D { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let visible = if let Some(array) = arrays_by_descr.get(&Self::descriptor_visible()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.LineGrid3D#visible")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let spacing = if let Some(array) = arrays_by_descr.get(&Self::descriptor_spacing()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.LineGrid3D#spacing")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let plane = if let Some(array) = arrays_by_descr.get(&Self::descriptor_plane()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.LineGrid3D#plane")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let stroke_width = - if let Some(array) = arrays_by_descr.get(&Self::descriptor_stroke_width()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.LineGrid3D#stroke_width")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let color = if let Some(array) = arrays_by_descr.get(&Self::descriptor_color()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.LineGrid3D#color")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let visible = arrays_by_descr + .get(&Self::descriptor_visible()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_visible())); + let spacing = arrays_by_descr + .get(&Self::descriptor_spacing()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_spacing())); + let plane = arrays_by_descr + .get(&Self::descriptor_plane()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_plane())); + let stroke_width = arrays_by_descr + .get(&Self::descriptor_stroke_width()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_stroke_width()) + }); + let color = arrays_by_descr + .get(&Self::descriptor_color()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_color())); Ok(Self { visible, spacing, @@ -251,51 +222,16 @@ impl ::re_types_core::Archetype for LineGrid3D { } impl ::re_types_core::AsComponents for LineGrid3D { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .visible - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_visible()), - }), - (self - .spacing - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_spacing()), - }), - (self - .plane - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_plane()), - }), - (self - .stroke_width - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_stroke_width()), - }), - (self - .color - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_color()), - }), + Self::indicator().serialized(), + self.visible.clone(), + self.spacing.clone(), + self.plane.clone(), + self.stroke_width.clone(), + self.color.clone(), ] .into_iter() .flatten() @@ -318,6 +254,40 @@ impl LineGrid3D { } } + /// Update only some specific fields of a `LineGrid3D`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `LineGrid3D`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + visible: Some(SerializedComponentBatch::new( + crate::blueprint::components::Visible::arrow_empty(), + Self::descriptor_visible(), + )), + spacing: Some(SerializedComponentBatch::new( + crate::blueprint::components::GridSpacing::arrow_empty(), + Self::descriptor_spacing(), + )), + plane: Some(SerializedComponentBatch::new( + crate::components::Plane3D::arrow_empty(), + Self::descriptor_plane(), + )), + stroke_width: Some(SerializedComponentBatch::new( + crate::components::StrokeWidth::arrow_empty(), + Self::descriptor_stroke_width(), + )), + color: Some(SerializedComponentBatch::new( + crate::components::Color::arrow_empty(), + Self::descriptor_color(), + )), + } + } + /// Whether the grid is visible. /// /// Defaults to true. @@ -326,7 +296,7 @@ impl LineGrid3D { mut self, visible: impl Into, ) -> Self { - self.visible = Some(visible.into()); + self.visible = try_serialize_field(Self::descriptor_visible(), [visible]); self } @@ -339,7 +309,7 @@ impl LineGrid3D { mut self, spacing: impl Into, ) -> Self { - self.spacing = Some(spacing.into()); + self.spacing = try_serialize_field(Self::descriptor_spacing(), [spacing]); self } @@ -348,7 +318,7 @@ impl LineGrid3D { /// Defaults to whatever plane is determined as the plane at zero units up/down as defined by [`components::ViewCoordinates`][crate::components::ViewCoordinates] if present. #[inline] pub fn with_plane(mut self, plane: impl Into) -> Self { - self.plane = Some(plane.into()); + self.plane = try_serialize_field(Self::descriptor_plane(), [plane]); self } @@ -360,7 +330,7 @@ impl LineGrid3D { mut self, stroke_width: impl Into, ) -> Self { - self.stroke_width = Some(stroke_width.into()); + self.stroke_width = try_serialize_field(Self::descriptor_stroke_width(), [stroke_width]); self } @@ -370,7 +340,7 @@ impl LineGrid3D { /// Defaults to a slightly transparent light gray. #[inline] pub fn with_color(mut self, color: impl Into) -> Self { - self.color = Some(color.into()); + self.color = try_serialize_field(Self::descriptor_color(), [color]); self } } @@ -384,13 +354,4 @@ impl ::re_byte_size::SizeBytes for LineGrid3D { + self.stroke_width.heap_size_bytes() + self.color.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - && >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/map_background.rs b/crates/store/re_types/src/blueprint/archetypes/map_background.rs index b1854843b142..dd19b53673ae 100644 --- a/crates/store/re_types/src/blueprint/archetypes/map_background.rs +++ b/crates/store/re_types/src/blueprint/archetypes/map_background.rs @@ -19,12 +19,12 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: Configuration for the background map of the map view. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct MapBackground { /// Map provider and style to use. /// /// **Note**: Requires a Mapbox API key in the `RERUN_MAPBOX_ACCESS_TOKEN` environment variable. - pub provider: crate::blueprint::components::MapProvider, + pub provider: Option, } impl MapBackground { @@ -120,39 +120,21 @@ impl ::re_types_core::Archetype for MapBackground { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let provider = { - let array = arrays_by_descr - .get(&Self::descriptor_provider()) - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.MapBackground#provider")?; - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.MapBackground#provider")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.MapBackground#provider")? - }; + let provider = arrays_by_descr + .get(&Self::descriptor_provider()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_provider())); Ok(Self { provider }) } } impl ::re_types_core::AsComponents for MapBackground { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - (Some(&self.provider as &dyn ComponentBatch)).map(|batch| { - ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_provider()), - } - }), - ] - .into_iter() - .flatten() - .collect() + [Self::indicator().serialized(), self.provider.clone()] + .into_iter() + .flatten() + .collect() } } @@ -163,9 +145,39 @@ impl MapBackground { #[inline] pub fn new(provider: impl Into) -> Self { Self { - provider: provider.into(), + provider: try_serialize_field(Self::descriptor_provider(), [provider]), } } + + /// Update only some specific fields of a `MapBackground`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `MapBackground`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + provider: Some(SerializedComponentBatch::new( + crate::blueprint::components::MapProvider::arrow_empty(), + Self::descriptor_provider(), + )), + } + } + + /// Map provider and style to use. + /// + /// **Note**: Requires a Mapbox API key in the `RERUN_MAPBOX_ACCESS_TOKEN` environment variable. + #[inline] + pub fn with_provider( + mut self, + provider: impl Into, + ) -> Self { + self.provider = try_serialize_field(Self::descriptor_provider(), [provider]); + self + } } impl ::re_byte_size::SizeBytes for MapBackground { @@ -173,9 +185,4 @@ impl ::re_byte_size::SizeBytes for MapBackground { fn heap_size_bytes(&self) -> u64 { self.provider.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/map_zoom.rs b/crates/store/re_types/src/blueprint/archetypes/map_zoom.rs index 4c08c0ded30d..5f8ac2714640 100644 --- a/crates/store/re_types/src/blueprint/archetypes/map_zoom.rs +++ b/crates/store/re_types/src/blueprint/archetypes/map_zoom.rs @@ -19,12 +19,12 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: Configuration of the map view zoom level. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct MapZoom { /// Zoom level for the map. /// /// Zoom level follow the [`OpenStreetMap` definition](https://wiki.openstreetmap.org/wiki/Zoom_levels). - pub zoom: crate::blueprint::components::ZoomLevel, + pub zoom: Option, } impl MapZoom { @@ -115,39 +115,21 @@ impl ::re_types_core::Archetype for MapZoom { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let zoom = { - let array = arrays_by_descr - .get(&Self::descriptor_zoom()) - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.MapZoom#zoom")?; - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.MapZoom#zoom")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.MapZoom#zoom")? - }; + let zoom = arrays_by_descr + .get(&Self::descriptor_zoom()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_zoom())); Ok(Self { zoom }) } } impl ::re_types_core::AsComponents for MapZoom { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - (Some(&self.zoom as &dyn ComponentBatch)).map(|batch| { - ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_zoom()), - } - }), - ] - .into_iter() - .flatten() - .collect() + [Self::indicator().serialized(), self.zoom.clone()] + .into_iter() + .flatten() + .collect() } } @@ -157,7 +139,36 @@ impl MapZoom { /// Create a new `MapZoom`. #[inline] pub fn new(zoom: impl Into) -> Self { - Self { zoom: zoom.into() } + Self { + zoom: try_serialize_field(Self::descriptor_zoom(), [zoom]), + } + } + + /// Update only some specific fields of a `MapZoom`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `MapZoom`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + zoom: Some(SerializedComponentBatch::new( + crate::blueprint::components::ZoomLevel::arrow_empty(), + Self::descriptor_zoom(), + )), + } + } + + /// Zoom level for the map. + /// + /// Zoom level follow the [`OpenStreetMap` definition](https://wiki.openstreetmap.org/wiki/Zoom_levels). + #[inline] + pub fn with_zoom(mut self, zoom: impl Into) -> Self { + self.zoom = try_serialize_field(Self::descriptor_zoom(), [zoom]); + self } } @@ -166,9 +177,4 @@ impl ::re_byte_size::SizeBytes for MapZoom { fn heap_size_bytes(&self) -> u64 { self.zoom.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index e226ce3141b4..20bbbac5355f 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -22,7 +22,6 @@ mod view_blueprint; mod view_contents; mod viewport_blueprint; mod visible_time_ranges; -mod visible_time_ranges_ext; mod visual_bounds2d; pub use self::background::Background; 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 index 3ecaabfff1e0..8aa5043ad643 100644 --- a/crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs +++ b/crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs @@ -19,12 +19,12 @@ 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)] +#[derive(Clone, Debug, Default)] 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, + pub near_clip_plane: Option, } impl NearClipPlane { @@ -120,39 +120,23 @@ impl ::re_types_core::Archetype for NearClipPlane { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let near_clip_plane = { - let array = arrays_by_descr - .get(&Self::descriptor_near_clip_plane()) - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.NearClipPlane#near_clip_plane")?; - ::from_arrow_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")? - }; + let near_clip_plane = arrays_by_descr + .get(&Self::descriptor_near_clip_plane()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_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!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { 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(Self::descriptor_near_clip_plane()), - } - }), - ] - .into_iter() - .flatten() - .collect() + [Self::indicator().serialized(), self.near_clip_plane.clone()] + .into_iter() + .flatten() + .collect() } } @@ -163,9 +147,43 @@ impl NearClipPlane { #[inline] pub fn new(near_clip_plane: impl Into) -> Self { Self { - near_clip_plane: near_clip_plane.into(), + near_clip_plane: try_serialize_field( + Self::descriptor_near_clip_plane(), + [near_clip_plane], + ), } } + + /// Update only some specific fields of a `NearClipPlane`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `NearClipPlane`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + near_clip_plane: Some(SerializedComponentBatch::new( + crate::blueprint::components::NearClipPlane::arrow_empty(), + Self::descriptor_near_clip_plane(), + )), + } + } + + /// Controls the distance to the near clip plane in 3D scene units. + /// + /// Content closer than this distance will not be visible. + #[inline] + pub fn with_near_clip_plane( + mut self, + near_clip_plane: impl Into, + ) -> Self { + self.near_clip_plane = + try_serialize_field(Self::descriptor_near_clip_plane(), [near_clip_plane]); + self + } } impl ::re_byte_size::SizeBytes for NearClipPlane { @@ -173,9 +191,4 @@ impl ::re_byte_size::SizeBytes for NearClipPlane { 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/panel_blueprint.rs b/crates/store/re_types/src/blueprint/archetypes/panel_blueprint.rs index 30f03a303bf5..8453243f90fe 100644 --- a/crates/store/re_types/src/blueprint/archetypes/panel_blueprint.rs +++ b/crates/store/re_types/src/blueprint/archetypes/panel_blueprint.rs @@ -22,7 +22,7 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; #[derive(Clone, Debug, Default)] pub struct PanelBlueprint { /// Current state of the panels. - pub state: Option, + pub state: Option, } impl PanelBlueprint { @@ -118,37 +118,21 @@ impl ::re_types_core::Archetype for PanelBlueprint { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let state = if let Some(array) = arrays_by_descr.get(&Self::descriptor_state()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.PanelBlueprint#state")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let state = arrays_by_descr + .get(&Self::descriptor_state()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_state())); Ok(Self { state }) } } impl ::re_types_core::AsComponents for PanelBlueprint { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - (self - .state - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_state()), - }), - ] - .into_iter() - .flatten() - .collect() + [Self::indicator().serialized(), self.state.clone()] + .into_iter() + .flatten() + .collect() } } @@ -161,13 +145,31 @@ impl PanelBlueprint { Self { state: None } } + /// Update only some specific fields of a `PanelBlueprint`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `PanelBlueprint`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + state: Some(SerializedComponentBatch::new( + crate::blueprint::components::PanelState::arrow_empty(), + Self::descriptor_state(), + )), + } + } + /// Current state of the panels. #[inline] pub fn with_state( mut self, state: impl Into, ) -> Self { - self.state = Some(state.into()); + self.state = try_serialize_field(Self::descriptor_state(), [state]); self } } @@ -177,9 +179,4 @@ impl ::re_byte_size::SizeBytes for PanelBlueprint { fn heap_size_bytes(&self) -> u64 { self.state.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/plot_legend.rs b/crates/store/re_types/src/blueprint/archetypes/plot_legend.rs index 3f5bde616686..1182b1644874 100644 --- a/crates/store/re_types/src/blueprint/archetypes/plot_legend.rs +++ b/crates/store/re_types/src/blueprint/archetypes/plot_legend.rs @@ -24,12 +24,12 @@ pub struct PlotLegend { /// To what corner the legend is aligned. /// /// Defaults to the right bottom corner. - pub corner: Option, + pub corner: Option, /// Whether the legend is shown at all. /// /// True by default. - pub visible: Option, + pub visible: Option, } impl PlotLegend { @@ -141,50 +141,24 @@ impl ::re_types_core::Archetype for PlotLegend { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let corner = if let Some(array) = arrays_by_descr.get(&Self::descriptor_corner()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.PlotLegend#corner")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let visible = if let Some(array) = arrays_by_descr.get(&Self::descriptor_visible()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.PlotLegend#visible")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let corner = arrays_by_descr + .get(&Self::descriptor_corner()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_corner())); + let visible = arrays_by_descr + .get(&Self::descriptor_visible()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_visible())); Ok(Self { corner, visible }) } } impl ::re_types_core::AsComponents for PlotLegend { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .corner - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_corner()), - }), - (self - .visible - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_visible()), - }), + Self::indicator().serialized(), + self.corner.clone(), + self.visible.clone(), ] .into_iter() .flatten() @@ -204,6 +178,28 @@ impl PlotLegend { } } + /// Update only some specific fields of a `PlotLegend`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `PlotLegend`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + corner: Some(SerializedComponentBatch::new( + crate::blueprint::components::Corner2D::arrow_empty(), + Self::descriptor_corner(), + )), + visible: Some(SerializedComponentBatch::new( + crate::blueprint::components::Visible::arrow_empty(), + Self::descriptor_visible(), + )), + } + } + /// To what corner the legend is aligned. /// /// Defaults to the right bottom corner. @@ -212,7 +208,7 @@ impl PlotLegend { mut self, corner: impl Into, ) -> Self { - self.corner = Some(corner.into()); + self.corner = try_serialize_field(Self::descriptor_corner(), [corner]); self } @@ -224,7 +220,7 @@ impl PlotLegend { mut self, visible: impl Into, ) -> Self { - self.visible = Some(visible.into()); + self.visible = try_serialize_field(Self::descriptor_visible(), [visible]); self } } @@ -234,10 +230,4 @@ impl ::re_byte_size::SizeBytes for PlotLegend { fn heap_size_bytes(&self) -> u64 { self.corner.heap_size_bytes() + self.visible.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/scalar_axis.rs b/crates/store/re_types/src/blueprint/archetypes/scalar_axis.rs index b354df518205..506b26ba017d 100644 --- a/crates/store/re_types/src/blueprint/archetypes/scalar_axis.rs +++ b/crates/store/re_types/src/blueprint/archetypes/scalar_axis.rs @@ -24,10 +24,10 @@ pub struct ScalarAxis { /// The range of the axis. /// /// If unset, the range well be automatically determined based on the queried data. - pub range: Option, + pub range: Option, /// If enabled, the Y axis range will remain locked to the specified range when zooming. - pub zoom_lock: Option, + pub zoom_lock: Option, } impl ScalarAxis { @@ -139,50 +139,26 @@ impl ::re_types_core::Archetype for ScalarAxis { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let range = if let Some(array) = arrays_by_descr.get(&Self::descriptor_range()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ScalarAxis#range")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let zoom_lock = if let Some(array) = arrays_by_descr.get(&Self::descriptor_zoom_lock()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ScalarAxis#zoom_lock")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let range = arrays_by_descr + .get(&Self::descriptor_range()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_range())); + let zoom_lock = arrays_by_descr + .get(&Self::descriptor_zoom_lock()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_zoom_lock()) + }); Ok(Self { range, zoom_lock }) } } impl ::re_types_core::AsComponents for ScalarAxis { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .range - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_range()), - }), - (self - .zoom_lock - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_zoom_lock()), - }), + Self::indicator().serialized(), + self.range.clone(), + self.zoom_lock.clone(), ] .into_iter() .flatten() @@ -202,12 +178,34 @@ impl ScalarAxis { } } + /// Update only some specific fields of a `ScalarAxis`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ScalarAxis`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + range: Some(SerializedComponentBatch::new( + crate::components::Range1D::arrow_empty(), + Self::descriptor_range(), + )), + zoom_lock: Some(SerializedComponentBatch::new( + crate::blueprint::components::LockRangeDuringZoom::arrow_empty(), + Self::descriptor_zoom_lock(), + )), + } + } + /// The range of the axis. /// /// If unset, the range well be automatically determined based on the queried data. #[inline] pub fn with_range(mut self, range: impl Into) -> Self { - self.range = Some(range.into()); + self.range = try_serialize_field(Self::descriptor_range(), [range]); self } @@ -217,7 +215,7 @@ impl ScalarAxis { mut self, zoom_lock: impl Into, ) -> Self { - self.zoom_lock = Some(zoom_lock.into()); + self.zoom_lock = try_serialize_field(Self::descriptor_zoom_lock(), [zoom_lock]); self } } @@ -227,10 +225,4 @@ impl ::re_byte_size::SizeBytes for ScalarAxis { fn heap_size_bytes(&self) -> u64 { self.range.heap_size_bytes() + self.zoom_lock.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/tensor_scalar_mapping.rs b/crates/store/re_types/src/blueprint/archetypes/tensor_scalar_mapping.rs index 17b9bf68667e..dc2e34caa03d 100644 --- a/crates/store/re_types/src/blueprint/archetypes/tensor_scalar_mapping.rs +++ b/crates/store/re_types/src/blueprint/archetypes/tensor_scalar_mapping.rs @@ -24,10 +24,10 @@ pub struct TensorScalarMapping { /// Filter used when zooming in on the tensor. /// /// Note that the filter is applied to the scalar values *before* they are mapped to color. - pub mag_filter: Option, + pub mag_filter: Option, /// How scalar values map to colors. - pub colormap: Option, + pub colormap: Option, /// Gamma exponent applied to normalized values before mapping to color. /// @@ -36,7 +36,7 @@ pub struct TensorScalarMapping { /// /// The final value for display is set as: /// `colormap( ((value - data_display_range.min) / (data_display_range.max - data_display_range.min)) ** gamma )` - pub gamma: Option, + pub gamma: Option, } impl TensorScalarMapping { @@ -161,33 +161,17 @@ impl ::re_types_core::Archetype for TensorScalarMapping { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let mag_filter = if let Some(array) = arrays_by_descr.get(&Self::descriptor_mag_filter()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.TensorScalarMapping#mag_filter")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let colormap = if let Some(array) = arrays_by_descr.get(&Self::descriptor_colormap()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.TensorScalarMapping#colormap")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let gamma = if let Some(array) = arrays_by_descr.get(&Self::descriptor_gamma()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.TensorScalarMapping#gamma")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let mag_filter = arrays_by_descr + .get(&Self::descriptor_mag_filter()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_mag_filter()) + }); + let colormap = arrays_by_descr + .get(&Self::descriptor_colormap()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colormap())); + let gamma = arrays_by_descr + .get(&Self::descriptor_gamma()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_gamma())); Ok(Self { mag_filter, colormap, @@ -197,35 +181,14 @@ impl ::re_types_core::Archetype for TensorScalarMapping { } impl ::re_types_core::AsComponents for TensorScalarMapping { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .mag_filter - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_mag_filter()), - }), - (self - .colormap - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_colormap()), - }), - (self - .gamma - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_gamma()), - }), + Self::indicator().serialized(), + self.mag_filter.clone(), + self.colormap.clone(), + self.gamma.clone(), ] .into_iter() .flatten() @@ -246,6 +209,32 @@ impl TensorScalarMapping { } } + /// Update only some specific fields of a `TensorScalarMapping`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `TensorScalarMapping`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + mag_filter: Some(SerializedComponentBatch::new( + crate::components::MagnificationFilter::arrow_empty(), + Self::descriptor_mag_filter(), + )), + colormap: Some(SerializedComponentBatch::new( + crate::components::Colormap::arrow_empty(), + Self::descriptor_colormap(), + )), + gamma: Some(SerializedComponentBatch::new( + crate::components::GammaCorrection::arrow_empty(), + Self::descriptor_gamma(), + )), + } + } + /// Filter used when zooming in on the tensor. /// /// Note that the filter is applied to the scalar values *before* they are mapped to color. @@ -254,14 +243,14 @@ impl TensorScalarMapping { mut self, mag_filter: impl Into, ) -> Self { - self.mag_filter = Some(mag_filter.into()); + self.mag_filter = try_serialize_field(Self::descriptor_mag_filter(), [mag_filter]); self } /// How scalar values map to colors. #[inline] pub fn with_colormap(mut self, colormap: impl Into) -> Self { - self.colormap = Some(colormap.into()); + self.colormap = try_serialize_field(Self::descriptor_colormap(), [colormap]); self } @@ -274,7 +263,7 @@ impl TensorScalarMapping { /// `colormap( ((value - data_display_range.min) / (data_display_range.max - data_display_range.min)) ** gamma )` #[inline] pub fn with_gamma(mut self, gamma: impl Into) -> Self { - self.gamma = Some(gamma.into()); + self.gamma = try_serialize_field(Self::descriptor_gamma(), [gamma]); self } } @@ -286,11 +275,4 @@ impl ::re_byte_size::SizeBytes for TensorScalarMapping { + self.colormap.heap_size_bytes() + self.gamma.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/tensor_slice_selection.rs b/crates/store/re_types/src/blueprint/archetypes/tensor_slice_selection.rs index 035003e10020..60ef51ce0bb4 100644 --- a/crates/store/re_types/src/blueprint/archetypes/tensor_slice_selection.rs +++ b/crates/store/re_types/src/blueprint/archetypes/tensor_slice_selection.rs @@ -19,29 +19,29 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: Specifies a 2D slice of a tensor. -#[derive(Clone, Debug, Default, Hash, PartialEq, Eq)] +#[derive(Clone, Debug, Default)] pub struct TensorSliceSelection { /// Which dimension to map to width. /// /// If not specified, the height will be determined automatically based on the name and index of the dimension. - pub width: Option, + pub width: Option, /// Which dimension to map to height. /// /// If not specified, the height will be determined automatically based on the name and index of the dimension. - pub height: Option, + pub height: Option, /// Selected indices for all other dimensions. /// /// If any of the here listed dimensions is equal to `width` or `height`, it will be ignored. - pub indices: Option>, + pub indices: Option, /// Any dimension listed here will have a slider for the index. /// /// Edits to the sliders will directly manipulate dimensions on the `indices` list. /// If any of the here listed dimensions is equal to `width` or `height`, it will be ignored. /// If not specified, adds slides for any dimension in `indices`. - pub slider: Option>, + pub slider: Option, } impl TensorSliceSelection { @@ -178,48 +178,18 @@ impl ::re_types_core::Archetype for TensorSliceSelection { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let width = if let Some(array) = arrays_by_descr.get(&Self::descriptor_width()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.TensorSliceSelection#width")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let height = if let Some(array) = arrays_by_descr.get(&Self::descriptor_height()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.TensorSliceSelection#height")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let indices = if let Some(array) = arrays_by_descr.get(&Self::descriptor_indices()) { - Some({ - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.TensorSliceSelection#indices")? - .into_iter() - .map(|v| v.ok_or_else(DeserializationError::missing_data)) - .collect::>>() - .with_context("rerun.blueprint.archetypes.TensorSliceSelection#indices")? - }) - } else { - None - }; - let slider = if let Some(array) = arrays_by_descr.get(&Self::descriptor_slider()) { - Some({ - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.TensorSliceSelection#slider")? - .into_iter() - .map(|v| v.ok_or_else(DeserializationError::missing_data)) - .collect::>>() - .with_context("rerun.blueprint.archetypes.TensorSliceSelection#slider")? - }) - } else { - None - }; + let width = arrays_by_descr + .get(&Self::descriptor_width()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_width())); + let height = arrays_by_descr + .get(&Self::descriptor_height()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_height())); + let indices = arrays_by_descr + .get(&Self::descriptor_indices()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_indices())); + let slider = arrays_by_descr + .get(&Self::descriptor_slider()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_slider())); Ok(Self { width, height, @@ -230,43 +200,15 @@ impl ::re_types_core::Archetype for TensorSliceSelection { } impl ::re_types_core::AsComponents for TensorSliceSelection { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .width - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_width()), - }), - (self - .height - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_height()), - }), - (self - .indices - .as_ref() - .map(|comp_batch| (comp_batch as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_indices()), - }), - (self - .slider - .as_ref() - .map(|comp_batch| (comp_batch as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_slider()), - }), + Self::indicator().serialized(), + self.width.clone(), + self.height.clone(), + self.indices.clone(), + self.slider.clone(), ] .into_iter() .flatten() @@ -288,12 +230,42 @@ impl TensorSliceSelection { } } + /// Update only some specific fields of a `TensorSliceSelection`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `TensorSliceSelection`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + width: Some(SerializedComponentBatch::new( + crate::components::TensorWidthDimension::arrow_empty(), + Self::descriptor_width(), + )), + height: Some(SerializedComponentBatch::new( + crate::components::TensorHeightDimension::arrow_empty(), + Self::descriptor_height(), + )), + indices: Some(SerializedComponentBatch::new( + crate::components::TensorDimensionIndexSelection::arrow_empty(), + Self::descriptor_indices(), + )), + slider: Some(SerializedComponentBatch::new( + crate::blueprint::components::TensorDimensionIndexSlider::arrow_empty(), + Self::descriptor_slider(), + )), + } + } + /// Which dimension to map to width. /// /// If not specified, the height will be determined automatically based on the name and index of the dimension. #[inline] pub fn with_width(mut self, width: impl Into) -> Self { - self.width = Some(width.into()); + self.width = try_serialize_field(Self::descriptor_width(), [width]); self } @@ -305,7 +277,7 @@ impl TensorSliceSelection { mut self, height: impl Into, ) -> Self { - self.height = Some(height.into()); + self.height = try_serialize_field(Self::descriptor_height(), [height]); self } @@ -317,7 +289,7 @@ impl TensorSliceSelection { mut self, indices: impl IntoIterator>, ) -> Self { - self.indices = Some(indices.into_iter().map(Into::into).collect()); + self.indices = try_serialize_field(Self::descriptor_indices(), indices); self } @@ -333,7 +305,7 @@ impl TensorSliceSelection { Item = impl Into, >, ) -> Self { - self.slider = Some(slider.into_iter().map(Into::into).collect()); + self.slider = try_serialize_field(Self::descriptor_slider(), slider); self } } @@ -346,12 +318,4 @@ impl ::re_byte_size::SizeBytes for TensorSliceSelection { + self.indices.heap_size_bytes() + self.slider.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >>::is_pod() - && >>::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/tensor_view_fit.rs b/crates/store/re_types/src/blueprint/archetypes/tensor_view_fit.rs index 009e5a72db54..ef0938daa70a 100644 --- a/crates/store/re_types/src/blueprint/archetypes/tensor_view_fit.rs +++ b/crates/store/re_types/src/blueprint/archetypes/tensor_view_fit.rs @@ -22,7 +22,7 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; #[derive(Clone, Debug, Default)] pub struct TensorViewFit { /// How the image is scaled to fit the view. - pub scaling: Option, + pub scaling: Option, } impl TensorViewFit { @@ -118,37 +118,21 @@ impl ::re_types_core::Archetype for TensorViewFit { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let scaling = if let Some(array) = arrays_by_descr.get(&Self::descriptor_scaling()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.TensorViewFit#scaling")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let scaling = arrays_by_descr + .get(&Self::descriptor_scaling()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_scaling())); Ok(Self { scaling }) } } impl ::re_types_core::AsComponents for TensorViewFit { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - (self - .scaling - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_scaling()), - }), - ] - .into_iter() - .flatten() - .collect() + [Self::indicator().serialized(), self.scaling.clone()] + .into_iter() + .flatten() + .collect() } } @@ -161,13 +145,31 @@ impl TensorViewFit { Self { scaling: None } } + /// Update only some specific fields of a `TensorViewFit`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `TensorViewFit`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + scaling: Some(SerializedComponentBatch::new( + crate::blueprint::components::ViewFit::arrow_empty(), + Self::descriptor_scaling(), + )), + } + } + /// How the image is scaled to fit the view. #[inline] pub fn with_scaling( mut self, scaling: impl Into, ) -> Self { - self.scaling = Some(scaling.into()); + self.scaling = try_serialize_field(Self::descriptor_scaling(), [scaling]); self } } @@ -177,9 +179,4 @@ impl ::re_byte_size::SizeBytes for TensorViewFit { fn heap_size_bytes(&self) -> u64 { self.scaling.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/view_blueprint.rs b/crates/store/re_types/src/blueprint/archetypes/view_blueprint.rs index e7699eda7997..21530cc8f904 100644 --- a/crates/store/re_types/src/blueprint/archetypes/view_blueprint.rs +++ b/crates/store/re_types/src/blueprint/archetypes/view_blueprint.rs @@ -19,13 +19,13 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: The description of a single view. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct ViewBlueprint { /// The class of the view. - pub class_identifier: crate::blueprint::components::ViewClass, + pub class_identifier: Option, /// The name of the view. - pub display_name: Option, + pub display_name: Option, /// The "anchor point" of this view. /// @@ -34,12 +34,12 @@ pub struct ViewBlueprint { /// The transform at this path forms the reference point for all scene->world transforms in this view. /// I.e. the position of this entity path in space forms the origin of the coordinate system in this view. /// Furthermore, this is the primary indicator for heuristics on what entities we show in this view. - pub space_origin: Option, + pub space_origin: Option, /// Whether this view is visible. /// /// Defaults to true if not specified. - pub visible: Option, + pub visible: Option, } impl ViewBlueprint { @@ -174,48 +174,24 @@ impl ::re_types_core::Archetype for ViewBlueprint { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let class_identifier = { - let array = arrays_by_descr - .get(&Self::descriptor_class_identifier()) - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ViewBlueprint#class_identifier")?; - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewBlueprint#class_identifier")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ViewBlueprint#class_identifier")? - }; - let display_name = - if let Some(array) = arrays_by_descr.get(&Self::descriptor_display_name()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewBlueprint#display_name")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let space_origin = - if let Some(array) = arrays_by_descr.get(&Self::descriptor_space_origin()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewBlueprint#space_origin")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let visible = if let Some(array) = arrays_by_descr.get(&Self::descriptor_visible()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewBlueprint#visible")? - .into_iter() - .next() - .flatten() - } else { - None - }; + let class_identifier = arrays_by_descr + .get(&Self::descriptor_class_identifier()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_class_identifier()) + }); + let display_name = arrays_by_descr + .get(&Self::descriptor_display_name()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_display_name()) + }); + let space_origin = arrays_by_descr + .get(&Self::descriptor_space_origin()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_space_origin()) + }); + let visible = arrays_by_descr + .get(&Self::descriptor_visible()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_visible())); Ok(Self { class_identifier, display_name, @@ -226,41 +202,15 @@ impl ::re_types_core::Archetype for ViewBlueprint { } impl ::re_types_core::AsComponents for ViewBlueprint { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (Some(&self.class_identifier as &dyn ComponentBatch)).map(|batch| { - ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_class_identifier()), - } - }), - (self - .display_name - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_display_name()), - }), - (self - .space_origin - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_space_origin()), - }), - (self - .visible - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_visible()), - }), + Self::indicator().serialized(), + self.class_identifier.clone(), + self.display_name.clone(), + self.space_origin.clone(), + self.visible.clone(), ] .into_iter() .flatten() @@ -275,17 +225,61 @@ impl ViewBlueprint { #[inline] pub fn new(class_identifier: impl Into) -> Self { Self { - class_identifier: class_identifier.into(), + class_identifier: try_serialize_field( + Self::descriptor_class_identifier(), + [class_identifier], + ), display_name: None, space_origin: None, visible: None, } } + /// Update only some specific fields of a `ViewBlueprint`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ViewBlueprint`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + class_identifier: Some(SerializedComponentBatch::new( + crate::blueprint::components::ViewClass::arrow_empty(), + Self::descriptor_class_identifier(), + )), + display_name: Some(SerializedComponentBatch::new( + crate::components::Name::arrow_empty(), + Self::descriptor_display_name(), + )), + space_origin: Some(SerializedComponentBatch::new( + crate::blueprint::components::ViewOrigin::arrow_empty(), + Self::descriptor_space_origin(), + )), + visible: Some(SerializedComponentBatch::new( + crate::blueprint::components::Visible::arrow_empty(), + Self::descriptor_visible(), + )), + } + } + + /// The class of the view. + #[inline] + pub fn with_class_identifier( + mut self, + class_identifier: impl Into, + ) -> Self { + self.class_identifier = + try_serialize_field(Self::descriptor_class_identifier(), [class_identifier]); + self + } + /// The name of the view. #[inline] pub fn with_display_name(mut self, display_name: impl Into) -> Self { - self.display_name = Some(display_name.into()); + self.display_name = try_serialize_field(Self::descriptor_display_name(), [display_name]); self } @@ -301,7 +295,7 @@ impl ViewBlueprint { mut self, space_origin: impl Into, ) -> Self { - self.space_origin = Some(space_origin.into()); + self.space_origin = try_serialize_field(Self::descriptor_space_origin(), [space_origin]); self } @@ -313,7 +307,7 @@ impl ViewBlueprint { mut self, visible: impl Into, ) -> Self { - self.visible = Some(visible.into()); + self.visible = try_serialize_field(Self::descriptor_visible(), [visible]); self } } @@ -326,12 +320,4 @@ impl ::re_byte_size::SizeBytes for ViewBlueprint { + self.space_origin.heap_size_bytes() + self.visible.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - && >::is_pod() - && >::is_pod() - && >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/view_contents.rs b/crates/store/re_types/src/blueprint/archetypes/view_contents.rs index d6c99cfa3613..1a767693fe74 100644 --- a/crates/store/re_types/src/blueprint/archetypes/view_contents.rs +++ b/crates/store/re_types/src/blueprint/archetypes/view_contents.rs @@ -61,7 +61,7 @@ pub struct ViewContents { /// The `QueryExpression` that populates the contents for the view. /// /// They determine which entities are part of the view. - pub query: Vec, + pub query: Option, } impl ViewContents { @@ -157,38 +157,21 @@ impl ::re_types_core::Archetype for ViewContents { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let query = { - let array = arrays_by_descr - .get(&Self::descriptor_query()) - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ViewContents#query")?; - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewContents#query")? - .into_iter() - .map(|v| v.ok_or_else(DeserializationError::missing_data)) - .collect::>>() - .with_context("rerun.blueprint.archetypes.ViewContents#query")? - }; + let query = arrays_by_descr + .get(&Self::descriptor_query()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_query())); Ok(Self { query }) } } impl ::re_types_core::AsComponents for ViewContents { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - (Some(&self.query as &dyn ComponentBatch)).map(|batch| { - ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_query()), - } - }), - ] - .into_iter() - .flatten() - .collect() + [Self::indicator().serialized(), self.query.clone()] + .into_iter() + .flatten() + .collect() } } @@ -201,9 +184,39 @@ impl ViewContents { query: impl IntoIterator>, ) -> Self { Self { - query: query.into_iter().map(Into::into).collect(), + query: try_serialize_field(Self::descriptor_query(), query), + } + } + + /// Update only some specific fields of a `ViewContents`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ViewContents`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + query: Some(SerializedComponentBatch::new( + crate::blueprint::components::QueryExpression::arrow_empty(), + Self::descriptor_query(), + )), } } + + /// The `QueryExpression` that populates the contents for the view. + /// + /// They determine which entities are part of the view. + #[inline] + pub fn with_query( + mut self, + query: impl IntoIterator>, + ) -> Self { + self.query = try_serialize_field(Self::descriptor_query(), query); + self + } } impl ::re_byte_size::SizeBytes for ViewContents { @@ -211,9 +224,4 @@ impl ::re_byte_size::SizeBytes for ViewContents { fn heap_size_bytes(&self) -> u64 { self.query.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/viewport_blueprint.rs b/crates/store/re_types/src/blueprint/archetypes/viewport_blueprint.rs index a72945cb4bb2..cd2b1d05ee0c 100644 --- a/crates/store/re_types/src/blueprint/archetypes/viewport_blueprint.rs +++ b/crates/store/re_types/src/blueprint/archetypes/viewport_blueprint.rs @@ -22,23 +22,23 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; #[derive(Clone, Debug, Default)] pub struct ViewportBlueprint { /// The layout of the views - pub root_container: Option, + pub root_container: Option, /// Show one tab as maximized? - pub maximized: Option, + pub maximized: Option, /// Whether the viewport layout is determined automatically. /// /// If `true`, the container layout will be reset whenever a new view is added or removed. /// This defaults to `false` and is automatically set to `false` when there is user determined layout. - pub auto_layout: Option, + pub auto_layout: Option, /// Whether or not views should be created automatically. /// /// If `true`, the viewer will only add views that it hasn't considered previously (as identified by `past_viewer_recommendations`) /// and which aren't deemed redundant to existing views. /// This defaults to `false` and is automatically set to `false` when the user adds views manually in the viewer. - pub auto_views: Option, + pub auto_views: Option, /// Hashes of all recommended views the viewer has already added and that should not be added again. /// @@ -46,8 +46,7 @@ pub struct ViewportBlueprint { /// If you want the viewer from stopping to add views, you should set `auto_views` to `false`. /// /// The viewer uses this to determine whether it should keep adding views. - pub past_viewer_recommendations: - Option>, + pub past_viewer_recommendations: Option, } impl ViewportBlueprint { @@ -195,62 +194,34 @@ impl ::re_types_core::Archetype for ViewportBlueprint { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let root_container = - if let Some(array) = arrays_by_descr.get(&Self::descriptor_root_container()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewportBlueprint#root_container")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let maximized = if let Some(array) = arrays_by_descr.get(&Self::descriptor_maximized()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewportBlueprint#maximized")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let auto_layout = if let Some(array) = arrays_by_descr.get(&Self::descriptor_auto_layout()) - { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewportBlueprint#auto_layout")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let auto_views = if let Some(array) = arrays_by_descr.get(&Self::descriptor_auto_views()) { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.ViewportBlueprint#auto_views")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let past_viewer_recommendations = if let Some(array) = - arrays_by_descr.get(&Self::descriptor_past_viewer_recommendations()) - { - Some({ - ::from_arrow_opt(&**array) - .with_context( - "rerun.blueprint.archetypes.ViewportBlueprint#past_viewer_recommendations", - )? - .into_iter() - .map(|v| v.ok_or_else(DeserializationError::missing_data)) - .collect::>>() - .with_context( - "rerun.blueprint.archetypes.ViewportBlueprint#past_viewer_recommendations", - )? - }) - } else { - None - }; + let root_container = arrays_by_descr + .get(&Self::descriptor_root_container()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_root_container()) + }); + let maximized = arrays_by_descr + .get(&Self::descriptor_maximized()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_maximized()) + }); + let auto_layout = arrays_by_descr + .get(&Self::descriptor_auto_layout()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_auto_layout()) + }); + let auto_views = arrays_by_descr + .get(&Self::descriptor_auto_views()) + .map(|array| { + SerializedComponentBatch::new(array.clone(), Self::descriptor_auto_views()) + }); + let past_viewer_recommendations = arrays_by_descr + .get(&Self::descriptor_past_viewer_recommendations()) + .map(|array| { + SerializedComponentBatch::new( + array.clone(), + Self::descriptor_past_viewer_recommendations(), + ) + }); Ok(Self { root_container, maximized, @@ -262,51 +233,16 @@ impl ::re_types_core::Archetype for ViewportBlueprint { } impl ::re_types_core::AsComponents for ViewportBlueprint { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; [ - Some(Self::indicator()), - (self - .root_container - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_root_container()), - }), - (self - .maximized - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_maximized()), - }), - (self - .auto_layout - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_auto_layout()), - }), - (self - .auto_views - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_auto_views()), - }), - (self - .past_viewer_recommendations - .as_ref() - .map(|comp_batch| (comp_batch as &dyn ComponentBatch))) - .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_past_viewer_recommendations()), - }), + Self::indicator().serialized(), + self.root_container.clone(), + self.maximized.clone(), + self.auto_layout.clone(), + self.auto_views.clone(), + self.past_viewer_recommendations.clone(), ] .into_iter() .flatten() @@ -329,13 +265,48 @@ impl ViewportBlueprint { } } + /// Update only some specific fields of a `ViewportBlueprint`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `ViewportBlueprint`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + root_container: Some(SerializedComponentBatch::new( + crate::blueprint::components::RootContainer::arrow_empty(), + Self::descriptor_root_container(), + )), + maximized: Some(SerializedComponentBatch::new( + crate::blueprint::components::ViewMaximized::arrow_empty(), + Self::descriptor_maximized(), + )), + auto_layout: Some(SerializedComponentBatch::new( + crate::blueprint::components::AutoLayout::arrow_empty(), + Self::descriptor_auto_layout(), + )), + auto_views: Some(SerializedComponentBatch::new( + crate::blueprint::components::AutoViews::arrow_empty(), + Self::descriptor_auto_views(), + )), + past_viewer_recommendations: Some(SerializedComponentBatch::new( + crate::blueprint::components::ViewerRecommendationHash::arrow_empty(), + Self::descriptor_past_viewer_recommendations(), + )), + } + } + /// The layout of the views #[inline] pub fn with_root_container( mut self, root_container: impl Into, ) -> Self { - self.root_container = Some(root_container.into()); + self.root_container = + try_serialize_field(Self::descriptor_root_container(), [root_container]); self } @@ -345,7 +316,7 @@ impl ViewportBlueprint { mut self, maximized: impl Into, ) -> Self { - self.maximized = Some(maximized.into()); + self.maximized = try_serialize_field(Self::descriptor_maximized(), [maximized]); self } @@ -358,7 +329,7 @@ impl ViewportBlueprint { mut self, auto_layout: impl Into, ) -> Self { - self.auto_layout = Some(auto_layout.into()); + self.auto_layout = try_serialize_field(Self::descriptor_auto_layout(), [auto_layout]); self } @@ -372,7 +343,7 @@ impl ViewportBlueprint { mut self, auto_views: impl Into, ) -> Self { - self.auto_views = Some(auto_views.into()); + self.auto_views = try_serialize_field(Self::descriptor_auto_views(), [auto_views]); self } @@ -389,11 +360,9 @@ impl ViewportBlueprint { Item = impl Into, >, ) -> Self { - self.past_viewer_recommendations = Some( - past_viewer_recommendations - .into_iter() - .map(Into::into) - .collect(), + self.past_viewer_recommendations = try_serialize_field( + Self::descriptor_past_viewer_recommendations(), + past_viewer_recommendations, ); self } @@ -408,13 +377,4 @@ impl ::re_byte_size::SizeBytes for ViewportBlueprint { + self.auto_views.heap_size_bytes() + self.past_viewer_recommendations.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - && >::is_pod() - && >>::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/visible_time_ranges.rs b/crates/store/re_types/src/blueprint/archetypes/visible_time_ranges.rs index db09e1d83237..e55280213b66 100644 --- a/crates/store/re_types/src/blueprint/archetypes/visible_time_ranges.rs +++ b/crates/store/re_types/src/blueprint/archetypes/visible_time_ranges.rs @@ -32,7 +32,7 @@ pub struct VisibleTimeRanges { /// The time ranges to show for each timeline unless specified otherwise on a per-entity basis. /// /// If a timeline is specified more than once, the first entry will be used. - pub ranges: Vec, + pub ranges: Option, } impl VisibleTimeRanges { @@ -128,38 +128,21 @@ impl ::re_types_core::Archetype for VisibleTimeRanges { re_tracing::profile_function!(); use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect(); - let ranges = { - let array = arrays_by_descr - .get(&Self::descriptor_ranges()) - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.VisibleTimeRanges#ranges")?; - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.VisibleTimeRanges#ranges")? - .into_iter() - .map(|v| v.ok_or_else(DeserializationError::missing_data)) - .collect::>>() - .with_context("rerun.blueprint.archetypes.VisibleTimeRanges#ranges")? - }; + let ranges = arrays_by_descr + .get(&Self::descriptor_ranges()) + .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_ranges())); Ok(Self { ranges }) } } impl ::re_types_core::AsComponents for VisibleTimeRanges { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); + #[inline] + fn as_serialized_batches(&self) -> Vec { use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - (Some(&self.ranges as &dyn ComponentBatch)).map(|batch| { - ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(Self::descriptor_ranges()), - } - }), - ] - .into_iter() - .flatten() - .collect() + [Self::indicator().serialized(), self.ranges.clone()] + .into_iter() + .flatten() + .collect() } } @@ -172,9 +155,39 @@ impl VisibleTimeRanges { ranges: impl IntoIterator>, ) -> Self { Self { - ranges: ranges.into_iter().map(Into::into).collect(), + ranges: try_serialize_field(Self::descriptor_ranges(), ranges), + } + } + + /// Update only some specific fields of a `VisibleTimeRanges`. + #[inline] + pub fn update_fields() -> Self { + Self::default() + } + + /// Clear all the fields of a `VisibleTimeRanges`. + #[inline] + pub fn clear_fields() -> Self { + use ::re_types_core::Loggable as _; + Self { + ranges: Some(SerializedComponentBatch::new( + crate::blueprint::components::VisibleTimeRange::arrow_empty(), + Self::descriptor_ranges(), + )), } } + + /// The time ranges to show for each timeline unless specified otherwise on a per-entity basis. + /// + /// If a timeline is specified more than once, the first entry will be used. + #[inline] + pub fn with_ranges( + mut self, + ranges: impl IntoIterator>, + ) -> Self { + self.ranges = try_serialize_field(Self::descriptor_ranges(), ranges); + self + } } impl ::re_byte_size::SizeBytes for VisibleTimeRanges { @@ -182,9 +195,4 @@ impl ::re_byte_size::SizeBytes for VisibleTimeRanges { fn heap_size_bytes(&self) -> u64 { self.ranges.heap_size_bytes() } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - } } diff --git a/crates/store/re_types/src/blueprint/archetypes/visible_time_ranges_ext.rs b/crates/store/re_types/src/blueprint/archetypes/visible_time_ranges_ext.rs deleted file mode 100644 index d57ffcac5a0f..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/visible_time_ranges_ext.rs +++ /dev/null @@ -1,38 +0,0 @@ -use re_types_core::datatypes::TimeRange; - -use super::VisibleTimeRanges; - -impl VisibleTimeRanges { - /// Retrieves the time range for a given timeline. - pub fn range_for_timeline(&self, timeline_name: &str) -> Option<&TimeRange> { - self.ranges - .iter() - .find(|range| range.timeline.as_str() == timeline_name) - .map(|range| &range.range) - } - - /// Sets the time range for a given timeline. - /// - /// If the range is `None`, the timeline will be removed from the list of visible time ranges. - pub fn set_range_for_timeline(&mut self, timeline_name: &str, range: Option) { - if let Some(range) = range { - if let Some(existing_range) = self - .ranges - .iter_mut() - .find(|range| range.timeline.as_str() == timeline_name) - { - existing_range.0.range = range; - } else { - self.ranges.push( - crate::datatypes::VisibleTimeRange { - timeline: timeline_name.to_owned().into(), - range, - } - .into(), - ); - } - } else { - self.ranges.retain(|r| r.timeline.as_str() != timeline_name); - } - } -} diff --git a/crates/viewer/re_selection_panel/src/visible_time_range_ui.rs b/crates/viewer/re_selection_panel/src/visible_time_range_ui.rs index 7caae1c0e531..01a309723497 100644 --- a/crates/viewer/re_selection_panel/src/visible_time_range_ui.rs +++ b/crates/viewer/re_selection_panel/src/visible_time_range_ui.rs @@ -61,7 +61,7 @@ fn visible_time_range_ui( ) { use re_types::Component as _; - let ranges = ctx + let visible_time_ranges = ctx .blueprint_db() .latest_at( ctx.blueprint_query, @@ -70,12 +70,11 @@ fn visible_time_range_ui( ) .component_batch::() .unwrap_or_default(); - let visible_time_ranges = re_types::blueprint::archetypes::VisibleTimeRanges { ranges }; let timeline_name = *ctx.rec_cfg.time_ctrl.read().timeline().name(); let mut has_individual_range = visible_time_ranges - .range_for_timeline(timeline_name.as_str()) - .is_some(); + .iter() + .any(|range| range.timeline.as_str() == timeline_name.as_str()); let has_individual_range_before = has_individual_range; let query_range_before = resolved_query_range.clone(); @@ -112,7 +111,7 @@ fn save_visible_time_ranges( has_individual_range: bool, query_range: QueryRange, property_path: &EntityPath, - mut visible_time_ranges: re_types::blueprint::archetypes::VisibleTimeRanges, + mut visible_time_range_list: Vec, ) { if has_individual_range { let time_range = match query_range { @@ -125,12 +124,26 @@ fn save_visible_time_ranges( return; } }; - visible_time_ranges.set_range_for_timeline(timeline_name, Some(time_range)); + + if let Some(existing) = visible_time_range_list + .iter_mut() + .find(|r| r.timeline.as_str() == timeline_name.as_str()) + { + existing.range = time_range; + } else { + visible_time_range_list.push( + re_types::datatypes::VisibleTimeRange { + timeline: timeline_name.as_str().into(), + range: time_range, + } + .into(), + ); + } } else { - visible_time_ranges.set_range_for_timeline(timeline_name, None); + visible_time_range_list.retain(|r| r.timeline.as_str() != timeline_name.as_str()); } - ctx.save_blueprint_archetype(property_path, &visible_time_ranges); + ctx.save_blueprint_component(property_path, &visible_time_range_list); } /// Draws ui for showing and configuring a query range. diff --git a/crates/viewer/re_view_tensor/src/dimension_mapping.rs b/crates/viewer/re_view_tensor/src/dimension_mapping.rs index 6fd1f1cd13aa..adbd7894597a 100644 --- a/crates/viewer/re_view_tensor/src/dimension_mapping.rs +++ b/crates/viewer/re_view_tensor/src/dimension_mapping.rs @@ -1,7 +1,7 @@ use egui::NumExt as _; use re_types::{ - blueprint::{archetypes::TensorSliceSelection, components::TensorDimensionIndexSlider}, + blueprint::components::TensorDimensionIndexSlider, components::{TensorDimensionIndexSelection, TensorHeightDimension, TensorWidthDimension}, datatypes::TensorDimensionSelection, }; @@ -9,38 +9,51 @@ use re_viewport_blueprint::ViewProperty; use crate::TensorDimension; -/// Loads slice selection from blueprint and makes modifications (without writing back) such that it is valid -/// for the given tensor shape. +/// Selection of a 2D slice of a tensor. /// -/// This is a best effort function and will insert fallbacks as needed. -/// Note that fallbacks are defined on the spot here and don't use the component fallback system. -/// We don't need the fallback system here since we're also not using generic ui either. -/// -/// General rules for scrubbing the input data: -/// * out of bounds dimensions and indices are clamped to valid -/// * missing width/height is filled in if there's at least 2 dimensions. -pub fn load_tensor_slice_selection_and_make_valid( - slice_selection: &ViewProperty, - shape: &[TensorDimension], -) -> Result { - re_tracing::profile_function!(); - - let mut width = slice_selection.component_or_empty::()?; - let mut height = slice_selection.component_or_empty::()?; - let mut indices = - slice_selection.component_array_or_empty::()?; - let mut slider = slice_selection.component_array::()?; - - make_width_height_valid(shape, &mut width, &mut height); - make_indices_valid(shape, &mut indices, width, height); - make_slider_valid(shape.len() as _, &mut slider, &indices, width, height); - - Ok(TensorSliceSelection { - width, - height, - indices: Some(indices), - slider, - }) +/// This is practically a deserialized & validated version of [`re_types::blueprint::archetypes::TensorSliceSelection`]. +#[derive(Clone, Debug, Hash)] +pub struct TensorSliceSelection { + pub width: Option, + pub height: Option, + pub indices: Vec, + pub slider: Option>, +} + +impl TensorSliceSelection { + /// Loads slice selection from blueprint and makes modifications (without writing back) such that it is valid + /// for the given tensor shape. + /// + /// This is a best effort function and will insert fallbacks as needed. + /// Note that fallbacks are defined on the spot here and don't use the component fallback system. + /// We don't need the fallback system here since we're also not using generic ui either. + /// + /// General rules for scrubbing the input data: + /// * out of bounds dimensions and indices are clamped to valid + /// * missing width/height is filled in if there's at least 2 dimensions. + pub fn load_and_make_valid( + slice_selection: &ViewProperty, + shape: &[TensorDimension], + ) -> Result { + re_tracing::profile_function!(); + + let mut width = slice_selection.component_or_empty::()?; + let mut height = slice_selection.component_or_empty::()?; + let mut indices = + slice_selection.component_array_or_empty::()?; + let mut slider = slice_selection.component_array::()?; + + make_width_height_valid(shape, &mut width, &mut height); + make_indices_valid(shape, &mut indices, width, height); + make_slider_valid(shape.len() as _, &mut slider, &indices, width, height); + + Ok(Self { + width, + height, + indices, + slider, + }) + } } fn make_width_height_valid( diff --git a/crates/viewer/re_view_tensor/src/tensor_dimension_mapper.rs b/crates/viewer/re_view_tensor/src/tensor_dimension_mapper.rs index 6a35e6bbe165..cc5613555961 100644 --- a/crates/viewer/re_view_tensor/src/tensor_dimension_mapper.rs +++ b/crates/viewer/re_view_tensor/src/tensor_dimension_mapper.rs @@ -1,11 +1,9 @@ -use re_types::{ - blueprint::archetypes::TensorSliceSelection, datatypes::TensorDimensionIndexSelection, -}; +use re_types::datatypes::TensorDimensionIndexSelection; use re_ui::UiExt as _; use re_viewer_context::ViewerContext; use re_viewport_blueprint::ViewProperty; -use crate::TensorDimension; +use crate::{dimension_mapping::TensorSliceSelection, TensorDimension}; #[derive(Clone, Copy, PartialEq, Eq)] enum DragDropAddress { @@ -41,9 +39,7 @@ impl DragDropAddress { index: shape[h.dimension as usize].size / 2, // Select middle if this becomes index fixed. }), #[allow(clippy::unwrap_used)] - Self::Selector(selector_idx) => { - Some(slice_selection.indices.as_ref().unwrap()[*selector_idx].0) - } + Self::Selector(selector_idx) => Some(slice_selection.indices[*selector_idx].0), Self::NewSelector => None, } } @@ -74,7 +70,7 @@ impl DragDropAddress { slice_property.save_blueprint_component(ctx, &height); } Self::Selector(selector_idx) => { - let mut indices = slice_selection.indices.clone().unwrap_or_default(); + let mut indices = slice_selection.indices.clone(); let mut slider = slice_selection.slider.clone().unwrap_or_default(); if let Some(new_selection) = new_selection { indices[*selector_idx] = new_selection.into(); @@ -90,7 +86,7 @@ impl DragDropAddress { Self::NewSelector => { // NewSelector can only be a drop *target*, therefore dim_idx can't be None! if let Some(new_selection) = new_selection { - let mut indices = slice_selection.indices.clone().unwrap_or_default(); + let mut indices = slice_selection.indices.clone(); let mut slider = slice_selection.slider.clone().unwrap_or_default(); indices.push(new_selection.into()); slider.push(new_selection.dimension.into()); // Enable slider by default. @@ -206,15 +202,11 @@ pub fn dimension_mapping_ui( ui.vertical(|ui| { ui.label("Selectors"); - let Some(indices) = &slice_selection.indices else { - return; - }; - // Use Grid instead of Vertical layout to match styling of the parallel Grid for egui::Grid::new("selectiongrid") .num_columns(2) .show(ui, |ui| { - for (selector_idx, selector) in indices.iter().enumerate() { + for (selector_idx, selector) in slice_selection.indices.iter().enumerate() { tensor_dimension_ui( ui, drag_context_id, diff --git a/crates/viewer/re_view_tensor/src/tensor_slice_to_gpu.rs b/crates/viewer/re_view_tensor/src/tensor_slice_to_gpu.rs index eb6c0a453f5a..df3be1ce8a00 100644 --- a/crates/viewer/re_view_tensor/src/tensor_slice_to_gpu.rs +++ b/crates/viewer/re_view_tensor/src/tensor_slice_to_gpu.rs @@ -4,7 +4,6 @@ use re_renderer::{ resource_managers::{GpuTexture2D, ImageDataDesc, TextureManager2DError}, }; use re_types::{ - blueprint::archetypes::TensorSliceSelection, components::GammaCorrection, datatypes::TensorData, tensor_data::{TensorCastError, TensorDataType}, @@ -14,7 +13,7 @@ use re_viewer_context::{ ColormapWithRange, }; -use crate::view_class::selected_tensor_slice; +use crate::{dimension_mapping::TensorSliceSelection, view_class::selected_tensor_slice}; #[derive(thiserror::Error, Debug, PartialEq)] pub enum TensorUploadError { diff --git a/crates/viewer/re_view_tensor/src/view_class.rs b/crates/viewer/re_view_tensor/src/view_class.rs index 5568eb2b239a..3727ee9c73cf 100644 --- a/crates/viewer/re_view_tensor/src/view_class.rs +++ b/crates/viewer/re_view_tensor/src/view_class.rs @@ -5,7 +5,7 @@ use re_data_ui::tensor_summary_ui_grid_contents; use re_log_types::EntityPath; use re_types::{ blueprint::{ - archetypes::{TensorScalarMapping, TensorSliceSelection, TensorViewFit}, + archetypes::{TensorScalarMapping, TensorViewFit}, components::ViewFit, }, components::{Colormap, GammaCorrection, MagnificationFilter, TensorDimensionIndexSelection}, @@ -23,7 +23,7 @@ use re_viewer_context::{ use re_viewport_blueprint::ViewProperty; use crate::{ - dimension_mapping::load_tensor_slice_selection_and_make_valid, + dimension_mapping::TensorSliceSelection, tensor_dimension_mapper::dimension_mapping_ui, visualizer_system::{TensorSystem, TensorVisualization}, TensorDimension, @@ -147,12 +147,10 @@ Note: select the view to configure which dimensions are shown." // TODO(#6075): Listitemify if let Some(TensorVisualization { tensor, .. }) = &state.tensor { - let slice_property = ViewProperty::from_archetype::( - ctx.blueprint_db(), - ctx.blueprint_query, - view_id, - ); - let slice_selection = load_tensor_slice_selection_and_make_valid( + let slice_property = ViewProperty::from_archetype::< + re_types::blueprint::archetypes::TensorSliceSelection, + >(ctx.blueprint_db(), ctx.blueprint_query, view_id); + let slice_selection = TensorSliceSelection::load_and_make_valid( &slice_property, &TensorDimension::from_tensor_data(tensor), )?; @@ -246,12 +244,10 @@ impl TensorView { ) -> Result<(), ViewSystemExecutionError> { re_tracing::profile_function!(); - let slice_property = ViewProperty::from_archetype::( - ctx.blueprint_db(), - ctx.blueprint_query, - view_id, - ); - let slice_selection = load_tensor_slice_selection_and_make_valid( + let slice_property = ViewProperty::from_archetype::< + re_types::blueprint::archetypes::TensorSliceSelection, + >(ctx.blueprint_db(), ctx.blueprint_query, view_id); + let slice_selection = TensorSliceSelection::load_and_make_valid( &slice_property, &TensorDimension::from_tensor_data(tensor), )?; @@ -426,9 +422,6 @@ pub fn selected_tensor_slice<'a, T: Copy>( slider: _, } = slice_selection; - let empty_indices = Vec::new(); - let indices = indices.as_ref().unwrap_or(&empty_indices); - let (dwidth, dheight) = if let (Some(width), Some(height)) = (width, height) { (width.dimension, height.dimension) } else if let Some(width) = width { @@ -628,7 +621,7 @@ fn selectors_ui( }; let mut changed_indices = false; - let mut indices = slice_selection.indices.clone().unwrap_or_default(); + let mut indices = slice_selection.indices.clone(); for index_slider in slider { let dim = &shape[index_slider.dimension as usize]; diff --git a/crates/viewer/re_viewport_blueprint/src/view.rs b/crates/viewer/re_viewport_blueprint/src/view.rs index e040eadcf27a..7d223dff19fb 100644 --- a/crates/viewer/re_viewport_blueprint/src/view.rs +++ b/crates/viewer/re_viewport_blueprint/src/view.rs @@ -137,19 +137,10 @@ impl ViewBlueprint { // This is a required component. Note that when loading views we crawl the subtree and so // cleared empty views paths may exist transiently. The fact that they have an empty class_identifier // is the marker that the have been cleared and not an error. - let class_identifier = results.component_instance::(0)?; - - let blueprint_archetypes::ViewBlueprint { - class_identifier, - display_name, - space_origin, - visible, - } = blueprint_archetypes::ViewBlueprint { - class_identifier, - display_name: results.component_instance::(0), - space_origin: results.component_instance::(0), - visible: results.component_instance::(0), - }; + let class_identifier = results.component_mono::()?; + let display_name = results.component_mono::(); + let space_origin = results.component_mono::(); + let visible = results.component_mono::(); let space_origin = space_origin.map_or_else(EntityPath::root, |origin| origin.0.into()); let class_identifier: ViewClassIdentifier = class_identifier.0.as_str().into(); @@ -373,12 +364,13 @@ impl ViewBlueprint { blueprint_query, self.id, ); - let ranges = property.component_array(); + let ranges = property.component_array::(); let time_range = ranges.ok().flatten().and_then(|ranges| { - blueprint_archetypes::VisibleTimeRanges { ranges } - .range_for_timeline(active_timeline.name().as_str()) - .cloned() + ranges + .iter() + .find(|range| range.timeline.as_str() == active_timeline.name().as_str()) + .map(|range| range.range.clone()) }); time_range.map_or_else( || { diff --git a/crates/viewer/re_viewport_blueprint/src/viewport_blueprint.rs b/crates/viewer/re_viewport_blueprint/src/viewport_blueprint.rs index 2142a7c4acbd..b2594f754134 100644 --- a/crates/viewer/re_viewport_blueprint/src/viewport_blueprint.rs +++ b/crates/viewer/re_viewport_blueprint/src/viewport_blueprint.rs @@ -93,19 +93,11 @@ impl ViewportBlueprint { blueprint_archetypes::ViewportBlueprint::all_components().iter(), ); - let blueprint_archetypes::ViewportBlueprint { - root_container, - maximized, - auto_layout, - auto_views, - past_viewer_recommendations, - } = blueprint_archetypes::ViewportBlueprint { - root_container: results.component_instance(0), - maximized: results.component_instance(0), - auto_layout: results.component_instance(0), - auto_views: results.component_instance(0), - past_viewer_recommendations: results.component_batch(), - }; + let root_container = results.component_mono::(); + let maximized = results.component_mono::(); + let auto_layout = results.component_mono::(); + let auto_views = results.component_mono::(); + let past_viewer_recommendations = results.component_batch::(); let root_container: Option = root_container.map(|id| id.0.into()); re_log::trace_once!("Loaded root_container: {root_container:?}");