re_types/blueprint/archetypes/
tensor_scalar_mapping.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 TensorScalarMapping {
27 pub mag_filter: Option<SerializedComponentBatch>,
31
32 pub colormap: Option<SerializedComponentBatch>,
34
35 pub gamma: Option<SerializedComponentBatch>,
43}
44
45impl TensorScalarMapping {
46 #[inline]
50 pub fn descriptor_mag_filter() -> ComponentDescriptor {
51 ComponentDescriptor {
52 archetype: Some("rerun.blueprint.archetypes.TensorScalarMapping".into()),
53 component: "TensorScalarMapping:mag_filter".into(),
54 component_type: Some("rerun.components.MagnificationFilter".into()),
55 }
56 }
57
58 #[inline]
62 pub fn descriptor_colormap() -> ComponentDescriptor {
63 ComponentDescriptor {
64 archetype: Some("rerun.blueprint.archetypes.TensorScalarMapping".into()),
65 component: "TensorScalarMapping:colormap".into(),
66 component_type: Some("rerun.components.Colormap".into()),
67 }
68 }
69
70 #[inline]
74 pub fn descriptor_gamma() -> ComponentDescriptor {
75 ComponentDescriptor {
76 archetype: Some("rerun.blueprint.archetypes.TensorScalarMapping".into()),
77 component: "TensorScalarMapping:gamma".into(),
78 component_type: Some("rerun.components.GammaCorrection".into()),
79 }
80 }
81}
82
83static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
84 once_cell::sync::Lazy::new(|| []);
85
86static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
87 once_cell::sync::Lazy::new(|| []);
88
89static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> =
90 once_cell::sync::Lazy::new(|| {
91 [
92 TensorScalarMapping::descriptor_mag_filter(),
93 TensorScalarMapping::descriptor_colormap(),
94 TensorScalarMapping::descriptor_gamma(),
95 ]
96 });
97
98static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> =
99 once_cell::sync::Lazy::new(|| {
100 [
101 TensorScalarMapping::descriptor_mag_filter(),
102 TensorScalarMapping::descriptor_colormap(),
103 TensorScalarMapping::descriptor_gamma(),
104 ]
105 });
106
107impl TensorScalarMapping {
108 pub const NUM_COMPONENTS: usize = 3usize;
110}
111
112impl ::re_types_core::Archetype for TensorScalarMapping {
113 #[inline]
114 fn name() -> ::re_types_core::ArchetypeName {
115 "rerun.blueprint.archetypes.TensorScalarMapping".into()
116 }
117
118 #[inline]
119 fn display_name() -> &'static str {
120 "Tensor scalar mapping"
121 }
122
123 #[inline]
124 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
125 REQUIRED_COMPONENTS.as_slice().into()
126 }
127
128 #[inline]
129 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
130 RECOMMENDED_COMPONENTS.as_slice().into()
131 }
132
133 #[inline]
134 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
135 OPTIONAL_COMPONENTS.as_slice().into()
136 }
137
138 #[inline]
139 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
140 ALL_COMPONENTS.as_slice().into()
141 }
142
143 #[inline]
144 fn from_arrow_components(
145 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
146 ) -> DeserializationResult<Self> {
147 re_tracing::profile_function!();
148 use ::re_types_core::{Loggable as _, ResultExt as _};
149 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
150 let mag_filter = arrays_by_descr
151 .get(&Self::descriptor_mag_filter())
152 .map(|array| {
153 SerializedComponentBatch::new(array.clone(), Self::descriptor_mag_filter())
154 });
155 let colormap = arrays_by_descr
156 .get(&Self::descriptor_colormap())
157 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colormap()));
158 let gamma = arrays_by_descr
159 .get(&Self::descriptor_gamma())
160 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_gamma()));
161 Ok(Self {
162 mag_filter,
163 colormap,
164 gamma,
165 })
166 }
167}
168
169impl ::re_types_core::AsComponents for TensorScalarMapping {
170 #[inline]
171 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
172 use ::re_types_core::Archetype as _;
173 [
174 self.mag_filter.clone(),
175 self.colormap.clone(),
176 self.gamma.clone(),
177 ]
178 .into_iter()
179 .flatten()
180 .collect()
181 }
182}
183
184impl ::re_types_core::ArchetypeReflectionMarker for TensorScalarMapping {}
185
186impl TensorScalarMapping {
187 #[inline]
189 pub fn new() -> Self {
190 Self {
191 mag_filter: None,
192 colormap: None,
193 gamma: None,
194 }
195 }
196
197 #[inline]
199 pub fn update_fields() -> Self {
200 Self::default()
201 }
202
203 #[inline]
205 pub fn clear_fields() -> Self {
206 use ::re_types_core::Loggable as _;
207 Self {
208 mag_filter: Some(SerializedComponentBatch::new(
209 crate::components::MagnificationFilter::arrow_empty(),
210 Self::descriptor_mag_filter(),
211 )),
212 colormap: Some(SerializedComponentBatch::new(
213 crate::components::Colormap::arrow_empty(),
214 Self::descriptor_colormap(),
215 )),
216 gamma: Some(SerializedComponentBatch::new(
217 crate::components::GammaCorrection::arrow_empty(),
218 Self::descriptor_gamma(),
219 )),
220 }
221 }
222
223 #[inline]
227 pub fn with_mag_filter(
228 mut self,
229 mag_filter: impl Into<crate::components::MagnificationFilter>,
230 ) -> Self {
231 self.mag_filter = try_serialize_field(Self::descriptor_mag_filter(), [mag_filter]);
232 self
233 }
234
235 #[inline]
237 pub fn with_colormap(mut self, colormap: impl Into<crate::components::Colormap>) -> Self {
238 self.colormap = try_serialize_field(Self::descriptor_colormap(), [colormap]);
239 self
240 }
241
242 #[inline]
250 pub fn with_gamma(mut self, gamma: impl Into<crate::components::GammaCorrection>) -> Self {
251 self.gamma = try_serialize_field(Self::descriptor_gamma(), [gamma]);
252 self
253 }
254}
255
256impl ::re_byte_size::SizeBytes for TensorScalarMapping {
257 #[inline]
258 fn heap_size_bytes(&self) -> u64 {
259 self.mag_filter.heap_size_bytes()
260 + self.colormap.heap_size_bytes()
261 + self.gamma.heap_size_bytes()
262 }
263}