re_components/
draw_order.rs1use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};
2
3#[derive(Debug, Clone, Copy, ArrowField, ArrowSerialize, ArrowDeserialize)]
21#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
22#[arrow_field(transparent)]
23pub struct DrawOrder(pub f32);
24
25impl DrawOrder {
26 pub const DEFAULT_IMAGE: DrawOrder = DrawOrder(-10.0);
28
29 pub const DEFAULT_BOX2D: DrawOrder = DrawOrder(10.0);
31
32 pub const DEFAULT_LINES2D: DrawOrder = DrawOrder(20.0);
34
35 pub const DEFAULT_POINTS2D: DrawOrder = DrawOrder(30.0);
37}
38
39impl re_log_types::LegacyComponent for DrawOrder {
40 #[inline]
41 fn legacy_name() -> re_log_types::ComponentName {
42 "rerun.draw_order".into()
43 }
44}
45
46impl std::cmp::PartialEq for DrawOrder {
47 #[inline]
48 fn eq(&self, other: &Self) -> bool {
49 self.0.is_nan() && other.0.is_nan() || self.0 == other.0
50 }
51}
52
53impl std::cmp::Eq for DrawOrder {}
54
55impl std::cmp::PartialOrd for DrawOrder {
56 #[inline]
57 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
58 if other == self {
59 Some(std::cmp::Ordering::Equal)
60 } else if other.0.is_nan() || self.0 < other.0 {
61 Some(std::cmp::Ordering::Less)
62 } else {
63 Some(std::cmp::Ordering::Greater)
64 }
65 }
66}
67
68impl std::cmp::Ord for DrawOrder {
69 #[inline]
70 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
71 self.partial_cmp(other).unwrap()
72 }
73}
74
75impl From<f32> for DrawOrder {
76 #[inline]
77 fn from(value: f32) -> Self {
78 Self(value)
79 }
80}
81
82impl From<DrawOrder> for f32 {
83 #[inline]
84 fn from(value: DrawOrder) -> Self {
85 value.0
86 }
87}
88
89re_log_types::component_legacy_shim!(DrawOrder);