From 05b3f89e0b00fbe1deb9c8c64faa9a3739ceb9d6 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 21 Jul 2023 12:49:24 +0200 Subject: [PATCH 01/37] codegen --- rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py | 4 ++-- rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py index 47a1ea91f26d..5bea0163e66c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py @@ -208,7 +208,7 @@ def _native_to_pa_array(data: AffixFuzzer2ArrayLike, data_type: pa.DataType) -> @define class AffixFuzzer3: - inner: float | list[datatypes.AffixFuzzer1] | npt.NDArray[np.float32] = field() + inner: Union[float, list[datatypes.AffixFuzzer1], npt.NDArray[np.float32]] = field() """ degrees (float): @@ -323,7 +323,7 @@ def _native_to_pa_array(data: AffixFuzzer3ArrayLike, data_type: pa.DataType) -> @define class AffixFuzzer4: - inner: datatypes.AffixFuzzer3 | list[datatypes.AffixFuzzer3] = field() + inner: Union[datatypes.AffixFuzzer3, list[datatypes.AffixFuzzer3]] = field() """ single_required (datatypes.AffixFuzzer3): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py index 76a5518a8374..3beed260f921 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py @@ -21,7 +21,7 @@ class Rotation3D: """A 3D rotation.""" - inner: datatypes.Quaternion | datatypes.RotationAxisAngle = field(converter=rotation3d_inner_converter) + inner: Union[datatypes.Quaternion, datatypes.RotationAxisAngle] = field(converter=rotation3d_inner_converter) """ Quaternion (datatypes.Quaternion): Rotation defined by a quaternion. diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py index d6e3db7632a7..995b695f3e31 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py @@ -34,7 +34,7 @@ class Scale3D: ``` """ - inner: datatypes.Vec3D | float = field(converter=scale3d_inner_converter) + inner: Union[datatypes.Vec3D, float] = field(converter=scale3d_inner_converter) """ ThreeD (datatypes.Vec3D): Individual scaling factors for each axis, distorting the original object. diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py index af7d518e3aeb..0e82fee5e47a 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py @@ -21,7 +21,7 @@ class Transform3D: """Representation of a 3D affine transform.""" - inner: datatypes.TranslationAndMat3x3 | datatypes.TranslationRotationScale3D = field() + inner: Union[datatypes.TranslationAndMat3x3, datatypes.TranslationRotationScale3D] = field() """ TranslationAndMat3x3 (datatypes.TranslationAndMat3x3): From 3db588726cb2014d72583e35569f5065055260df Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 21 Jul 2023 12:53:12 +0200 Subject: [PATCH 02/37] fmt --- rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py | 4 ++-- rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py index 5bea0163e66c..47a1ea91f26d 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py @@ -208,7 +208,7 @@ def _native_to_pa_array(data: AffixFuzzer2ArrayLike, data_type: pa.DataType) -> @define class AffixFuzzer3: - inner: Union[float, list[datatypes.AffixFuzzer1], npt.NDArray[np.float32]] = field() + inner: float | list[datatypes.AffixFuzzer1] | npt.NDArray[np.float32] = field() """ degrees (float): @@ -323,7 +323,7 @@ def _native_to_pa_array(data: AffixFuzzer3ArrayLike, data_type: pa.DataType) -> @define class AffixFuzzer4: - inner: Union[datatypes.AffixFuzzer3, list[datatypes.AffixFuzzer3]] = field() + inner: datatypes.AffixFuzzer3 | list[datatypes.AffixFuzzer3] = field() """ single_required (datatypes.AffixFuzzer3): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py index 3beed260f921..76a5518a8374 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/rotation3d.py @@ -21,7 +21,7 @@ class Rotation3D: """A 3D rotation.""" - inner: Union[datatypes.Quaternion, datatypes.RotationAxisAngle] = field(converter=rotation3d_inner_converter) + inner: datatypes.Quaternion | datatypes.RotationAxisAngle = field(converter=rotation3d_inner_converter) """ Quaternion (datatypes.Quaternion): Rotation defined by a quaternion. diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py index 995b695f3e31..d6e3db7632a7 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/scale3d.py @@ -34,7 +34,7 @@ class Scale3D: ``` """ - inner: Union[datatypes.Vec3D, float] = field(converter=scale3d_inner_converter) + inner: datatypes.Vec3D | float = field(converter=scale3d_inner_converter) """ ThreeD (datatypes.Vec3D): Individual scaling factors for each axis, distorting the original object. diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py index 0e82fee5e47a..af7d518e3aeb 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/transform3d.py @@ -21,7 +21,7 @@ class Transform3D: """Representation of a 3D affine transform.""" - inner: Union[datatypes.TranslationAndMat3x3, datatypes.TranslationRotationScale3D] = field() + inner: datatypes.TranslationAndMat3x3 | datatypes.TranslationRotationScale3D = field() """ TranslationAndMat3x3 (datatypes.TranslationAndMat3x3): From 76b7cc46df8eec814cad23ee5c49fa201975032b Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Thu, 20 Jul 2023 16:10:16 +0200 Subject: [PATCH 03/37] turn Point2D into LegacyPoint2D, and expose new Point2D in its stead --- crates/re_arrow_store/benches/arrow2.rs | 4 +- .../examples/latest_component.rs | 6 +- .../examples/latest_components.rs | 4 +- .../examples/range_components.rs | 10 +- crates/re_arrow_store/tests/correctness.rs | 14 +- crates/re_arrow_store/tests/data_store.rs | 212 +++++++++++------- crates/re_components/src/datagen.rs | 11 +- crates/re_components/src/lib.rs | 6 +- crates/re_components/src/point.rs | 22 +- crates/re_components/tests/data_row.rs | 12 +- crates/re_components/tests/data_table.rs | 12 +- .../re_components/tests/data_table_batcher.rs | 4 +- crates/re_query/benches/query_benchmark.rs | 20 +- crates/re_query/examples/range.rs | 13 +- crates/re_query/src/dataframe_util.rs | 12 +- crates/re_query/src/entity_view.rs | 30 ++- crates/re_query/src/query.rs | 48 ++-- crates/re_query/tests/query_tests.rs | 57 +++-- crates/re_query/tests/range_tests.rs | 163 +++++++++----- crates/re_query/tests/visit_tests.rs | 60 ++--- docs/code-examples/point2d_random.rs | 4 +- docs/code-examples/point2d_simple.rs | 4 +- docs/code-examples/point3d_simple.rs | 1 + examples/rust/objectron/src/main.rs | 4 +- tests/rust/test_api/src/main.rs | 12 +- 25 files changed, 433 insertions(+), 312 deletions(-) diff --git a/crates/re_arrow_store/benches/arrow2.rs b/crates/re_arrow_store/benches/arrow2.rs index 578591987101..1b34e78f1769 100644 --- a/crates/re_arrow_store/benches/arrow2.rs +++ b/crates/re_arrow_store/benches/arrow2.rs @@ -10,7 +10,7 @@ use criterion::{criterion_group, Criterion}; use itertools::Itertools; use re_components::{ datagen::{build_some_instances, build_some_point2d, build_some_rects}, - Point2D, Rect2D, + LegacyPoint2D, Rect2D, }; use re_log_types::{DataCell, SizeBytes as _}; use re_types::{components::InstanceKey, Component}; @@ -295,7 +295,7 @@ fn estimated_size_bytes(c: &mut Criterion) { } { - fn generate_points() -> Vec> { + fn generate_points() -> Vec> { (0..NUM_ROWS) .map(|_| build_some_point2d(NUM_INSTANCES)) .collect() diff --git a/crates/re_arrow_store/examples/latest_component.rs b/crates/re_arrow_store/examples/latest_component.rs index 4c859e4966c4..eb97a3f30687 100644 --- a/crates/re_arrow_store/examples/latest_component.rs +++ b/crates/re_arrow_store/examples/latest_component.rs @@ -8,7 +8,7 @@ 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, + LegacyPoint2D, Rect2D, }; use re_log_types::EntityPath; use re_types::{components::InstanceKey, Loggable}; @@ -45,8 +45,8 @@ fn main() { &store, &LatestAtQuery::new(timeline_frame_nr, 10.into()), &ent_path, - Point2D::name(), + LegacyPoint2D::name(), ) .unwrap(); - println!("Query results from {:?}'s PoV:\n{df}", Point2D::name()); + println!("Query results from {:?}'s PoV:\n{df}", LegacyPoint2D::name()); } diff --git a/crates/re_arrow_store/examples/latest_components.rs b/crates/re_arrow_store/examples/latest_components.rs index b1023d548816..d6f1dc649634 100644 --- a/crates/re_arrow_store/examples/latest_components.rs +++ b/crates/re_arrow_store/examples/latest_components.rs @@ -10,7 +10,7 @@ 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, + LegacyPoint2D, Rect2D, }; use re_log_types::EntityPath; use re_types::{components::InstanceKey, Loggable}; @@ -31,7 +31,7 @@ fn main() { &store, &LatestAtQuery::new(timeline_frame_nr, 10.into()), &ent_path, - &[Point2D::name(), Rect2D::name()], + &[LegacyPoint2D::name(), Rect2D::name()], &JoinType::Outer, ) .unwrap(); diff --git a/crates/re_arrow_store/examples/range_components.rs b/crates/re_arrow_store/examples/range_components.rs index 14e71b0398cc..a598b584a3f9 100644 --- a/crates/re_arrow_store/examples/range_components.rs +++ b/crates/re_arrow_store/examples/range_components.rs @@ -8,7 +8,7 @@ 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, + LegacyPoint2D, Rect2D, }; use re_log_types::{EntityPath, TimeType, Timeline}; use re_types::{components::InstanceKey, Loggable}; @@ -56,7 +56,7 @@ fn main() { &query, &ent_path, Rect2D::name(), - [InstanceKey::name(), Rect2D::name(), Point2D::name()], + [InstanceKey::name(), Rect2D::name(), LegacyPoint2D::name()], &JoinType::Outer, ); for (time, df) in dfs.map(Result::unwrap) { @@ -77,8 +77,8 @@ fn main() { &store, &query, &ent_path, - Point2D::name(), - [InstanceKey::name(), Rect2D::name(), Point2D::name()], + LegacyPoint2D::name(), + [InstanceKey::name(), Rect2D::name(), LegacyPoint2D::name()], &JoinType::Outer, ); for (time, df) in dfs.map(Result::unwrap) { @@ -88,7 +88,7 @@ fn main() { || "".into(), |time| TimeType::Sequence.format(time) ), - Point2D::name(), + LegacyPoint2D::name(), df, ); } diff --git a/crates/re_arrow_store/tests/correctness.rs b/crates/re_arrow_store/tests/correctness.rs index 7357bbead031..71cbb7b4544e 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_components::{ColorRGBA, LegacyPoint2D}; let ent_path = EntityPath::from("this/that"); @@ -232,12 +232,16 @@ 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(), + LegacyPoint2D::name(), + ColorRGBA::name(), + ]; let dfs = re_arrow_store::polars_util::range_components( store, &query, &ent_path, - Point2D::name(), + LegacyPoint2D::name(), components, &JoinType::Outer, ) @@ -246,12 +250,12 @@ fn range_join_across_single_row_impl(store: &mut DataStore) { let df_expected = { let instances = InstanceKey::to_arrow(vec![InstanceKey(0), InstanceKey(1), InstanceKey(2)], None); - let points = Point2D::to_arrow(points, None); + let points = LegacyPoint2D::to_arrow(points, None); let colors = ColorRGBA::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((LegacyPoint2D::name().as_ref(), points)).unwrap(), Series::try_from((ColorRGBA::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..0c44709c7261 100644 --- a/crates/re_arrow_store/tests/data_store.rs +++ b/crates/re_arrow_store/tests/data_store.rs @@ -19,7 +19,7 @@ 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, + ColorRGBA, InstanceKey, LegacyPoint2D, Rect2D, }; use re_log_types::{DataCell, DataRow, DataTable, EntityPath, TableId, TimeType, Timeline}; use re_types::{ComponentName, Loggable as _}; @@ -93,10 +93,10 @@ fn all_components() { ]; let components_b = &[ - ColorRGBA::name(), // added by test, timeless - Point2D::name(), // added by test - Rect2D::name(), // added by test - cluster_key, // always here + ColorRGBA::name(), // added by test, timeless + LegacyPoint2D::name(), // added by test + Rect2D::name(), // added by test + cluster_key, // always here ]; let row = test_row!(ent_path @ [] => 2; [build_some_colors(2)]); @@ -148,10 +148,10 @@ fn all_components() { ]; 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 + ColorRGBA::name(), // added by test, timeless + Rect2D::name(), // ⚠ inherited before the buckets got split apart! + LegacyPoint2D::name(), // added by test + cluster_key, // always here ]; let row = test_row!(ent_path @ [] => 2; [build_some_colors(2)]); @@ -209,10 +209,10 @@ fn all_components() { ]; 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 + ColorRGBA::name(), // added by test, timeless + LegacyPoint2D::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 +312,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 = &[ColorRGBA::name(), LegacyPoint2D::name()]; let df = polars_util::latest_components( &store, @@ -333,26 +333,26 @@ fn latest_at_impl(store: &mut DataStore) { assert_latest_components( frame0, - &[(ColorRGBA::name(), &row4), (Point2D::name(), &row3)], // timeless + &[(ColorRGBA::name(), &row4), (LegacyPoint2D::name(), &row3)], // timeless ); assert_latest_components( frame1, &[ (ColorRGBA::name(), &row1), - (Point2D::name(), &row3), // timeless + (LegacyPoint2D::name(), &row3), // timeless ], ); assert_latest_components( frame2, - &[(ColorRGBA::name(), &row1), (Point2D::name(), &row2)], + &[(ColorRGBA::name(), &row1), (LegacyPoint2D::name(), &row2)], ); assert_latest_components( frame3, - &[(ColorRGBA::name(), &row1), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row1), (LegacyPoint2D::name(), &row3)], ); assert_latest_components( frame4, - &[(ColorRGBA::name(), &row4), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4), (LegacyPoint2D::name(), &row3)], ); } @@ -507,145 +507,166 @@ fn range_impl(store: &mut DataStore) { assert_range_components( TimeRange::new(frame1, frame1), - [ColorRGBA::name(), Point2D::name()], + [ColorRGBA::name(), LegacyPoint2D::name()], &[ ( Some(frame0), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_4)], + &[ + (ColorRGBA::name(), &row4_3), + (LegacyPoint2D::name(), &row4_4), + ], ), // timeless ( Some(frame1), &[ (ColorRGBA::name(), &row1), - (Point2D::name(), &row4_4), // timeless + (LegacyPoint2D::name(), &row4_4), // timeless ], ), ], ); assert_range_components( TimeRange::new(frame2, frame2), - [ColorRGBA::name(), Point2D::name()], + [ColorRGBA::name(), LegacyPoint2D::name()], &[ ( Some(frame1), &[ (ColorRGBA::name(), &row1), - (Point2D::name(), &row4_4), // timeless + (LegacyPoint2D::name(), &row4_4), // timeless ], ), // ], ); assert_range_components( TimeRange::new(frame3, frame3), - [ColorRGBA::name(), Point2D::name()], + [ColorRGBA::name(), LegacyPoint2D::name()], &[ ( Some(frame2), - &[(ColorRGBA::name(), &row1), (Point2D::name(), &row2)], + &[(ColorRGBA::name(), &row1), (LegacyPoint2D::name(), &row2)], ), // ], ); assert_range_components( TimeRange::new(frame4, frame4), - [ColorRGBA::name(), Point2D::name()], + [ColorRGBA::name(), LegacyPoint2D::name()], &[ ( Some(frame3), - &[(ColorRGBA::name(), &row1), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row1), (LegacyPoint2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_1), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4_1), (LegacyPoint2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_2), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4_2), (LegacyPoint2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! + &[ + (ColorRGBA::name(), &row4_3), + (LegacyPoint2D::name(), &row4_25), + ], // !!! ), ], ); assert_range_components( TimeRange::new(frame5, frame5), - [ColorRGBA::name(), Point2D::name()], + [ColorRGBA::name(), LegacyPoint2D::name()], &[ ( Some(frame4), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_4)], // !!! + &[ + (ColorRGBA::name(), &row4_3), + (LegacyPoint2D::name(), &row4_4), + ], // !!! ), // ], ); - // Unit ranges (Point2D's PoV) + // Unit ranges (LegacyPoint2D's PoV) assert_range_components( TimeRange::new(frame1, frame1), - [Point2D::name(), ColorRGBA::name()], + [LegacyPoint2D::name(), ColorRGBA::name()], &[ ( Some(frame0), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[ + (LegacyPoint2D::name(), &row4_4), + (ColorRGBA::name(), &row4_3), + ], ), // timeless ], ); assert_range_components( TimeRange::new(frame2, frame2), - [Point2D::name(), ColorRGBA::name()], + [LegacyPoint2D::name(), ColorRGBA::name()], &[ ( Some(frame1), &[ - (Point2D::name(), &row4_4), // timeless + (LegacyPoint2D::name(), &row4_4), // timeless (ColorRGBA::name(), &row1), ], ), ( Some(frame2), - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row2), (ColorRGBA::name(), &row1)], ), // ], ); assert_range_components( TimeRange::new(frame3, frame3), - [Point2D::name(), ColorRGBA::name()], + [LegacyPoint2D::name(), ColorRGBA::name()], &[ ( Some(frame2), - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row2), (ColorRGBA::name(), &row1)], ), ( Some(frame3), - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row3), (ColorRGBA::name(), &row1)], ), ], ); assert_range_components( TimeRange::new(frame4, frame4), - [Point2D::name(), ColorRGBA::name()], + [LegacyPoint2D::name(), ColorRGBA::name()], &[ ( Some(frame3), - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row3), (ColorRGBA::name(), &row1)], ), ( Some(frame4), - &[(Point2D::name(), &row4_25), (ColorRGBA::name(), &row4_2)], + &[ + (LegacyPoint2D::name(), &row4_25), + (ColorRGBA::name(), &row4_2), + ], ), ( Some(frame4), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[ + (LegacyPoint2D::name(), &row4_4), + (ColorRGBA::name(), &row4_3), + ], ), ], ); assert_range_components( TimeRange::new(frame5, frame5), - [Point2D::name(), ColorRGBA::name()], + [LegacyPoint2D::name(), ColorRGBA::name()], &[ ( Some(frame4), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[ + (LegacyPoint2D::name(), &row4_4), + (ColorRGBA::name(), &row4_3), + ], ), // ], ); @@ -654,59 +675,74 @@ fn range_impl(store: &mut DataStore) { assert_range_components( TimeRange::new(frame1, frame5), - [ColorRGBA::name(), Point2D::name()], + [ColorRGBA::name(), LegacyPoint2D::name()], &[ ( Some(frame0), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_4)], + &[ + (ColorRGBA::name(), &row4_3), + (LegacyPoint2D::name(), &row4_4), + ], ), // timeless ( Some(frame1), &[ (ColorRGBA::name(), &row1), - (Point2D::name(), &row4_4), // timeless + (LegacyPoint2D::name(), &row4_4), // timeless ], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_1), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4_1), (LegacyPoint2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_2), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4_2), (LegacyPoint2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! + &[ + (ColorRGBA::name(), &row4_3), + (LegacyPoint2D::name(), &row4_25), + ], // !!! ), ], ); - // Full range (Point2D's PoV) + // Full range (LegacyPoint2D's PoV) assert_range_components( TimeRange::new(frame1, frame5), - [Point2D::name(), ColorRGBA::name()], + [LegacyPoint2D::name(), ColorRGBA::name()], &[ ( Some(frame0), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[ + (LegacyPoint2D::name(), &row4_4), + (ColorRGBA::name(), &row4_3), + ], ), // timeless ( Some(frame2), - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row2), (ColorRGBA::name(), &row1)], ), ( Some(frame3), - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row3), (ColorRGBA::name(), &row1)], ), ( Some(frame4), - &[(Point2D::name(), &row4_25), (ColorRGBA::name(), &row4_2)], + &[ + (LegacyPoint2D::name(), &row4_25), + (ColorRGBA::name(), &row4_2), + ], ), ( Some(frame4), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[ + (LegacyPoint2D::name(), &row4_4), + (ColorRGBA::name(), &row4_3), + ], ), ], ); @@ -715,80 +751,98 @@ fn range_impl(store: &mut DataStore) { assert_range_components( TimeRange::new(TimeInt::MIN, TimeInt::MAX), - [ColorRGBA::name(), Point2D::name()], + [ColorRGBA::name(), LegacyPoint2D::name()], &[ (None, &[(ColorRGBA::name(), &row1)]), ( None, - &[(ColorRGBA::name(), &row4_1), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4_1), (LegacyPoint2D::name(), &row3)], ), ( None, - &[(ColorRGBA::name(), &row4_2), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4_2), (LegacyPoint2D::name(), &row3)], ), ( None, - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! + &[ + (ColorRGBA::name(), &row4_3), + (LegacyPoint2D::name(), &row4_25), + ], // !!! ), ( Some(frame1), &[ (ColorRGBA::name(), &row1), - (Point2D::name(), &row4_4), // timeless + (LegacyPoint2D::name(), &row4_4), // timeless ], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_1), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4_1), (LegacyPoint2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_2), (Point2D::name(), &row3)], + &[(ColorRGBA::name(), &row4_2), (LegacyPoint2D::name(), &row3)], ), ( Some(frame4), - &[(ColorRGBA::name(), &row4_3), (Point2D::name(), &row4_25)], // !!! + &[ + (ColorRGBA::name(), &row4_3), + (LegacyPoint2D::name(), &row4_25), + ], // !!! ), ], ); - // Infinite range (Point2D's PoV) + // Infinite range (LegacyPoint2D's PoV) assert_range_components( TimeRange::new(TimeInt::MIN, TimeInt::MAX), - [Point2D::name(), ColorRGBA::name()], + [LegacyPoint2D::name(), ColorRGBA::name()], &[ ( None, - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row2), (ColorRGBA::name(), &row1)], ), ( None, - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row3), (ColorRGBA::name(), &row1)], ), ( None, - &[(Point2D::name(), &row4_25), (ColorRGBA::name(), &row4_2)], + &[ + (LegacyPoint2D::name(), &row4_25), + (ColorRGBA::name(), &row4_2), + ], ), ( None, - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[ + (LegacyPoint2D::name(), &row4_4), + (ColorRGBA::name(), &row4_3), + ], ), ( Some(frame2), - &[(Point2D::name(), &row2), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row2), (ColorRGBA::name(), &row1)], ), ( Some(frame3), - &[(Point2D::name(), &row3), (ColorRGBA::name(), &row1)], + &[(LegacyPoint2D::name(), &row3), (ColorRGBA::name(), &row1)], ), ( Some(frame4), - &[(Point2D::name(), &row4_25), (ColorRGBA::name(), &row4_2)], + &[ + (LegacyPoint2D::name(), &row4_25), + (ColorRGBA::name(), &row4_2), + ], ), ( Some(frame4), - &[(Point2D::name(), &row4_4), (ColorRGBA::name(), &row4_3)], + &[ + (LegacyPoint2D::name(), &row4_4), + (ColorRGBA::name(), &row4_3), + ], ), ], ); diff --git a/crates/re_components/src/datagen.rs b/crates/re_components/src/datagen.rs index acbf203dc1e5..18bea95a1238 100644 --- a/crates/re_components/src/datagen.rs +++ b/crates/re_components/src/datagen.rs @@ -23,15 +23,12 @@ pub fn build_some_labels(len: usize) -> Vec { } /// Create `len` dummy `Point2D` -pub fn build_some_point2d(len: usize) -> Vec { +pub fn build_some_point2d(len: usize) -> Vec { use rand::Rng as _; let mut rng = rand::thread_rng(); (0..len) - .map(|_| crate::Point2D { - x: rng.gen_range(0.0..10.0), - y: rng.gen_range(0.0..10.0), - }) + .map(|_| crate::LegacyPoint2D::new(rng.gen_range(0.0..10.0), rng.gen_range(0.0..10.0))) .collect() } @@ -87,7 +84,7 @@ pub fn build_some_instances_from(instances: impl IntoIterator) -> Ve /// Crafts a simple but interesting [`re_log_types::DataTable`]. #[cfg(not(target_arch = "wasm32"))] pub fn data_table_example(timeless: bool) -> re_log_types::DataTable { - use crate::{ColorRGBA, Label, Point2D}; + use crate::{ColorRGBA, Label, LegacyPoint2D}; use re_log_types::{DataRow, DataTable, RowId, TableId, TimePoint}; let table_id = TableId::random(); @@ -109,7 +106,7 @@ pub fn data_table_example(timeless: bool) -> re_log_types::DataTable { let row0 = { let num_instances = 2; - let points: &[Point2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; + let points: &[LegacyPoint2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; let colors: &[_] = &[ColorRGBA::from_rgb(128, 128, 128)]; let labels: &[Label] = &[]; diff --git a/crates/re_components/src/lib.rs b/crates/re_components/src/lib.rs index 2caa9bac8001..0733716f1a4f 100644 --- a/crates/re_components/src/lib.rs +++ b/crates/re_components/src/lib.rs @@ -68,7 +68,7 @@ pub use self::{ mat::Mat3x3, mesh3d::{EncodedMesh3D, Mesh3D, MeshFormat, MeshId, RawMesh3D}, pinhole::Pinhole, - point::{Point2D, Point3D}, + point::{LegacyPoint2D, Point3D}, quaternion::Quaternion, radius::Radius, rect::Rect2D, @@ -94,7 +94,7 @@ pub use self::tensor::{TensorImageLoadError, TensorImageSaveError}; pub use self::load_file::{data_cell_from_file_path, data_cell_from_mesh_file_path, FromFileError}; // This is a component -pub use re_types::components::InstanceKey; +pub use re_types::components::{InstanceKey, Point2D}; // This is very convenient to re-export pub use re_log_types::LegacyComponent; @@ -126,7 +126,7 @@ lazy_static! { ::field(), ::field(), ::field(), - ::field(), + ::field(), ::field(), ::field(), ::field(), diff --git a/crates/re_components/src/point.rs b/crates/re_components/src/point.rs index 956ec981bc7a..c530c242e2b9 100644 --- a/crates/re_components/src/point.rs +++ b/crates/re_components/src/point.rs @@ -18,13 +18,13 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; /// ); /// ``` #[derive(Clone, Debug, ArrowField, ArrowSerialize, ArrowDeserialize, PartialEq)] -pub struct Point2D { +pub struct LegacyPoint2D { pub x: f32, pub y: f32, } -impl Point2D { - pub const ZERO: Point2D = Point2D { x: 0.0, y: 0.0 }; +impl LegacyPoint2D { + pub const ZERO: LegacyPoint2D = LegacyPoint2D { x: 0.0, y: 0.0 }; #[inline] pub fn new(x: f32, y: f32) -> Self { @@ -32,14 +32,14 @@ impl Point2D { } } -impl re_log_types::LegacyComponent for Point2D { +impl re_log_types::LegacyComponent for LegacyPoint2D { #[inline] fn legacy_name() -> re_log_types::ComponentName { "rerun.point2d".into() } } -impl From<[f32; 2]> for Point2D { +impl From<[f32; 2]> for LegacyPoint2D { #[inline] fn from(p: [f32; 2]) -> Self { Self { x: p[0], y: p[1] } @@ -47,7 +47,7 @@ impl From<[f32; 2]> for Point2D { } #[cfg(feature = "glam")] -impl From for Point2D { +impl From for LegacyPoint2D { #[inline] fn from(pt: glam::Vec2) -> Self { Self::new(pt.x, pt.y) @@ -55,22 +55,22 @@ impl From for Point2D { } #[cfg(feature = "glam")] -impl From for glam::Vec2 { +impl From for glam::Vec2 { #[inline] - fn from(pt: Point2D) -> Self { + fn from(pt: LegacyPoint2D) -> Self { Self::new(pt.x, pt.y) } } #[cfg(feature = "glam")] -impl From for glam::Vec3 { +impl From for glam::Vec3 { #[inline] - fn from(pt: Point2D) -> Self { + fn from(pt: LegacyPoint2D) -> Self { Self::new(pt.x, pt.y, 0.0) } } -re_log_types::component_legacy_shim!(Point2D); +re_log_types::component_legacy_shim!(LegacyPoint2D); /// A point in 3D space. /// diff --git a/crates/re_components/tests/data_row.rs b/crates/re_components/tests/data_row.rs index 7171c573cea2..cd5268e6ea42 100644 --- a/crates/re_components/tests/data_row.rs +++ b/crates/re_components/tests/data_row.rs @@ -1,4 +1,4 @@ -use re_components::{ColorRGBA, Label, Point2D}; +use re_components::{ColorRGBA, Label, LegacyPoint2D}; use re_log_types::{DataRow, DataRowError, EntityPath, RowId, TimePoint}; use re_types::Loggable as _; @@ -8,7 +8,7 @@ fn data_row_error_num_instances() { let timepoint = TimePoint::timeless(); let num_instances = 2; - let points: &[Point2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; + let points: &[LegacyPoint2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; let colors: &[_] = &[ColorRGBA::from_rgb(128, 128, 128)]; let labels: &[Label] = &[]; @@ -22,7 +22,7 @@ fn data_row_error_num_instances() { DataRow::try_from_cells1(row_id, "a/b/c", timepoint.clone(), num_instances, points).unwrap(); // anything else is illegal - let points: &[Point2D] = &[ + let points: &[LegacyPoint2D] = &[ [10.0, 10.0].into(), [20.0, 20.0].into(), [30.0, 30.0].into(), @@ -38,7 +38,7 @@ fn data_row_error_num_instances() { num_instances, } => { assert_eq!(EntityPath::from("a/b/c"), entity_path); - assert_eq!(Point2D::name(), component); + assert_eq!(LegacyPoint2D::name(), component); assert_eq!(2, expected_num_instances); assert_eq!(3, num_instances); } @@ -51,7 +51,7 @@ fn data_row_error_duped_components() { let row_id = RowId::ZERO; let timepoint = TimePoint::timeless(); - let points: &[Point2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; + let points: &[LegacyPoint2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; let err = DataRow::try_from_cells2(row_id, "a/b/c", timepoint, 2, (points, points)).unwrap_err(); @@ -62,7 +62,7 @@ fn data_row_error_duped_components() { component, } => { assert_eq!(EntityPath::from("a/b/c"), entity_path); - assert_eq!(Point2D::name(), component); + assert_eq!(LegacyPoint2D::name(), component); } _ => unreachable!(), } diff --git a/crates/re_components/tests/data_table.rs b/crates/re_components/tests/data_table.rs index d5dde12d2367..36e624ba4ace 100644 --- a/crates/re_components/tests/data_table.rs +++ b/crates/re_components/tests/data_table.rs @@ -86,9 +86,9 @@ fn data_table_sizes_basics() { // struct let mut cell = DataCell::from_native( [ - re_components::Point2D::new(42.0, 666.0), - re_components::Point2D::new(42.0, 666.0), - re_components::Point2D::new(42.0, 666.0), + re_components::LegacyPoint2D::new(42.0, 666.0), + re_components::LegacyPoint2D::new(42.0, 666.0), + re_components::LegacyPoint2D::new(42.0, 666.0), ] .as_slice(), ); @@ -99,7 +99,7 @@ fn data_table_sizes_basics() { 5_260_064, // expected_num_bytes ); expect( - DataCell::from_arrow(re_components::Point2D::name(), cell.to_arrow().sliced(1, 1)), + DataCell::from_arrow(re_components::LegacyPoint2D::name(), cell.to_arrow().sliced(1, 1)), 10_000, // num_rows 5_100_064, // expected_num_bytes ); @@ -120,7 +120,7 @@ fn data_table_sizes_basics() { 4_080_064, // expected_num_bytes ); expect( - DataCell::from_arrow(re_components::Point2D::name(), cell.to_arrow().sliced(1, 1)), + DataCell::from_arrow(re_components::LegacyPoint2D::name(), cell.to_arrow().sliced(1, 1)), 10_000, // num_rows 3_920_064, // expected_num_bytes ); @@ -141,7 +141,7 @@ fn data_table_sizes_basics() { 6_120_064, // expected_num_bytes ); expect( - DataCell::from_arrow(re_components::Point2D::name(), cell.to_arrow().sliced(1, 1)), + DataCell::from_arrow(re_components::LegacyPoint2D::name(), cell.to_arrow().sliced(1, 1)), 10_000, // num_rows 5_560_064, // expected_num_bytes ); diff --git a/crates/re_components/tests/data_table_batcher.rs b/crates/re_components/tests/data_table_batcher.rs index 312694c25f12..034c9cbccb75 100644 --- a/crates/re_components/tests/data_table_batcher.rs +++ b/crates/re_components/tests/data_table_batcher.rs @@ -1,7 +1,7 @@ use crossbeam::{channel::TryRecvError, select}; use itertools::Itertools as _; -use re_components::{ColorRGBA, Label, Point2D}; +use re_components::{ColorRGBA, Label, LegacyPoint2D}; use re_log_types::{ DataRow, DataTableBatcher, DataTableBatcherConfig, RowId, SizeBytes, TimePoint, Timeline, }; @@ -281,7 +281,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 points: &[LegacyPoint2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()]; let colors: &[_] = &[ColorRGBA::from_rgb(128, 128, 128)]; let labels: &[Label] = &[]; diff --git a/crates/re_query/benches/query_benchmark.rs b/crates/re_query/benches/query_benchmark.rs index ec7a264927aa..f291660f1ea9 100644 --- a/crates/re_query/benches/query_benchmark.rs +++ b/crates/re_query/benches/query_benchmark.rs @@ -7,7 +7,7 @@ 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}, - ColorRGBA, Point2D, Vec3D, + ColorRGBA, LegacyPoint2D, Vec3D, }; use re_log_types::{entity_path, DataRow, EntityPath, Index, RowId, TimeType, Timeline}; use re_query::query_entity_with_primary; @@ -171,7 +171,7 @@ fn insert_rows<'a>(msgs: impl Iterator) -> DataStore { } struct SavePoint { - _pos: Point2D, + _pos: LegacyPoint2D, _color: Option, } @@ -183,14 +183,16 @@ fn query_and_visit_points(store: &mut DataStore, paths: &[EntityPath]) -> Vec(store, &query, path, &[ColorRGBA::name()]) + query_entity_with_primary::(store, &query, path, &[ColorRGBA::name()]) .and_then(|entity_view| { - entity_view.visit2(|_: InstanceKey, pos: Point2D, color: Option| { - points.push(SavePoint { - _pos: pos, - _color: color, - }); - }) + entity_view.visit2( + |_: InstanceKey, pos: LegacyPoint2D, color: Option| { + points.push(SavePoint { + _pos: pos, + _color: color, + }); + }, + ) }) .ok() .unwrap(); diff --git a/crates/re_query/examples/range.rs b/crates/re_query/examples/range.rs index 5b5b4cf33b87..12a3aa618ff5 100644 --- a/crates/re_query/examples/range.rs +++ b/crates/re_query/examples/range.rs @@ -7,7 +7,7 @@ use re_arrow_store::{DataStore, RangeQuery, TimeRange}; use re_components::{ datagen::{build_frame_nr, build_some_point2d, build_some_rects}, - Point2D, Rect2D, + LegacyPoint2D, Rect2D, }; use re_log_types::{DataRow, EntityPath, RowId, TimeType}; use re_query::range_entity_with_primary; @@ -53,7 +53,7 @@ fn main() { println!("\n-----\n"); - let components = [InstanceKey::name(), Rect2D::name(), Point2D::name()]; + let components = [InstanceKey::name(), Rect2D::name(), LegacyPoint2D::name()]; let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); for (time, ent_view) in ent_views { eprintln!( @@ -63,14 +63,15 @@ fn main() { |time| TimeType::Sequence.format(time) ), Rect2D::name(), - &ent_view.as_df2::().unwrap() + &ent_view.as_df2::().unwrap() ); } println!("\n-----\n"); - let components = [InstanceKey::name(), Rect2D::name(), Point2D::name()]; - let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [InstanceKey::name(), Rect2D::name(), LegacyPoint2D::name()]; + let ent_views = + range_entity_with_primary::(&store, &query, &ent_path, components); for (time, ent_view) in ent_views { eprintln!( "Found data at time {} from {}'s PoV:\n{}", @@ -78,7 +79,7 @@ fn main() { || "".into(), |time| TimeType::Sequence.format(time) ), - Point2D::name(), + LegacyPoint2D::name(), &ent_view.as_df2::().unwrap() ); } diff --git a/crates/re_query/src/dataframe_util.rs b/crates/re_query/src/dataframe_util.rs index 2a8aabd9000e..1ef0b89fc794 100644 --- a/crates/re_query/src/dataframe_util.rs +++ b/crates/re_query/src/dataframe_util.rs @@ -213,13 +213,13 @@ impl ArchetypeView { #[test] fn test_df_builder() { - use re_components::{ColorRGBA, Point2D}; + use re_components::{ColorRGBA, LegacyPoint2D}; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), - Some(Point2D { x: 5.0, y: 6.0 }), - Some(Point2D { x: 7.0, y: 8.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 5.0, y: 6.0 }), + Some(LegacyPoint2D { x: 7.0, y: 8.0 }), ]; let colors = vec![ @@ -247,7 +247,7 @@ fn test_df_builder() { // └───────────┴────────────┘ // Unnesting the struct makes it easier to validate the results. - let df = df.unnest([Point2D::name()]).unwrap(); + let df = df.unnest([LegacyPoint2D::name()]).unwrap(); // eprintln!("{df:?}"); // // ┌─────┬─────┬────────────┐ diff --git a/crates/re_query/src/entity_view.rs b/crates/re_query/src/entity_view.rs index e61fec638eec..b1fdb02d241d 100644 --- a/crates/re_query/src/entity_view.rs +++ b/crates/re_query/src/entity_view.rs @@ -154,17 +154,17 @@ where #[test] fn lookup_value() { use crate::QueryError; - use re_components::{Point2D, Rect2D}; + use re_components::{LegacyPoint2D, Rect2D}; use re_types::Loggable as _; let instance_keys = InstanceKey::from_iter(0..5); let points = [ - Point2D { x: 1.0, y: 2.0 }, // - Point2D { x: 3.0, y: 4.0 }, - Point2D { x: 5.0, y: 6.0 }, - Point2D { x: 7.0, y: 8.0 }, - Point2D { x: 9.0, y: 10.0 }, + LegacyPoint2D::new(1.0, 2.0), // + LegacyPoint2D::new(3.0, 4.0), + LegacyPoint2D::new(5.0, 6.0), + LegacyPoint2D::new(7.0, 8.0), + LegacyPoint2D::new(9.0, 10.0), ]; let component = @@ -176,7 +176,7 @@ fn lookup_value() { let value = component.lookup_arrow(&InstanceKey(2)).unwrap(); let expected_point = [points[2].clone()]; - let expected_arrow = Point2D::to_arrow(expected_point, None); + let expected_arrow = LegacyPoint2D::to_arrow(expected_point, None); assert_eq!(expected_arrow, value); @@ -196,16 +196,16 @@ fn lookup_value() { let value = component.lookup_arrow(&InstanceKey(99)).unwrap(); let expected_point = [points[3].clone()]; - let expected_arrow = Point2D::to_arrow(&expected_point, None); + let expected_arrow = LegacyPoint2D::to_arrow(&expected_point, None); assert_eq!(expected_arrow, value); // Lookups with serialization - let value = component.lookup::(&InstanceKey(99)).unwrap(); + let value = component.lookup::(&InstanceKey(99)).unwrap(); assert_eq!(expected_point[0], value); - let missing_value = component.lookup::(&InstanceKey(46)); + let missing_value = component.lookup::(&InstanceKey(46)); assert!(matches!( missing_value.err().unwrap(), QueryError::ComponentNotFound @@ -220,20 +220,18 @@ fn lookup_value() { #[test] fn lookup_splat() { - use re_components::Point2D; + use re_components::LegacyPoint2D; let instances = [ InstanceKey::SPLAT, // ]; - let points = [ - Point2D { x: 1.0, y: 2.0 }, // - ]; + let points = [LegacyPoint2D::new(1.0, 2.0)]; let component = ComponentWithInstances::from_native(instances.as_slice(), points.as_slice()); // Any instance we look up will return the slatted value - let value = component.lookup::(&InstanceKey(1)).unwrap(); + let value = component.lookup::(&InstanceKey(1)).unwrap(); assert_eq!(points[0], value); - let value = component.lookup::(&InstanceKey(99)).unwrap(); + let value = component.lookup::(&InstanceKey(99)).unwrap(); assert_eq!(points[0], value); } diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index 4eea123bff32..c4bda0c66e57 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -13,7 +13,7 @@ use crate::{ArchetypeView, ComponentWithInstances, EntityView, QueryError}; /// /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_components::Point2D; +/// # use re_components::LegacyPoint2D; /// # use re_log_types::Timeline; /// # use re_types::Loggable as _; /// # let store = re_query::__populate_example_store(); @@ -25,12 +25,12 @@ use crate::{ArchetypeView, ComponentWithInstances, EntityView, QueryError}; /// &store, /// &query, /// &ent_path.into(), -/// Point2D::name(), +/// LegacyPoint2D::name(), /// ) /// .unwrap(); /// /// # #[cfg(feature = "polars")] -/// let df = component.as_df::().unwrap(); +/// let df = component.as_df::().unwrap(); /// /// //println!("{df:?}"); /// ``` @@ -86,7 +86,7 @@ pub fn get_component_with_instances( /// /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_components::{Point2D, ColorRGBA}; +/// # use re_components::{LegacyPoint2D, ColorRGBA}; /// # use re_log_types::Timeline; /// # use re_types::Loggable as _; /// # let store = re_query::__populate_example_store(); @@ -94,7 +94,7 @@ pub fn get_component_with_instances( /// let ent_path = "point"; /// let query = LatestAtQuery::new(Timeline::new_sequence("frame_nr"), 123.into()); /// -/// let entity_view = re_query::query_entity_with_primary::( +/// let entity_view = re_query::query_entity_with_primary::( /// &store, /// &query, /// &ent_path.into(), @@ -165,7 +165,7 @@ pub fn query_entity_with_primary( /// # use re_arrow_store::LatestAtQuery; /// # use re_log_types::Timeline; /// # use re_types::Component; -/// # use re_types::components::{Point2D, Color}; +/// # use re_types::components::{LegacyPoint2D, Color}; /// # use re_types::archetypes::Points2D; /// # let store = re_query::__populate_example_store(); /// @@ -180,7 +180,7 @@ pub fn query_entity_with_primary( /// .unwrap(); /// /// # #[cfg(feature = "polars")] -/// let df = arch_view.as_df2::().unwrap(); +/// let df = arch_view.as_df2::().unwrap(); /// /// //println!("{df:?}"); /// ``` @@ -241,7 +241,7 @@ 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, ColorRGBA, Point2D}; + use re_components::{datagen::build_frame_nr, ColorRGBA, LegacyPoint2D}; let mut store = DataStore::new(InstanceKey::name(), Default::default()); @@ -249,7 +249,7 @@ pub fn __populate_example_store() -> DataStore { let timepoint = [build_frame_nr(123.into())]; let instances = vec![InstanceKey(42), InstanceKey(96)]; - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![LegacyPoint2D::new(1.0, 2.0), LegacyPoint2D::new(3.0, 4.0)]; let row = DataRow::from_cells2_sized( RowId::random(), @@ -279,7 +279,7 @@ pub fn __populate_example_store() -> DataStore { #[test] fn simple_get_component() { use re_arrow_store::LatestAtQuery; - use re_components::Point2D; + use re_components::LegacyPoint2D; use re_log_types::Timeline; let store = __populate_example_store(); @@ -288,17 +288,18 @@ fn simple_get_component() { let query = LatestAtQuery::new(Timeline::new_sequence("frame_nr"), 123.into()); let (_, component) = - get_component_with_instances(&store, &query, &ent_path.into(), Point2D::name()).unwrap(); + get_component_with_instances(&store, &query, &ent_path.into(), LegacyPoint2D::name()) + .unwrap(); #[cfg(feature = "polars")] { - let df = component.as_df::().unwrap(); + let df = component.as_df::().unwrap(); eprintln!("{df:?}"); let instances = vec![Some(InstanceKey(42)), Some(InstanceKey(96))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D::new(1.0, 2.0)), + Some(LegacyPoint2D::new(3.0, 4.0)), ]; let expected = crate::dataframe_util::df_builder2(&instances, &points).unwrap(); @@ -315,22 +316,17 @@ fn simple_get_component() { #[test] fn simple_query_entity() { use re_arrow_store::LatestAtQuery; - use re_components::{ColorRGBA, Point2D}; + use re_components::{ColorRGBA, Rect2D, Vec4D}; use re_log_types::Timeline; let store = __populate_example_store(); - let ent_path = "point"; + let ent_path = "rect"; let query = LatestAtQuery::new(Timeline::new_sequence("frame_nr"), 123.into()); - let entity_view = query_entity_with_primary::( - &store, - &query, - &ent_path.into(), - &[ColorRGBA::name()], - ) - .unwrap(); - + let entity_view = + query_entity_with_primary::(&store, &query, &ent_path.into(), &[ColorRGBA::name()]) + .unwrap(); #[cfg(feature = "polars")] { let df = entity_view.as_df2::().unwrap(); @@ -338,8 +334,8 @@ fn simple_query_entity() { let instances = vec![Some(InstanceKey(42)), Some(InstanceKey(96))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(Rect2D::XYWH(Vec4D([1.0, 2.0, 3.0, 4.0]))), + Some(Rect2D::XYWH(Vec4D([5.0, 6.0, 7.0, 8.0]))), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; diff --git a/crates/re_query/tests/query_tests.rs b/crates/re_query/tests/query_tests.rs index c5cf4179bf30..2f634fe5a5e9 100644 --- a/crates/re_query/tests/query_tests.rs +++ b/crates/re_query/tests/query_tests.rs @@ -1,7 +1,7 @@ mod common; use re_arrow_store::DataStore; -use re_components::{datagen::build_frame_nr, ColorRGBA, Point2D}; +use re_components::{datagen::build_frame_nr, ColorRGBA, LegacyPoint2D}; use re_log_types::{DataRow, RowId}; use re_query::query_entity_with_primary; use re_types::{components::InstanceKey, Loggable}; @@ -14,7 +14,10 @@ fn simple_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with implicit instances - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![ + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); @@ -33,7 +36,7 @@ fn simple_query() { // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -59,8 +62,8 @@ fn simple_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -85,7 +88,10 @@ fn timeless_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with implicit instances - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![ + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); @@ -99,7 +105,7 @@ fn timeless_query() { // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -125,8 +131,8 @@ fn timeless_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -151,7 +157,10 @@ fn no_instance_join_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with an implicit instance - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![ + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); @@ -163,7 +172,7 @@ fn no_instance_join_query() { // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -189,8 +198,8 @@ fn no_instance_join_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![Some(ColorRGBA(0xff000000)), Some(ColorRGBA(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -215,14 +224,17 @@ fn missing_column_join_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with an implicit instance - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![ + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -248,8 +260,8 @@ fn missing_column_join_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let expected = df_builder2(&instances, &points).unwrap(); @@ -273,7 +285,10 @@ fn splatted_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with implicit instances - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![ + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); @@ -292,7 +307,7 @@ fn splatted_query() { // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -318,8 +333,8 @@ fn splatted_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![Some(ColorRGBA(0xff000000)), Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); diff --git a/crates/re_query/tests/range_tests.rs b/crates/re_query/tests/range_tests.rs index 1285be7f3f58..e856808e28f7 100644 --- a/crates/re_query/tests/range_tests.rs +++ b/crates/re_query/tests/range_tests.rs @@ -1,7 +1,7 @@ mod common; use re_arrow_store::{DataStore, TimeInt, TimeRange}; -use re_components::{datagen::build_frame_nr, ColorRGBA, Point2D}; +use re_components::{datagen::build_frame_nr, ColorRGBA, LegacyPoint2D}; use re_log_types::{DataRow, EntityPath, RowId}; use re_query::range_entity_with_primary; use re_types::{components::InstanceKey, Loggable as _}; @@ -15,7 +15,10 @@ fn simple_range() { let timepoint1 = [build_frame_nr(123.into())]; { // Create some points with implicit instances - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![ + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint1, 2, points); store.insert_row(&row).unwrap(); @@ -51,7 +54,10 @@ fn simple_range() { let timepoint3 = [build_frame_nr(323.into())]; { // Create some points with implicit instances - let points = vec![Point2D { x: 10.0, y: 20.0 }, Point2D { x: 30.0, y: 40.0 }]; + let points = vec![ + LegacyPoint2D { x: 10.0, y: 20.0 }, + LegacyPoint2D { x: 30.0, y: 40.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint3, 2, points); store.insert_row(&row).unwrap(); @@ -66,8 +72,13 @@ fn simple_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; - let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [ + InstanceKey::name(), + LegacyPoint2D::name(), + ColorRGBA::name(), + ]; + let ent_views = + range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -103,8 +114,8 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -123,8 +134,8 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -150,8 +161,13 @@ fn simple_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; - let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [ + InstanceKey::name(), + LegacyPoint2D::name(), + ColorRGBA::name(), + ]; + let ent_views = + range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -187,8 +203,8 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -207,8 +223,8 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -235,7 +251,10 @@ fn timeless_range() { let timepoint1 = [build_frame_nr(123.into())]; { // Create some points with implicit instances - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![ + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + ]; let mut row = DataRow::from_cells1(RowId::random(), ent_path.clone(), timepoint1, 2, &points); row.compute_all_size_bytes(); @@ -296,7 +315,10 @@ fn timeless_range() { let timepoint3 = [build_frame_nr(323.into())]; { // Create some points with implicit instances - let points = vec![Point2D { x: 10.0, y: 20.0 }, Point2D { x: 30.0, y: 40.0 }]; + let points = vec![ + LegacyPoint2D { x: 10.0, y: 20.0 }, + LegacyPoint2D { x: 30.0, y: 40.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint3, 2, &points); store.insert_row(&row).unwrap(); @@ -335,8 +357,13 @@ fn timeless_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; - let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [ + InstanceKey::name(), + LegacyPoint2D::name(), + ColorRGBA::name(), + ]; + let ent_views = + range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -372,8 +399,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -392,8 +419,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -419,8 +446,13 @@ fn timeless_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; - let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [ + InstanceKey::name(), + LegacyPoint2D::name(), + ColorRGBA::name(), + ]; + let ent_views = + range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -465,8 +497,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -485,8 +517,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -505,8 +537,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -530,8 +562,13 @@ fn timeless_range() { TimeRange::new(TimeInt::MIN, TimeInt::MAX), ); - let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; - let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [ + InstanceKey::name(), + LegacyPoint2D::name(), + ColorRGBA::name(), + ]; + let ent_views = + range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -584,8 +621,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -603,8 +640,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -623,8 +660,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -643,8 +680,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -671,7 +708,10 @@ fn simple_splatted_range() { let timepoint1 = [build_frame_nr(123.into())]; { // Create some points with implicit instances - let points = vec![Point2D { x: 1.0, y: 2.0 }, Point2D { x: 3.0, y: 4.0 }]; + let points = vec![ + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint1, 2, points); store.insert_row(&row).unwrap(); @@ -707,7 +747,10 @@ fn simple_splatted_range() { let timepoint3 = [build_frame_nr(323.into())]; { // Create some points with implicit instances - let points = vec![Point2D { x: 10.0, y: 20.0 }, Point2D { x: 30.0, y: 40.0 }]; + let points = vec![ + LegacyPoint2D { x: 10.0, y: 20.0 }, + LegacyPoint2D { x: 30.0, y: 40.0 }, + ]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint3, 2, points); store.insert_row(&row).unwrap(); @@ -722,8 +765,13 @@ fn simple_splatted_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; - let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [ + InstanceKey::name(), + LegacyPoint2D::name(), + ColorRGBA::name(), + ]; + let ent_views = + range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -759,8 +807,8 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -779,8 +827,8 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![Some(ColorRGBA(0x00ff0000)), Some(ColorRGBA(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -806,8 +854,13 @@ fn simple_splatted_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; - let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [ + InstanceKey::name(), + LegacyPoint2D::name(), + ColorRGBA::name(), + ]; + let ent_views = + range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -843,8 +896,8 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 1.0, y: 2.0 }), - Some(Point2D { x: 3.0, y: 4.0 }), + Some(LegacyPoint2D { x: 1.0, y: 2.0 }), + Some(LegacyPoint2D { x: 3.0, y: 4.0 }), ]; let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -863,8 +916,8 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(Point2D { x: 10.0, y: 20.0 }), - Some(Point2D { x: 30.0, y: 40.0 }), + Some(LegacyPoint2D { x: 10.0, y: 20.0 }), + Some(LegacyPoint2D { x: 30.0, y: 40.0 }), ]; let colors = vec![Some(ColorRGBA(0x00ff0000)), Some(ColorRGBA(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); diff --git a/crates/re_query/tests/visit_tests.rs b/crates/re_query/tests/visit_tests.rs index 6b9d251058de..6fe64ae06fa0 100644 --- a/crates/re_query/tests/visit_tests.rs +++ b/crates/re_query/tests/visit_tests.rs @@ -1,5 +1,5 @@ use itertools::Itertools; -use re_components::{ColorRGBA, Point2D}; +use re_components::{ColorRGBA, LegacyPoint2D}; use re_query::{ComponentWithInstances, EntityView}; use re_types::components::InstanceKey; @@ -7,15 +7,15 @@ use re_types::components::InstanceKey; fn basic_single_iter() { let instance_keys = InstanceKey::from_iter(0..2); let points = [ - Point2D { x: 1.0, y: 2.0 }, // - Point2D { x: 3.0, y: 4.0 }, + LegacyPoint2D { x: 1.0, y: 2.0 }, // + LegacyPoint2D { x: 3.0, y: 4.0 }, ]; let component = ComponentWithInstances::from_native(instance_keys, &points); let results = itertools::izip!( points.into_iter(), - component.iter_values::().unwrap() + component.iter_values::().unwrap() ) .collect_vec(); assert_eq!(results.len(), 2); @@ -29,9 +29,9 @@ fn implicit_joined_iter() { let instance_keys = InstanceKey::from_iter(0..3); let points = [ - Point2D { x: 1.0, y: 2.0 }, // - Point2D { x: 3.0, y: 4.0 }, - Point2D { x: 5.0, y: 6.0 }, + LegacyPoint2D { x: 1.0, y: 2.0 }, // + LegacyPoint2D { x: 3.0, y: 4.0 }, + LegacyPoint2D { x: 5.0, y: 6.0 }, ]; let colors = [ @@ -66,9 +66,9 @@ fn implicit_primary_joined_iter() { let point_ids = InstanceKey::from_iter(0..3); let points = [ - Point2D { x: 1.0, y: 2.0 }, // - Point2D { x: 3.0, y: 4.0 }, - Point2D { x: 5.0, y: 6.0 }, + LegacyPoint2D { x: 1.0, y: 2.0 }, // + LegacyPoint2D { x: 3.0, y: 4.0 }, + LegacyPoint2D { x: 5.0, y: 6.0 }, ]; let color_ids = [ @@ -111,9 +111,9 @@ fn implicit_component_joined_iter() { ]; let points = [ - Point2D { x: 1.0, y: 2.0 }, // - Point2D { x: 3.0, y: 4.0 }, - Point2D { x: 5.0, y: 6.0 }, + LegacyPoint2D { x: 1.0, y: 2.0 }, // + LegacyPoint2D { x: 3.0, y: 4.0 }, + LegacyPoint2D { x: 5.0, y: 6.0 }, ]; let color_ids = InstanceKey::from_iter(0..5); @@ -157,10 +157,10 @@ fn complex_joined_iter() { ]; let points = vec![ - Point2D { x: 1.0, y: 2.0 }, // - Point2D { x: 3.0, y: 4.0 }, - Point2D { x: 5.0, y: 6.0 }, - Point2D { x: 7.0, y: 8.0 }, + LegacyPoint2D { x: 1.0, y: 2.0 }, // + LegacyPoint2D { x: 3.0, y: 4.0 }, + LegacyPoint2D { x: 5.0, y: 6.0 }, + LegacyPoint2D { x: 7.0, y: 8.0 }, ]; let color_ids = vec![ @@ -205,19 +205,19 @@ fn complex_joined_iter() { fn single_visit() { let instance_keys = InstanceKey::from_iter(0..4); let points = [ - Point2D { x: 1.0, y: 2.0 }, - Point2D { x: 3.0, y: 4.0 }, - Point2D { x: 5.0, y: 6.0 }, - Point2D { x: 7.0, y: 8.0 }, + LegacyPoint2D { x: 1.0, y: 2.0 }, + LegacyPoint2D { x: 3.0, y: 4.0 }, + LegacyPoint2D { x: 5.0, y: 6.0 }, + LegacyPoint2D { x: 7.0, y: 8.0 }, ]; let entity_view = EntityView::from_native((&instance_keys, &points)); let mut instance_key_out = Vec::::new(); - let mut points_out = Vec::::new(); + let mut points_out = Vec::::new(); entity_view - .visit1(|instance_key: InstanceKey, point: Point2D| { + .visit1(|instance_key: InstanceKey, point: LegacyPoint2D| { instance_key_out.push(instance_key); points_out.push(point); }) @@ -231,11 +231,11 @@ fn single_visit() { #[test] fn joint_visit() { let points = vec![ - Point2D { x: 1.0, y: 2.0 }, // - Point2D { x: 3.0, y: 4.0 }, - Point2D { x: 5.0, y: 6.0 }, - Point2D { x: 7.0, y: 8.0 }, - Point2D { x: 9.0, y: 10.0 }, + LegacyPoint2D { x: 1.0, y: 2.0 }, // + LegacyPoint2D { x: 3.0, y: 4.0 }, + LegacyPoint2D { x: 5.0, y: 6.0 }, + LegacyPoint2D { x: 7.0, y: 8.0 }, + LegacyPoint2D { x: 9.0, y: 10.0 }, ]; let point_ids = InstanceKey::from_iter(0..5); @@ -255,11 +255,11 @@ fn joint_visit() { (&color_ids, &colors), ); - let mut points_out = Vec::::new(); + let mut points_out = Vec::::new(); let mut colors_out = Vec::>::new(); entity_view - .visit2(|_: InstanceKey, point: Point2D, color: Option| { + .visit2(|_: InstanceKey, point: LegacyPoint2D, color: Option| { points_out.push(point); colors_out.push(color); }) diff --git a/docs/code-examples/point2d_random.rs b/docs/code-examples/point2d_random.rs index 575158be9715..7a37b76cbc01 100644 --- a/docs/code-examples/point2d_random.rs +++ b/docs/code-examples/point2d_random.rs @@ -1,7 +1,7 @@ //! Log some random points with color and radii. use rand::distributions::Uniform; use rand::Rng; -use rerun::components::{ColorRGBA, Point2D, Radius, Rect2D, Vec4D}; +use rerun::components::{ColorRGBA, LegacyPoint2D, Radius, Rect2D, Vec4D}; use rerun::{MsgSender, RecordingStreamBuilder}; fn main() -> Result<(), Box> { @@ -14,7 +14,7 @@ fn main() -> Result<(), Box> { let mut colors = vec![]; let mut radii = vec![]; for _ in 0..10 { - positions.push(Point2D::new( + positions.push(LegacyPoint2D::new( rng.sample(position_distribs), rng.sample(position_distribs), )); diff --git a/docs/code-examples/point2d_simple.rs b/docs/code-examples/point2d_simple.rs index 8f6a54b479dd..e2fbc438104e 100644 --- a/docs/code-examples/point2d_simple.rs +++ b/docs/code-examples/point2d_simple.rs @@ -1,6 +1,6 @@ //! Log some very simple points. use rerun::{ - components::{Point2D, Rect2D, Vec4D}, + components::{LegacyPoint2D, Rect2D, Vec4D}, MsgSender, RecordingStreamBuilder, }; @@ -9,7 +9,7 @@ fn main() -> Result<(), Box> { let points = [[0.0, 0.0], [1.0, 1.0]] .into_iter() - .map(Point2D::from) + .map(LegacyPoint2D::from) .collect::>(); MsgSender::new("points") diff --git a/docs/code-examples/point3d_simple.rs b/docs/code-examples/point3d_simple.rs index 8cbf6ec4263b..055ef9fe35d7 100644 --- a/docs/code-examples/point3d_simple.rs +++ b/docs/code-examples/point3d_simple.rs @@ -1,4 +1,5 @@ //! Log some very simple points. + use rerun::{components::Point3D, MsgSender, RecordingStreamBuilder}; fn main() -> Result<(), Box> { diff --git a/examples/rust/objectron/src/main.rs b/examples/rust/objectron/src/main.rs index 383a3956a42d..7206c8e667a9 100644 --- a/examples/rust/objectron/src/main.rs +++ b/examples/rust/objectron/src/main.rs @@ -247,7 +247,7 @@ fn log_frame_annotations( timepoint: &TimePoint, annotations: &objectron::FrameAnnotation, ) -> anyhow::Result<()> { - use rerun::components::{ColorRGBA, InstanceKey, LineStrip2D, Point2D}; + use rerun::components::{ColorRGBA, InstanceKey, LineStrip2D, LegacyPoint2D}; for ann in &annotations.annotations { // TODO(cmc): we shouldn't be using those preprojected 2D points to begin with, Rerun is @@ -301,7 +301,7 @@ fn log_frame_annotations( } else { msg = msg .with_component(&ids)? - .with_component(&points.into_iter().map(Point2D::from).collect::>())?; + .with_component(&points.into_iter().map(LegacyPoint2D::from).collect::>())?; } msg.send(rec_stream)?; diff --git a/tests/rust/test_api/src/main.rs b/tests/rust/test_api/src/main.rs index 5380c8e1a57d..87dda1da8e99 100644 --- a/tests/rust/test_api/src/main.rs +++ b/tests/rust/test_api/src/main.rs @@ -18,7 +18,7 @@ use itertools::Itertools; use rerun::{ components::{ AnnotationContext, AnnotationInfo, Box3D, ClassDescription, ClassId, ColorRGBA, DrawOrder, - Label, LineStrip2D, LineStrip3D, Point2D, Point3D, Radius, Rect2D, Tensor, + Label, LineStrip2D, LineStrip3D, LegacyPoint2D, Point3D, Radius, Rect2D, Tensor, TensorDataMeaning, TextEntry, Vec2D, Vec3D, ViewCoordinates, }, coordinates::SignedAxis3, @@ -103,7 +103,7 @@ fn test_extension_components(rec_stream: &RecordingStream) -> anyhow::Result<()> // Single point with our custom component! rec_stream.set_time_seconds("sim_time", 0f64); MsgSender::new("extension_components/point") - .with_component(&[Point2D::new(64.0, 64.0)])? + .with_component(&[LegacyPoint2D::new(64.0, 64.0)])? .with_component(&[ColorRGBA::from_rgb(255, 0, 0)])? .with_component(&[Confidence(0.9)])? .send(rec_stream)?; @@ -148,10 +148,10 @@ fn test_extension_components(rec_stream: &RecordingStream) -> anyhow::Result<()> rec_stream.set_time_seconds("sim_time", 1f64); MsgSender::new("extension_components/points") .with_component(&[ - Point2D::new(32.0, 32.0), - Point2D::new(32.0, 96.0), - Point2D::new(96.0, 32.0), - Point2D::new(96.0, 96.0), + LegacyPoint2D::new(32.0, 32.0), + LegacyPoint2D::new(32.0, 96.0), + LegacyPoint2D::new(96.0, 32.0), + LegacyPoint2D::new(96.0, 96.0), ])? .with_splat(ColorRGBA::from_rgb(0, 255, 0))? .with_component(&[ From 1b034ad69b2a1ef148ac140fa106f4348bbb0bd5 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Thu, 20 Jul 2023 16:53:15 +0200 Subject: [PATCH 04/37] use new Point2D component all the way through for Rust stuff --- crates/re_components/src/lib.rs | 7 ++- crates/re_components/src/point.rs | 4 +- crates/re_query/src/query.rs | 4 +- crates/re_query/src/visit.rs | 12 ++-- crates/re_sdk/src/lib.rs | 6 +- crates/re_types/src/archetypes/points2d.rs | 2 +- crates/re_types/src/archetypes/transform3d.rs | 9 +-- docs/code-examples/point2d_random.rs | 4 +- docs/code-examples/point2d_random_v2.rs | 4 +- docs/code-examples/point2d_simple.rs | 4 +- docs/code-examples/point2d_simple_v2.rs | 2 +- docs/code-examples/transform3d_simple_v2.rs | 9 +-- examples/rust/objectron/src/main.rs | 4 +- tests/rust/roundtrips/points2d/src/main.rs | 3 +- tests/rust/roundtrips/transform3d/src/main.rs | 12 ++-- tests/rust/test_api/src/main.rs | 58 +++++++++---------- 16 files changed, 67 insertions(+), 77 deletions(-) diff --git a/crates/re_components/src/lib.rs b/crates/re_components/src/lib.rs index 0733716f1a4f..b1ae439ce556 100644 --- a/crates/re_components/src/lib.rs +++ b/crates/re_components/src/lib.rs @@ -17,6 +17,7 @@ use arrow2_convert::{ serialize::ArrowSerialize, }; use lazy_static::lazy_static; +use re_types::Loggable; mod arrow; mod bbox; @@ -117,16 +118,14 @@ lazy_static! { ::field(), ::field(), ::field(), - ::field(), ::field(), - ::field(), + ::field(), ::field(), { #[test] fn test_df_builder() { - use re_components::{ColorRGBA, LegacyPoint2D}; + use re_components::{ColorRGBA, Point2D}; let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - Some(LegacyPoint2D { x: 5.0, y: 6.0 }), - Some(LegacyPoint2D { x: 7.0, y: 8.0 }), + Some(Point2D::new(1.0, 2.0)), + Some(Point2D::new(3.0, 4.0)), + Some(Point2D::new(5.0, 6.0)), + Some(Point2D::new(7.0, 8.0)), ]; let colors = vec![ @@ -247,7 +247,7 @@ fn test_df_builder() { // └───────────┴────────────┘ // Unnesting the struct makes it easier to validate the results. - let df = df.unnest([LegacyPoint2D::name()]).unwrap(); + let df = df.unnest([Point2D::name()]).unwrap(); // eprintln!("{df:?}"); // // ┌─────┬─────┬────────────┐ diff --git a/crates/re_query/src/entity_view.rs b/crates/re_query/src/entity_view.rs index b1fdb02d241d..b210905af9bd 100644 --- a/crates/re_query/src/entity_view.rs +++ b/crates/re_query/src/entity_view.rs @@ -154,17 +154,17 @@ where #[test] fn lookup_value() { use crate::QueryError; - use re_components::{LegacyPoint2D, Rect2D}; + use re_components::{Point2D, Rect2D}; use re_types::Loggable as _; let instance_keys = InstanceKey::from_iter(0..5); let points = [ - LegacyPoint2D::new(1.0, 2.0), // - LegacyPoint2D::new(3.0, 4.0), - LegacyPoint2D::new(5.0, 6.0), - LegacyPoint2D::new(7.0, 8.0), - LegacyPoint2D::new(9.0, 10.0), + Point2D::new(1.0, 2.0), // + Point2D::new(3.0, 4.0), + Point2D::new(5.0, 6.0), + Point2D::new(7.0, 8.0), + Point2D::new(9.0, 10.0), ]; let component = @@ -176,7 +176,7 @@ fn lookup_value() { let value = component.lookup_arrow(&InstanceKey(2)).unwrap(); let expected_point = [points[2].clone()]; - let expected_arrow = LegacyPoint2D::to_arrow(expected_point, None); + let expected_arrow = Point2D::to_arrow(expected_point, None); assert_eq!(expected_arrow, value); @@ -196,16 +196,16 @@ fn lookup_value() { let value = component.lookup_arrow(&InstanceKey(99)).unwrap(); let expected_point = [points[3].clone()]; - let expected_arrow = LegacyPoint2D::to_arrow(&expected_point, None); + let expected_arrow = Point2D::to_arrow(&expected_point, None); assert_eq!(expected_arrow, value); // Lookups with serialization - let value = component.lookup::(&InstanceKey(99)).unwrap(); + let value = component.lookup::(&InstanceKey(99)).unwrap(); assert_eq!(expected_point[0], value); - let missing_value = component.lookup::(&InstanceKey(46)); + let missing_value = component.lookup::(&InstanceKey(46)); assert!(matches!( missing_value.err().unwrap(), QueryError::ComponentNotFound @@ -220,18 +220,18 @@ fn lookup_value() { #[test] fn lookup_splat() { - use re_components::LegacyPoint2D; + use re_components::Point2D; let instances = [ InstanceKey::SPLAT, // ]; - let points = [LegacyPoint2D::new(1.0, 2.0)]; + let points = [Point2D::new(1.0, 2.0)]; let component = ComponentWithInstances::from_native(instances.as_slice(), points.as_slice()); // Any instance we look up will return the slatted value - let value = component.lookup::(&InstanceKey(1)).unwrap(); + let value = component.lookup::(&InstanceKey(1)).unwrap(); assert_eq!(points[0], value); - let value = component.lookup::(&InstanceKey(99)).unwrap(); + let value = component.lookup::(&InstanceKey(99)).unwrap(); assert_eq!(points[0], value); } diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index 025142eb0215..a960c645bf5d 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -13,7 +13,7 @@ use crate::{ArchetypeView, ComponentWithInstances, EntityView, QueryError}; /// /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_components::LegacyPoint2D; +/// # use re_components::Point2D; /// # use re_log_types::Timeline; /// # use re_types::Loggable as _; /// # let store = re_query::__populate_example_store(); @@ -25,12 +25,12 @@ use crate::{ArchetypeView, ComponentWithInstances, EntityView, QueryError}; /// &store, /// &query, /// &ent_path.into(), -/// LegacyPoint2D::name(), +/// Point2D::name(), /// ) /// .unwrap(); /// /// # #[cfg(feature = "polars")] -/// let df = component.as_df::().unwrap(); +/// let df = component.as_df::().unwrap(); /// /// //println!("{df:?}"); /// ``` @@ -86,7 +86,7 @@ pub fn get_component_with_instances( /// /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_components::{LegacyPoint2D, ColorRGBA}; +/// # use re_components::{Point2D, ColorRGBA}; /// # use re_log_types::Timeline; /// # use re_types::Loggable as _; /// # let store = re_query::__populate_example_store(); @@ -94,7 +94,7 @@ pub fn get_component_with_instances( /// let ent_path = "point"; /// let query = LatestAtQuery::new(Timeline::new_sequence("frame_nr"), 123.into()); /// -/// let entity_view = re_query::query_entity_with_primary::( +/// let entity_view = re_query::query_entity_with_primary::( /// &store, /// &query, /// &ent_path.into(), @@ -241,7 +241,7 @@ 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, ColorRGBA, LegacyPoint2D}; + use re_components::{datagen::build_frame_nr, ColorRGBA, Point2D}; let mut store = DataStore::new(InstanceKey::name(), Default::default()); @@ -249,7 +249,7 @@ pub fn __populate_example_store() -> DataStore { let timepoint = [build_frame_nr(123.into())]; let instances = vec![InstanceKey(42), InstanceKey(96)]; - let points = vec![LegacyPoint2D::new(1.0, 2.0), LegacyPoint2D::new(3.0, 4.0)]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let row = DataRow::from_cells2_sized( RowId::random(), @@ -279,7 +279,7 @@ pub fn __populate_example_store() -> DataStore { #[test] fn simple_get_component() { use re_arrow_store::LatestAtQuery; - use re_components::LegacyPoint2D; + use re_components::Point2D; use re_log_types::Timeline; let store = __populate_example_store(); @@ -288,19 +288,15 @@ fn simple_get_component() { let query = LatestAtQuery::new(Timeline::new_sequence("frame_nr"), 123.into()); let (_, component) = - get_component_with_instances(&store, &query, &ent_path.into(), LegacyPoint2D::name()) - .unwrap(); + get_component_with_instances(&store, &query, &ent_path.into(), Point2D::name()).unwrap(); #[cfg(feature = "polars")] { - let df = component.as_df::().unwrap(); + let df = component.as_df::().unwrap(); eprintln!("{df:?}"); let instances = vec![Some(InstanceKey(42)), Some(InstanceKey(96))]; - let points = vec![ - Some(LegacyPoint2D::new(1.0, 2.0)), - Some(LegacyPoint2D::new(3.0, 4.0)), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let expected = crate::dataframe_util::df_builder2(&instances, &points).unwrap(); @@ -316,27 +312,29 @@ fn simple_get_component() { #[test] fn simple_query_entity() { use re_arrow_store::LatestAtQuery; - use re_components::{ColorRGBA, Rect2D, Vec4D}; + use re_components::{ColorRGBA, Point2D}; use re_log_types::Timeline; let store = __populate_example_store(); - let ent_path = "rect"; + 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(), &[ColorRGBA::name()]) - .unwrap(); + let entity_view = query_entity_with_primary::( + &store, + &query, + &ent_path.into(), + &[ColorRGBA::name()], + ) + .unwrap(); + #[cfg(feature = "polars")] { let df = entity_view.as_df2::().unwrap(); eprintln!("{df:?}"); let instances = vec![Some(InstanceKey(42)), Some(InstanceKey(96))]; - let points = vec![ - Some(Rect2D::XYWH(Vec4D([1.0, 2.0, 3.0, 4.0]))), - Some(Rect2D::XYWH(Vec4D([5.0, 6.0, 7.0, 8.0]))), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = crate::dataframe_util::df_builder3(&instances, &points, &colors).unwrap(); diff --git a/crates/re_query/src/visit.rs b/crates/re_query/src/visit.rs index e9a6bf8c3ce2..69ca4bdce5b9 100644 --- a/crates/re_query/src/visit.rs +++ b/crates/re_query/src/visit.rs @@ -7,15 +7,15 @@ //! # Usage //! ``` //! # use re_query::EntityView; -//! # use re_components::{ColorRGBA, LegacyPoint2D}; +//! # use re_components::{ColorRGBA, Point2D}; //! # use re_types::components::InstanceKey; //! //! let instances = InstanceKey::from_iter(0..3); //! //! let points = [ -//! LegacyPoint2D { x: 1.0, y: 2.0 }, -//! LegacyPoint2D { x: 3.0, y: 4.0 }, -//! LegacyPoint2D { x: 5.0, y: 6.0 }, +//! Point2D::new(1.0, 2.0), +//! Point2D::new(3.0, 4.0), +//! Point2D::new(5.0, 6.0), //! ]; //! //! let colors = [ @@ -29,11 +29,11 @@ //! (&instances, &colors), //! ); //! -//! let mut points_out = Vec::::new(); +//! let mut points_out = Vec::::new(); //! let mut colors_out = Vec::::new(); //! //! entity_view -//! .visit2(|_: InstanceKey, point: LegacyPoint2D, color: Option| { +//! .visit2(|_: InstanceKey, point: Point2D, color: Option| { //! points_out.push(point); //! colors_out.push(color.unwrap()); //! }) diff --git a/crates/re_query/tests/query_tests.rs b/crates/re_query/tests/query_tests.rs index 2f634fe5a5e9..0c44c78cac16 100644 --- a/crates/re_query/tests/query_tests.rs +++ b/crates/re_query/tests/query_tests.rs @@ -1,7 +1,7 @@ mod common; use re_arrow_store::DataStore; -use re_components::{datagen::build_frame_nr, ColorRGBA, LegacyPoint2D}; +use re_components::{datagen::build_frame_nr, ColorRGBA, Point2D}; use re_log_types::{DataRow, RowId}; use re_query::query_entity_with_primary; use re_types::{components::InstanceKey, Loggable}; @@ -14,10 +14,7 @@ fn simple_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - ]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); @@ -36,7 +33,7 @@ fn simple_query() { // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -61,10 +58,7 @@ fn simple_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -88,10 +82,7 @@ fn timeless_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - ]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); @@ -105,7 +96,7 @@ fn timeless_query() { // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -130,10 +121,7 @@ fn timeless_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -157,10 +145,7 @@ fn no_instance_join_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with an implicit instance - let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - ]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); @@ -172,7 +157,7 @@ fn no_instance_join_query() { // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -197,10 +182,7 @@ fn no_instance_join_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![Some(ColorRGBA(0xff000000)), Some(ColorRGBA(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -224,17 +206,14 @@ fn missing_column_join_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with an implicit instance - let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - ]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -259,10 +238,7 @@ fn missing_column_join_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let expected = df_builder2(&instances, &points).unwrap(); //eprintln!("{df:?}"); @@ -285,10 +261,7 @@ fn splatted_query() { let timepoint = [build_frame_nr(123.into())]; // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - ]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path, timepoint, 2, points); store.insert_row(&row).unwrap(); @@ -307,7 +280,7 @@ fn splatted_query() { // Retrieve the view let timeline_query = re_arrow_store::LatestAtQuery::new(timepoint[0].0, timepoint[0].1); - let entity_view = query_entity_with_primary::( + let entity_view = query_entity_with_primary::( &store, &timeline_query, &ent_path.into(), @@ -332,10 +305,7 @@ fn splatted_query() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![Some(ColorRGBA(0xff000000)), Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); diff --git a/crates/re_query/tests/range_tests.rs b/crates/re_query/tests/range_tests.rs index e856808e28f7..ee50c93b40a1 100644 --- a/crates/re_query/tests/range_tests.rs +++ b/crates/re_query/tests/range_tests.rs @@ -1,7 +1,7 @@ mod common; use re_arrow_store::{DataStore, TimeInt, TimeRange}; -use re_components::{datagen::build_frame_nr, ColorRGBA, LegacyPoint2D}; +use re_components::{datagen::build_frame_nr, ColorRGBA, Point2D}; use re_log_types::{DataRow, EntityPath, RowId}; use re_query::range_entity_with_primary; use re_types::{components::InstanceKey, Loggable as _}; @@ -15,10 +15,7 @@ fn simple_range() { let timepoint1 = [build_frame_nr(123.into())]; { // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - ]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint1, 2, points); store.insert_row(&row).unwrap(); @@ -54,10 +51,7 @@ fn simple_range() { let timepoint3 = [build_frame_nr(323.into())]; { // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 10.0, y: 20.0 }, - LegacyPoint2D { x: 30.0, y: 40.0 }, - ]; + let points = vec![Point2D::new(10.0, 20.0), Point2D::new(30.0, 40.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint3, 2, points); store.insert_row(&row).unwrap(); @@ -72,13 +66,8 @@ fn simple_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [ - InstanceKey::name(), - LegacyPoint2D::name(), - ColorRGBA::name(), - ]; - let ent_views = - range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; + let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -113,10 +102,7 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -134,8 +120,8 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -161,13 +147,8 @@ fn simple_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [ - InstanceKey::name(), - LegacyPoint2D::name(), - ColorRGBA::name(), - ]; - let ent_views = - range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; + let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -202,10 +183,7 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -223,8 +201,8 @@ fn simple_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -251,10 +229,7 @@ fn timeless_range() { let timepoint1 = [build_frame_nr(123.into())]; { // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - ]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let mut row = DataRow::from_cells1(RowId::random(), ent_path.clone(), timepoint1, 2, &points); row.compute_all_size_bytes(); @@ -315,10 +290,7 @@ fn timeless_range() { let timepoint3 = [build_frame_nr(323.into())]; { // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 10.0, y: 20.0 }, - LegacyPoint2D { x: 30.0, y: 40.0 }, - ]; + let points = vec![Point2D::new(10.0, 20.0), Point2D::new(30.0, 40.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint3, 2, &points); store.insert_row(&row).unwrap(); @@ -357,13 +329,8 @@ fn timeless_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [ - InstanceKey::name(), - LegacyPoint2D::name(), - ColorRGBA::name(), - ]; - let ent_views = - range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; + let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -398,10 +365,7 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -419,8 +383,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -446,13 +410,8 @@ fn timeless_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [ - InstanceKey::name(), - LegacyPoint2D::name(), - ColorRGBA::name(), - ]; - let ent_views = - range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; + let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -497,8 +456,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -516,10 +475,7 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -537,8 +493,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -562,13 +518,8 @@ fn timeless_range() { TimeRange::new(TimeInt::MIN, TimeInt::MAX), ); - let components = [ - InstanceKey::name(), - LegacyPoint2D::name(), - ColorRGBA::name(), - ]; - let ent_views = - range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; + let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -620,10 +571,7 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -640,8 +588,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -659,10 +607,7 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -680,8 +625,8 @@ fn timeless_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![Some(ColorRGBA(0xff000000)), None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -708,10 +653,7 @@ fn simple_splatted_range() { let timepoint1 = [build_frame_nr(123.into())]; { // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - ]; + let points = vec![Point2D::new(1.0, 2.0), Point2D::new(3.0, 4.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint1, 2, points); store.insert_row(&row).unwrap(); @@ -747,10 +689,7 @@ fn simple_splatted_range() { let timepoint3 = [build_frame_nr(323.into())]; { // Create some points with implicit instances - let points = vec![ - LegacyPoint2D { x: 10.0, y: 20.0 }, - LegacyPoint2D { x: 30.0, y: 40.0 }, - ]; + let points = vec![Point2D::new(10.0, 20.0), Point2D::new(30.0, 40.0)]; let row = DataRow::from_cells1_sized(RowId::random(), ent_path.clone(), timepoint3, 2, points); store.insert_row(&row).unwrap(); @@ -765,13 +704,8 @@ fn simple_splatted_range() { TimeRange::new((timepoint1[0].1.as_i64() + 1).into(), timepoint3[0].1), ); - let components = [ - InstanceKey::name(), - LegacyPoint2D::name(), - ColorRGBA::name(), - ]; - let ent_views = - range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; + let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -806,10 +740,7 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors = vec![None, Some(ColorRGBA(0xff000000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -827,8 +758,8 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![Some(ColorRGBA(0x00ff0000)), Some(ColorRGBA(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -854,13 +785,8 @@ fn simple_splatted_range() { TimeRange::new(timepoint1[0].1, timepoint3[0].1), ); - let components = [ - InstanceKey::name(), - LegacyPoint2D::name(), - ColorRGBA::name(), - ]; - let ent_views = - range_entity_with_primary::(&store, &query, &ent_path, components); + let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()]; + let ent_views = range_entity_with_primary::(&store, &query, &ent_path, components); let results = ent_views.collect::>(); @@ -895,10 +821,7 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; - let points = vec![ - Some(LegacyPoint2D { x: 1.0, y: 2.0 }), - Some(LegacyPoint2D { x: 3.0, y: 4.0 }), - ]; + let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; let colors: Vec> = vec![None, None]; let expected = df_builder3(&instances, &points, &colors).unwrap(); @@ -916,8 +839,8 @@ fn simple_splatted_range() { // Build expected df manually let instances = vec![Some(InstanceKey(0)), Some(InstanceKey(1))]; let points = vec![ - Some(LegacyPoint2D { x: 10.0, y: 20.0 }), - Some(LegacyPoint2D { x: 30.0, y: 40.0 }), + Some(Point2D::new(10.0, 20.0)), + Some(Point2D::new(30.0, 40.0)), ]; let colors = vec![Some(ColorRGBA(0x00ff0000)), Some(ColorRGBA(0x00ff0000))]; let expected = df_builder3(&instances, &points, &colors).unwrap(); diff --git a/crates/re_query/tests/visit_tests.rs b/crates/re_query/tests/visit_tests.rs index e152224d7df3..71232ee203fb 100644 --- a/crates/re_query/tests/visit_tests.rs +++ b/crates/re_query/tests/visit_tests.rs @@ -1,5 +1,5 @@ use itertools::Itertools; -use re_components::{ColorRGBA, LegacyPoint2D}; +use re_components::{ColorRGBA, Point2D}; use re_query::{ComponentWithInstances, EntityView}; use re_types::components::InstanceKey; @@ -7,15 +7,15 @@ use re_types::components::InstanceKey; fn basic_single_iter() { let instance_keys = InstanceKey::from_iter(0..2); let points = [ - LegacyPoint2D { x: 1.0, y: 2.0 }, // - LegacyPoint2D { x: 3.0, y: 4.0 }, + Point2D::new(1.0, 2.0), // + Point2D::new(3.0, 4.0), ]; - let component = ComponentWithInstances::from_native(instance_keys, &points); + let component = ComponentWithInstances::from_native(instance_keys, points); let results = itertools::izip!( points.into_iter(), - component.iter_values::().unwrap() + component.iter_values::().unwrap() ) .collect_vec(); assert_eq!(results.len(), 2); @@ -29,9 +29,9 @@ fn implicit_joined_iter() { let instance_keys = InstanceKey::from_iter(0..3); let points = [ - LegacyPoint2D { x: 1.0, y: 2.0 }, // - LegacyPoint2D { x: 3.0, y: 4.0 }, - LegacyPoint2D { x: 5.0, y: 6.0 }, + Point2D::new(1.0, 2.0), // + Point2D::new(3.0, 4.0), + Point2D::new(5.0, 6.0), ]; let colors = [ @@ -66,9 +66,9 @@ fn implicit_primary_joined_iter() { let point_ids = InstanceKey::from_iter(0..3); let points = [ - LegacyPoint2D { x: 1.0, y: 2.0 }, // - LegacyPoint2D { x: 3.0, y: 4.0 }, - LegacyPoint2D { x: 5.0, y: 6.0 }, + Point2D::new(1.0, 2.0), // + Point2D::new(3.0, 4.0), + Point2D::new(5.0, 6.0), ]; let color_ids = [ @@ -111,9 +111,9 @@ fn implicit_component_joined_iter() { ]; let points = [ - LegacyPoint2D { x: 1.0, y: 2.0 }, // - LegacyPoint2D { x: 3.0, y: 4.0 }, - LegacyPoint2D { x: 5.0, y: 6.0 }, + Point2D::new(1.0, 2.0), // + Point2D::new(3.0, 4.0), + Point2D::new(5.0, 6.0), ]; let color_ids = InstanceKey::from_iter(0..5); @@ -157,10 +157,10 @@ fn complex_joined_iter() { ]; let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, // - LegacyPoint2D { x: 3.0, y: 4.0 }, - LegacyPoint2D { x: 5.0, y: 6.0 }, - LegacyPoint2D { x: 7.0, y: 8.0 }, + Point2D::new(1.0, 2.0), // + Point2D::new(3.0, 4.0), + Point2D::new(5.0, 6.0), + Point2D::new(7.0, 8.0), ]; let color_ids = vec![ @@ -205,19 +205,19 @@ fn complex_joined_iter() { fn single_visit() { let instance_keys = InstanceKey::from_iter(0..4); let points = [ - LegacyPoint2D { x: 1.0, y: 2.0 }, - LegacyPoint2D { x: 3.0, y: 4.0 }, - LegacyPoint2D { x: 5.0, y: 6.0 }, - LegacyPoint2D { x: 7.0, y: 8.0 }, + Point2D::new(1.0, 2.0), + Point2D::new(3.0, 4.0), + Point2D::new(5.0, 6.0), + Point2D::new(7.0, 8.0), ]; let entity_view = EntityView::from_native((&instance_keys, &points)); let mut instance_key_out = Vec::::new(); - let mut points_out = Vec::::new(); + let mut points_out = Vec::::new(); entity_view - .visit1(|instance_key: InstanceKey, point: LegacyPoint2D| { + .visit1(|instance_key: InstanceKey, point: Point2D| { instance_key_out.push(instance_key); points_out.push(point); }) @@ -231,11 +231,11 @@ fn single_visit() { #[test] fn joint_visit() { let points = vec![ - LegacyPoint2D { x: 1.0, y: 2.0 }, // - LegacyPoint2D { x: 3.0, y: 4.0 }, - LegacyPoint2D { x: 5.0, y: 6.0 }, - LegacyPoint2D { x: 7.0, y: 8.0 }, - LegacyPoint2D { x: 9.0, y: 10.0 }, + Point2D::new(1.0, 2.0), // + Point2D::new(3.0, 4.0), + Point2D::new(5.0, 6.0), + Point2D::new(7.0, 8.0), + Point2D::new(9.0, 10.0), ]; let point_ids = InstanceKey::from_iter(0..5); @@ -255,16 +255,14 @@ fn joint_visit() { (&color_ids, &colors), ); - let mut points_out = Vec::::new(); + let mut points_out = Vec::::new(); let mut colors_out = Vec::>::new(); entity_view - .visit2( - |_: InstanceKey, point: LegacyPoint2D, 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(); From 03706459a85f5f80f83f9ee579bae37f995ec80d Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 21 Jul 2023 17:09:22 +0200 Subject: [PATCH 09/37] annihilated legacy Point3D --- crates/re_arrow_store/benches/arrow2.rs | 7 +- crates/re_components/src/lib.rs | 6 +- crates/re_components/src/point.rs | 75 ------------- crates/re_query/src/entity_view.rs | 8 +- crates/re_sdk/src/lib.rs | 2 +- crates/re_space_view_spatial/src/parts/mod.rs | 104 +----------------- .../src/parts/points2d.rs | 14 ++- .../src/parts/points3d.rs | 86 +++++++-------- crates/re_types/src/archetypes/points3d.rs | 2 +- docs/code-examples/point3d_random_v2.rs | 5 +- docs/code-examples/point3d_simple_v2.rs | 2 +- .../rerun_sdk/rerun/components/__init__.py | 1 - rerun_py/rerun_sdk/rerun/components/point.py | 54 --------- tests/rust/roundtrips/points3d/src/main.rs | 2 +- 14 files changed, 62 insertions(+), 306 deletions(-) delete mode 100644 crates/re_components/src/point.rs delete mode 100644 rerun_py/rerun_sdk/rerun/components/point.py diff --git a/crates/re_arrow_store/benches/arrow2.rs b/crates/re_arrow_store/benches/arrow2.rs index 63686651e887..578591987101 100644 --- a/crates/re_arrow_store/benches/arrow2.rs +++ b/crates/re_arrow_store/benches/arrow2.rs @@ -297,12 +297,7 @@ fn estimated_size_bytes(c: &mut Criterion) { { fn generate_points() -> Vec> { (0..NUM_ROWS) - .map(|_| { - build_some_point2d(NUM_INSTANCES) - .into_iter() - .map(|p| Point2D::new(p.x, p.y)) - .collect_vec() - }) + .map(|_| build_some_point2d(NUM_INSTANCES)) .collect() } diff --git a/crates/re_components/src/lib.rs b/crates/re_components/src/lib.rs index 95e1799b8d04..7acb6c58fd56 100644 --- a/crates/re_components/src/lib.rs +++ b/crates/re_components/src/lib.rs @@ -33,7 +33,6 @@ mod linestrip; mod mat; mod mesh3d; mod pinhole; -mod point; mod quaternion; mod radius; mod rect; @@ -69,7 +68,6 @@ pub use self::{ mat::Mat3x3, mesh3d::{EncodedMesh3D, Mesh3D, MeshFormat, MeshId, RawMesh3D}, pinhole::Pinhole, - point::Point3D, quaternion::Quaternion, radius::Radius, rect::Rect2D, @@ -95,7 +93,7 @@ pub use self::tensor::{TensorImageLoadError, TensorImageSaveError}; pub use self::load_file::{data_cell_from_file_path, data_cell_from_mesh_file_path, FromFileError}; // This is a component -pub use re_types::components::{InstanceKey, Point2D}; +pub use re_types::components::{InstanceKey, Point2D, Point3D}; // This is very convenient to re-export pub use re_log_types::LegacyComponent; @@ -126,7 +124,6 @@ lazy_static! { ::field(), ::field(), ::field(), - ::field(), ::field(), ::field(), ::field(), @@ -141,6 +138,7 @@ lazy_static! { ::field(), ::field(), Field::new(Point2D::name().as_str(), Point2D::to_arrow_datatype(), false), + Field::new(Point3D::name().as_str(), Point2D::to_arrow_datatype(), false), ]; } diff --git a/crates/re_components/src/point.rs b/crates/re_components/src/point.rs deleted file mode 100644 index ac258bda2f3f..000000000000 --- a/crates/re_components/src/point.rs +++ /dev/null @@ -1,75 +0,0 @@ -use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; - -// TODO(cmc): Points should just be containers of Vecs. - -/// A point in 3D space. -/// -/// ``` -/// use re_components::Point3D; -/// use arrow2_convert::field::ArrowField; -/// use arrow2::datatypes::{DataType, Field}; -/// -/// assert_eq!( -/// Point3D::data_type(), -/// DataType::Struct(vec![ -/// Field::new("x", DataType::Float32, false), -/// Field::new("y", DataType::Float32, false), -/// Field::new("z", DataType::Float32, false), -/// ]) -/// ); -/// ``` -#[derive(Clone, Debug, ArrowField, ArrowSerialize, ArrowDeserialize, PartialEq)] -pub struct Point3D { - pub x: f32, - pub y: f32, - pub z: f32, -} - -impl Point3D { - pub const ZERO: Point3D = Point3D { - x: 0.0, - y: 0.0, - z: 0.0, - }; - - #[inline] - pub fn new(x: f32, y: f32, z: f32) -> Self { - Self { x, y, z } - } -} - -impl re_log_types::LegacyComponent for Point3D { - #[inline] - fn legacy_name() -> re_log_types::ComponentName { - "rerun.point3d".into() - } -} - -impl From<[f32; 3]> for Point3D { - #[inline] - fn from(p: [f32; 3]) -> Self { - Self { - x: p[0], - y: p[1], - z: p[2], - } - } -} - -#[cfg(feature = "glam")] -impl From for Point3D { - #[inline] - fn from(pt: glam::Vec3) -> Self { - Self::new(pt.x, pt.y, pt.z) - } -} - -#[cfg(feature = "glam")] -impl From for glam::Vec3 { - #[inline] - fn from(pt: Point3D) -> Self { - Self::new(pt.x, pt.y, pt.z) - } -} - -re_log_types::component_legacy_shim!(Point3D); diff --git a/crates/re_query/src/entity_view.rs b/crates/re_query/src/entity_view.rs index b210905af9bd..b799a41b0ff4 100644 --- a/crates/re_query/src/entity_view.rs +++ b/crates/re_query/src/entity_view.rs @@ -175,7 +175,7 @@ fn lookup_value() { let value = component.lookup_arrow(&InstanceKey(2)).unwrap(); - let expected_point = [points[2].clone()]; + let expected_point = [points[2]]; let expected_arrow = Point2D::to_arrow(expected_point, None); assert_eq!(expected_arrow, value); @@ -188,15 +188,15 @@ fn lookup_value() { InstanceKey(472), ]; - let component = ComponentWithInstances::from_native(instance_keys.as_slice(), &points); + let component = ComponentWithInstances::from_native(instance_keys.as_slice(), points); let missing_value = component.lookup_arrow(&InstanceKey(46)); assert_eq!(missing_value, None); let value = component.lookup_arrow(&InstanceKey(99)).unwrap(); - let expected_point = [points[3].clone()]; - let expected_arrow = Point2D::to_arrow(&expected_point, None); + let expected_point = [points[3]]; + let expected_arrow = Point2D::to_arrow(expected_point, None); assert_eq!(expected_arrow, value); diff --git a/crates/re_sdk/src/lib.rs b/crates/re_sdk/src/lib.rs index 2f63647d25e2..91fa9fc03b89 100644 --- a/crates/re_sdk/src/lib.rs +++ b/crates/re_sdk/src/lib.rs @@ -79,7 +79,7 @@ pub mod components { Radius, RawMesh3D, Rect2D, Scalar, ScalarPlotProps, Tensor, TensorData, TensorDataMeaning, TensorDimension, TensorId, TextEntry, Transform3D, Vec2D, Vec3D, Vec4D, ViewCoordinates, }; - pub use re_types::components::{Color, Point2D}; + pub use re_types::components::{Color, Point2D, Point3D}; } /// Transform helpers, for use with [`components::Transform3D`]. diff --git a/crates/re_space_view_spatial/src/parts/mod.rs b/crates/re_space_view_spatial/src/parts/mod.rs index a617876ba9dc..848c5767da27 100644 --- a/crates/re_space_view_spatial/src/parts/mod.rs +++ b/crates/re_space_view_spatial/src/parts/mod.rs @@ -26,7 +26,7 @@ pub use transform3d_arrows::add_axis_arrows; use ahash::HashMap; use std::sync::Arc; -use re_components::{ClassId, ColorRGBA, KeypointId, Radius}; +use re_components::{ClassId, KeypointId}; use re_data_store::{EntityPath, InstancePathHash}; use re_viewer_context::SpaceViewClassRegistryError; use re_viewer_context::{ @@ -101,28 +101,6 @@ pub fn picking_id_from_instance_key( re_renderer::PickingLayerInstanceId(instance_key.0) } -/// Process [`ColorRGBA`] components using annotations and default colors. -pub fn process_colors<'a, Primary>( - entity_view: &'a re_query::EntityView, - ent_path: &'a EntityPath, - annotation_infos: &'a [ResolvedAnnotationInfo], -) -> Result + 'a, re_query::QueryError> -where - Primary: re_types::Component, - &'a Primary: std::convert::Into>, -{ - re_tracing::profile_function!(); - let default_color = DefaultColor::EntityPath(ent_path); - - Ok(itertools::izip!( - annotation_infos.iter(), - entity_view.iter_component::()?, - ) - .map(move |(annotation_info, color)| { - annotation_info.color(color.map(move |c| c.to_array()).as_ref(), default_color) - })) -} - /// Process [`Color`] components using annotations and default colors. #[allow(dead_code)] pub fn process_colors_arch<'a, A: Archetype>( @@ -143,36 +121,6 @@ pub fn process_colors_arch<'a, A: Archetype>( } /// Process [`Radius`] components to [`re_renderer::Size`] using auto size where no radius is specified. -pub fn process_radii<'a, Primary>( - ent_path: &EntityPath, - entity_view: &'a re_query::EntityView, -) -> Result + 'a, re_query::QueryError> -where - Primary: re_types::Component, - &'a Primary: std::convert::Into>, -{ - re_tracing::profile_function!(); - let ent_path = ent_path.clone(); - Ok(entity_view.iter_component::()?.map(move |radius| { - radius.map_or(re_renderer::Size::AUTO, |r| { - if 0.0 <= r.0 && r.0.is_finite() { - re_renderer::Size::new_scene(r.0) - } else { - if r.0 < 0.0 { - re_log::warn_once!("Found negative radius in entity {ent_path}"); - } else if r.0.is_infinite() { - re_log::warn_once!("Found infinite radius in entity {ent_path}"); - } else { - re_log::warn_once!("Found NaN radius in entity {ent_path}"); - } - re_renderer::Size::AUTO - } - }) - })) -} - -/// Process [`Radius`] components to [`re_renderer::Size`] using auto size where no radius is specified. -#[allow(dead_code)] pub fn process_radii_arch<'a, A: Archetype>( arch_view: &'a re_query::ArchetypeView, ent_path: &EntityPath, @@ -200,56 +148,6 @@ pub fn process_radii_arch<'a, A: Archetype>( } /// Resolves all annotations and keypoints for the given entity view. -fn process_annotations_and_keypoints<'a, Primary>( - query: &ViewQuery<'_>, - entity_view: &re_query::EntityView, - annotations: &Arc, -) -> Result<(Vec, Keypoints), re_query::QueryError> -where - Primary: re_types::Component + 'a, - &'a Primary: std::convert::Into>, - glam::Vec3: std::convert::From, -{ - re_tracing::profile_function!(); - - let mut keypoints: Keypoints = HashMap::default(); - - // No need to process annotations if we don't have keypoints or class-ids - if !entity_view.has_component::() && !entity_view.has_component::() { - let resolved_annotation = annotations.class_description(None).annotation_info(); - return Ok(( - vec![resolved_annotation; entity_view.num_instances()], - keypoints, - )); - } - - let annotation_info = itertools::izip!( - entity_view.iter_primary()?, - entity_view.iter_component::()?, - entity_view.iter_component::()?, - ) - .map(|(position, keypoint_id, class_id)| { - let class_description = annotations.class_description(class_id); - - if let (Some(keypoint_id), Some(class_id), Some(position)) = - (keypoint_id, class_id, position) - { - keypoints - .entry((class_id, query.latest_at.as_i64())) - .or_insert_with(Default::default) - .insert(keypoint_id, position.into()); - class_description.annotation_info_with_keypoint(keypoint_id) - } else { - class_description.annotation_info() - } - }) - .collect(); - - Ok((annotation_info, keypoints)) -} - -/// Resolves all annotations and keypoints for the given entity view. -#[allow(dead_code)] fn process_annotations_and_keypoints_arch( query: &ViewQuery<'_>, arch_view: &re_query::ArchetypeView, diff --git a/crates/re_space_view_spatial/src/parts/points2d.rs b/crates/re_space_view_spatial/src/parts/points2d.rs index 54e7037feb52..441288138566 100644 --- a/crates/re_space_view_spatial/src/parts/points2d.rs +++ b/crates/re_space_view_spatial/src/parts/points2d.rs @@ -1,7 +1,11 @@ use re_components::{ClassId, ColorRGBA, InstanceKey, KeypointId, Label, Point2D, Radius}; use re_data_store::{EntityPath, InstancePathHash}; -use re_query::{EntityView, QueryError}; -use re_types::Loggable; +use re_query::{ArchetypeView, QueryError}; +use re_types::{ + archetypes::Points2D, + components::{Label, Point2D}, + Archetype as _, +}; use re_viewer_context::{ ArchetypeDefinition, ResolvedAnnotationInfo, SpaceViewSystemExecutionError, ViewContextCollection, ViewPartSystem, ViewQuery, ViewerContext, @@ -118,9 +122,9 @@ impl Points2DPart { let point_positions = { re_tracing::profile_scope!("collect_points"); - entity_view - .iter_primary()? - .filter_map(|pt| pt.map(glam::Vec2::from)) + arch_view + .iter_required_component::()? + .map(glam::Vec2::from) }; let picking_instance_ids = entity_view diff --git a/crates/re_space_view_spatial/src/parts/points3d.rs b/crates/re_space_view_spatial/src/parts/points3d.rs index c63278e3ccaf..875ba67f4e6e 100644 --- a/crates/re_space_view_spatial/src/parts/points3d.rs +++ b/crates/re_space_view_spatial/src/parts/points3d.rs @@ -1,24 +1,24 @@ -use re_components::{ClassId, ColorRGBA, InstanceKey, KeypointId, Label, Point3D, Radius}; +use re_components::{Label, Point3D}; use re_data_store::{EntityPath, InstancePathHash}; -use re_query::{EntityView, QueryError}; -use re_types::Loggable as _; +use re_query::{ArchetypeView, QueryError}; +use re_types::archetypes::Points3D; +use re_types::Archetype as _; use re_viewer_context::{ ArchetypeDefinition, ResolvedAnnotationInfo, SpaceViewSystemExecutionError, ViewContextCollection, ViewPartSystem, ViewQuery, ViewerContext, }; use crate::{ - contexts::SpatialSceneEntityContext, + contexts::{EntityDepthOffsets, SpatialSceneEntityContext}, parts::{ - entity_iterator::process_entity_views, load_keypoint_connections, UiLabel, UiLabelTarget, + entity_iterator::process_archetype_views, load_keypoint_connections, + process_annotations_and_keypoints_arch, process_colors_arch, process_radii_arch, UiLabel, + UiLabelTarget, }, view_kind::SpatialSpaceViewKind, }; -use super::{ - picking_id_from_instance_key, process_annotations_and_keypoints, process_colors, process_radii, - SpatialViewPartData, -}; +use super::{picking_id_from_instance_key, SpatialViewPartData}; pub struct Points3DPart { /// If the number of points in the batch is > max_labels, don't render point labels. @@ -37,7 +37,7 @@ impl Default for Points3DPart { impl Points3DPart { fn process_labels<'a>( - entity_view: &'a EntityView, + arch_view: &'a ArchetypeView, instance_path_hashes: &'a [InstancePathHash], colors: &'a [egui::Color32], annotation_infos: &'a [ResolvedAnnotationInfo], @@ -45,8 +45,8 @@ impl Points3DPart { ) -> Result + 'a, QueryError> { let labels = itertools::izip!( annotation_infos.iter(), - entity_view.iter_primary()?, - entity_view.iter_component:: { #[test] fn test_df_builder() { - use re_components::{ColorRGBA, Point2D}; + use re_components::ColorRGBA; + use re_types::components::Point2D; let points = vec![ Some(Point2D::new(1.0, 2.0)), diff --git a/crates/re_query/src/entity_view.rs b/crates/re_query/src/entity_view.rs index b799a41b0ff4..c6eef7d28a60 100644 --- a/crates/re_query/src/entity_view.rs +++ b/crates/re_query/src/entity_view.rs @@ -154,7 +154,8 @@ where #[test] fn lookup_value() { use crate::QueryError; - use re_components::{Point2D, Rect2D}; + use re_components::Rect2D; + use re_types::components::Point2D; use re_types::Loggable as _; let instance_keys = InstanceKey::from_iter(0..5); @@ -220,7 +221,7 @@ fn lookup_value() { #[test] fn lookup_splat() { - use re_components::Point2D; + use re_types::components::Point2D; let instances = [ InstanceKey::SPLAT, // ]; diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index a960c645bf5d..cb101af58fe7 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -13,7 +13,7 @@ use crate::{ArchetypeView, ComponentWithInstances, EntityView, QueryError}; /// /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_components::Point2D; +/// # use re_types::components::Point2D; /// # use re_log_types::Timeline; /// # use re_types::Loggable as _; /// # let store = re_query::__populate_example_store(); @@ -86,7 +86,7 @@ pub fn get_component_with_instances( /// /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_components::{Point2D, ColorRGBA}; +/// # use re_types::components::{Point2D, ColorRGBA}; /// # use re_log_types::Timeline; /// # use re_types::Loggable as _; /// # let store = re_query::__populate_example_store(); @@ -241,7 +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, ColorRGBA, Point2D}; + use re_components::{datagen::build_frame_nr, ColorRGBA}; + use re_types::components::Point2D; let mut store = DataStore::new(InstanceKey::name(), Default::default()); @@ -279,8 +280,8 @@ pub fn __populate_example_store() -> DataStore { #[test] fn simple_get_component() { use re_arrow_store::LatestAtQuery; - use re_components::Point2D; use re_log_types::Timeline; + use re_types::components::Point2D; let store = __populate_example_store(); @@ -312,8 +313,9 @@ fn simple_get_component() { #[test] fn simple_query_entity() { use re_arrow_store::LatestAtQuery; - use re_components::{ColorRGBA, Point2D}; + use re_components::ColorRGBA; use re_log_types::Timeline; + use re_types::components::Point2D; let store = __populate_example_store(); diff --git a/crates/re_query/tests/query_tests.rs b/crates/re_query/tests/query_tests.rs index 0c44c78cac16..e744dec9b07a 100644 --- a/crates/re_query/tests/query_tests.rs +++ b/crates/re_query/tests/query_tests.rs @@ -1,10 +1,13 @@ mod common; use re_arrow_store::DataStore; -use re_components::{datagen::build_frame_nr, ColorRGBA, Point2D}; +use re_components::{datagen::build_frame_nr, ColorRGBA}; use re_log_types::{DataRow, RowId}; use re_query::query_entity_with_primary; -use re_types::{components::InstanceKey, Loggable}; +use re_types::{ + components::{InstanceKey, Point2D}, + Loggable as _, +}; #[test] fn simple_query() { diff --git a/crates/re_query/tests/range_tests.rs b/crates/re_query/tests/range_tests.rs index ee50c93b40a1..db34c2acdc25 100644 --- a/crates/re_query/tests/range_tests.rs +++ b/crates/re_query/tests/range_tests.rs @@ -1,10 +1,13 @@ mod common; use re_arrow_store::{DataStore, TimeInt, TimeRange}; -use re_components::{datagen::build_frame_nr, ColorRGBA, Point2D}; +use re_components::{datagen::build_frame_nr, ColorRGBA}; use re_log_types::{DataRow, EntityPath, RowId}; use re_query::range_entity_with_primary; -use re_types::{components::InstanceKey, Loggable as _}; +use re_types::{ + components::{InstanceKey, Point2D}, + Loggable as _, +}; #[test] fn simple_range() { diff --git a/crates/re_query/tests/visit_tests.rs b/crates/re_query/tests/visit_tests.rs index 71232ee203fb..6fe64d9bbe28 100644 --- a/crates/re_query/tests/visit_tests.rs +++ b/crates/re_query/tests/visit_tests.rs @@ -1,7 +1,7 @@ use itertools::Itertools; -use re_components::{ColorRGBA, Point2D}; +use re_components::ColorRGBA; use re_query::{ComponentWithInstances, EntityView}; -use re_types::components::InstanceKey; +use re_types::components::{InstanceKey, Point2D}; #[test] fn basic_single_iter() { diff --git a/crates/re_sdk/src/lib.rs b/crates/re_sdk/src/lib.rs index 91fa9fc03b89..32b328336ca8 100644 --- a/crates/re_sdk/src/lib.rs +++ b/crates/re_sdk/src/lib.rs @@ -79,7 +79,7 @@ pub mod components { Radius, RawMesh3D, Rect2D, Scalar, ScalarPlotProps, Tensor, TensorData, TensorDataMeaning, TensorDimension, TensorId, TextEntry, Transform3D, Vec2D, Vec3D, Vec4D, ViewCoordinates, }; - pub use re_types::components::{Color, Point2D, Point3D}; + pub use re_types::components::{Color, InstanceKey, Point2D, Point3D}; } /// Transform helpers, for use with [`components::Transform3D`]. diff --git a/crates/re_space_view_spatial/src/parts/boxes2d.rs b/crates/re_space_view_spatial/src/parts/boxes2d.rs index fafe9bcaf72b..8b508d20ffc9 100644 --- a/crates/re_space_view_spatial/src/parts/boxes2d.rs +++ b/crates/re_space_view_spatial/src/parts/boxes2d.rs @@ -1,8 +1,8 @@ -use re_components::{ClassId, ColorRGBA, InstanceKey, Label, Radius, Rect2D}; +use re_components::{ClassId, ColorRGBA, Label, Radius, Rect2D}; use re_data_store::EntityPath; use re_query::{EntityView, QueryError}; use re_renderer::Size; -use re_types::Loggable as _; +use re_types::{components::InstanceKey, Loggable as _}; use re_viewer_context::{ ArchetypeDefinition, DefaultColor, SpaceViewSystemExecutionError, ViewContextCollection, ViewPartSystem, ViewQuery, ViewerContext, diff --git a/crates/re_space_view_spatial/src/parts/images.rs b/crates/re_space_view_spatial/src/parts/images.rs index 46233fc5bf0d..8eb6eb1a6dd1 100644 --- a/crates/re_space_view_spatial/src/parts/images.rs +++ b/crates/re_space_view_spatial/src/parts/images.rs @@ -5,9 +5,7 @@ use egui::NumExt; use itertools::Itertools as _; use nohash_hasher::IntSet; use re_arrow_store::LatestAtQuery; -use re_components::{ - ColorRGBA, DecodedTensor, DrawOrder, InstanceKey, Pinhole, Tensor, TensorDataMeaning, -}; +use re_components::{ColorRGBA, DecodedTensor, DrawOrder, Pinhole, Tensor, TensorDataMeaning}; use re_data_store::{EntityPath, EntityProperties}; use re_log_types::{ComponentName, EntityPathHash, TimeInt, Timeline}; use re_query::{EntityView, QueryError}; @@ -15,7 +13,7 @@ use re_renderer::{ renderer::{DepthCloud, DepthClouds, RectangleOptions, TexturedRect}, Colormap, }; -use re_types::Loggable as _; +use re_types::{components::InstanceKey, Loggable as _}; use re_viewer_context::ViewContextCollection; use re_viewer_context::{ gpu_bridge, ArchetypeDefinition, DefaultColor, SpaceViewSystemExecutionError, diff --git a/crates/re_space_view_spatial/src/parts/points3d.rs b/crates/re_space_view_spatial/src/parts/points3d.rs index 875ba67f4e6e..b09d30c7f087 100644 --- a/crates/re_space_view_spatial/src/parts/points3d.rs +++ b/crates/re_space_view_spatial/src/parts/points3d.rs @@ -1,8 +1,7 @@ -use re_components::{Label, Point3D}; +use re_components::Label; use re_data_store::{EntityPath, InstancePathHash}; use re_query::{ArchetypeView, QueryError}; -use re_types::archetypes::Points3D; -use re_types::Archetype as _; +use re_types::{archetypes::Points3D, components::Point3D, Archetype as _}; use re_viewer_context::{ ArchetypeDefinition, ResolvedAnnotationInfo, SpaceViewSystemExecutionError, ViewContextCollection, ViewPartSystem, ViewQuery, ViewerContext, diff --git a/crates/re_space_view_spatial/src/parts/transform3d_arrows.rs b/crates/re_space_view_spatial/src/parts/transform3d_arrows.rs index 2c0c95cbc29a..2b4db54cf23f 100644 --- a/crates/re_space_view_spatial/src/parts/transform3d_arrows.rs +++ b/crates/re_space_view_spatial/src/parts/transform3d_arrows.rs @@ -1,8 +1,8 @@ use egui::Color32; -use re_components::{InstanceKey, Transform3D}; +use re_components::Transform3D; use re_log_types::EntityPath; use re_renderer::LineStripSeriesBuilder; -use re_types::Loggable as _; +use re_types::{components::InstanceKey, Loggable as _}; use re_viewer_context::{ ArchetypeDefinition, SpaceViewSystemExecutionError, ViewContextCollection, ViewPartSystem, ViewQuery, ViewerContext, From 871953d8ccaca19ad51b66034b291b9577c5f54d Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 21 Jul 2023 17:37:01 +0200 Subject: [PATCH 11/37] fully rewrite legacy log_point(s) in terms of Points{2|3}D --- crates/re_components/src/lib.rs | 2 +- rerun_py/rerun_sdk/rerun/log/points.py | 185 +++++++------------------ 2 files changed, 54 insertions(+), 133 deletions(-) diff --git a/crates/re_components/src/lib.rs b/crates/re_components/src/lib.rs index b85c2f0927dc..cf31bcfe334f 100644 --- a/crates/re_components/src/lib.rs +++ b/crates/re_components/src/lib.rs @@ -137,7 +137,7 @@ lazy_static! { ::field(), ::field(), Field::new(Point2D::name().as_str(), Point2D::to_arrow_datatype(), false), - Field::new(Point3D::name().as_str(), Point2D::to_arrow_datatype(), false), + Field::new(Point3D::name().as_str(), Point3D::to_arrow_datatype(), false), ]; } diff --git a/rerun_py/rerun_sdk/rerun/log/points.py b/rerun_py/rerun_sdk/rerun/log/points.py index d85246cb844e..c8c7968ef584 100644 --- a/rerun_py/rerun_sdk/rerun/log/points.py +++ b/rerun_py/rerun_sdk/rerun/log/points.py @@ -5,26 +5,13 @@ import numpy as np import numpy.typing as npt -from rerun import bindings -from rerun.components.annotation import ClassIdArray -from rerun.components.color import ColorRGBAArray -from rerun.components.draw_order import DrawOrderArray -from rerun.components.instance import InstanceArray -from rerun.components.label import LabelArray -from rerun.components.point import Point3DArray -from rerun.components.radius import RadiusArray from rerun.log import ( Color, Colors, OptionalClassIds, OptionalKeyPointIds, - _normalize_colors, - _normalize_ids, - _normalize_labels, - _normalize_radii, ) from rerun.log.error_utils import _send_warning -from rerun.log.extension_components import _add_extension_components from rerun.log.log_decorator import log_decorator from rerun.recording_stream import RecordingStream @@ -98,6 +85,8 @@ def log_point( If left unspecified, defaults to the current active data recording, if there is one. See also: [`rerun.init`][], [`rerun.set_global_data_recording`][]. """ + from rerun.experimental import Points2D, Points3D, log_any + recording = RecordingStream.to_native(recording) if keypoint_id is not None and class_id is None: @@ -105,59 +94,31 @@ def log_point( if position is not None: position = np.require(position, dtype="float32") - # NOTE: Point2D goes through the new API! - if position is not None and position.size == 2: - from rerun.experimental import Points2D, log_any - - p = Points2D( - points=position, - radii=radius, - colors=color, - labels=label, - draw_order=draw_order, - class_ids=class_id, - keypoint_ids=keypoint_id, - ) - log_any(entity_path, p, ext=ext, timeless=timeless, recording=recording) - return - - instanced: dict[str, Any] = {} - splats: dict[str, Any] = {} - if position is not None: - if position.size == 3: - instanced["rerun.point3d"] = Point3DArray.from_numpy(position.reshape(1, 3)) + if position.size == 2: + p = Points2D( + points=position, + radii=radius, + colors=color, + labels=label, + draw_order=draw_order, + class_ids=class_id, + keypoint_ids=keypoint_id, + ) + return log_any(entity_path, p, ext=ext, timeless=timeless, recording=recording) + elif position.size == 3: + p = Points3D( + points=position, + radii=radius, + colors=color, + labels=label, + draw_order=draw_order, + class_ids=class_id, + keypoint_ids=keypoint_id, + ) + return log_any(entity_path, p, ext=ext, timeless=timeless, recording=recording) else: - raise TypeError("Position must have a total size of 3") - - if color is not None: - colors = _normalize_colors(color) - instanced["rerun.colorrgba"] = ColorRGBAArray.from_numpy(colors) - - if radius: - radii = _normalize_radii([radius]) - instanced["rerun.radius"] = RadiusArray.from_numpy(radii) - - if label: - instanced["rerun.label"] = LabelArray.new([label]) - - if class_id: - class_ids = _normalize_ids([class_id]) - instanced["rerun.class_id"] = ClassIdArray.from_numpy(class_ids) - - if draw_order is not None: - instanced["rerun.draw_order"] = DrawOrderArray.splat(draw_order) - - if ext: - _add_extension_components(instanced, splats, ext, None) - - if splats: - splats["rerun.instance_key"] = InstanceArray.splat() - bindings.log_arrow_msg(entity_path, components=splats, timeless=timeless, recording=recording) - - # Always the primary component last so range-based queries will include the other data. See(#1215) - if instanced: - bindings.log_arrow_msg(entity_path, components=instanced, timeless=timeless, recording=recording) + raise TypeError("Position must have a total size of 2 or 3") @log_decorator @@ -232,6 +193,8 @@ def log_points( See also: [`rerun.init`][], [`rerun.set_global_data_recording`][]. """ + from rerun.experimental import Points2D, Points3D, log_any + recording = RecordingStream.to_native(recording) if keypoint_ids is not None and class_ids is None: @@ -248,73 +211,31 @@ def log_points( except ValueError: _send_warning("Only integer identifiers supported", 1) - # NOTE: Point2D goes through the new API! - if positions.any() and positions.shape[1] == 2: - from rerun.experimental import Points2D, log_any - - # TODO: but then we probably don't support empty positions anymore... - p = Points2D( - points=positions, - radii=radii, - colors=colors, - labels=labels, - draw_order=draw_order, - class_ids=class_ids, - keypoint_ids=keypoint_ids, - instance_keys=identifiers_np, - ) - log_any(entity_path, p, ext=ext, timeless=timeless, recording=recording) - return - - colors = _normalize_colors(colors) - radii = _normalize_radii(radii) - labels = _normalize_labels(labels) - class_ids = _normalize_ids(class_ids) - keypoint_ids = _normalize_ids(keypoint_ids) - - # 0 = instanced, 1 = splat - comps = [{}, {}] # type: ignore[var-annotated] - if positions.any(): - if positions.shape[1] == 3: - comps[0]["rerun.point3d"] = Point3DArray.from_numpy(positions) + if positions.shape[1] == 2: + # TODO: but then we probably don't support empty positions anymore... + p = Points2D( + points=positions, + radii=radii, + colors=colors, + labels=labels, + draw_order=draw_order, + class_ids=class_ids, + keypoint_ids=keypoint_ids, + instance_keys=identifiers_np, + ) + return log_any(entity_path, p, ext=ext, timeless=timeless, recording=recording) + elif positions.shape[1] == 3: + p = Points3D( + points=positions, + radii=radii, + colors=colors, + labels=labels, + draw_order=draw_order, + class_ids=class_ids, + keypoint_ids=keypoint_ids, + instance_keys=identifiers_np, + ) + return log_any(entity_path, p, ext=ext, timeless=timeless, recording=recording) else: - raise TypeError("Positions should be Nx3") - - if len(identifiers_np): - comps[0]["rerun.instance_key"] = InstanceArray.from_numpy(identifiers_np) - - if len(colors): - is_splat = len(colors.shape) == 1 - if is_splat: - colors = colors.reshape(1, len(colors)) - comps[is_splat]["rerun.colorrgba"] = ColorRGBAArray.from_numpy(colors) - - if len(radii): - is_splat = len(radii) == 1 - comps[is_splat]["rerun.radius"] = RadiusArray.from_numpy(radii) - - if len(labels): - is_splat = len(labels) == 1 - comps[is_splat]["rerun.label"] = LabelArray.new(labels) - - if len(class_ids): - is_splat = len(class_ids) == 1 - comps[is_splat]["rerun.class_id"] = ClassIdArray.from_numpy(class_ids) - - if len(keypoint_ids): - is_splat = len(keypoint_ids) == 1 - comps[is_splat]["rerun.keypoint_id"] = ClassIdArray.from_numpy(keypoint_ids) - - if draw_order is not None: - comps[True]["rerun.draw_order"] = DrawOrderArray.splat(draw_order) - - if ext: - _add_extension_components(comps[0], comps[1], ext, identifiers_np) - - if comps[1]: - comps[1]["rerun.instance_key"] = InstanceArray.splat() - bindings.log_arrow_msg(entity_path, components=comps[1], timeless=timeless, recording=recording) - - # Always the primary component last so range-based queries will include the other data. See(#1215) - bindings.log_arrow_msg(entity_path, components=comps[0], timeless=timeless, recording=recording) + raise TypeError("Positions should be Nx2 or Nx3") From a0fc954b3095c385d977fdcb7f4188170de2b8e8 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 21 Jul 2023 17:41:32 +0200 Subject: [PATCH 12/37] annihilate legacy DrawOrder --- crates/re_components/src/draw_order.rs | 89 ------------------- crates/re_components/src/lib.rs | 6 +- crates/re_sdk/src/lib.rs | 2 +- .../src/contexts/depth_offsets.rs | 3 +- .../re_space_view_spatial/src/parts/images.rs | 7 +- .../re_viewport/src/space_view_heuristics.rs | 5 +- 6 files changed, 13 insertions(+), 99 deletions(-) delete mode 100644 crates/re_components/src/draw_order.rs diff --git a/crates/re_components/src/draw_order.rs b/crates/re_components/src/draw_order.rs deleted file mode 100644 index 2f0247e92f3b..000000000000 --- a/crates/re_components/src/draw_order.rs +++ /dev/null @@ -1,89 +0,0 @@ -use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; - -/// Draw order used for the display order of 2D elements. -/// -/// Higher values are drawn on top of lower values. -/// An entity can have only a single draw order component. -/// Within an entity draw order is governed by the order of the components. -/// -/// Draw order for entities with the same draw order is generally undefined. -/// -/// This component is a "mono-component". See [the crate level docs](crate) for details. -/// -/// ``` -/// use re_components::DrawOrder; -/// use arrow2_convert::field::ArrowField; -/// use arrow2::datatypes::{DataType, Field}; -/// -/// assert_eq!(DrawOrder::data_type(), DataType::Float32); -/// ``` -#[derive(Debug, Clone, Copy, ArrowField, ArrowSerialize, ArrowDeserialize)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] -#[arrow_field(transparent)] -pub struct DrawOrder(pub f32); - -impl DrawOrder { - /// Draw order used for images if no draw order was specified. - pub const DEFAULT_IMAGE: DrawOrder = DrawOrder(-10.0); - - /// Draw order used for 2D boxes if no draw order was specified. - pub const DEFAULT_BOX2D: DrawOrder = DrawOrder(10.0); - - /// Draw order used for 2D lines if no draw order was specified. - pub const DEFAULT_LINES2D: DrawOrder = DrawOrder(20.0); - - /// Draw order used for 2D points if no draw order was specified. - pub const DEFAULT_POINTS2D: DrawOrder = DrawOrder(30.0); -} - -impl re_log_types::LegacyComponent for DrawOrder { - #[inline] - fn legacy_name() -> re_log_types::ComponentName { - "rerun.draw_order".into() - } -} - -impl std::cmp::PartialEq for DrawOrder { - #[inline] - fn eq(&self, other: &Self) -> bool { - self.0.is_nan() && other.0.is_nan() || self.0 == other.0 - } -} - -impl std::cmp::Eq for DrawOrder {} - -impl std::cmp::PartialOrd for DrawOrder { - #[inline] - fn partial_cmp(&self, other: &Self) -> Option { - if other == self { - Some(std::cmp::Ordering::Equal) - } else if other.0.is_nan() || self.0 < other.0 { - Some(std::cmp::Ordering::Less) - } else { - Some(std::cmp::Ordering::Greater) - } - } -} - -impl std::cmp::Ord for DrawOrder { - #[inline] - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.partial_cmp(other).unwrap() - } -} - -impl From for DrawOrder { - #[inline] - fn from(value: f32) -> Self { - Self(value) - } -} - -impl From for f32 { - #[inline] - fn from(value: DrawOrder) -> Self { - value.0 - } -} - -re_log_types::component_legacy_shim!(DrawOrder); diff --git a/crates/re_components/src/lib.rs b/crates/re_components/src/lib.rs index cf31bcfe334f..b246e70fec94 100644 --- a/crates/re_components/src/lib.rs +++ b/crates/re_components/src/lib.rs @@ -26,7 +26,6 @@ mod color; pub mod context; pub mod coordinates; mod disconnected_space; -mod draw_order; mod keypoint_id; mod label; mod linestrip; @@ -61,7 +60,6 @@ pub use self::{ context::{AnnotationContext, AnnotationInfo, ClassDescription}, coordinates::ViewCoordinates, disconnected_space::DisconnectedSpace, - draw_order::DrawOrder, keypoint_id::KeypointId, label::Label, linestrip::{LineStrip2D, LineStrip3D}, @@ -105,7 +103,7 @@ pub mod external { // ---------------------------------------------------------------------------- -use re_types::components::{Point2D, Point3D}; +use re_types::components::{DrawOrder, Point2D, Point3D}; lazy_static! { //TODO(john): use a run-time type registry @@ -116,7 +114,6 @@ lazy_static! { ::field(), ::field(), ::field(), - ::field(), ::field(), { #[test] fn test_df_builder() { - use re_components::ColorRGBA; - use re_types::components::Point2D; + use re_types::components::{Color, Point2D}; let points = vec![ Some(Point2D::new(1.0, 2.0)), @@ -223,12 +222,7 @@ fn test_df_builder() { Some(Point2D::new(7.0, 8.0)), ]; - let colors = vec![ - None, - Some(ColorRGBA(0xff000000)), - Some(ColorRGBA(0x00ff0000)), - None, - ]; + let colors = vec![None, Some(Color(0xff000000)), Some(Color(0x00ff0000)), None]; let df = df_builder2(&points, &colors).unwrap(); // eprintln!("{df:?}"); @@ -268,7 +262,7 @@ fn test_df_builder() { let expected = df![ "x" => &[1.0_f32, 3.0_f32, 5.0_f32, 7.0_f32], "y" => &[2.0_f32, 4.0_f32, 6.0_f32, 8.0_f32], - ColorRGBA::name().as_ref() => &[None, Some(0xff000000_u32), Some(0x00ff0000_u32), None ], + Color::name().as_ref() => &[None, Some(0xff000000_u32), Some(0x00ff0000_u32), None ], ] .unwrap(); diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index cb101af58fe7..dad3446ea835 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -86,7 +86,7 @@ pub fn get_component_with_instances( /// /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_types::components::{Point2D, ColorRGBA}; +/// # use re_types::components::{Point2D, Color}; /// # use re_log_types::Timeline; /// # use re_types::Loggable as _; /// # let store = re_query::__populate_example_store(); @@ -98,7 +98,7 @@ pub fn get_component_with_instances( /// &store, /// &query, /// &ent_path.into(), -/// &[ColorRGBA::name()], +/// &[Color::name()], /// ) /// .unwrap(); /// @@ -241,7 +241,7 @@ 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, ColorRGBA}; + use re_components::{datagen::build_frame_nr, LegacyColor}; use re_types::components::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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), @@ -313,9 +313,9 @@ fn simple_get_component() { #[test] fn simple_query_entity() { use re_arrow_store::LatestAtQuery; - use re_components::ColorRGBA; + use re_components::LegacyColor; use re_log_types::Timeline; - use re_types::components::Point2D; + use re_types::components::{Color, Point2D}; let store = __populate_example_store(); @@ -326,18 +326,18 @@ fn simple_query_entity() { &store, &query, &ent_path.into(), - &[ColorRGBA::name()], + &[LegacyColor::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))]; let points = vec![Some(Point2D::new(1.0, 2.0)), Some(Point2D::new(3.0, 4.0))]; - let colors = vec![None, Some(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(Color(0xff000000))]; let expected = crate::dataframe_util::df_builder3(&instances, &points, &colors).unwrap(); assert_eq!(expected, df); diff --git a/crates/re_query/tests/query_tests.rs b/crates/re_query/tests/query_tests.rs index e744dec9b07a..e34bc9f0df25 100644 --- a/crates/re_query/tests/query_tests.rs +++ b/crates/re_query/tests/query_tests.rs @@ -1,7 +1,7 @@ mod common; use re_arrow_store::DataStore; -use re_components::{datagen::build_frame_nr, ColorRGBA}; +use re_components::{datagen::build_frame_nr, LegacyColor}; use re_log_types::{DataRow, RowId}; use re_query::query_entity_with_primary; use re_types::{ @@ -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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path, @@ -40,7 +40,7 @@ fn simple_query() { &store, &timeline_query, &ent_path.into(), - &[ColorRGBA::name()], + &[LegacyColor::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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(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(), - &[ColorRGBA::name()], + &[LegacyColor::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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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![ColorRGBA(0xff000000), ColorRGBA(0x00ff0000)]; + let colors = vec![LegacyColor(0xff000000), LegacyColor(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(), - &[ColorRGBA::name()], + &[LegacyColor::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(ColorRGBA(0xff000000)), Some(ColorRGBA(0x00ff0000))]; + let colors = vec![Some(LegacyColor(0xff000000)), Some(LegacyColor(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(), - &[ColorRGBA::name()], + &[LegacyColor::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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(0xff000000)]; let row = DataRow::from_cells2_sized( RowId::random(), ent_path, @@ -287,7 +287,7 @@ fn splatted_query() { &store, &timeline_query, &ent_path.into(), - &[ColorRGBA::name()], + &[LegacyColor::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(ColorRGBA(0xff000000)), Some(ColorRGBA(0xff000000))]; + let colors = vec![Some(LegacyColor(0xff000000)), Some(LegacyColor(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 db34c2acdc25..5a03565adb92 100644 --- a/crates/re_query/tests/range_tests.rs +++ b/crates/re_query/tests/range_tests.rs @@ -1,7 +1,7 @@ mod common; use re_arrow_store::{DataStore, TimeInt, TimeRange}; -use re_components::{datagen::build_frame_nr, ColorRGBA}; +use re_components::{datagen::build_frame_nr, LegacyColor}; use re_log_types::{DataRow, EntityPath, RowId}; use re_query::range_entity_with_primary; use re_types::{ @@ -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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(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(), ColorRGBA::name()]; + let components = [InstanceKey::name(), Point2D::name(), LegacyColor::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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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(ColorRGBA(0xff000000)), None]; + let colors = vec![Some(LegacyColor(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(), ColorRGBA::name()]; + let components = [InstanceKey::name(), Point2D::name(), LegacyColor::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(ColorRGBA(0xff000000)), None]; + let colors = vec![Some(LegacyColor(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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(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(), ColorRGBA::name()]; + let components = [InstanceKey::name(), Point2D::name(), LegacyColor::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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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(ColorRGBA(0xff000000)), None]; + let colors = vec![Some(LegacyColor(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(), ColorRGBA::name()]; + let components = [InstanceKey::name(), Point2D::name(), LegacyColor::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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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(ColorRGBA(0xff000000)), None]; + let colors = vec![Some(LegacyColor(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(), ColorRGBA::name()]; + let components = [InstanceKey::name(), Point2D::name(), LegacyColor::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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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(ColorRGBA(0xff000000)), None]; + let colors = vec![Some(LegacyColor(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![ColorRGBA(0xff000000)]; + let colors = vec![LegacyColor(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![ColorRGBA(0x00ff0000)]; + let colors = vec![LegacyColor(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(), ColorRGBA::name()]; + let components = [InstanceKey::name(), Point2D::name(), LegacyColor::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(ColorRGBA(0xff000000))]; + let colors = vec![None, Some(LegacyColor(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(ColorRGBA(0x00ff0000)), Some(ColorRGBA(0x00ff0000))]; + let colors = vec![Some(LegacyColor(0x00ff0000)), Some(LegacyColor(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(), ColorRGBA::name()]; + let components = [InstanceKey::name(), Point2D::name(), LegacyColor::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(ColorRGBA(0x00ff0000)), Some(ColorRGBA(0x00ff0000))]; + let colors = vec![Some(LegacyColor(0x00ff0000)), Some(LegacyColor(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 6fe64d9bbe28..25a4b27e1af0 100644 --- a/crates/re_query/tests/visit_tests.rs +++ b/crates/re_query/tests/visit_tests.rs @@ -1,5 +1,5 @@ use itertools::Itertools; -use re_components::ColorRGBA; +use re_components::LegacyColor; use re_query::{ComponentWithInstances, EntityView}; use re_types::components::{InstanceKey, Point2D}; @@ -35,9 +35,9 @@ fn implicit_joined_iter() { ]; let colors = [ - ColorRGBA(0), // - ColorRGBA(1), - ColorRGBA(2), + LegacyColor(0), // + LegacyColor(1), + LegacyColor(2), ]; let entity_view = EntityView::from_native2( @@ -46,14 +46,14 @@ fn implicit_joined_iter() { ); let expected_colors = [ - Some(ColorRGBA(0)), // - Some(ColorRGBA(1)), - Some(ColorRGBA(2)), + Some(LegacyColor(0)), // + Some(LegacyColor(1)), + Some(LegacyColor(2)), ]; let results = itertools::izip!( expected_colors.iter(), - entity_view.iter_component::().unwrap() + entity_view.iter_component::().unwrap() ) .collect_vec(); @@ -77,8 +77,8 @@ fn implicit_primary_joined_iter() { ]; let colors = [ - ColorRGBA(1), // - ColorRGBA(2), + LegacyColor(1), // + LegacyColor(2), ]; let entity_view = EntityView::from_native2( @@ -88,13 +88,13 @@ fn implicit_primary_joined_iter() { let expected_colors = vec![ None, // - Some(ColorRGBA(1)), - Some(ColorRGBA(2)), + Some(LegacyColor(1)), + Some(LegacyColor(2)), ]; let results = itertools::izip!( expected_colors.iter(), - entity_view.iter_component::().unwrap() + entity_view.iter_component::().unwrap() ) .collect_vec(); @@ -119,11 +119,11 @@ fn implicit_component_joined_iter() { let color_ids = InstanceKey::from_iter(0..5); let colors = [ - ColorRGBA(0), // - ColorRGBA(1), - ColorRGBA(2), - ColorRGBA(3), - ColorRGBA(4), + LegacyColor(0), // + LegacyColor(1), + LegacyColor(2), + LegacyColor(3), + LegacyColor(4), ]; let entity_view = EntityView::from_native2( @@ -132,14 +132,14 @@ fn implicit_component_joined_iter() { ); let expected_colors = vec![ - Some(ColorRGBA(0)), // - Some(ColorRGBA(2)), - Some(ColorRGBA(4)), + Some(LegacyColor(0)), // + Some(LegacyColor(2)), + Some(LegacyColor(4)), ]; let results = itertools::izip!( expected_colors.iter(), - entity_view.iter_component::().unwrap() + entity_view.iter_component::().unwrap() ) .collect_vec(); @@ -172,11 +172,11 @@ fn complex_joined_iter() { ]; let colors = vec![ - ColorRGBA(17), // - ColorRGBA(19), - ColorRGBA(44), - ColorRGBA(96), - ColorRGBA(254), + LegacyColor(17), // + LegacyColor(19), + LegacyColor(44), + LegacyColor(96), + LegacyColor(254), ]; let entity_view = EntityView::from_native2( @@ -186,14 +186,14 @@ fn complex_joined_iter() { let expected_colors = vec![ None, - Some(ColorRGBA(17)), // + Some(LegacyColor(17)), // None, - Some(ColorRGBA(96)), + Some(LegacyColor(96)), ]; let results = itertools::izip!( expected_colors.iter(), - entity_view.iter_component::().unwrap() + entity_view.iter_component::().unwrap() ) .collect_vec(); @@ -241,8 +241,8 @@ fn joint_visit() { let point_ids = InstanceKey::from_iter(0..5); let colors = vec![ - ColorRGBA(0xff000000), // - ColorRGBA(0x00ff0000), + LegacyColor(0xff000000), // + LegacyColor(0x00ff0000), ]; let color_ids = vec![ @@ -256,22 +256,24 @@ 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(ColorRGBA(0xff000000)), + Some(LegacyColor(0xff000000)), None, - Some(ColorRGBA(0x00ff0000)), + Some(LegacyColor(0x00ff0000)), ]; assert_eq!(points, points_out); diff --git a/crates/re_sdk/src/msg_sender.rs b/crates/re_sdk/src/msg_sender.rs index 39eadea04c03..28d951152746 100644 --- a/crates/re_sdk/src/msg_sender.rs +++ b/crates/re_sdk/src/msg_sender.rs @@ -424,7 +424,7 @@ mod tests { components::LegacyLabel("label2".into()), ]; let transform = vec![components::Transform3D::IDENTITY]; - let color = components::ColorRGBA::from_rgb(255, 0, 255); + let color = components::LegacyColor::from_rgb(255, 0, 255); let [standard, splats] = MsgSender::new("some/path") .with_component(&labels)? @@ -446,7 +446,7 @@ mod tests { let cell = &splats.cells[idx]; assert!(cell.num_instances() == 1); - let idx = splats.find_cell(&components::ColorRGBA::name()).unwrap(); + let idx = splats.find_cell(&components::LegacyColor::name()).unwrap(); let cell = &splats.cells[idx]; assert!(cell.num_instances() == 1); } @@ -512,7 +512,7 @@ mod tests { { MsgSender::new("some/path") .with_component([components::LegacyLabel("label1".into())].as_slice())? - .with_component([components::ColorRGBA::from_rgb(1, 1, 1)].as_slice())?; + .with_component([components::LegacyColor::from_rgb(1, 1, 1)].as_slice())?; } // 3 for 1 -- fine, implicit splat @@ -526,7 +526,7 @@ mod tests { ] .as_slice(), )? - .with_component([components::ColorRGBA::from_rgb(1, 1, 1)].as_slice())?; + .with_component([components::LegacyColor::from_rgb(1, 1, 1)].as_slice())?; } // 3 for 2 -- nope, makes no sense @@ -542,8 +542,8 @@ mod tests { )? .with_component( [ - components::ColorRGBA::from_rgb(1, 1, 1), - components::ColorRGBA::from_rgb(1, 1, 1), + components::LegacyColor::from_rgb(1, 1, 1), + components::LegacyColor::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 252fbadd326e..ef832ece7718 100644 --- a/crates/re_space_view_spatial/src/mesh_loader.rs +++ b/crates/re_space_view_spatial/src/mesh_loader.rs @@ -1,4 +1,4 @@ -use re_components::{ColorRGBA, EncodedMesh3D, Mesh3D, MeshFormat, RawMesh3D}; +use re_components::{LegacyColor, EncodedMesh3D, Mesh3D, MeshFormat, RawMesh3D}; use re_renderer::{resource_managers::ResourceLifeTime, RenderContext, Rgba32Unmul}; pub struct LoadedMesh { @@ -115,7 +115,7 @@ impl LoadedMesh { let vertex_colors = if let Some(vertex_colors) = vertex_colors { vertex_colors .iter() - .map(|c| Rgba32Unmul::from_rgba_unmul_array(ColorRGBA(*c).to_array())) + .map(|c| Rgba32Unmul::from_rgba_unmul_array(LegacyColor(*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 70ede2338263..7a48fce613ab 100644 --- a/crates/re_space_view_spatial/src/parts/arrows3d.rs +++ b/crates/re_space_view_spatial/src/parts/arrows3d.rs @@ -1,4 +1,4 @@ -use re_components::{Arrow3D, ColorRGBA, LegacyLabel}; +use re_components::{Arrow3D, LegacyColor, LegacyLabel}; use re_data_store::EntityPath; use re_query::{EntityView, QueryError}; use re_renderer::{renderer::LineStripFlags, Size}; @@ -48,7 +48,7 @@ impl Arrows3DPart { ent_view.visit4( |instance_key: InstanceKey, arrow: Arrow3D, - color: Option, + color: Option, radius: Option, _label: Option| { // TODO(andreas): support labels @@ -102,7 +102,7 @@ impl ViewPartSystem for Arrows3DPart { vec1::vec1![ Arrow3D::name(), InstanceKey::name(), - ColorRGBA::name(), + LegacyColor::name(), Radius::name(), LegacyLabel::name(), ] diff --git a/crates/re_space_view_spatial/src/parts/boxes2d.rs b/crates/re_space_view_spatial/src/parts/boxes2d.rs index ee7c3160260b..ddaf3db1fab7 100644 --- a/crates/re_space_view_spatial/src/parts/boxes2d.rs +++ b/crates/re_space_view_spatial/src/parts/boxes2d.rs @@ -1,4 +1,4 @@ -use re_components::{ClassId, ColorRGBA, LegacyLabel, Rect2D}; +use re_components::{ClassId, LegacyColor, LegacyLabel, Rect2D}; use re_data_store::EntityPath; use re_query::{EntityView, QueryError}; use re_renderer::Size; @@ -48,7 +48,7 @@ impl Boxes2DPart { ent_view.visit5( |instance_key, rect, - color: Option, + color: Option, radius: Option, label: Option, class_id: Option| { @@ -113,7 +113,7 @@ impl ViewPartSystem for Boxes2DPart { vec1::vec1![ Rect2D::name(), InstanceKey::name(), - ColorRGBA::name(), + LegacyColor::name(), Radius::name(), LegacyLabel::name(), ClassId::name(), diff --git a/crates/re_space_view_spatial/src/parts/boxes3d.rs b/crates/re_space_view_spatial/src/parts/boxes3d.rs index a4501690399c..cd7fff5f54d3 100644 --- a/crates/re_space_view_spatial/src/parts/boxes3d.rs +++ b/crates/re_space_view_spatial/src/parts/boxes3d.rs @@ -1,4 +1,4 @@ -use re_components::{Box3D, ClassId, ColorRGBA, LegacyLabel, Quaternion, Vec3D}; +use re_components::{Box3D, ClassId, LegacyColor, LegacyLabel, Quaternion, Vec3D}; use re_data_store::EntityPath; use re_query::{EntityView, QueryError}; use re_renderer::Size; @@ -48,7 +48,7 @@ impl Boxes3DPart { half_size: Box3D, position: Option, rotation: Option, - color: Option, + color: Option, radius: Option, label: Option, class_id: Option| { @@ -110,7 +110,7 @@ impl ViewPartSystem for Boxes3DPart { InstanceKey::name(), Vec3D::name(), // obb.position Quaternion::name(), // obb.rotation - ColorRGBA::name(), + LegacyColor::name(), Radius::name(), // stroke_width LegacyLabel::name(), ClassId::name(), diff --git a/crates/re_space_view_spatial/src/parts/images.rs b/crates/re_space_view_spatial/src/parts/images.rs index 0a1a3bf796c7..b3136c5429bf 100644 --- a/crates/re_space_view_spatial/src/parts/images.rs +++ b/crates/re_space_view_spatial/src/parts/images.rs @@ -5,7 +5,7 @@ use egui::NumExt; use itertools::Itertools as _; use nohash_hasher::IntSet; use re_arrow_store::LatestAtQuery; -use re_components::{ColorRGBA, DecodedTensor, Pinhole, Tensor, TensorDataMeaning}; +use re_components::{DecodedTensor, LegacyColor, Pinhole, Tensor, TensorDataMeaning}; use re_data_store::{EntityPath, EntityProperties}; use re_log_types::{ComponentName, EntityPathHash, TimeInt, Timeline}; use re_query::{EntityView, QueryError}; @@ -205,7 +205,7 @@ impl ImagesPart { // Instance ids of tensors refer to entries inside the tensor. for (tensor, color, draw_order) in itertools::izip!( ent_view.iter_primary()?, - ent_view.iter_component::()?, + ent_view.iter_component::()?, ent_view.iter_component::()? ) { re_tracing::profile_scope!("loop_iter"); @@ -385,7 +385,7 @@ impl ViewPartSystem for ImagesPart { vec1::vec1![ Tensor::name(), InstanceKey::name(), - ColorRGBA::name(), + LegacyColor::name(), DrawOrder::name(), ] } diff --git a/crates/re_space_view_spatial/src/parts/lines2d.rs b/crates/re_space_view_spatial/src/parts/lines2d.rs index 5a59a4bbd62a..92c4e4b259c7 100644 --- a/crates/re_space_view_spatial/src/parts/lines2d.rs +++ b/crates/re_space_view_spatial/src/parts/lines2d.rs @@ -1,4 +1,4 @@ -use re_components::{ColorRGBA, LineStrip2D}; +use re_components::{LegacyColor, LineStrip2D}; use re_data_store::EntityPath; use re_query::{EntityView, QueryError}; use re_renderer::Size; @@ -47,7 +47,7 @@ impl Lines2DPart { let visitor = |instance_key: InstanceKey, strip: LineStrip2D, - color: Option, + color: Option, radius: Option| { // TODO(andreas): support class ids for lines let annotation_info = ent_context @@ -90,7 +90,7 @@ impl ViewPartSystem for Lines2DPart { vec1::vec1![ LineStrip2D::name(), InstanceKey::name(), - ColorRGBA::name(), + LegacyColor::name(), Radius::name(), ] } diff --git a/crates/re_space_view_spatial/src/parts/lines3d.rs b/crates/re_space_view_spatial/src/parts/lines3d.rs index 3a9520a419e3..1d2943442e98 100644 --- a/crates/re_space_view_spatial/src/parts/lines3d.rs +++ b/crates/re_space_view_spatial/src/parts/lines3d.rs @@ -1,4 +1,4 @@ -use re_components::{ColorRGBA, LineStrip3D}; +use re_components::{LegacyColor, LineStrip3D}; use re_data_store::EntityPath; use re_query::{EntityView, QueryError}; use re_renderer::Size; @@ -45,7 +45,7 @@ impl Lines3DPart { let visitor = |instance_key: InstanceKey, strip: LineStrip3D, - color: Option, + color: Option, radius: Option| { // TODO(andreas): support class ids for lines let annotation_info = ent_context @@ -88,7 +88,7 @@ impl ViewPartSystem for Lines3DPart { vec1::vec1![ LineStrip3D::name(), InstanceKey::name(), - ColorRGBA::name(), + LegacyColor::name(), Radius::name(), ] } diff --git a/crates/re_space_view_spatial/src/parts/meshes.rs b/crates/re_space_view_spatial/src/parts/meshes.rs index 917ddbba05e5..30eee703d986 100644 --- a/crates/re_space_view_spatial/src/parts/meshes.rs +++ b/crates/re_space_view_spatial/src/parts/meshes.rs @@ -1,4 +1,4 @@ -use re_components::{ColorRGBA, Mesh3D}; +use re_components::{LegacyColor, Mesh3D}; use re_data_store::EntityPath; use re_query::{EntityView, QueryError}; use re_renderer::renderer::MeshInstance; @@ -36,7 +36,7 @@ impl MeshPart { let visitor = |instance_key: InstanceKey, mesh: re_components::Mesh3D, - _color: Option| { + _color: Option| { let picking_instance_hash = re_data_store::InstancePathHash::instance(ent_path, instance_key); @@ -71,7 +71,7 @@ impl MeshPart { impl ViewPartSystem for MeshPart { fn archetype(&self) -> ArchetypeDefinition { - vec1::vec1![Mesh3D::name(), InstanceKey::name(), ColorRGBA::name()] + vec1::vec1![Mesh3D::name(), InstanceKey::name(), LegacyColor::name()] } fn execute( diff --git a/crates/re_space_view_text/src/view_part_system.rs b/crates/re_space_view_text/src/view_part_system.rs index 877788bba108..057703c39b81 100644 --- a/crates/re_space_view_text/src/view_part_system.rs +++ b/crates/re_space_view_text/src/view_part_system.rs @@ -53,7 +53,7 @@ impl ViewPartSystem for TextSystem { let components = [ InstanceKey::name(), re_components::TextEntry::name(), - re_components::ColorRGBA::name(), + re_components::LegacyColor::name(), ]; let ent_views = range_entity_with_primary::( store, &query, ent_path, components, @@ -63,7 +63,7 @@ impl ViewPartSystem for TextSystem { match ent_view.visit2( |_instance, text_entry: re_components::TextEntry, - color: Option| { + color: Option| { let re_components::TextEntry { body, level } = text_entry; self.text_entries.push(TextEntry { diff --git a/crates/re_space_view_time_series/src/view_part_system.rs b/crates/re_space_view_time_series/src/view_part_system.rs index 29d9963e6db2..e2d3078ec40e 100644 --- a/crates/re_space_view_time_series/src/view_part_system.rs +++ b/crates/re_space_view_time_series/src/view_part_system.rs @@ -102,7 +102,7 @@ impl TimeSeriesSystem { InstanceKey::name(), re_components::Scalar::name(), re_components::ScalarPlotProps::name(), - re_components::ColorRGBA::name(), + re_components::LegacyColor::name(), re_types::components::Radius::name(), re_components::LegacyLabel::name(), ] @@ -136,7 +136,7 @@ impl TimeSeriesSystem { |_instance, scalar: re_components::Scalar, props: Option, - color: Option, + color: Option, radius: Option, label: Option| { // TODO(andreas): Support entity path diff --git a/docs/code-examples/annotation_context_connections.rs b/docs/code-examples/annotation_context_connections.rs index 1d5455b86c13..50905d781926 100644 --- a/docs/code-examples/annotation_context_connections.rs +++ b/docs/code-examples/annotation_context_connections.rs @@ -1,6 +1,6 @@ //! Log some very simple points. use rerun::components::{ - AnnotationContext, AnnotationInfo, ClassDescription, ClassId, ColorRGBA, KeypointId, + AnnotationContext, AnnotationInfo, ClassDescription, ClassId, KeypointId, LegacyColor, LegacyLabel, Point3D, }; use rerun::{MsgSender, RecordingStreamBuilder}; @@ -18,7 +18,7 @@ fn main() -> Result<(), Box> { AnnotationInfo { id: 0, label: Some(LegacyLabel("zero".to_owned())), - color: Some(ColorRGBA::from_rgb(255, 0, 0)), + color: Some(LegacyColor::from_rgb(255, 0, 0)), }, ); class_desc.keypoint_map.insert( @@ -26,7 +26,7 @@ fn main() -> Result<(), Box> { AnnotationInfo { id: 1, label: Some(LegacyLabel("one".to_owned())), - color: Some(ColorRGBA::from_rgb(0, 255, 0)), + color: Some(LegacyColor::from_rgb(0, 255, 0)), }, ); class_desc.keypoint_map.insert( @@ -34,7 +34,7 @@ fn main() -> Result<(), Box> { AnnotationInfo { id: 2, label: Some(LegacyLabel("two".to_owned())), - color: Some(ColorRGBA::from_rgb(0, 0, 255)), + color: Some(LegacyColor::from_rgb(0, 0, 255)), }, ); class_desc.keypoint_map.insert( @@ -42,7 +42,7 @@ fn main() -> Result<(), Box> { AnnotationInfo { id: 3, label: Some(LegacyLabel("three".to_owned())), - color: Some(ColorRGBA::from_rgb(255, 255, 0)), + color: Some(LegacyColor::from_rgb(255, 255, 0)), }, ); class_desc.keypoint_connections = [(0, 2), (1, 2), (2, 3)] diff --git a/docs/code-examples/annotation_context_rects.rs b/docs/code-examples/annotation_context_rects.rs index 69f065e83ea2..a2aaba760132 100644 --- a/docs/code-examples/annotation_context_rects.rs +++ b/docs/code-examples/annotation_context_rects.rs @@ -1,6 +1,6 @@ //! Log rectangles with different colors and labels. use rerun::components::{ - AnnotationContext, AnnotationInfo, ClassDescription, ClassId, ColorRGBA, LegacyLabel, Rect2D, Vec4D, + AnnotationContext, AnnotationInfo, ClassDescription, ClassId, LegacyColor, LegacyLabel, Rect2D, Vec4D, }; use rerun::{MsgSender, RecordingStreamBuilder}; @@ -15,7 +15,7 @@ fn main() -> Result<(), Box> { info: AnnotationInfo { id: 1, label: Some(LegacyLabel("red".to_owned())), - color: Some(ColorRGBA::from_rgb(255, 0, 0)), + color: Some(LegacyColor::from_rgb(255, 0, 0)), }, ..Default::default() }, @@ -26,7 +26,7 @@ fn main() -> Result<(), Box> { info: AnnotationInfo { id: 2, label: Some(LegacyLabel("green".to_owned())), - color: Some(ColorRGBA::from_rgb(0, 255, 0)), + color: Some(LegacyColor::from_rgb(0, 255, 0)), }, ..Default::default() }, diff --git a/docs/code-examples/annotation_context_segmentation.rs b/docs/code-examples/annotation_context_segmentation.rs index 91c25ec8c91c..19311af4f534 100644 --- a/docs/code-examples/annotation_context_segmentation.rs +++ b/docs/code-examples/annotation_context_segmentation.rs @@ -1,7 +1,7 @@ //! Log a segmentation image with annotations. use ndarray::{s, Array, ShapeBuilder}; use rerun::components::{ - AnnotationContext, AnnotationInfo, ClassDescription, ClassId, ColorRGBA, LegacyLabel, Tensor, + AnnotationContext, AnnotationInfo, ClassDescription, ClassId, LegacyColor, LegacyLabel, Tensor, TensorDataMeaning, }; use rerun::{MsgSender, RecordingStreamBuilder}; @@ -26,7 +26,7 @@ fn main() -> Result<(), Box> { info: AnnotationInfo { id: 1, label: Some(LegacyLabel("red".to_owned())), - color: Some(ColorRGBA::from_rgb(255, 0, 0)), + color: Some(LegacyColor::from_rgb(255, 0, 0)), }, ..Default::default() }, @@ -37,7 +37,7 @@ fn main() -> Result<(), Box> { info: AnnotationInfo { id: 2, label: Some(LegacyLabel("green".to_owned())), - color: Some(ColorRGBA::from_rgb(0, 255, 0)), + color: Some(LegacyColor::from_rgb(0, 255, 0)), }, ..Default::default() }, diff --git a/docs/code-examples/point2d_random.rs b/docs/code-examples/point2d_random.rs index 575158be9715..39598ec4a0b0 100644 --- a/docs/code-examples/point2d_random.rs +++ b/docs/code-examples/point2d_random.rs @@ -1,7 +1,7 @@ //! Log some random points with color and radii. use rand::distributions::Uniform; use rand::Rng; -use rerun::components::{ColorRGBA, Point2D, Radius, Rect2D, Vec4D}; +use rerun::components::{LegacyColor, Point2D, Radius, Rect2D, Vec4D}; use rerun::{MsgSender, RecordingStreamBuilder}; fn main() -> Result<(), Box> { @@ -18,7 +18,7 @@ fn main() -> Result<(), Box> { rng.sample(position_distribs), rng.sample(position_distribs), )); - colors.push(ColorRGBA::from_rgb(rng.gen(), rng.gen(), rng.gen())); + colors.push(LegacyColor::from_rgb(rng.gen(), rng.gen(), rng.gen())); radii.push(Radius(rng.gen())); } diff --git a/docs/code-examples/point3d_random.rs b/docs/code-examples/point3d_random.rs index 52a3b8aeba12..63293853ff01 100644 --- a/docs/code-examples/point3d_random.rs +++ b/docs/code-examples/point3d_random.rs @@ -1,7 +1,7 @@ //! Log some random points with color and radii.""" use rand::distributions::Uniform; use rand::Rng; -use rerun::components::{ColorRGBA, Point3D, Radius}; +use rerun::components::{LegacyColor, Point3D, Radius}; use rerun::{MsgSender, RecordingStreamBuilder}; fn main() -> Result<(), Box> { @@ -19,7 +19,7 @@ fn main() -> Result<(), Box> { rng.sample(position_distribs), rng.sample(position_distribs), )); - colors.push(ColorRGBA::from_rgb(rng.gen(), rng.gen(), rng.gen())); + colors.push(LegacyColor::from_rgb(rng.gen(), rng.gen(), rng.gen())); radii.push(Radius(rng.gen())); } diff --git a/docs/code-examples/segmentation_image_simple.rs b/docs/code-examples/segmentation_image_simple.rs index b16b2a6a9960..2d535999dd38 100644 --- a/docs/code-examples/segmentation_image_simple.rs +++ b/docs/code-examples/segmentation_image_simple.rs @@ -1,7 +1,7 @@ //! Create and log a segmentation image. use ndarray::{s, Array, ShapeBuilder}; use rerun::components::{ - AnnotationContext, AnnotationInfo, ClassDescription, ClassId, ColorRGBA, LegacyLabel, Tensor, + AnnotationContext, AnnotationInfo, ClassDescription, ClassId, LegacyColor, LegacyLabel, Tensor, TensorDataMeaning, }; use rerun::{MsgSender, RecordingStreamBuilder}; @@ -25,7 +25,7 @@ fn main() -> Result<(), Box> { info: AnnotationInfo { id: 1, label: Some(LegacyLabel("red".to_owned())), - color: Some(ColorRGBA::from_rgb(255, 0, 0)), + color: Some(LegacyColor::from_rgb(255, 0, 0)), }, ..Default::default() }, @@ -36,7 +36,7 @@ fn main() -> Result<(), Box> { info: AnnotationInfo { id: 2, label: Some(LegacyLabel("green".to_owned())), - color: Some(ColorRGBA::from_rgb(0, 255, 0)), + color: Some(LegacyColor::from_rgb(0, 255, 0)), }, ..Default::default() }, diff --git a/examples/rust/clock/src/main.rs b/examples/rust/clock/src/main.rs index 7b9d1c1aaef9..93f32f5b348e 100644 --- a/examples/rust/clock/src/main.rs +++ b/examples/rust/clock/src/main.rs @@ -9,7 +9,7 @@ use std::f32::consts::TAU; -use rerun::components::{Arrow3D, Box3D, ColorRGBA, Radius, Vec3D, ViewCoordinates}; +use rerun::components::{Arrow3D, Box3D, LegacyColor, Radius, Vec3D, ViewCoordinates}; use rerun::coordinates::SignedAxis3; use rerun::{external::re_log, MsgSender, RecordingStream}; @@ -49,9 +49,9 @@ fn run(rec_stream: &RecordingStream, args: &Args) -> anyhow::Result<()> { Vec3D::new(length * angle.sin(), length * angle.cos(), 0.0) } - fn color(angle: f32, blue: u8) -> ColorRGBA { + fn color(angle: f32, blue: u8) -> LegacyColor { let c = (angle * 255.0) as u8; - ColorRGBA::from_unmultiplied_rgba(255 - c, c, blue, u8::max(128, blue)) + LegacyColor::from_unmultiplied_rgba(255 - c, c, blue, u8::max(128, blue)) } fn log_hand( diff --git a/examples/rust/custom_space_view/src/color_coordinates_view_part_system.rs b/examples/rust/custom_space_view/src/color_coordinates_view_part_system.rs index b1fb0cf21be0..0523da2e0445 100644 --- a/examples/rust/custom_space_view/src/color_coordinates_view_part_system.rs +++ b/examples/rust/custom_space_view/src/color_coordinates_view_part_system.rs @@ -27,7 +27,7 @@ impl ViewPartSystem for InstanceColorSystem { /// TODO(wumpf): In future versions there will be a hard restriction that limits the queries /// within the `populate` method to this archetype. fn archetype(&self) -> ArchetypeDefinition { - ArchetypeDefinition::new(re_components::ColorRGBA::name()) + ArchetypeDefinition::new(re_components::LegacyColor::name()) } /// Populates the scene part with data from the store. @@ -44,11 +44,11 @@ impl ViewPartSystem for InstanceColorSystem { } // ...gather all colors and their instance ids. - if let Ok(ent_view) = query_entity_with_primary::( + if let Ok(ent_view) = query_entity_with_primary::( &ctx.store_db.entity_db.data_store, &ctx.current_query(), ent_path, - &[re_components::ColorRGBA::name()], + &[re_components::LegacyColor::name()], ) { if let Ok(primary_iterator) = ent_view.iter_primary() { self.colors.push(( diff --git a/examples/rust/dna/src/main.rs b/examples/rust/dna/src/main.rs index 6506821f2ae5..b7c2e8519227 100644 --- a/examples/rust/dna/src/main.rs +++ b/examples/rust/dna/src/main.rs @@ -5,7 +5,7 @@ use std::f32::consts::TAU; use itertools::Itertools as _; use rerun::{ - components::{ColorRGBA, LineStrip3D, Point3D, Radius, Transform3D, Vec3D}, + components::{LegacyColor, LineStrip3D, Point3D, Radius, Transform3D, Vec3D}, demo_util::{bounce_lerp, color_spiral}, external::glam, MsgSender, MsgSenderError, RecordingStream, @@ -29,13 +29,13 @@ fn run(rec_stream: &RecordingStream) -> Result<(), MsgSenderError> { MsgSender::new("dna/structure/left") .with_component(&points1.iter().copied().map(Point3D::from).collect_vec())? - .with_component(&colors1.iter().copied().map(ColorRGBA::from).collect_vec())? + .with_component(&colors1.iter().copied().map(LegacyColor::from).collect_vec())? .with_splat(Radius(0.08))? .send(rec_stream)?; MsgSender::new("dna/structure/right") .with_component(&points2.iter().copied().map(Point3D::from).collect_vec())? - .with_component(&colors2.iter().copied().map(ColorRGBA::from).collect_vec())? + .with_component(&colors2.iter().copied().map(LegacyColor::from).collect_vec())? .with_splat(Radius(0.08))? .send(rec_stream)?; @@ -50,7 +50,7 @@ fn run(rec_stream: &RecordingStream) -> Result<(), MsgSenderError> { .collect_vec(); MsgSender::new("dna/structure/scaffolding") .with_component(&scaffolding)? - .with_splat(ColorRGBA::from([128, 128, 128, 255]))? + .with_splat(LegacyColor::from([128, 128, 128, 255]))? .send(rec_stream)?; use rand::Rng as _; @@ -75,7 +75,7 @@ fn run(rec_stream: &RecordingStream) -> Result<(), MsgSenderError> { let c = bounce_lerp(80.0, 230.0, times[n] * 2.0) as u8; ( Point3D::from(bounce_lerp(p1, p2, times[n])), - ColorRGBA::from_rgb(c, c, c), + LegacyColor::from_rgb(c, c, c), ) }) .unzip(); diff --git a/examples/rust/minimal/src/main.rs b/examples/rust/minimal/src/main.rs index 6c54f7246079..4a5ec38cd0d2 100644 --- a/examples/rust/minimal/src/main.rs +++ b/examples/rust/minimal/src/main.rs @@ -1,7 +1,7 @@ //! Demonstrates the most barebone usage of the Rerun SDK. use rerun::{ - components::{ColorRGBA, Point3D, Radius}, + components::{LegacyColor, Point3D, Radius}, demo_util::grid, external::glam, MsgSender, RecordingStreamBuilder, @@ -14,7 +14,7 @@ fn main() -> Result<(), Box> { .map(Point3D::from) .collect::>(); let colors = grid(glam::Vec3::ZERO, glam::Vec3::splat(255.0), 10) - .map(|v| ColorRGBA::from_rgb(v.x as u8, v.y as u8, v.z as u8)) + .map(|v| LegacyColor::from_rgb(v.x as u8, v.y as u8, v.z as u8)) .collect::>(); MsgSender::new("my_points") diff --git a/examples/rust/minimal_options/src/main.rs b/examples/rust/minimal_options/src/main.rs index 600fe3c6559f..68a6ca1459e3 100644 --- a/examples/rust/minimal_options/src/main.rs +++ b/examples/rust/minimal_options/src/main.rs @@ -5,7 +5,7 @@ //! cargo run -p minimal_options -- --help //! ``` -use rerun::components::{ColorRGBA, Point3D, Radius}; +use rerun::components::{LegacyColor, Point3D, Radius}; use rerun::{external::re_log, MsgSender, RecordingStream}; use rerun::demo_util::grid; @@ -36,7 +36,7 @@ fn run(rec_stream: &RecordingStream, args: &Args) -> anyhow::Result<()> { glam::Vec3::splat(255.0), args.num_points_per_axis, ) - .map(|v| ColorRGBA::from_rgb(v.x as u8, v.y as u8, v.z as u8)) + .map(|v| LegacyColor::from_rgb(v.x as u8, v.y as u8, v.z as u8)) .collect::>(); rec_stream.set_time_sequence("keyframe", 0); diff --git a/examples/rust/objectron/src/main.rs b/examples/rust/objectron/src/main.rs index 164aec6f3341..05bffc9b4674 100644 --- a/examples/rust/objectron/src/main.rs +++ b/examples/rust/objectron/src/main.rs @@ -113,7 +113,7 @@ fn log_baseline_objects( rec_stream: &RecordingStream, objects: &[objectron::Object], ) -> anyhow::Result<()> { - use rerun::components::{Box3D, ColorRGBA, LegacyLabel, Transform3D}; + use rerun::components::{Box3D, LegacyColor, LegacyLabel, Transform3D}; use rerun::transform::TranslationAndMat3; let boxes = objects.iter().filter_map(|object| { @@ -142,7 +142,7 @@ fn log_baseline_objects( .with_component(&[bbox])? .with_component(&[transform])? .with_component(&[label])? - .with_splat(ColorRGBA::from_rgb(160, 230, 130))? + .with_splat(LegacyColor::from_rgb(160, 230, 130))? .send(rec_stream)?; } @@ -214,7 +214,7 @@ fn log_feature_points( timepoint: TimePoint, points: &objectron::ArPointCloud, ) -> anyhow::Result<()> { - use rerun::components::{ColorRGBA, InstanceKey, Point3D}; + use rerun::components::{InstanceKey, LegacyColor, Point3D}; let ids = points.identifier.iter(); let points = points.point.iter(); @@ -236,7 +236,7 @@ fn log_feature_points( .with_timepoint(timepoint) .with_component(&points)? .with_component(&ids)? - .with_splat(ColorRGBA::from_rgb(255, 255, 255))? + .with_splat(LegacyColor::from_rgb(255, 255, 255))? .send(rec_stream)?; Ok(()) @@ -247,7 +247,7 @@ fn log_frame_annotations( timepoint: &TimePoint, annotations: &objectron::FrameAnnotation, ) -> anyhow::Result<()> { - use rerun::components::{ColorRGBA, InstanceKey, LineStrip2D, Point2D}; + use rerun::components::{InstanceKey, LegacyColor, LineStrip2D, Point2D}; for ann in &annotations.annotations { // TODO(cmc): we shouldn't be using those preprojected 2D points to begin with, Rerun is @@ -264,7 +264,7 @@ fn log_frame_annotations( let mut msg = MsgSender::new(format!("world/camera/estimates/box-{}", ann.object_id)) .with_timepoint(timepoint.clone()) - .with_splat(ColorRGBA::from_rgb(130, 160, 250))?; + .with_splat(LegacyColor::from_rgb(130, 160, 250))?; if points.len() == 9 { // Build the preprojected bounding box out of 2D line segments. diff --git a/examples/rust/raw_mesh/src/main.rs b/examples/rust/raw_mesh/src/main.rs index a605ca396290..6dd591c03fcd 100644 --- a/examples/rust/raw_mesh/src/main.rs +++ b/examples/rust/raw_mesh/src/main.rs @@ -13,7 +13,7 @@ use std::path::PathBuf; use anyhow::anyhow; use bytes::Bytes; use rerun::components::{ - ColorRGBA, Mesh3D, MeshId, RawMesh3D, Transform3D, Vec4D, ViewCoordinates, + LegacyColor, Mesh3D, MeshId, RawMesh3D, Transform3D, Vec4D, ViewCoordinates, }; use rerun::transform::TranslationRotationScale3D; use rerun::{ @@ -210,7 +210,7 @@ struct GltfPrimitive { albedo_factor: Option<[f32; 4]>, indices: Option>, vertex_positions: Vec<[f32; 3]>, - vertex_colors: Option>, + vertex_colors: Option>, vertex_normals: Option>, #[allow(dead_code)] vertex_texcoords: Option>, @@ -281,7 +281,7 @@ fn node_primitives<'data>( let vertex_colors = vertex_colors.map(|colors| { colors .into_rgba_u8() - .map(|[r, g, b, a]| ColorRGBA::from_unmultiplied_rgba(r, g, b, a)) + .map(|[r, g, b, a]| LegacyColor::from_unmultiplied_rgba(r, g, b, a)) .collect() }); diff --git a/rerun_py/src/python_bridge.rs b/rerun_py/src/python_bridge.rs index 17eb052a98d8..73c589588dcb 100644 --- a/rerun_py/src/python_bridge.rs +++ b/rerun_py/src/python_bridge.rs @@ -900,13 +900,13 @@ fn log_meshes( [_, 3] => Some( slice_from_np_array(&vertex_colors) .chunks_exact(3) - .map(|c| ColorRGBA::from_rgb(c[0], c[1], c[2]).0) + .map(|c| LegacyColor::from_rgb(c[0], c[1], c[2]).0) .collect(), ), [_, 4] => Some( slice_from_np_array(&vertex_colors) .chunks_exact(4) - .map(|c| ColorRGBA::from_unmultiplied_rgba(c[0], c[1], c[2], c[3]).0) + .map(|c| LegacyColor::from_unmultiplied_rgba(c[0], c[1], c[2], c[3]).0) .collect(), ), shape => { diff --git a/tests/rust/test_api/src/main.rs b/tests/rust/test_api/src/main.rs index fae29df24648..3b1ffe6b4ed4 100644 --- a/tests/rust/test_api/src/main.rs +++ b/tests/rust/test_api/src/main.rs @@ -17,9 +17,9 @@ use std::{collections::HashSet, f32::consts::TAU}; use itertools::Itertools; use rerun::{ components::{ - AnnotationContext, AnnotationInfo, Box3D, ClassDescription, ClassId, ColorRGBA, DrawOrder, - Label, LegacyLabel, LineStrip2D, LineStrip3D, Point2D, Point3D, Radius, Rect2D, Tensor, - TensorDataMeaning, TextEntry, Vec2D, Vec3D, ViewCoordinates, + AnnotationContext, AnnotationInfo, Box3D, ClassDescription, ClassId, DrawOrder, Label, + LegacyColor, LegacyLabel, LineStrip2D, LineStrip3D, Point2D, Point3D, Radius, Rect2D, + Tensor, TensorDataMeaning, TextEntry, Vec2D, Vec3D, ViewCoordinates, }, coordinates::SignedAxis3, external::{ @@ -36,7 +36,7 @@ fn test_bbox(rec_stream: &RecordingStream) -> anyhow::Result<()> { rec_stream.set_time_seconds("sim_time", 0f64); MsgSender::new("bbox_test/bbox") .with_component(&[Box3D::new(1.0, 0.5, 0.25)])? - .with_component(&[ColorRGBA::from_rgb(0, 255, 0)])? + .with_component(&[LegacyColor::from_rgb(0, 255, 0)])? .with_component(&[Radius(0.005)])? .with_component(&[Label("box/t0".to_owned())])? .send(rec_stream)?; @@ -52,7 +52,7 @@ fn test_bbox(rec_stream: &RecordingStream) -> anyhow::Result<()> { rec_stream.set_time_seconds("sim_time", 1f64); MsgSender::new("bbox_test/bbox") .with_component(&[Box3D::new(1.0, 0.5, 0.25)])? - .with_component(&[ColorRGBA::from_rgb(255, 255, 0)])? + .with_component(&[LegacyColor::from_rgb(255, 255, 0)])? .with_component(&[Radius(0.01)])? .with_component(&[Label("box/t1".to_owned())])? .send(rec_stream)?; @@ -100,7 +100,7 @@ fn test_extension_components(rec_stream: &RecordingStream) -> anyhow::Result<()> rec_stream.set_time_seconds("sim_time", 0f64); MsgSender::new("extension_components/point") .with_component(&[Point2D::new(64.0, 64.0)])? - .with_component(&[ColorRGBA::from_rgb(255, 0, 0)])? + .with_component(&[LegacyColor::from_rgb(255, 0, 0)])? .with_component(&[Confidence(0.9)])? .send(rec_stream)?; @@ -149,7 +149,7 @@ fn test_extension_components(rec_stream: &RecordingStream) -> anyhow::Result<()> Point2D::new(96.0, 32.0), Point2D::new(96.0, 96.0), ])? - .with_splat(ColorRGBA::from_rgb(0, 255, 0))? + .with_splat(LegacyColor::from_rgb(0, 255, 0))? .with_component(&[ Corner("upper left".into()), Corner("lower left".into()), @@ -172,12 +172,12 @@ fn test_log_cleared(rec_stream: &RecordingStream) -> anyhow::Result<()> { rec_stream.set_time_seconds("sim_time", 1f64); MsgSender::new("null_test/rect/0") .with_component(&[Rect2D::from_xywh(5.0, 5.0, 4.0, 4.0)])? - .with_component(&[ColorRGBA::from_rgb(255, 0, 0)])? + .with_component(&[LegacyColor::from_rgb(255, 0, 0)])? .with_component(&[Label("Rect1".into())])? .send(rec_stream)?; MsgSender::new("null_test/rect/1") .with_component(&[Rect2D::from_xywh(10.0, 5.0, 4.0, 4.0)])? - .with_component(&[ColorRGBA::from_rgb(0, 255, 0)])? + .with_component(&[LegacyColor::from_rgb(0, 255, 0)])? .with_component(&[Label("Rect2".into())])? .send(rec_stream)?; @@ -217,7 +217,7 @@ fn test_3d_points(rec_stream: &RecordingStream) -> anyhow::Result<()> { x: impl Fn(f32) -> f32, y: impl Fn(f32) -> f32, z: impl Fn(f32) -> f32, - ) -> (Vec, ent_path: &EntityPath, From 4507d8165f87452dd23a82941628c8398617e6c5 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 28 Jul 2023 10:07:05 +0200 Subject: [PATCH 36/37] expose Loggable in re_sdk too --- crates/re_sdk/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/re_sdk/src/lib.rs b/crates/re_sdk/src/lib.rs index e1b05ea633ee..be374c5bc4cf 100644 --- a/crates/re_sdk/src/lib.rs +++ b/crates/re_sdk/src/lib.rs @@ -23,7 +23,6 @@ pub use self::recording_stream::{RecordingStream, RecordingStreamBuilder}; pub use re_sdk_comms::{default_flush_timeout, default_server_addr}; pub use re_log_types::{ApplicationId, EntityPath, LegacyComponent, StoreId, StoreKind}; -pub use re_types::ComponentName; pub use global::cleanup_if_forked_child; @@ -97,7 +96,9 @@ pub mod coordinates { pub use re_components::coordinates::{Axis3, Handedness, Sign, SignedAxis3}; } -pub use re_types::{archetypes, datatypes, Archetype, Component, Datatype}; +pub use re_types::{ + archetypes, datatypes, Archetype, Component, ComponentName, Datatype, Loggable, +}; /// Methods for spawning the web viewer and streaming the SDK log stream to it. #[cfg(feature = "web_viewer")] From d0f296f4b6027a4ed50e0bbb0ba10a83bc416b2f Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 28 Jul 2023 10:30:10 +0200 Subject: [PATCH 37/37] lints --- crates/re_arrow_store/tests/correctness.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/re_arrow_store/tests/correctness.rs b/crates/re_arrow_store/tests/correctness.rs index 15d3a285f987..05c41f8f1a51 100644 --- a/crates/re_arrow_store/tests/correctness.rs +++ b/crates/re_arrow_store/tests/correctness.rs @@ -14,10 +14,7 @@ use re_components::datagen::{ build_frame_nr, build_log_time, build_some_colors, build_some_instances, build_some_point2d, }; use re_log_types::{DataCell, Duration, EntityPath, Time, TimeType, Timeline}; -use re_types::{ - components::{Color, InstanceKey}, - Loggable as _, -}; +use re_types::{components::InstanceKey, Loggable as _}; // --- @@ -220,7 +217,7 @@ fn range_join_across_single_row_impl(store: &mut DataStore) { prelude::{DataFrame, JoinType}, series::Series, }; - use re_types::components::Point2D; + use re_types::components::{Color, Point2D}; let ent_path = EntityPath::from("this/that");