re_types/blueprint/components/
eye3d_kind.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/components/eye3d_kind.fbs".
3
4#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::allow_attributes)]
8#![allow(clippy::clone_on_copy)]
9#![allow(clippy::cloned_instead_of_copied)]
10#![allow(clippy::map_flatten)]
11#![allow(clippy::needless_question_mark)]
12#![allow(clippy::new_without_default)]
13#![allow(clippy::redundant_closure)]
14#![allow(clippy::too_many_arguments)]
15#![allow(clippy::too_many_lines)]
16#![allow(clippy::wildcard_imports)]
17#![allow(non_camel_case_types)]
18
19use ::re_types_core::SerializationResult;
20use ::re_types_core::try_serialize_field;
21use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
22use ::re_types_core::{ComponentDescriptor, ComponentType};
23use ::re_types_core::{DeserializationError, DeserializationResult};
24
25/// **Component**: The kind of the 3D eye to view a scene in a [`views::Spatial3DView`][crate::blueprint::views::Spatial3DView].
26///
27/// This is used to specify how the controls of the view react to user input (such as mouse gestures).
28#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)]
29#[repr(u8)]
30pub enum Eye3DKind {
31    /// First person point of view.
32    ///
33    /// The camera perspective as if one is seeing it through the eyes of a person as popularized by first-person games.
34    /// The center of rotation is the position of the eye (the camera).
35    /// Dragging the mouse on the spatial 3D view, will rotation the scene as if one is moving
36    /// their head around.
37    FirstPerson = 1,
38
39    /// Orbital eye.
40    ///
41    /// The center of rotation is located to a center location in front of the eye (it is different from the eye
42    /// location itself), as if the eye was orbiting around the scene.
43    #[default]
44    Orbital = 2,
45}
46
47impl ::re_types_core::Component for Eye3DKind {
48    #[inline]
49    fn name() -> ComponentType {
50        "rerun.blueprint.components.Eye3DKind".into()
51    }
52}
53
54::re_types_core::macros::impl_into_cow!(Eye3DKind);
55
56impl ::re_types_core::Loggable for Eye3DKind {
57    #[inline]
58    fn arrow_datatype() -> arrow::datatypes::DataType {
59        use arrow::datatypes::*;
60        DataType::UInt8
61    }
62
63    fn to_arrow_opt<'a>(
64        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
65    ) -> SerializationResult<arrow::array::ArrayRef>
66    where
67        Self: Clone + 'a,
68    {
69        #![allow(clippy::manual_is_variant_and)]
70        use ::re_types_core::{Loggable as _, ResultExt as _, arrow_helpers::as_array_ref};
71        use arrow::{array::*, buffer::*, datatypes::*};
72        Ok({
73            let (somes, data0): (Vec<_>, Vec<_>) = data
74                .into_iter()
75                .map(|datum| {
76                    let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
77                    let datum = datum.map(|datum| *datum as u8);
78                    (datum.is_some(), datum)
79                })
80                .unzip();
81            let data0_validity: Option<arrow::buffer::NullBuffer> = {
82                let any_nones = somes.iter().any(|some| !*some);
83                any_nones.then(|| somes.into())
84            };
85            as_array_ref(PrimitiveArray::<UInt8Type>::new(
86                ScalarBuffer::from(
87                    data0
88                        .into_iter()
89                        .map(|v| v.unwrap_or_default())
90                        .collect::<Vec<_>>(),
91                ),
92                data0_validity,
93            ))
94        })
95    }
96
97    fn from_arrow_opt(
98        arrow_data: &dyn arrow::array::Array,
99    ) -> DeserializationResult<Vec<Option<Self>>>
100    where
101        Self: Sized,
102    {
103        use ::re_types_core::{Loggable as _, ResultExt as _, arrow_zip_validity::ZipValidity};
104        use arrow::{array::*, buffer::*, datatypes::*};
105        Ok(arrow_data
106            .as_any()
107            .downcast_ref::<UInt8Array>()
108            .ok_or_else(|| {
109                let expected = Self::arrow_datatype();
110                let actual = arrow_data.data_type().clone();
111                DeserializationError::datatype_mismatch(expected, actual)
112            })
113            .with_context("rerun.blueprint.components.Eye3DKind#enum")?
114            .into_iter()
115            .map(|typ| match typ {
116                Some(1) => Ok(Some(Self::FirstPerson)),
117                Some(2) => Ok(Some(Self::Orbital)),
118                None => Ok(None),
119                Some(invalid) => Err(DeserializationError::missing_union_arm(
120                    Self::arrow_datatype(),
121                    "<invalid>",
122                    invalid as _,
123                )),
124            })
125            .collect::<DeserializationResult<Vec<Option<_>>>>()
126            .with_context("rerun.blueprint.components.Eye3DKind")?)
127    }
128}
129
130impl std::fmt::Display for Eye3DKind {
131    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
132        match self {
133            Self::FirstPerson => write!(f, "FirstPerson"),
134            Self::Orbital => write!(f, "Orbital"),
135        }
136    }
137}
138
139impl ::re_types_core::reflection::Enum for Eye3DKind {
140    #[inline]
141    fn variants() -> &'static [Self] {
142        &[Self::FirstPerson, Self::Orbital]
143    }
144
145    #[inline]
146    fn docstring_md(self) -> &'static str {
147        match self {
148            Self::FirstPerson => {
149                "First person point of view.\n\nThe camera perspective as if one is seeing it through the eyes of a person as popularized by first-person games.\nThe center of rotation is the position of the eye (the camera).\nDragging the mouse on the spatial 3D view, will rotation the scene as if one is moving\ntheir head around."
150            }
151            Self::Orbital => {
152                "Orbital eye.\n\nThe center of rotation is located to a center location in front of the eye (it is different from the eye\nlocation itself), as if the eye was orbiting around the scene."
153            }
154        }
155    }
156}
157
158impl ::re_byte_size::SizeBytes for Eye3DKind {
159    #[inline]
160    fn heap_size_bytes(&self) -> u64 {
161        0
162    }
163
164    #[inline]
165    fn is_pod() -> bool {
166        true
167    }
168}