re_types/blueprint/archetypes/
plot_legend.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 PlotLegend {
27 pub corner: Option<SerializedComponentBatch>,
31
32 pub visible: Option<SerializedComponentBatch>,
36}
37
38impl PlotLegend {
39 #[inline]
43 pub fn descriptor_corner() -> ComponentDescriptor {
44 ComponentDescriptor {
45 archetype: Some("rerun.blueprint.archetypes.PlotLegend".into()),
46 component: "PlotLegend:corner".into(),
47 component_type: Some("rerun.blueprint.components.Corner2D".into()),
48 }
49 }
50
51 #[inline]
55 pub fn descriptor_visible() -> ComponentDescriptor {
56 ComponentDescriptor {
57 archetype: Some("rerun.blueprint.archetypes.PlotLegend".into()),
58 component: "PlotLegend:visible".into(),
59 component_type: Some("rerun.components.Visible".into()),
60 }
61 }
62}
63
64static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
65 once_cell::sync::Lazy::new(|| []);
66
67static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
68 once_cell::sync::Lazy::new(|| []);
69
70static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
71 once_cell::sync::Lazy::new(|| {
72 [
73 PlotLegend::descriptor_corner(),
74 PlotLegend::descriptor_visible(),
75 ]
76 });
77
78static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
79 once_cell::sync::Lazy::new(|| {
80 [
81 PlotLegend::descriptor_corner(),
82 PlotLegend::descriptor_visible(),
83 ]
84 });
85
86impl PlotLegend {
87 pub const NUM_COMPONENTS: usize = 2usize;
89}
90
91impl ::re_types_core::Archetype for PlotLegend {
92 #[inline]
93 fn name() -> ::re_types_core::ArchetypeName {
94 "rerun.blueprint.archetypes.PlotLegend".into()
95 }
96
97 #[inline]
98 fn display_name() -> &'static str {
99 "Plot legend"
100 }
101
102 #[inline]
103 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
104 REQUIRED_COMPONENTS.as_slice().into()
105 }
106
107 #[inline]
108 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
109 RECOMMENDED_COMPONENTS.as_slice().into()
110 }
111
112 #[inline]
113 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
114 OPTIONAL_COMPONENTS.as_slice().into()
115 }
116
117 #[inline]
118 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
119 ALL_COMPONENTS.as_slice().into()
120 }
121
122 #[inline]
123 fn from_arrow_components(
124 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
125 ) -> DeserializationResult<Self> {
126 re_tracing::profile_function!();
127 use ::re_types_core::{Loggable as _, ResultExt as _};
128 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
129 let corner = arrays_by_descr
130 .get(&Self::descriptor_corner())
131 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_corner()));
132 let visible = arrays_by_descr
133 .get(&Self::descriptor_visible())
134 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_visible()));
135 Ok(Self { corner, visible })
136 }
137}
138
139impl ::re_types_core::AsComponents for PlotLegend {
140 #[inline]
141 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
142 use ::re_types_core::Archetype as _;
143 [self.corner.clone(), self.visible.clone()]
144 .into_iter()
145 .flatten()
146 .collect()
147 }
148}
149
150impl ::re_types_core::ArchetypeReflectionMarker for PlotLegend {}
151
152impl PlotLegend {
153 #[inline]
155 pub fn new() -> Self {
156 Self {
157 corner: None,
158 visible: None,
159 }
160 }
161
162 #[inline]
164 pub fn update_fields() -> Self {
165 Self::default()
166 }
167
168 #[inline]
170 pub fn clear_fields() -> Self {
171 use ::re_types_core::Loggable as _;
172 Self {
173 corner: Some(SerializedComponentBatch::new(
174 crate::blueprint::components::Corner2D::arrow_empty(),
175 Self::descriptor_corner(),
176 )),
177 visible: Some(SerializedComponentBatch::new(
178 crate::components::Visible::arrow_empty(),
179 Self::descriptor_visible(),
180 )),
181 }
182 }
183
184 #[inline]
188 pub fn with_corner(
189 mut self,
190 corner: impl Into<crate::blueprint::components::Corner2D>,
191 ) -> Self {
192 self.corner = try_serialize_field(Self::descriptor_corner(), [corner]);
193 self
194 }
195
196 #[inline]
200 pub fn with_visible(mut self, visible: impl Into<crate::components::Visible>) -> Self {
201 self.visible = try_serialize_field(Self::descriptor_visible(), [visible]);
202 self
203 }
204}
205
206impl ::re_byte_size::SizeBytes for PlotLegend {
207 #[inline]
208 fn heap_size_bytes(&self) -> u64 {
209 self.corner.heap_size_bytes() + self.visible.heap_size_bytes()
210 }
211}