re_types/blueprint/archetypes/
visual_bounds2d.rs

1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs
2// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs".
3
4#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::clone_on_copy)]
8#![allow(clippy::cloned_instead_of_copied)]
9#![allow(clippy::map_flatten)]
10#![allow(clippy::needless_question_mark)]
11#![allow(clippy::new_without_default)]
12#![allow(clippy::redundant_closure)]
13#![allow(clippy::too_many_arguments)]
14#![allow(clippy::too_many_lines)]
15
16use ::re_types_core::try_serialize_field;
17use ::re_types_core::SerializationResult;
18use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
19use ::re_types_core::{ComponentDescriptor, ComponentType};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22/// **Archetype**: Controls the visual bounds of a 2D view.
23///
24/// Everything within these bounds are guaranteed to be visible.
25/// Somethings outside of these bounds may also be visible due to letterboxing.
26///
27/// If no visual bounds are set, it will be determined automatically,
28/// based on the bounding-box of the data or other camera information present in the view.
29///
30/// ⚠️ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
31#[derive(Clone, Debug, Default)]
32pub struct VisualBounds2D {
33    /// Controls the visible range of a 2D view.
34    ///
35    /// Use this to control pan & zoom of the view.
36    pub range: Option<SerializedComponentBatch>,
37}
38
39impl VisualBounds2D {
40    /// Returns the [`ComponentDescriptor`] for [`Self::range`].
41    ///
42    /// The corresponding component is [`crate::blueprint::components::VisualBounds2D`].
43    #[inline]
44    pub fn descriptor_range() -> ComponentDescriptor {
45        ComponentDescriptor {
46            archetype: Some("rerun.blueprint.archetypes.VisualBounds2D".into()),
47            component: "VisualBounds2D:range".into(),
48            component_type: Some("rerun.blueprint.components.VisualBounds2D".into()),
49        }
50    }
51}
52
53static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
54    once_cell::sync::Lazy::new(|| [VisualBounds2D::descriptor_range()]);
55
56static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
57    once_cell::sync::Lazy::new(|| []);
58
59static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
60    once_cell::sync::Lazy::new(|| []);
61
62static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
63    once_cell::sync::Lazy::new(|| [VisualBounds2D::descriptor_range()]);
64
65impl VisualBounds2D {
66    /// The total number of components in the archetype: 1 required, 0 recommended, 0 optional
67    pub const NUM_COMPONENTS: usize = 1usize;
68}
69
70impl ::re_types_core::Archetype for VisualBounds2D {
71    #[inline]
72    fn name() -> ::re_types_core::ArchetypeName {
73        "rerun.blueprint.archetypes.VisualBounds2D".into()
74    }
75
76    #[inline]
77    fn display_name() -> &'static str {
78        "Visual bounds 2D"
79    }
80
81    #[inline]
82    fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
83        REQUIRED_COMPONENTS.as_slice().into()
84    }
85
86    #[inline]
87    fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
88        RECOMMENDED_COMPONENTS.as_slice().into()
89    }
90
91    #[inline]
92    fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
93        OPTIONAL_COMPONENTS.as_slice().into()
94    }
95
96    #[inline]
97    fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
98        ALL_COMPONENTS.as_slice().into()
99    }
100
101    #[inline]
102    fn from_arrow_components(
103        arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
104    ) -> DeserializationResult<Self> {
105        re_tracing::profile_function!();
106        use ::re_types_core::{Loggable as _, ResultExt as _};
107        let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
108        let range = arrays_by_descr
109            .get(&Self::descriptor_range())
110            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_range()));
111        Ok(Self { range })
112    }
113}
114
115impl ::re_types_core::AsComponents for VisualBounds2D {
116    #[inline]
117    fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
118        use ::re_types_core::Archetype as _;
119        std::iter::once(self.range.clone()).flatten().collect()
120    }
121}
122
123impl ::re_types_core::ArchetypeReflectionMarker for VisualBounds2D {}
124
125impl VisualBounds2D {
126    /// Create a new `VisualBounds2D`.
127    #[inline]
128    pub fn new(range: impl Into<crate::blueprint::components::VisualBounds2D>) -> Self {
129        Self {
130            range: try_serialize_field(Self::descriptor_range(), [range]),
131        }
132    }
133
134    /// Update only some specific fields of a `VisualBounds2D`.
135    #[inline]
136    pub fn update_fields() -> Self {
137        Self::default()
138    }
139
140    /// Clear all the fields of a `VisualBounds2D`.
141    #[inline]
142    pub fn clear_fields() -> Self {
143        use ::re_types_core::Loggable as _;
144        Self {
145            range: Some(SerializedComponentBatch::new(
146                crate::blueprint::components::VisualBounds2D::arrow_empty(),
147                Self::descriptor_range(),
148            )),
149        }
150    }
151
152    /// Controls the visible range of a 2D view.
153    ///
154    /// Use this to control pan & zoom of the view.
155    #[inline]
156    pub fn with_range(
157        mut self,
158        range: impl Into<crate::blueprint::components::VisualBounds2D>,
159    ) -> Self {
160        self.range = try_serialize_field(Self::descriptor_range(), [range]);
161        self
162    }
163}
164
165impl ::re_byte_size::SizeBytes for VisualBounds2D {
166    #[inline]
167    fn heap_size_bytes(&self) -> u64 {
168        self.range.heap_size_bytes()
169    }
170}