diff --git a/Cargo.lock b/Cargo.lock index b249a7befbd4..d0ee46a24908 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1220,6 +1220,7 @@ name = "custom_space_view" version = "0.9.0-alpha.0" dependencies = [ "mimalloc", + "once_cell", "re_crash_handler", "re_sdk_comms", "re_viewer", @@ -3253,9 +3254,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "oorandom" @@ -4556,6 +4557,7 @@ version = "0.9.0-alpha.0" dependencies = [ "anyhow", "arrow2", + "arrow2_convert", "backtrace", "bytemuck", "document-features", diff --git a/crates/re_arrow_store/benches/arrow2.rs b/crates/re_arrow_store/benches/arrow2.rs index 578591987101..3c5c6ca624df 100644 --- a/crates/re_arrow_store/benches/arrow2.rs +++ b/crates/re_arrow_store/benches/arrow2.rs @@ -10,10 +10,13 @@ use criterion::{criterion_group, Criterion}; use itertools::Itertools; use re_components::{ datagen::{build_some_instances, build_some_point2d, build_some_rects}, - Point2D, Rect2D, + Rect2D, }; use re_log_types::{DataCell, SizeBytes as _}; -use re_types::{components::InstanceKey, Component}; +use re_types::{ + components::{InstanceKey, Point2D}, + Component, +}; // --- diff --git a/crates/re_arrow_store/examples/latest_component.rs b/crates/re_arrow_store/examples/latest_component.rs index 4c859e4966c4..d026983b5511 100644 --- a/crates/re_arrow_store/examples/latest_component.rs +++ b/crates/re_arrow_store/examples/latest_component.rs @@ -8,10 +8,13 @@ use re_arrow_store::polars_util::latest_component; use re_arrow_store::{test_row, DataStore, LatestAtQuery, TimeType, Timeline}; use re_components::{ datagen::{build_frame_nr, build_some_point2d, build_some_rects}, - Point2D, Rect2D, + Rect2D, }; use re_log_types::EntityPath; -use re_types::{components::InstanceKey, Loggable}; +use re_types::{ + components::{InstanceKey, Point2D}, + Loggable, +}; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/examples/latest_components.rs b/crates/re_arrow_store/examples/latest_components.rs index b1023d548816..3fab9591d716 100644 --- a/crates/re_arrow_store/examples/latest_components.rs +++ b/crates/re_arrow_store/examples/latest_components.rs @@ -10,10 +10,13 @@ use re_arrow_store::polars_util::latest_components; use re_arrow_store::{test_row, DataStore, LatestAtQuery, TimeType, Timeline}; use re_components::{ datagen::{build_frame_nr, build_some_point2d, build_some_rects}, - Point2D, Rect2D, + Rect2D, }; use re_log_types::EntityPath; -use re_types::{components::InstanceKey, Loggable}; +use re_types::{ + components::{InstanceKey, Point2D}, + Loggable, +}; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/examples/range_components.rs b/crates/re_arrow_store/examples/range_components.rs index 14e71b0398cc..ac0bb2532822 100644 --- a/crates/re_arrow_store/examples/range_components.rs +++ b/crates/re_arrow_store/examples/range_components.rs @@ -8,10 +8,13 @@ use polars_core::prelude::JoinType; use re_arrow_store::{polars_util, test_row, DataStore, RangeQuery, TimeRange}; use re_components::{ datagen::{build_frame_nr, build_some_point2d, build_some_rects}, - Point2D, Rect2D, + Rect2D, }; use re_log_types::{EntityPath, TimeType, Timeline}; -use re_types::{components::InstanceKey, Loggable}; +use re_types::{ + components::{InstanceKey, Point2D}, + Loggable as _, +}; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/src/store_write.rs b/crates/re_arrow_store/src/store_write.rs index 526c16eb715c..ef988dc65a74 100644 --- a/crates/re_arrow_store/src/store_write.rs +++ b/crates/re_arrow_store/src/store_write.rs @@ -85,11 +85,15 @@ impl DataStore { use std::collections::hash_map::Entry; match self.type_registry.entry(cell.component_name()) { Entry::Occupied(entry) => { - if entry.get() != cell.datatype() { + // NOTE: Don't care about extensions until the migration is over (arrow2-convert + // issues). + let expected = entry.get().to_logical_type().clone(); + let got = cell.datatype().to_logical_type().clone(); + if expected != got { return Err(WriteError::TypeCheck { component: cell.component_name(), - expected: entry.get().clone(), - got: cell.datatype().clone(), + expected, + got, }); } } diff --git a/crates/re_arrow_store/tests/correctness.rs b/crates/re_arrow_store/tests/correctness.rs index 7357bbead031..05c41f8f1a51 100644 --- a/crates/re_arrow_store/tests/correctness.rs +++ b/crates/re_arrow_store/tests/correctness.rs @@ -217,7 +217,7 @@ fn range_join_across_single_row_impl(store: &mut DataStore) { prelude::{DataFrame, JoinType}, series::Series, }; - use re_components::{ColorRGBA, Point2D}; + use re_types::components::{Color, Point2D}; let ent_path = EntityPath::from("this/that"); @@ -232,7 +232,7 @@ fn range_join_across_single_row_impl(store: &mut DataStore) { timeline_frame_nr, re_arrow_store::TimeRange::new(i64::MIN.into(), i64::MAX.into()), ); - let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; + let components = [InstanceKey::name(), Point2D::name(), Color::name()]; let dfs = re_arrow_store::polars_util::range_components( store, &query, @@ -247,12 +247,12 @@ fn range_join_across_single_row_impl(store: &mut DataStore) { let instances = InstanceKey::to_arrow(vec![InstanceKey(0), InstanceKey(1), InstanceKey(2)], None); let points = Point2D::to_arrow(points, None); - let colors = ColorRGBA::to_arrow(colors, None); + let colors = Color::to_arrow(colors, None); DataFrame::new(vec![ Series::try_from((InstanceKey::name().as_ref(), instances)).unwrap(), Series::try_from((Point2D::name().as_ref(), points)).unwrap(), - Series::try_from((ColorRGBA::name().as_ref(), colors)).unwrap(), + Series::try_from((Color::name().as_ref(), colors)).unwrap(), ]) .unwrap() }; diff --git a/crates/re_arrow_store/tests/data_store.rs b/crates/re_arrow_store/tests/data_store.rs index 1413eb028c37..056fd63a8fc6 100644 --- a/crates/re_arrow_store/tests/data_store.rs +++ b/crates/re_arrow_store/tests/data_store.rs @@ -19,10 +19,13 @@ use re_components::{ build_frame_nr, build_some_colors, build_some_instances, build_some_instances_from, build_some_point2d, build_some_rects, }, - ColorRGBA, InstanceKey, Point2D, Rect2D, + Rect2D, }; use re_log_types::{DataCell, DataRow, DataTable, EntityPath, TableId, TimeType, Timeline}; -use re_types::{ComponentName, Loggable as _}; +use re_types::{ + components::{Color, InstanceKey, Point2D}, + ComponentName, Loggable as _, +}; // --- LatestComponentsAt --- @@ -87,16 +90,16 @@ fn all_components() { let cluster_key = store.cluster_key(); let components_a = &[ - ColorRGBA::name(), // added by test, timeless - Rect2D::name(), // added by test - cluster_key, // always here + Color::name(), // added by test, timeless + Rect2D::name(), // added by test + cluster_key, // always here ]; let components_b = &[ - ColorRGBA::name(), // added by test, timeless - Point2D::name(), // added by test - Rect2D::name(), // added by test - cluster_key, // always here + Color::name(), // added by test, timeless + Point2D::name(), // added by test + Rect2D::name(), // added by test + cluster_key, // always here ]; let row = test_row!(ent_path @ [] => 2; [build_some_colors(2)]); @@ -142,16 +145,16 @@ fn all_components() { // └──────────┴────────┴─────────┴────────┴───────────┴──────────┘ let components_a = &[ - ColorRGBA::name(), // added by test, timeless - Rect2D::name(), // added by test - cluster_key, // always here + Color::name(), // added by test, timeless + Rect2D::name(), // added by test + cluster_key, // always here ]; let components_b = &[ - ColorRGBA::name(), // added by test, timeless - Rect2D::name(), // ⚠ inherited before the buckets got split apart! - Point2D::name(), // added by test - cluster_key, // always here + Color::name(), // added by test, timeless + Rect2D::name(), // ⚠ inherited before the buckets got split apart! + Point2D::name(), // added by test + cluster_key, // always here ]; let row = test_row!(ent_path @ [] => 2; [build_some_colors(2)]); @@ -203,16 +206,16 @@ fn all_components() { // └──────────┴────────┴────────┴───────────┴──────────┘ let components_a = &[ - ColorRGBA::name(), // added by test, timeless - Rect2D::name(), // added by test - cluster_key, // always here + Color::name(), // added by test, timeless + Rect2D::name(), // added by test + cluster_key, // always here ]; let components_b = &[ - ColorRGBA::name(), // added by test, timeless - Point2D::name(), // added by test but not contained in the second bucket - Rect2D::name(), // added by test - cluster_key, // always here + Color::name(), // added by test, timeless + Point2D::name(), // added by test but not contained in the second bucket + Rect2D::name(), // added by test + cluster_key, // always here ]; let row = test_row!(ent_path @ [] => 2; [build_some_colors(2)]); @@ -312,7 +315,7 @@ fn latest_at_impl(store: &mut DataStore) { let mut assert_latest_components = |frame_nr: TimeInt, rows: &[(ComponentName, &DataRow)]| { let timeline_frame_nr = Timeline::new("frame_nr", TimeType::Sequence); - let components_all = &[ColorRGBA::name(), Point2D::name()]; + let components_all = &[Color::name(), Point2D::name()]; let df = polars_util::latest_components( &store, @@ -333,27 +336,18 @@ fn latest_at_impl(store: &mut DataStore) { assert_latest_components( frame0, - &[(ColorRGBA::name(), &row4), (Point2D::name(), &row3)], // timeless + &[(Color::name(), &row4), (Point2D::name(), &row3)], // timeless ); assert_latest_components( frame1, &[ - (ColorRGBA::name(), &row1), + (Color::name(), &row1), (Point2D::name(), &row3), // timeless ], ); - assert_latest_components( - frame2, - &[(ColorRGBA::name(), &row1), (Point2D::name(), &row2)], - ); - assert_latest_components( - frame3, - &[(ColorRGBA::name(), &row1), (Point2D::name(), &row3)], - ); - assert_latest_components( - frame4, - &[(ColorRGBA::name(), &row4), (Point2D::name(), &row3)], - ); + assert_latest_components(frame2, &[(Color::name(), &row1), (Point2D::name(), &row2)]); + assert_latest_components(frame3, &[(Color::name(), &row1), (Point2D::name(), &row3)]); + assert_latest_components(frame4, &[(Color::name(), &row4), (Point2D::name(), &row3)]); } // --- Range --- @@ -503,20 +497,20 @@ fn range_impl(store: &mut DataStore) { // TODO(cmc): bring back some log_time scenarios - // Unit ranges (ColorRGBA's PoV) + // Unit ranges (Color's PoV) assert_range_components( TimeRange::new(frame1, frame1), - [ColorRGBA::name(), Point2D::name()], + [Color::name(), Point2D::name()], &[ ( Some(frame0), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_4)], + &[(Color::name(), &row4_3), (Point2D::name(), &row4_4)], ), // timeless ( Some(frame1), &[ - (ColorRGBA::name(), &row1), + (Color::name(), &row1), (Point2D::name(), &row4_4), // timeless ], ), @@ -524,12 +518,12 @@ fn range_impl(store: &mut DataStore) { ); assert_range_components( TimeRange::new(frame2, frame2), - [ColorRGBA::name(), Point2D::name()], + [Color::name(), Point2D::name()], &[ ( Some(frame1), &[ - (ColorRGBA::name(), &row1), + (Color::name(), &row1), (Point2D::name(), &row4_4), // timeless ], ), // @@ -537,43 +531,43 @@ fn range_impl(store: &mut DataStore) { ); assert_range_components( TimeRange::new(frame3, frame3), - [ColorRGBA::name(), Point2D::name()], + [Color::name(), Point2D::name()], &[ ( Some(frame2), - &[(ColorRGBA::name(), &row1), (Point2D::name(), &row2)], + &[(Color::name(), &row1), (Point2D::name(), &row2)], ), // ], ); assert_range_components( TimeRange::new(frame4, frame4), - [ColorRGBA::name(), Point2D::name()], + [Color::name(), Point2D::name()], &[ ( Some(frame3), - &[(ColorRGBA::name(), &row1), (Point2D::name(), &row3)], + &[(Color::name(), &row1), (Point2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_1), (Point2D::name(), &row3)], + &[(Color::name(), &row4_1), (Point2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_2), (Point2D::name(), &row3)], + &[(Color::name(), &row4_2), (Point2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! + &[(Color::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! ), ], ); assert_range_components( TimeRange::new(frame5, frame5), - [ColorRGBA::name(), Point2D::name()], + [Color::name(), Point2D::name()], &[ ( Some(frame4), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_4)], // !!! + &[(Color::name(), &row4_3), (Point2D::name(), &row4_4)], // !!! ), // ], ); @@ -582,102 +576,102 @@ fn range_impl(store: &mut DataStore) { assert_range_components( TimeRange::new(frame1, frame1), - [Point2D::name(), ColorRGBA::name()], + [Point2D::name(), Color::name()], &[ ( Some(frame0), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[(Point2D::name(), &row4_4), (Color::name(), &row4_3)], ), // timeless ], ); assert_range_components( TimeRange::new(frame2, frame2), - [Point2D::name(), ColorRGBA::name()], + [Point2D::name(), Color::name()], &[ ( Some(frame1), &[ (Point2D::name(), &row4_4), // timeless - (ColorRGBA::name(), &row1), + (Color::name(), &row1), ], ), ( Some(frame2), - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(Point2D::name(), &row2), (Color::name(), &row1)], ), // ], ); assert_range_components( TimeRange::new(frame3, frame3), - [Point2D::name(), ColorRGBA::name()], + [Point2D::name(), Color::name()], &[ ( Some(frame2), - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(Point2D::name(), &row2), (Color::name(), &row1)], ), ( Some(frame3), - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(Point2D::name(), &row3), (Color::name(), &row1)], ), ], ); assert_range_components( TimeRange::new(frame4, frame4), - [Point2D::name(), ColorRGBA::name()], + [Point2D::name(), Color::name()], &[ ( Some(frame3), - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(Point2D::name(), &row3), (Color::name(), &row1)], ), ( Some(frame4), - &[(Point2D::name(), &row4_25), (ColorRGBA::name(), &row4_2)], + &[(Point2D::name(), &row4_25), (Color::name(), &row4_2)], ), ( Some(frame4), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[(Point2D::name(), &row4_4), (Color::name(), &row4_3)], ), ], ); assert_range_components( TimeRange::new(frame5, frame5), - [Point2D::name(), ColorRGBA::name()], + [Point2D::name(), Color::name()], &[ ( Some(frame4), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[(Point2D::name(), &row4_4), (Color::name(), &row4_3)], ), // ], ); - // Full range (ColorRGBA's PoV) + // Full range (Color's PoV) assert_range_components( TimeRange::new(frame1, frame5), - [ColorRGBA::name(), Point2D::name()], + [Color::name(), Point2D::name()], &[ ( Some(frame0), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_4)], + &[(Color::name(), &row4_3), (Point2D::name(), &row4_4)], ), // timeless ( Some(frame1), &[ - (ColorRGBA::name(), &row1), + (Color::name(), &row1), (Point2D::name(), &row4_4), // timeless ], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_1), (Point2D::name(), &row3)], + &[(Color::name(), &row4_1), (Point2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_2), (Point2D::name(), &row3)], + &[(Color::name(), &row4_2), (Point2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! + &[(Color::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! ), ], ); @@ -686,68 +680,62 @@ fn range_impl(store: &mut DataStore) { assert_range_components( TimeRange::new(frame1, frame5), - [Point2D::name(), ColorRGBA::name()], + [Point2D::name(), Color::name()], &[ ( Some(frame0), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[(Point2D::name(), &row4_4), (Color::name(), &row4_3)], ), // timeless ( Some(frame2), - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(Point2D::name(), &row2), (Color::name(), &row1)], ), ( Some(frame3), - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(Point2D::name(), &row3), (Color::name(), &row1)], ), ( Some(frame4), - &[(Point2D::name(), &row4_25), (ColorRGBA::name(), &row4_2)], + &[(Point2D::name(), &row4_25), (Color::name(), &row4_2)], ), ( Some(frame4), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[(Point2D::name(), &row4_4), (Color::name(), &row4_3)], ), ], ); - // Infinite range (ColorRGBA's PoV) + // Infinite range (Color's PoV) assert_range_components( TimeRange::new(TimeInt::MIN, TimeInt::MAX), - [ColorRGBA::name(), Point2D::name()], + [Color::name(), Point2D::name()], &[ - (None, &[(ColorRGBA::name(), &row1)]), - ( - None, - &[(ColorRGBA::name(), &row4_1), (Point2D::name(), &row3)], - ), + (None, &[(Color::name(), &row1)]), + (None, &[(Color::name(), &row4_1), (Point2D::name(), &row3)]), + (None, &[(Color::name(), &row4_2), (Point2D::name(), &row3)]), ( None, - &[(ColorRGBA::name(), &row4_2), (Point2D::name(), &row3)], - ), - ( - None, - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! + &[(Color::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! ), ( Some(frame1), &[ - (ColorRGBA::name(), &row1), + (Color::name(), &row1), (Point2D::name(), &row4_4), // timeless ], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_1), (Point2D::name(), &row3)], + &[(Color::name(), &row4_1), (Point2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_2), (Point2D::name(), &row3)], + &[(Color::name(), &row4_2), (Point2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! + &[(Color::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! ), ], ); @@ -756,39 +744,33 @@ fn range_impl(store: &mut DataStore) { assert_range_components( TimeRange::new(TimeInt::MIN, TimeInt::MAX), - [Point2D::name(), ColorRGBA::name()], + [Point2D::name(), Color::name()], &[ + (None, &[(Point2D::name(), &row2), (Color::name(), &row1)]), + (None, &[(Point2D::name(), &row3), (Color::name(), &row1)]), ( None, - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], - ), - ( - None, - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], - ), - ( - None, - &[(Point2D::name(), &row4_25), (ColorRGBA::name(), &row4_2)], + &[(Point2D::name(), &row4_25), (Color::name(), &row4_2)], ), ( None, - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[(Point2D::name(), &row4_4), (Color::name(), &row4_3)], ), ( Some(frame2), - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(Point2D::name(), &row2), (Color::name(), &row1)], ), ( Some(frame3), - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(Point2D::name(), &row3), (Color::name(), &row1)], ), ( Some(frame4), - &[(Point2D::name(), &row4_25), (ColorRGBA::name(), &row4_2)], + &[(Point2D::name(), &row4_25), (Color::name(), &row4_2)], ), ( Some(frame4), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[(Point2D::name(), &row4_4), (Color::name(), &row4_3)], ), ], ); diff --git a/crates/re_components/src/class_id.rs b/crates/re_components/src/class_id.rs index ee40da03ef28..e92676312889 100644 --- a/crates/re_components/src/class_id.rs +++ b/crates/re_components/src/class_id.rs @@ -19,19 +19,25 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; ArrowDeserialize, )] #[arrow_field(transparent)] -pub struct ClassId(pub u16); +pub struct LegacyClassId(pub u16); -impl re_log_types::LegacyComponent for ClassId { +impl From for re_types::components::ClassId { + fn from(val: LegacyClassId) -> Self { + re_types::components::ClassId(val.0) + } +} + +impl re_log_types::LegacyComponent for LegacyClassId { #[inline] fn legacy_name() -> re_log_types::ComponentName { "rerun.class_id".into() } } -impl From for ClassId { +impl From for LegacyClassId { fn from(other: re_types::components::ClassId) -> Self { Self(other.0) } } -re_log_types::component_legacy_shim!(ClassId); +re_log_types::component_legacy_shim!(LegacyClassId); diff --git a/crates/re_components/src/color.rs b/crates/re_components/src/color.rs index 92884d5e730b..7cde9e8d9400 100644 --- a/crates/re_components/src/color.rs +++ b/crates/re_components/src/color.rs @@ -1,13 +1,5 @@ /// An RGBA color tuple with unmultiplied/separate alpha, /// in sRGB gamma space with linear alpha. -/// -/// ``` -/// use re_components::ColorRGBA; -/// use arrow2_convert::field::ArrowField; -/// use arrow2::datatypes::{DataType, Field}; -/// -/// assert_eq!(ColorRGBA::data_type(), DataType::UInt32); -/// ``` #[derive( Clone, Copy, @@ -23,9 +15,21 @@ #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[arrow_field(transparent)] #[repr(transparent)] -pub struct ColorRGBA(pub u32); +pub struct LegacyColor(pub u32); -impl ColorRGBA { +impl From for re_types::components::Color { + fn from(val: LegacyColor) -> Self { + re_types::components::Color(val.0) + } +} + +impl From for LegacyColor { + fn from(val: re_types::components::Color) -> Self { + LegacyColor(val.0) + } +} + +impl LegacyColor { #[inline] pub fn from_rgb(r: u8, g: u8, b: u8) -> Self { Self::from([r, g, b, 255]) @@ -47,7 +51,7 @@ impl ColorRGBA { } } -impl From<[u8; 4]> for ColorRGBA { +impl From<[u8; 4]> for LegacyColor { #[inline] fn from(bytes: [u8; 4]) -> Self { Self( @@ -59,7 +63,7 @@ impl From<[u8; 4]> for ColorRGBA { } } -impl re_log_types::LegacyComponent for ColorRGBA { +impl re_log_types::LegacyComponent for LegacyColor { #[inline] fn legacy_name() -> re_log_types::ComponentName { "rerun.colorrgba".into() @@ -67,22 +71,22 @@ impl re_log_types::LegacyComponent for ColorRGBA { } #[cfg(feature = "ecolor")] -impl From for ecolor::Color32 { - fn from(color: ColorRGBA) -> Self { +impl From for ecolor::Color32 { + fn from(color: LegacyColor) -> Self { let [r, g, b, a] = color.to_array(); Self::from_rgba_premultiplied(r, g, b, a) } } -re_log_types::component_legacy_shim!(ColorRGBA); +re_log_types::component_legacy_shim!(LegacyColor); #[test] fn test_colorrgba_roundtrip() { use arrow2::array::Array; use arrow2_convert::{deserialize::TryIntoCollection, serialize::TryIntoArrow}; - let colors_in = vec![ColorRGBA(0u32), ColorRGBA(255u32)]; + let colors_in = vec![LegacyColor(0u32), LegacyColor(255u32)]; let array: Box = colors_in.try_into_arrow().unwrap(); - let colors_out: Vec = TryIntoCollection::try_into_collection(array).unwrap(); + let colors_out: Vec = TryIntoCollection::try_into_collection(array).unwrap(); assert_eq!(colors_in, colors_out); } diff --git a/crates/re_components/src/context.rs b/crates/re_components/src/context.rs index 287e34207e7b..2f160716022b 100644 --- a/crates/re_components/src/context.rs +++ b/crates/re_components/src/context.rs @@ -4,8 +4,9 @@ use arrow2_convert::{ deserialize::ArrowDeserialize, field::ArrowField, serialize::ArrowSerialize, ArrowDeserialize, ArrowField, ArrowSerialize, }; +use re_types::components::{ClassId, KeypointId}; -use crate::{ClassId, ColorRGBA, KeypointId, Label}; +use crate::{LegacyClassId, LegacyColor, LegacyKeypointId, LegacyLabel}; /// Information about an Annotation. /// @@ -15,8 +16,8 @@ use crate::{ClassId, ColorRGBA, KeypointId, Label}; pub struct AnnotationInfo { /// [`ClassId`] or [`KeypointId`] to which this annotation info belongs. pub id: u16, - pub label: Option