#![allow(unused_imports)]
#![allow(unused_parens)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::cloned_instead_of_copied)]
#![allow(clippy::map_flatten)]
#![allow(clippy::needless_question_mark)]
#![allow(clippy::new_without_default)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::too_many_lines)]
use ::re_types_core::try_serialize_field;
use ::re_types_core::SerializationResult;
use ::re_types_core::{ComponentBatch, SerializedComponentBatch};
use ::re_types_core::{ComponentDescriptor, ComponentName};
use ::re_types_core::{DeserializationError, DeserializationResult};
#[derive(Clone, Debug, PartialEq, Default)]
pub struct Arrows2D {
pub vectors: Option<SerializedComponentBatch>,
pub origins: Option<SerializedComponentBatch>,
pub radii: Option<SerializedComponentBatch>,
pub colors: Option<SerializedComponentBatch>,
pub labels: Option<SerializedComponentBatch>,
pub show_labels: Option<SerializedComponentBatch>,
pub draw_order: Option<SerializedComponentBatch>,
pub class_ids: Option<SerializedComponentBatch>,
}
impl Arrows2D {
#[inline]
pub fn descriptor_vectors() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.Vector2D".into(),
archetype_field_name: Some("vectors".into()),
}
}
#[inline]
pub fn descriptor_origins() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.Position2D".into(),
archetype_field_name: Some("origins".into()),
}
}
#[inline]
pub fn descriptor_radii() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.Radius".into(),
archetype_field_name: Some("radii".into()),
}
}
#[inline]
pub fn descriptor_colors() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.Color".into(),
archetype_field_name: Some("colors".into()),
}
}
#[inline]
pub fn descriptor_labels() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.Text".into(),
archetype_field_name: Some("labels".into()),
}
}
#[inline]
pub fn descriptor_show_labels() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.ShowLabels".into(),
archetype_field_name: Some("show_labels".into()),
}
}
#[inline]
pub fn descriptor_draw_order() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.DrawOrder".into(),
archetype_field_name: Some("draw_order".into()),
}
}
#[inline]
pub fn descriptor_class_ids() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.ClassId".into(),
archetype_field_name: Some("class_ids".into()),
}
}
#[inline]
pub fn descriptor_indicator() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Arrows2D".into()),
component_name: "rerun.components.Arrows2DIndicator".into(),
archetype_field_name: None,
}
}
}
static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
once_cell::sync::Lazy::new(|| [Arrows2D::descriptor_vectors()]);
static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
once_cell::sync::Lazy::new(|| {
[
Arrows2D::descriptor_origins(),
Arrows2D::descriptor_indicator(),
]
});
static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 6usize]> =
once_cell::sync::Lazy::new(|| {
[
Arrows2D::descriptor_radii(),
Arrows2D::descriptor_colors(),
Arrows2D::descriptor_labels(),
Arrows2D::descriptor_show_labels(),
Arrows2D::descriptor_draw_order(),
Arrows2D::descriptor_class_ids(),
]
});
static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 9usize]> =
once_cell::sync::Lazy::new(|| {
[
Arrows2D::descriptor_vectors(),
Arrows2D::descriptor_origins(),
Arrows2D::descriptor_indicator(),
Arrows2D::descriptor_radii(),
Arrows2D::descriptor_colors(),
Arrows2D::descriptor_labels(),
Arrows2D::descriptor_show_labels(),
Arrows2D::descriptor_draw_order(),
Arrows2D::descriptor_class_ids(),
]
});
impl Arrows2D {
pub const NUM_COMPONENTS: usize = 9usize;
}
pub type Arrows2DIndicator = ::re_types_core::GenericIndicatorComponent<Arrows2D>;
impl ::re_types_core::Archetype for Arrows2D {
type Indicator = Arrows2DIndicator;
#[inline]
fn name() -> ::re_types_core::ArchetypeName {
"rerun.archetypes.Arrows2D".into()
}
#[inline]
fn display_name() -> &'static str {
"Arrows 2D"
}
#[inline]
fn indicator() -> SerializedComponentBatch {
#[allow(clippy::unwrap_used)]
Arrows2DIndicator::DEFAULT.serialized().unwrap()
}
#[inline]
fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
REQUIRED_COMPONENTS.as_slice().into()
}
#[inline]
fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
RECOMMENDED_COMPONENTS.as_slice().into()
}
#[inline]
fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
OPTIONAL_COMPONENTS.as_slice().into()
}
#[inline]
fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
ALL_COMPONENTS.as_slice().into()
}
#[inline]
fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
) -> DeserializationResult<Self> {
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 vectors = arrays_by_descr
.get(&Self::descriptor_vectors())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_vectors()));
let origins = arrays_by_descr
.get(&Self::descriptor_origins())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_origins()));
let radii = arrays_by_descr
.get(&Self::descriptor_radii())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_radii()));
let colors = arrays_by_descr
.get(&Self::descriptor_colors())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
let labels = arrays_by_descr
.get(&Self::descriptor_labels())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_labels()));
let show_labels = arrays_by_descr
.get(&Self::descriptor_show_labels())
.map(|array| {
SerializedComponentBatch::new(array.clone(), Self::descriptor_show_labels())
});
let draw_order = arrays_by_descr
.get(&Self::descriptor_draw_order())
.map(|array| {
SerializedComponentBatch::new(array.clone(), Self::descriptor_draw_order())
});
let class_ids = arrays_by_descr
.get(&Self::descriptor_class_ids())
.map(|array| {
SerializedComponentBatch::new(array.clone(), Self::descriptor_class_ids())
});
Ok(Self {
vectors,
origins,
radii,
colors,
labels,
show_labels,
draw_order,
class_ids,
})
}
}
impl ::re_types_core::AsComponents for Arrows2D {
#[inline]
fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
use ::re_types_core::Archetype as _;
[
Some(Self::indicator()),
self.vectors.clone(),
self.origins.clone(),
self.radii.clone(),
self.colors.clone(),
self.labels.clone(),
self.show_labels.clone(),
self.draw_order.clone(),
self.class_ids.clone(),
]
.into_iter()
.flatten()
.collect()
}
}
impl ::re_types_core::ArchetypeReflectionMarker for Arrows2D {}
impl Arrows2D {
#[inline]
pub(crate) fn new(
vectors: impl IntoIterator<Item = impl Into<crate::components::Vector2D>>,
) -> Self {
Self {
vectors: try_serialize_field(Self::descriptor_vectors(), vectors),
origins: None,
radii: None,
colors: None,
labels: None,
show_labels: None,
draw_order: None,
class_ids: None,
}
}
#[inline]
pub fn update_fields() -> Self {
Self::default()
}
#[inline]
pub fn clear_fields() -> Self {
use ::re_types_core::Loggable as _;
Self {
vectors: Some(SerializedComponentBatch::new(
crate::components::Vector2D::arrow_empty(),
Self::descriptor_vectors(),
)),
origins: Some(SerializedComponentBatch::new(
crate::components::Position2D::arrow_empty(),
Self::descriptor_origins(),
)),
radii: Some(SerializedComponentBatch::new(
crate::components::Radius::arrow_empty(),
Self::descriptor_radii(),
)),
colors: Some(SerializedComponentBatch::new(
crate::components::Color::arrow_empty(),
Self::descriptor_colors(),
)),
labels: Some(SerializedComponentBatch::new(
crate::components::Text::arrow_empty(),
Self::descriptor_labels(),
)),
show_labels: Some(SerializedComponentBatch::new(
crate::components::ShowLabels::arrow_empty(),
Self::descriptor_show_labels(),
)),
draw_order: Some(SerializedComponentBatch::new(
crate::components::DrawOrder::arrow_empty(),
Self::descriptor_draw_order(),
)),
class_ids: Some(SerializedComponentBatch::new(
crate::components::ClassId::arrow_empty(),
Self::descriptor_class_ids(),
)),
}
}
#[inline]
pub fn columns<I>(
self,
_lengths: I,
) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
where
I: IntoIterator<Item = usize> + Clone,
{
let columns = [
self.vectors
.map(|vectors| vectors.partitioned(_lengths.clone()))
.transpose()?,
self.origins
.map(|origins| origins.partitioned(_lengths.clone()))
.transpose()?,
self.radii
.map(|radii| radii.partitioned(_lengths.clone()))
.transpose()?,
self.colors
.map(|colors| colors.partitioned(_lengths.clone()))
.transpose()?,
self.labels
.map(|labels| labels.partitioned(_lengths.clone()))
.transpose()?,
self.show_labels
.map(|show_labels| show_labels.partitioned(_lengths.clone()))
.transpose()?,
self.draw_order
.map(|draw_order| draw_order.partitioned(_lengths.clone()))
.transpose()?,
self.class_ids
.map(|class_ids| class_ids.partitioned(_lengths.clone()))
.transpose()?,
];
Ok(columns
.into_iter()
.flatten()
.chain([::re_types_core::indicator_column::<Self>(
_lengths.into_iter().count(),
)?]))
}
#[inline]
pub fn columns_of_unit_batches(
self,
) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
let len_vectors = self.vectors.as_ref().map(|b| b.array.len());
let len_origins = self.origins.as_ref().map(|b| b.array.len());
let len_radii = self.radii.as_ref().map(|b| b.array.len());
let len_colors = self.colors.as_ref().map(|b| b.array.len());
let len_labels = self.labels.as_ref().map(|b| b.array.len());
let len_show_labels = self.show_labels.as_ref().map(|b| b.array.len());
let len_draw_order = self.draw_order.as_ref().map(|b| b.array.len());
let len_class_ids = self.class_ids.as_ref().map(|b| b.array.len());
let len = None
.or(len_vectors)
.or(len_origins)
.or(len_radii)
.or(len_colors)
.or(len_labels)
.or(len_show_labels)
.or(len_draw_order)
.or(len_class_ids)
.unwrap_or(0);
self.columns(std::iter::repeat(1).take(len))
}
#[inline]
pub fn with_vectors(
mut self,
vectors: impl IntoIterator<Item = impl Into<crate::components::Vector2D>>,
) -> Self {
self.vectors = try_serialize_field(Self::descriptor_vectors(), vectors);
self
}
#[inline]
pub fn with_origins(
mut self,
origins: impl IntoIterator<Item = impl Into<crate::components::Position2D>>,
) -> Self {
self.origins = try_serialize_field(Self::descriptor_origins(), origins);
self
}
#[inline]
pub fn with_radii(
mut self,
radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
) -> Self {
self.radii = try_serialize_field(Self::descriptor_radii(), radii);
self
}
#[inline]
pub fn with_colors(
mut self,
colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
) -> Self {
self.colors = try_serialize_field(Self::descriptor_colors(), colors);
self
}
#[inline]
pub fn with_labels(
mut self,
labels: impl IntoIterator<Item = impl Into<crate::components::Text>>,
) -> Self {
self.labels = try_serialize_field(Self::descriptor_labels(), labels);
self
}
#[inline]
pub fn with_show_labels(
mut self,
show_labels: impl Into<crate::components::ShowLabels>,
) -> Self {
self.show_labels = try_serialize_field(Self::descriptor_show_labels(), [show_labels]);
self
}
#[inline]
pub fn with_many_show_labels(
mut self,
show_labels: impl IntoIterator<Item = impl Into<crate::components::ShowLabels>>,
) -> Self {
self.show_labels = try_serialize_field(Self::descriptor_show_labels(), show_labels);
self
}
#[inline]
pub fn with_draw_order(mut self, draw_order: impl Into<crate::components::DrawOrder>) -> Self {
self.draw_order = try_serialize_field(Self::descriptor_draw_order(), [draw_order]);
self
}
#[inline]
pub fn with_many_draw_order(
mut self,
draw_order: impl IntoIterator<Item = impl Into<crate::components::DrawOrder>>,
) -> Self {
self.draw_order = try_serialize_field(Self::descriptor_draw_order(), draw_order);
self
}
#[inline]
pub fn with_class_ids(
mut self,
class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
) -> Self {
self.class_ids = try_serialize_field(Self::descriptor_class_ids(), class_ids);
self
}
}
impl ::re_byte_size::SizeBytes for Arrows2D {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.vectors.heap_size_bytes()
+ self.origins.heap_size_bytes()
+ self.radii.heap_size_bytes()
+ self.colors.heap_size_bytes()
+ self.labels.heap_size_bytes()
+ self.show_labels.heap_size_bytes()
+ self.draw_order.heap_size_bytes()
+ self.class_ids.heap_size_bytes()
}
}