From 07b6138491910b026f83de4b1878b98c2741958f Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 24 Jul 2023 17:16:06 +0200 Subject: [PATCH] annihilate legacy Color (as much as humanly possible) --- Cargo.lock | 5 +- crates/re_components/src/color.rs | 8 +- crates/re_components/src/lib.rs | 4 +- crates/re_components/tests/data_row.rs | 5 +- .../re_components/tests/data_table_batcher.rs | 9 +- .../re_data_ui/src/component_ui_registry.rs | 2 +- crates/re_data_ui/src/data.rs | 5 +- crates/re_query/benches/query_benchmark.rs | 10 +- crates/re_query/src/query.rs | 19 ++-- crates/re_query/tests/query_tests.rs | 38 +++---- crates/re_query/tests/range_tests.rs | 98 +++++++++---------- crates/re_query/tests/visit_tests.rs | 81 ++++++++------- crates/re_sdk/src/lib.rs | 8 +- crates/re_sdk/src/msg_sender.rs | 12 +-- .../re_space_view_spatial/src/mesh_loader.rs | 5 +- .../src/parts/arrows3d.rs | 8 +- .../src/parts/boxes2d.rs | 8 +- .../src/parts/boxes3d.rs | 8 +- .../re_space_view_spatial/src/parts/images.rs | 8 +- .../src/parts/lines2d.rs | 8 +- .../src/parts/lines3d.rs | 8 +- .../re_space_view_spatial/src/parts/meshes.rs | 11 ++- .../src/view_part_system.rs | 4 +- .../src/view_part_system.rs | 4 +- crates/re_types/source_hash.txt | 2 +- .../annotation_context_connections.rs | 11 +-- .../code-examples/annotation_context_rects.rs | 6 +- .../annotation_context_segmentation.rs | 6 +- docs/code-examples/point2d_random.rs | 4 +- docs/code-examples/point3d_random.rs | 4 +- .../segmentation_image_simple.rs | 6 +- examples/rust/clock/src/main.rs | 6 +- examples/rust/custom_space_view/Cargo.toml | 1 + .../src/color_coordinates_view_part_system.rs | 86 ++++++++++++---- examples/rust/dna/src/main.rs | 10 +- examples/rust/minimal/src/main.rs | 4 +- examples/rust/minimal_options/src/main.rs | 4 +- examples/rust/objectron/src/main.rs | 12 +-- examples/rust/raw_mesh/src/main.rs | 6 +- rerun_py/src/python_bridge.rs | 6 +- tests/rust/test_api/src/main.rs | 32 +++--- 41 files changed, 319 insertions(+), 263 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 538a74bde0a81..6b15ddaac37f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1220,6 +1220,7 @@ name = "custom_space_view" version = "0.8.0-alpha.6" dependencies = [ "mimalloc", + "once_cell", "re_crash_handler", "re_sdk_comms", "re_viewer", @@ -3245,9 +3246,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" diff --git a/crates/re_components/src/color.rs b/crates/re_components/src/color.rs index a31cd4a5d2ae2..16b06a892a9ed 100644 --- a/crates/re_components/src/color.rs +++ b/crates/re_components/src/color.rs @@ -4,7 +4,7 @@ /// in sRGB gamma space with linear alpha. /// /// ``` -/// use re_components::ColorRGBA; +/// use re_types::components::ColorRGBA; /// use arrow2_convert::field::ArrowField; /// use arrow2::datatypes::{DataType, Field}; /// @@ -33,6 +33,12 @@ impl From for re_types::components::Color { } } +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 { diff --git a/crates/re_components/src/lib.rs b/crates/re_components/src/lib.rs index 7fa75b965ecee..1b271cc9b58e0 100644 --- a/crates/re_components/src/lib.rs +++ b/crates/re_components/src/lib.rs @@ -55,10 +55,12 @@ pub mod datagen; // TODO: stuff we keep for annotation context pub(crate) use self::{class_id::LegacyClassId, keypoint_id::LegacyKeypointId, label::LegacyLabel}; +// TODO: has to be fully public cause we have something weird +pub use self::color::LegacyColor; + pub use self::{ arrow::Arrow3D, bbox::Box3D, - color::LegacyColor, context::{AnnotationContext, AnnotationInfo, ClassDescription}, coordinates::ViewCoordinates, disconnected_space::DisconnectedSpace, diff --git a/crates/re_components/tests/data_row.rs b/crates/re_components/tests/data_row.rs index 1a550369785bd..5870335a4bad5 100644 --- a/crates/re_components/tests/data_row.rs +++ b/crates/re_components/tests/data_row.rs @@ -1,7 +1,6 @@ -use re_components::LegacyColor; use re_log_types::{DataRow, DataRowError, EntityPath, RowId, TimePoint}; use re_types::{ - components::{Label, Point2D}, + components::{Color, Label, Point2D}, Loggable as _, }; @@ -12,7 +11,7 @@ fn data_row_error_num_instances() { let num_instances = 2; let points: &[Point2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; - let colors: &[_] = &[LegacyColor::from_rgb(128, 128, 128)]; + let colors: &[_] = &[Color::from_rgb(128, 128, 128)]; let labels: &[Label] = &[]; // 0 = clear: legal diff --git a/crates/re_components/tests/data_table_batcher.rs b/crates/re_components/tests/data_table_batcher.rs index 61d94ca36ad97..e35bf67903d2a 100644 --- a/crates/re_components/tests/data_table_batcher.rs +++ b/crates/re_components/tests/data_table_batcher.rs @@ -1,12 +1,11 @@ use crossbeam::{channel::TryRecvError, select}; use itertools::Itertools as _; -use re_components::LegacyColor; use re_log_types::{ DataRow, DataTableBatcher, DataTableBatcherConfig, RowId, SizeBytes, TimePoint, Timeline, }; use re_log_types::{DataTable, TableId, Time}; -use re_types::components::{Label, Point2D}; +use re_types::components::{Color, Label, Point2D}; #[test] fn manual_trigger() { @@ -283,7 +282,7 @@ fn create_table() -> DataTable { let row0 = { let num_instances = 2; let points: &[Point2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; - let colors: &[_] = &[LegacyColor::from_rgb(128, 128, 128)]; + let colors: &[_] = &[Color::from_rgb(128, 128, 128)]; let labels: &[Label] = &[]; DataRow::from_cells3( @@ -297,14 +296,14 @@ fn create_table() -> DataTable { let row1 = { let num_instances = 0; - let colors: &[LegacyColor] = &[]; + let colors: &[Color] = &[]; DataRow::from_cells1(RowId::random(), "b", timepoint(1), num_instances, colors) }; let row2 = { let num_instances = 1; - let colors: &[_] = &[LegacyColor::from_rgb(255, 255, 255)]; + let colors: &[_] = &[Color::from_rgb(255, 255, 255)]; let labels: &[_] = &[Label("hey".into())]; DataRow::from_cells2( diff --git a/crates/re_data_ui/src/component_ui_registry.rs b/crates/re_data_ui/src/component_ui_registry.rs index 37696eb965e99..3af2ee23d52ab 100644 --- a/crates/re_data_ui/src/component_ui_registry.rs +++ b/crates/re_data_ui/src/component_ui_registry.rs @@ -37,7 +37,7 @@ pub fn create_component_ui_registry() -> ComponentUiRegistry { // add::(&mut registry); // add::(&mut registry); add::(&mut registry); - add::(&mut registry); + add::(&mut registry); add::(&mut registry); // add::(&mut registry); add::(&mut registry); diff --git a/crates/re_data_ui/src/data.rs b/crates/re_data_ui/src/data.rs index a8bb67a43234f..9352de4d013db 100644 --- a/crates/re_data_ui/src/data.rs +++ b/crates/re_data_ui/src/data.rs @@ -1,9 +1,10 @@ use egui::Vec2; use re_components::{ - LegacyColor, LineStrip2D, LineStrip3D, Mat3x3, Rect2D, Vec2D, Vec3D, Vec4D, ViewCoordinates, + LineStrip2D, LineStrip3D, Mat3x3, Rect2D, Vec2D, Vec3D, Vec4D, ViewCoordinates, }; use re_format::format_f32; +use re_types::components::Color; use re_viewer_context::{UiVerbosity, ViewerContext}; use super::DataUi; @@ -31,7 +32,7 @@ impl DataUi for [u8; 4] { } } -impl DataUi for LegacyColor { +impl DataUi for Color { fn data_ui( &self, _ctx: &mut ViewerContext<'_>, diff --git a/crates/re_query/benches/query_benchmark.rs b/crates/re_query/benches/query_benchmark.rs index f6f3c0473cbf2..240a62c78b713 100644 --- a/crates/re_query/benches/query_benchmark.rs +++ b/crates/re_query/benches/query_benchmark.rs @@ -7,12 +7,12 @@ use itertools::Itertools; use re_arrow_store::{DataStore, LatestAtQuery}; use re_components::{ datagen::{build_frame_nr, build_some_colors, build_some_point2d, build_some_vec3d}, - LegacyColor, Vec3D, + Vec3D, }; use re_log_types::{entity_path, DataRow, EntityPath, Index, RowId, TimeType, Timeline}; use re_query::query_entity_with_primary; use re_types::{ - components::{InstanceKey, Point2D}, + components::{Color, InstanceKey, Point2D}, Loggable as _, }; @@ -175,7 +175,7 @@ fn insert_rows<'a>(msgs: impl Iterator) -> DataStore { struct SavePoint { _pos: Point2D, - _color: Option, + _color: Option, } fn query_and_visit_points(store: &mut DataStore, paths: &[EntityPath]) -> Vec { @@ -186,9 +186,9 @@ fn query_and_visit_points(store: &mut DataStore, paths: &[EntityPath]) -> Vec(store, &query, path, &[LegacyColor::name()]) + query_entity_with_primary::(store, &query, path, &[Color::name()]) .and_then(|entity_view| { - entity_view.visit2(|_: InstanceKey, pos: Point2D, color: Option| { + entity_view.visit2(|_: InstanceKey, pos: Point2D, color: Option| { points.push(SavePoint { _pos: pos, _color: color, diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index dad3446ea8350..23ccb423f5d30 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -241,8 +241,8 @@ pub fn query_archetype( /// Helper used to create an example store we can use for querying in doctests pub fn __populate_example_store() -> DataStore { - use re_components::{datagen::build_frame_nr, LegacyColor}; - use re_types::components::Point2D; + use re_components::datagen::build_frame_nr; + use re_types::components::{Color, Point2D}; let mut store = DataStore::new(InstanceKey::name(), Default::default()); @@ -262,7 +262,7 @@ pub fn __populate_example_store() -> DataStore { store.insert_row(&row).unwrap(); let instances = vec![InstanceKey(96)]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), @@ -313,7 +313,6 @@ fn simple_get_component() { #[test] fn simple_query_entity() { use re_arrow_store::LatestAtQuery; - use re_components::LegacyColor; use re_log_types::Timeline; use re_types::components::{Color, Point2D}; @@ -322,17 +321,13 @@ fn simple_query_entity() { let ent_path = "point"; let query = LatestAtQuery::new(Timeline::new_sequence("frame_nr"), 123.into()); - let entity_view = query_entity_with_primary::( - &store, - &query, - &ent_path.into(), - &[LegacyColor::name()], - ) - .unwrap(); + let entity_view = + query_entity_with_primary::(&store, &query, &ent_path.into(), &[Color::name()]) + .unwrap(); #[cfg(feature = "polars")] { - let df = entity_view.as_df2::().unwrap(); + let df = entity_view.as_df2::().unwrap(); eprintln!("{df:?}"); let instances = vec![Some(InstanceKey(42)), Some(InstanceKey(96))]; diff --git a/crates/re_query/tests/query_tests.rs b/crates/re_query/tests/query_tests.rs index e34bc9f0df252..1f58aeeebbc63 100644 --- a/crates/re_query/tests/query_tests.rs +++ b/crates/re_query/tests/query_tests.rs @@ -1,11 +1,11 @@ mod common; use re_arrow_store::DataStore; -use re_components::{datagen::build_frame_nr, LegacyColor}; +use re_components::datagen::build_frame_nr; use re_log_types::{DataRow, RowId}; use re_query::query_entity_with_primary; use re_types::{ - components::{InstanceKey, Point2D}, + components::{Color, InstanceKey, Point2D}, Loggable as _, }; @@ -23,7 +23,7 @@ fn simple_query() { // Assign one of them a color with an explicit instance let color_instances = vec![InstanceKey(1)]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path, @@ -40,7 +40,7 @@ fn simple_query() { &store, &timeline_query, &ent_path.into(), - &[LegacyColor::name()], + &[Color::name()], ) .unwrap(); @@ -62,13 +62,13 @@ fn simple_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); - common::compare_df(&expected, &entity_view.as_df2::().unwrap()); + common::compare_df(&expected, &entity_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -91,7 +91,7 @@ fn timeless_query() { // Assign one of them a color with an explicit instance.. timelessly! let color_instances = vec![InstanceKey(1)]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized(RowId::random(), ent_path, [], 1, (color_instances, colors)); store.insert_row(&row).unwrap(); @@ -103,7 +103,7 @@ fn timeless_query() { &store, &timeline_query, &ent_path.into(), - &[LegacyColor::name()], + &[Color::name()], ) .unwrap(); @@ -125,13 +125,13 @@ fn timeless_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); - common::compare_df(&expected, &entity_view.as_df2::().unwrap()); + common::compare_df(&expected, &entity_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -153,7 +153,7 @@ fn no_instance_join_query() { store.insert_row(&row).unwrap(); // Assign them colors with explicit instances - let colors = vec![LegacyColor(0xff000000), LegacyColor(0x00ff0000)]; + let colors = vec![Color(0xff000000), Color(0x00ff0000)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, colors); store.insert_row(&row).unwrap(); @@ -164,7 +164,7 @@ fn no_instance_join_query() { &store, &timeline_query, &ent_path.into(), - &[LegacyColor::name()], + &[Color::name()], ) .unwrap(); @@ -186,13 +186,13 @@ fn no_instance_join_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![Some(LegacyColor(0xff000000)), Some(LegacyColor(0x00ff0000))]; + let colors = vec![Some(Color(0xff000000)), Some(Color(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); - common::compare_df(&expected, &entity_view.as_df2::().unwrap()); + common::compare_df(&expected, &entity_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -220,7 +220,7 @@ fn missing_column_join_query() { &store, &timeline_query, &ent_path.into(), - &[LegacyColor::name()], + &[Color::name()], ) .unwrap(); @@ -270,7 +270,7 @@ fn splatted_query() { // Assign all of them a color via splat let color_instances = vec![InstanceKey::SPLAT]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path, @@ -287,7 +287,7 @@ fn splatted_query() { &store, &timeline_query, &ent_path.into(), - &[LegacyColor::name()], + &[Color::name()], ) .unwrap(); @@ -309,13 +309,13 @@ fn splatted_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![Some(LegacyColor(0xff000000)), Some(LegacyColor(0xff000000))]; + let colors = vec![Some(Color(0xff000000)), Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); - common::compare_df(&expected, &entity_view.as_df2::().unwrap()); + common::compare_df(&expected, &entity_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { diff --git a/crates/re_query/tests/range_tests.rs b/crates/re_query/tests/range_tests.rs index 5a03565adb92b..ba8519690fc80 100644 --- a/crates/re_query/tests/range_tests.rs +++ b/crates/re_query/tests/range_tests.rs @@ -1,11 +1,11 @@ mod common; use re_arrow_store::{DataStore, TimeInt, TimeRange}; -use re_components::{datagen::build_frame_nr, LegacyColor}; +use re_components::datagen::build_frame_nr; use re_log_types::{DataRow, EntityPath, RowId}; use re_query::range_entity_with_primary; use re_types::{ - components::{InstanceKey, Point2D}, + components::{Color, InstanceKey, Point2D}, Loggable as _, }; @@ -25,7 +25,7 @@ fn simple_range() { // Assign one of them a color with an explicit instance let color_instances = vec![InstanceKey(1)]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path.clone(), @@ -40,7 +40,7 @@ fn simple_range() { { // Assign one of them a color with an explicit instance let color_instances = vec![InstanceKey(0)]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path.clone(), @@ -69,7 +69,7 @@ fn simple_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), LegacyColor::name()]; + let components = [InstanceKey::name(), Point2D::name(), Color::name()]; let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -106,14 +106,14 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(123), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #323 @@ -126,14 +126,14 @@ fn simple_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![Some(LegacyColor(0xff000000)), None]; + let colors = vec![Some(Color(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(323), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -150,7 +150,7 @@ fn simple_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), LegacyColor::name()]; + let components = [InstanceKey::name(), Point2D::name(), Color::name()]; let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -187,14 +187,14 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors: Vec> = vec![None, None]; + let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(123), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #323 @@ -207,14 +207,14 @@ fn simple_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![Some(LegacyColor(0xff000000)), None]; + let colors = vec![Some(Color(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(323), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -244,7 +244,7 @@ fn timeless_range() { // Assign one of them a color with an explicit instance let color_instances = vec![InstanceKey(1)]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path.clone(), @@ -269,7 +269,7 @@ fn timeless_range() { { // Assign one of them a color with an explicit instance let color_instances = vec![InstanceKey(0)]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path.clone(), @@ -332,7 +332,7 @@ fn timeless_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), LegacyColor::name()]; + let components = [InstanceKey::name(), Point2D::name(), Color::name()]; let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -369,14 +369,14 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(123), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #323 @@ -389,14 +389,14 @@ fn timeless_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![Some(LegacyColor(0xff000000)), None]; + let colors = vec![Some(Color(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(323), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -413,7 +413,7 @@ fn timeless_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), LegacyColor::name()]; + let components = [InstanceKey::name(), Point2D::name(), Color::name()]; let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -462,14 +462,14 @@ fn timeless_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(122), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #123 (partially timeless) @@ -479,14 +479,14 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(123), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #323 @@ -499,14 +499,14 @@ fn timeless_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![Some(LegacyColor(0xff000000)), None]; + let colors = vec![Some(Color(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(323), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -521,7 +521,7 @@ fn timeless_range() { TimeRange::new(TimeInt::MIN, TimeInt::MAX), ); - let components = [InstanceKey::name(), Point2D::name(), LegacyColor::name()]; + let components = [InstanceKey::name(), Point2D::name(), Color::name()]; let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -575,14 +575,14 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors: Vec> = vec![None, None]; + let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(&None, time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Timeless #2 @@ -594,14 +594,14 @@ fn timeless_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(&None, time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #123 (partially timeless) @@ -611,14 +611,14 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(123), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #323 @@ -631,14 +631,14 @@ fn timeless_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![Some(LegacyColor(0xff000000)), None]; + let colors = vec![Some(Color(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(323), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -663,7 +663,7 @@ fn simple_splatted_range() { // Assign one of them a color with an explicit instance let color_instances = vec![InstanceKey(1)]; - let colors = vec![LegacyColor(0xff000000)]; + let colors = vec![Color(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path.clone(), @@ -678,7 +678,7 @@ fn simple_splatted_range() { { // Assign one of them a color with a splatted instance let color_instances = vec![InstanceKey::SPLAT]; - let colors = vec![LegacyColor(0x00ff0000)]; + let colors = vec![Color(0x00ff0000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path.clone(), @@ -707,7 +707,7 @@ fn simple_splatted_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), LegacyColor::name()]; + let components = [InstanceKey::name(), Point2D::name(), Color::name()]; let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -744,14 +744,14 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![None, Some(LegacyColor(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(123), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #323 @@ -764,14 +764,14 @@ fn simple_splatted_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![Some(LegacyColor(0x00ff0000)), Some(LegacyColor(0x00ff0000))]; + let colors = vec![Some(Color(0x00ff0000)), Some(Color(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(323), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { @@ -788,7 +788,7 @@ fn simple_splatted_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), LegacyColor::name()]; + let components = [InstanceKey::name(), Point2D::name(), Color::name()]; let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -825,14 +825,14 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors: Vec> = vec![None, None]; + let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(123), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); // Frame #323 @@ -845,14 +845,14 @@ fn simple_splatted_range() { Some(Point2D::new(10.0, 20.0)), Some(Point2D::new(30.0, 40.0)), ]; - let colors = vec![Some(LegacyColor(0x00ff0000)), Some(LegacyColor(0x00ff0000))]; + let colors = vec![Some(Color(0x00ff0000)), Some(Color(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); //eprintln!("{df:?}"); //eprintln!("{expected:?}"); assert_eq!(TimeInt::from(323), time); - common::compare_df(&expected, &ent_view.as_df2::().unwrap()); + common::compare_df(&expected, &ent_view.as_df2::().unwrap()); } #[cfg(not(feature = "polars"))] { diff --git a/crates/re_query/tests/visit_tests.rs b/crates/re_query/tests/visit_tests.rs index 25a4b27e1af05..05c95195287a6 100644 --- a/crates/re_query/tests/visit_tests.rs +++ b/crates/re_query/tests/visit_tests.rs @@ -1,7 +1,6 @@ use itertools::Itertools; -use re_components::LegacyColor; use re_query::{ComponentWithInstances, EntityView}; -use re_types::components::{InstanceKey, Point2D}; +use re_types::components::{Color, InstanceKey, Point2D}; #[test] fn basic_single_iter() { @@ -35,9 +34,9 @@ fn implicit_joined_iter() { ]; let colors = [ - LegacyColor(0), // - LegacyColor(1), - LegacyColor(2), + Color(0), // + Color(1), + Color(2), ]; let entity_view = EntityView::from_native2( @@ -46,14 +45,14 @@ fn implicit_joined_iter() { ); let expected_colors = [ - Some(LegacyColor(0)), // - Some(LegacyColor(1)), - Some(LegacyColor(2)), + Some(Color(0)), // + Some(Color(1)), + Some(Color(2)), ]; let results = itertools::izip!( expected_colors.iter(), - entity_view.iter_component::().unwrap() + entity_view.iter_component::().unwrap() ) .collect_vec(); @@ -77,8 +76,8 @@ fn implicit_primary_joined_iter() { ]; let colors = [ - LegacyColor(1), // - LegacyColor(2), + Color(1), // + Color(2), ]; let entity_view = EntityView::from_native2( @@ -88,13 +87,13 @@ fn implicit_primary_joined_iter() { let expected_colors = vec![ None, // - Some(LegacyColor(1)), - Some(LegacyColor(2)), + Some(Color(1)), + Some(Color(2)), ]; let results = itertools::izip!( expected_colors.iter(), - entity_view.iter_component::().unwrap() + entity_view.iter_component::().unwrap() ) .collect_vec(); @@ -119,11 +118,11 @@ fn implicit_component_joined_iter() { let color_ids = InstanceKey::from_iter(0..5); let colors = [ - LegacyColor(0), // - LegacyColor(1), - LegacyColor(2), - LegacyColor(3), - LegacyColor(4), + Color(0), // + Color(1), + Color(2), + Color(3), + Color(4), ]; let entity_view = EntityView::from_native2( @@ -132,14 +131,14 @@ fn implicit_component_joined_iter() { ); let expected_colors = vec![ - Some(LegacyColor(0)), // - Some(LegacyColor(2)), - Some(LegacyColor(4)), + Some(Color(0)), // + Some(Color(2)), + Some(Color(4)), ]; let results = itertools::izip!( expected_colors.iter(), - entity_view.iter_component::().unwrap() + entity_view.iter_component::().unwrap() ) .collect_vec(); @@ -172,11 +171,11 @@ fn complex_joined_iter() { ]; let colors = vec![ - LegacyColor(17), // - LegacyColor(19), - LegacyColor(44), - LegacyColor(96), - LegacyColor(254), + Color(17), // + Color(19), + Color(44), + Color(96), + Color(254), ]; let entity_view = EntityView::from_native2( @@ -186,14 +185,14 @@ fn complex_joined_iter() { let expected_colors = vec![ None, - Some(LegacyColor(17)), // + Some(Color(17)), // None, - Some(LegacyColor(96)), + Some(Color(96)), ]; let results = itertools::izip!( expected_colors.iter(), - entity_view.iter_component::().unwrap() + entity_view.iter_component::().unwrap() ) .collect_vec(); @@ -241,8 +240,8 @@ fn joint_visit() { let point_ids = InstanceKey::from_iter(0..5); let colors = vec![ - LegacyColor(0xff000000), // - LegacyColor(0x00ff0000), + Color(0xff000000), // + Color(0x00ff0000), ]; let color_ids = vec![ @@ -256,24 +255,22 @@ fn joint_visit() { ); let mut points_out = Vec::::new(); - let mut colors_out = Vec::>::new(); + let mut colors_out = Vec::>::new(); entity_view - .visit2( - |_: InstanceKey, point: Point2D, color: Option| { - points_out.push(point); - colors_out.push(color); - }, - ) + .visit2(|_: InstanceKey, point: Point2D, color: Option| { + points_out.push(point); + colors_out.push(color); + }) .ok() .unwrap(); let expected_colors = vec![ None, None, - Some(LegacyColor(0xff000000)), + Some(Color(0xff000000)), None, - Some(LegacyColor(0x00ff0000)), + Some(Color(0x00ff0000)), ]; assert_eq!(points, points_out); diff --git a/crates/re_sdk/src/lib.rs b/crates/re_sdk/src/lib.rs index e519a445c3bae..f3ad8018de68c 100644 --- a/crates/re_sdk/src/lib.rs +++ b/crates/re_sdk/src/lib.rs @@ -74,10 +74,10 @@ pub mod time { pub mod components { pub use re_components::{ AnnotationContext, AnnotationInfo, Arrow3D, Box3D, ClassDescription, DisconnectedSpace, - EncodedMesh3D, LegacyColor, LineStrip2D, LineStrip3D, Mat3x3, Mesh3D, MeshFormat, MeshId, - Pinhole, Quaternion, RawMesh3D, Rect2D, Scalar, ScalarPlotProps, Size3D, Tensor, - TensorData, TensorDataMeaning, TensorDimension, TensorId, TextEntry, Transform3D, Vec2D, - Vec3D, Vec4D, ViewCoordinates, + EncodedMesh3D, LineStrip2D, LineStrip3D, Mat3x3, Mesh3D, MeshFormat, MeshId, Pinhole, + Quaternion, RawMesh3D, Rect2D, Scalar, ScalarPlotProps, Size3D, Tensor, TensorData, + TensorDataMeaning, TensorDimension, TensorId, TextEntry, Transform3D, Vec2D, Vec3D, Vec4D, + ViewCoordinates, }; pub use re_types::components::{ ClassId, Color, DrawOrder, InstanceKey, KeypointId, Label, Point2D, Point3D, Radius, diff --git a/crates/re_sdk/src/msg_sender.rs b/crates/re_sdk/src/msg_sender.rs index 6d1c78aea1964..9b047525a97a1 100644 --- a/crates/re_sdk/src/msg_sender.rs +++ b/crates/re_sdk/src/msg_sender.rs @@ -424,7 +424,7 @@ mod tests { re_types::components::Label("label2".into()), ]; let transform = vec![components::Transform3D::IDENTITY]; - let color = components::LegacyColor::from_rgb(255, 0, 255); + let color = components::Color::from_rgb(255, 0, 255); let [standard, splats] = MsgSender::new("some/path") .with_component(&labels)? @@ -448,7 +448,7 @@ mod tests { let cell = &splats.cells[idx]; assert!(cell.num_instances() == 1); - let idx = splats.find_cell(&components::LegacyColor::name()).unwrap(); + let idx = splats.find_cell(&components::Color::name()).unwrap(); let cell = &splats.cells[idx]; assert!(cell.num_instances() == 1); } @@ -514,7 +514,7 @@ mod tests { { MsgSender::new("some/path") .with_component([re_types::components::Label("label1".into())].as_slice())? - .with_component([components::LegacyColor::from_rgb(1, 1, 1)].as_slice())?; + .with_component([components::Color::from_rgb(1, 1, 1)].as_slice())?; } // 3 for 1 -- fine, implicit splat @@ -528,7 +528,7 @@ mod tests { ] .as_slice(), )? - .with_component([components::LegacyColor::from_rgb(1, 1, 1)].as_slice())?; + .with_component([components::Color::from_rgb(1, 1, 1)].as_slice())?; } // 3 for 2 -- nope, makes no sense @@ -544,8 +544,8 @@ mod tests { )? .with_component( [ - components::LegacyColor::from_rgb(1, 1, 1), - components::LegacyColor::from_rgb(1, 1, 1), + components::Color::from_rgb(1, 1, 1), + components::Color::from_rgb(1, 1, 1), ] .as_slice(), ); diff --git a/crates/re_space_view_spatial/src/mesh_loader.rs b/crates/re_space_view_spatial/src/mesh_loader.rs index 2a26b45523482..db67354fd4617 100644 --- a/crates/re_space_view_spatial/src/mesh_loader.rs +++ b/crates/re_space_view_spatial/src/mesh_loader.rs @@ -1,5 +1,6 @@ -use re_components::{EncodedMesh3D, LegacyColor, Mesh3D, MeshFormat, RawMesh3D}; +use re_components::{EncodedMesh3D, Mesh3D, MeshFormat, RawMesh3D}; use re_renderer::{resource_managers::ResourceLifeTime, RenderContext, Rgba32Unmul}; +use re_types::components::Color; pub struct LoadedMesh { name: String, @@ -115,7 +116,7 @@ impl LoadedMesh { let vertex_colors = if let Some(vertex_colors) = vertex_colors { vertex_colors .iter() - .map(|c| Rgba32Unmul::from_rgba_unmul_array(LegacyColor(*c).to_array())) + .map(|c| Rgba32Unmul::from_rgba_unmul_array(Color(*c).to_array())) .collect() } else { std::iter::repeat(Rgba32Unmul::WHITE) diff --git a/crates/re_space_view_spatial/src/parts/arrows3d.rs b/crates/re_space_view_spatial/src/parts/arrows3d.rs index 5752a71a2904d..a021ac8858008 100644 --- a/crates/re_space_view_spatial/src/parts/arrows3d.rs +++ b/crates/re_space_view_spatial/src/parts/arrows3d.rs @@ -1,9 +1,9 @@ -use re_components::{Arrow3D, LegacyColor}; +use re_components::Arrow3D; use re_data_store::EntityPath; use re_query::{EntityView, QueryError}; use re_renderer::{renderer::LineStripFlags, Size}; use re_types::{ - components::{InstanceKey, Label, Radius}, + components::{Color, InstanceKey, Label, Radius}, Loggable as _, }; use re_viewer_context::{ @@ -48,7 +48,7 @@ impl Arrows3DPart { ent_view.visit4( |instance_key: InstanceKey, arrow: Arrow3D, - color: Option, + color: Option, radius: Option, _label: Option