re_types/blueprint/archetypes/
viewport_blueprint.rs1#![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#[derive(Clone, Debug, Default)]
26pub struct ViewportBlueprint {
27 pub root_container: Option<SerializedComponentBatch>,
29
30 pub maximized: Option<SerializedComponentBatch>,
32
33 pub auto_layout: Option<SerializedComponentBatch>,
38
39 pub auto_views: Option<SerializedComponentBatch>,
45
46 pub past_viewer_recommendations: Option<SerializedComponentBatch>,
53}
54
55impl ViewportBlueprint {
56 #[inline]
60 pub fn descriptor_root_container() -> ComponentDescriptor {
61 ComponentDescriptor {
62 archetype: Some("rerun.blueprint.archetypes.ViewportBlueprint".into()),
63 component: "ViewportBlueprint:root_container".into(),
64 component_type: Some("rerun.blueprint.components.RootContainer".into()),
65 }
66 }
67
68 #[inline]
72 pub fn descriptor_maximized() -> ComponentDescriptor {
73 ComponentDescriptor {
74 archetype: Some("rerun.blueprint.archetypes.ViewportBlueprint".into()),
75 component: "ViewportBlueprint:maximized".into(),
76 component_type: Some("rerun.blueprint.components.ViewMaximized".into()),
77 }
78 }
79
80 #[inline]
84 pub fn descriptor_auto_layout() -> ComponentDescriptor {
85 ComponentDescriptor {
86 archetype: Some("rerun.blueprint.archetypes.ViewportBlueprint".into()),
87 component: "ViewportBlueprint:auto_layout".into(),
88 component_type: Some("rerun.blueprint.components.AutoLayout".into()),
89 }
90 }
91
92 #[inline]
96 pub fn descriptor_auto_views() -> ComponentDescriptor {
97 ComponentDescriptor {
98 archetype: Some("rerun.blueprint.archetypes.ViewportBlueprint".into()),
99 component: "ViewportBlueprint:auto_views".into(),
100 component_type: Some("rerun.blueprint.components.AutoViews".into()),
101 }
102 }
103
104 #[inline]
108 pub fn descriptor_past_viewer_recommendations() -> ComponentDescriptor {
109 ComponentDescriptor {
110 archetype: Some("rerun.blueprint.archetypes.ViewportBlueprint".into()),
111 component: "ViewportBlueprint:past_viewer_recommendations".into(),
112 component_type: Some("rerun.blueprint.components.ViewerRecommendationHash".into()),
113 }
114 }
115}
116
117static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
118 once_cell::sync::Lazy::new(|| []);
119
120static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
121 once_cell::sync::Lazy::new(|| []);
122
123static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 5usize]> =
124 once_cell::sync::Lazy::new(|| {
125 [
126 ViewportBlueprint::descriptor_root_container(),
127 ViewportBlueprint::descriptor_maximized(),
128 ViewportBlueprint::descriptor_auto_layout(),
129 ViewportBlueprint::descriptor_auto_views(),
130 ViewportBlueprint::descriptor_past_viewer_recommendations(),
131 ]
132 });
133
134static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 5usize]> =
135 once_cell::sync::Lazy::new(|| {
136 [
137 ViewportBlueprint::descriptor_root_container(),
138 ViewportBlueprint::descriptor_maximized(),
139 ViewportBlueprint::descriptor_auto_layout(),
140 ViewportBlueprint::descriptor_auto_views(),
141 ViewportBlueprint::descriptor_past_viewer_recommendations(),
142 ]
143 });
144
145impl ViewportBlueprint {
146 pub const NUM_COMPONENTS: usize = 5usize;
148}
149
150impl ::re_types_core::Archetype for ViewportBlueprint {
151 #[inline]
152 fn name() -> ::re_types_core::ArchetypeName {
153 "rerun.blueprint.archetypes.ViewportBlueprint".into()
154 }
155
156 #[inline]
157 fn display_name() -> &'static str {
158 "Viewport blueprint"
159 }
160
161 #[inline]
162 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
163 REQUIRED_COMPONENTS.as_slice().into()
164 }
165
166 #[inline]
167 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
168 RECOMMENDED_COMPONENTS.as_slice().into()
169 }
170
171 #[inline]
172 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
173 OPTIONAL_COMPONENTS.as_slice().into()
174 }
175
176 #[inline]
177 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
178 ALL_COMPONENTS.as_slice().into()
179 }
180
181 #[inline]
182 fn from_arrow_components(
183 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
184 ) -> DeserializationResult<Self> {
185 re_tracing::profile_function!();
186 use ::re_types_core::{Loggable as _, ResultExt as _};
187 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
188 let root_container = arrays_by_descr
189 .get(&Self::descriptor_root_container())
190 .map(|array| {
191 SerializedComponentBatch::new(array.clone(), Self::descriptor_root_container())
192 });
193 let maximized = arrays_by_descr
194 .get(&Self::descriptor_maximized())
195 .map(|array| {
196 SerializedComponentBatch::new(array.clone(), Self::descriptor_maximized())
197 });
198 let auto_layout = arrays_by_descr
199 .get(&Self::descriptor_auto_layout())
200 .map(|array| {
201 SerializedComponentBatch::new(array.clone(), Self::descriptor_auto_layout())
202 });
203 let auto_views = arrays_by_descr
204 .get(&Self::descriptor_auto_views())
205 .map(|array| {
206 SerializedComponentBatch::new(array.clone(), Self::descriptor_auto_views())
207 });
208 let past_viewer_recommendations = arrays_by_descr
209 .get(&Self::descriptor_past_viewer_recommendations())
210 .map(|array| {
211 SerializedComponentBatch::new(
212 array.clone(),
213 Self::descriptor_past_viewer_recommendations(),
214 )
215 });
216 Ok(Self {
217 root_container,
218 maximized,
219 auto_layout,
220 auto_views,
221 past_viewer_recommendations,
222 })
223 }
224}
225
226impl ::re_types_core::AsComponents for ViewportBlueprint {
227 #[inline]
228 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
229 use ::re_types_core::Archetype as _;
230 [
231 self.root_container.clone(),
232 self.maximized.clone(),
233 self.auto_layout.clone(),
234 self.auto_views.clone(),
235 self.past_viewer_recommendations.clone(),
236 ]
237 .into_iter()
238 .flatten()
239 .collect()
240 }
241}
242
243impl ::re_types_core::ArchetypeReflectionMarker for ViewportBlueprint {}
244
245impl ViewportBlueprint {
246 #[inline]
248 pub fn new() -> Self {
249 Self {
250 root_container: None,
251 maximized: None,
252 auto_layout: None,
253 auto_views: None,
254 past_viewer_recommendations: None,
255 }
256 }
257
258 #[inline]
260 pub fn update_fields() -> Self {
261 Self::default()
262 }
263
264 #[inline]
266 pub fn clear_fields() -> Self {
267 use ::re_types_core::Loggable as _;
268 Self {
269 root_container: Some(SerializedComponentBatch::new(
270 crate::blueprint::components::RootContainer::arrow_empty(),
271 Self::descriptor_root_container(),
272 )),
273 maximized: Some(SerializedComponentBatch::new(
274 crate::blueprint::components::ViewMaximized::arrow_empty(),
275 Self::descriptor_maximized(),
276 )),
277 auto_layout: Some(SerializedComponentBatch::new(
278 crate::blueprint::components::AutoLayout::arrow_empty(),
279 Self::descriptor_auto_layout(),
280 )),
281 auto_views: Some(SerializedComponentBatch::new(
282 crate::blueprint::components::AutoViews::arrow_empty(),
283 Self::descriptor_auto_views(),
284 )),
285 past_viewer_recommendations: Some(SerializedComponentBatch::new(
286 crate::blueprint::components::ViewerRecommendationHash::arrow_empty(),
287 Self::descriptor_past_viewer_recommendations(),
288 )),
289 }
290 }
291
292 #[inline]
294 pub fn with_root_container(
295 mut self,
296 root_container: impl Into<crate::blueprint::components::RootContainer>,
297 ) -> Self {
298 self.root_container =
299 try_serialize_field(Self::descriptor_root_container(), [root_container]);
300 self
301 }
302
303 #[inline]
305 pub fn with_maximized(
306 mut self,
307 maximized: impl Into<crate::blueprint::components::ViewMaximized>,
308 ) -> Self {
309 self.maximized = try_serialize_field(Self::descriptor_maximized(), [maximized]);
310 self
311 }
312
313 #[inline]
318 pub fn with_auto_layout(
319 mut self,
320 auto_layout: impl Into<crate::blueprint::components::AutoLayout>,
321 ) -> Self {
322 self.auto_layout = try_serialize_field(Self::descriptor_auto_layout(), [auto_layout]);
323 self
324 }
325
326 #[inline]
332 pub fn with_auto_views(
333 mut self,
334 auto_views: impl Into<crate::blueprint::components::AutoViews>,
335 ) -> Self {
336 self.auto_views = try_serialize_field(Self::descriptor_auto_views(), [auto_views]);
337 self
338 }
339
340 #[inline]
347 pub fn with_past_viewer_recommendations(
348 mut self,
349 past_viewer_recommendations: impl IntoIterator<
350 Item = impl Into<crate::blueprint::components::ViewerRecommendationHash>,
351 >,
352 ) -> Self {
353 self.past_viewer_recommendations = try_serialize_field(
354 Self::descriptor_past_viewer_recommendations(),
355 past_viewer_recommendations,
356 );
357 self
358 }
359}
360
361impl ::re_byte_size::SizeBytes for ViewportBlueprint {
362 #[inline]
363 fn heap_size_bytes(&self) -> u64 {
364 self.root_container.heap_size_bytes()
365 + self.maximized.heap_size_bytes()
366 + self.auto_layout.heap_size_bytes()
367 + self.auto_views.heap_size_bytes()
368 + self.past_viewer_recommendations.heap_size_bytes()
369 }
370}