From 3f2f2678e6fe1a9ed3c298983c90f77f8c9e2590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 3 Dec 2024 15:24:18 +0100 Subject: [PATCH 01/44] Add sketch of `ForcePositionX` [skip ci] --- .../blueprint/archetypes/force_position_x.fbs | 8 ++++++++ .../blueprint/components/force_position_x.fbs | 8 ++++++++ .../blueprint/datatypes/force_position_x.fbs | 16 ++++++++++++++++ .../definitions/rerun/blueprint/views/graph.fbs | 2 ++ 4 files changed, 34 insertions(+) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs new file mode 100644 index 000000000000..c5cb2e7f2ef5 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.archetypes; + +struct ForcePositionX ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default", +) { + force: rerun.datatypes.ForcePositionX (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs new file mode 100644 index 000000000000..e1b04b12e944 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.components; + +struct ForcePositionX ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default, Clone, PartialEq, Eq", +) { + position_x: rerun.datatypes.ForcePositionX (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs new file mode 100644 index 000000000000..47bd0ea0f3db --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs @@ -0,0 +1,16 @@ +namespace rerun.blueprint.datatypes; + +/// Defines a force that pulls nodes towards an `x` position. +struct ForcePositionX ( + "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rerun.scope": "blueprint", +) { + /// Whether the force is enabled. + enabled: bool (order: 100); + + /// The x position to pull nodes towards. + x: double (order: 200); + + /// The strength of the force. + strength: double (order: 300); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index 2f808bb8df2a..0d25e1d87d30 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -11,4 +11,6 @@ table GraphView ( /// /// Somethings outside of these bounds may also be visible due to letterboxing. visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 1000); + + force_position_x: rerun.blueprint.archetypes.ForcePositionX (order: 2000); } From 916502b8a49dad2cd7660246caef14554d61dc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 3 Dec 2024 15:36:24 +0100 Subject: [PATCH 02/44] Add sketch of `ForcePositionY` [skip ci] --- .../blueprint/archetypes/force_position_y.fbs | 8 ++++++++ .../blueprint/components/force_position_y.fbs | 8 ++++++++ .../blueprint/datatypes/force_position_x.fbs | 2 +- .../blueprint/datatypes/force_position_y.fbs | 16 ++++++++++++++++ .../definitions/rerun/blueprint/views/graph.fbs | 4 ++++ 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs new file mode 100644 index 000000000000..4c72b9c19eb6 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.archetypes; + +struct ForcePositionY ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default", +) { + force: rerun.datatypes.ForcePositionY (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs new file mode 100644 index 000000000000..ec646a5db992 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.components; + +struct ForcePositionY ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default, Clone, PartialEq, Eq", +) { + position_y: rerun.datatypes.ForcePositionY (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs index 47bd0ea0f3db..b815dff9926b 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs @@ -8,7 +8,7 @@ struct ForcePositionX ( /// Whether the force is enabled. enabled: bool (order: 100); - /// The x position to pull nodes towards. + /// The `x` position to pull nodes towards. x: double (order: 200); /// The strength of the force. diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs new file mode 100644 index 000000000000..06d5ace3f586 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs @@ -0,0 +1,16 @@ +namespace rerun.blueprint.datatypes; + +/// Defines a force that pulls nodes towards an `y` position. +struct ForcePositionY ( + "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rerun.scope": "blueprint", +) { + /// Whether the force is enabled. + enabled: bool (order: 100); + + /// The `y` position to pull nodes towards. + y: double (order: 200); + + /// The strength of the force. + strength: double (order: 300); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index 0d25e1d87d30..d244948e21e7 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -12,5 +12,9 @@ table GraphView ( /// Somethings outside of these bounds may also be visible due to letterboxing. visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 1000); + /// Adds a force that pull nodes towards an `x` position. force_position_x: rerun.blueprint.archetypes.ForcePositionX (order: 2000); + + /// Adds a force that pull nodes towards an `y` position. + force_position_y: rerun.blueprint.archetypes.ForcePositionY (order: 2100); } From 20705ed12fccfcabae2841a6f1a61a6186581abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 3 Dec 2024 15:42:16 +0100 Subject: [PATCH 03/44] Run `pixi run codegen` [skip ci] --- .../rerun/blueprint/archetypes.fbs | 2 + .../blueprint/archetypes/force_position_x.fbs | 4 +- .../blueprint/archetypes/force_position_y.fbs | 4 +- .../rerun/blueprint/components.fbs | 2 + .../blueprint/components/force_position_x.fbs | 4 +- .../blueprint/components/force_position_y.fbs | 4 +- .../definitions/rerun/blueprint/datatypes.fbs | 2 + .../blueprint/datatypes/force_position_x.fbs | 2 +- .../blueprint/datatypes/force_position_y.fbs | 2 +- .../src/blueprint/archetypes/.gitattributes | 2 + .../blueprint/archetypes/force_position_x.rs | 148 +++++++++ .../blueprint/archetypes/force_position_y.rs | 148 +++++++++ .../re_types/src/blueprint/archetypes/mod.rs | 4 + .../src/blueprint/components/.gitattributes | 2 + .../blueprint/components/force_position_x.rs | 103 +++++++ .../blueprint/components/force_position_y.rs | 103 +++++++ .../re_types/src/blueprint/components/mod.rs | 4 + .../src/blueprint/datatypes/.gitattributes | 2 + .../blueprint/datatypes/force_position_x.rs | 284 ++++++++++++++++++ .../blueprint/datatypes/force_position_y.rs | 284 ++++++++++++++++++ .../re_types/src/blueprint/datatypes/mod.rs | 4 + .../src/blueprint/views/graph_view.rs | 41 +-- .../src/blueprint/validation_gen/mod.rs | 4 + crates/viewer/re_viewer/src/reflection/mod.rs | 40 +++ .../reference/types/views/graph_view.md | 4 + rerun_cpp/src/rerun/blueprint/archetypes.hpp | 2 + .../rerun/blueprint/archetypes/.gitattributes | 4 + .../blueprint/archetypes/force_position_x.cpp | 34 +++ .../blueprint/archetypes/force_position_x.hpp | 50 +++ .../blueprint/archetypes/force_position_y.cpp | 34 +++ .../blueprint/archetypes/force_position_y.hpp | 50 +++ rerun_cpp/src/rerun/blueprint/components.hpp | 2 + .../rerun/blueprint/components/.gitattributes | 2 + .../blueprint/components/force_position_x.hpp | 69 +++++ .../blueprint/components/force_position_y.hpp | 69 +++++ rerun_cpp/src/rerun/blueprint/datatypes.hpp | 2 + .../rerun/blueprint/datatypes/.gitattributes | 4 + .../blueprint/datatypes/force_position_x.cpp | 83 +++++ .../blueprint/datatypes/force_position_x.hpp | 57 ++++ .../blueprint/datatypes/force_position_y.cpp | 83 +++++ .../blueprint/datatypes/force_position_y.hpp | 57 ++++ .../rerun/blueprint/archetypes/.gitattributes | 2 + .../rerun/blueprint/archetypes/__init__.py | 4 + .../blueprint/archetypes/force_position_x.py | 50 +++ .../blueprint/archetypes/force_position_y.py | 50 +++ .../rerun/blueprint/components/.gitattributes | 2 + .../rerun/blueprint/components/__init__.py | 6 + .../blueprint/components/force_position_x.py | 30 ++ .../blueprint/components/force_position_y.py | 30 ++ .../rerun/blueprint/datatypes/.gitattributes | 2 + .../rerun/blueprint/datatypes/__init__.py | 10 + .../blueprint/datatypes/force_position_x.py | 85 ++++++ .../blueprint/datatypes/force_position_y.py | 85 ++++++ .../rerun/blueprint/views/graph_view.py | 16 + 54 files changed, 2136 insertions(+), 41 deletions(-) create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_position_x.rs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_position_y.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_position_x.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_position_y.rs create mode 100644 crates/store/re_types/src/blueprint/datatypes/force_position_x.rs create mode 100644 crates/store/re_types/src/blueprint/datatypes/force_position_y.rs create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_position_x.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_position_y.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.hpp create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_x.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_y.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_position_x.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_position_y.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_x.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_y.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index 47eb842fc7c0..ed0928b1e019 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -3,6 +3,8 @@ include "./archetypes/background.fbs"; include "./archetypes/container_blueprint.fbs"; include "./archetypes/dataframe_query.fbs"; +include "./archetypes/force_position_x.fbs"; +include "./archetypes/force_position_y.fbs"; include "./archetypes/map_background.fbs"; include "./archetypes/map_zoom.fbs"; include "./archetypes/panel_blueprint.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs index c5cb2e7f2ef5..95f196dff25f 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.archetypes; struct ForcePositionX ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default", + "attr.rust.derive": "Default" ) { - force: rerun.datatypes.ForcePositionX (order: 100); + force: rerun.blueprint.components.ForcePositionX (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs index 4c72b9c19eb6..1c1c7a5874fd 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.archetypes; struct ForcePositionY ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default", + "attr.rust.derive": "Default" ) { - force: rerun.datatypes.ForcePositionY (order: 100); + force: rerun.blueprint.components.ForcePositionY (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components.fbs b/crates/store/re_types/definitions/rerun/blueprint/components.fbs index f52c3ae986f1..8afd142e19cf 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -11,6 +11,8 @@ include "./components/container_kind.fbs"; include "./components/corner_2d.fbs"; include "./components/filter_by_range.fbs"; include "./components/filter_is_not_null.fbs"; +include "./components/force_position_x.fbs"; +include "./components/force_position_y.fbs"; include "./components/grid_columns.fbs"; include "./components/included_content.fbs"; include "./components/interactive.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs index e1b04b12e944..5f114f746d9c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForcePositionX ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, Clone, PartialEq, Eq" ) { - position_x: rerun.datatypes.ForcePositionX (order: 100); + position_x: rerun.blueprint.datatypes.ForcePositionX (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs index ec646a5db992..f0eae5b69717 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForcePositionY ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, Clone, PartialEq, Eq" ) { - position_y: rerun.datatypes.ForcePositionY (order: 100); + position_y: rerun.blueprint.datatypes.ForcePositionY (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs index e08bb0e9f7d3..315d9dd7e08c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs @@ -3,6 +3,8 @@ include "./datatypes/component_column_selector.fbs"; include "./datatypes/filter_by_range.fbs"; include "./datatypes/filter_is_not_null.fbs"; +include "./datatypes/force_position_x.fbs"; +include "./datatypes/force_position_y.fbs"; include "./datatypes/selected_columns.fbs"; include "./datatypes/tensor_dimension_index_slider.fbs"; include "./datatypes/utf8_list.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs index b815dff9926b..821d0ec6a0ef 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs @@ -3,7 +3,7 @@ namespace rerun.blueprint.datatypes; /// Defines a force that pulls nodes towards an `x` position. struct ForcePositionX ( "attr.rust.derive": "Default, Clone, PartialEq, Eq", - "attr.rerun.scope": "blueprint", + "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. enabled: bool (order: 100); diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs index 06d5ace3f586..658de5f53703 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs @@ -3,7 +3,7 @@ namespace rerun.blueprint.datatypes; /// Defines a force that pulls nodes towards an `y` position. struct ForcePositionY ( "attr.rust.derive": "Default, Clone, PartialEq, Eq", - "attr.rerun.scope": "blueprint", + "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. enabled: bool (order: 100); diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index 158c53d4bb45..f982b7a0d3f2 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -3,6 +3,8 @@ .gitattributes linguist-generated=true background.rs linguist-generated=true dataframe_query.rs linguist-generated=true +force_position_x.rs linguist-generated=true +force_position_y.rs linguist-generated=true map_background.rs linguist-generated=true map_zoom.rs linguist-generated=true mod.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position_x.rs b/crates/store/re_types/src/blueprint/archetypes/force_position_x.rs new file mode 100644 index 000000000000..ccc4e9b972dc --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_position_x.rs @@ -0,0 +1,148 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default)] +pub struct ForcePositionX { + pub force: crate::blueprint::components::ForcePositionX, +} + +impl ::re_types_core::SizeBytes for ForcePositionX { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.force.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionXIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionXIndicator".into()]); + +impl ForcePositionX { + /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 1usize; +} + +/// Indicator component for the [`ForcePositionX`] [`::re_types_core::Archetype`] +pub type ForcePositionXIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForcePositionX { + type Indicator = ForcePositionXIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForcePositionX".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force position x" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForcePositionXIndicator = ForcePositionXIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let force = { + let array = arrays_by_name + .get("rerun.blueprint.components.ForcePositionX") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForcePositionX#force")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForcePositionX#force")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForcePositionX#force")? + }; + Ok(Self { force }) + } +} + +impl ::re_types_core::AsComponents for ForcePositionX { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + Some((&self.force as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForcePositionX {} + +impl ForcePositionX { + /// Create a new `ForcePositionX`. + #[inline] + pub fn new(force: impl Into) -> Self { + Self { + force: force.into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position_y.rs b/crates/store/re_types/src/blueprint/archetypes/force_position_y.rs new file mode 100644 index 000000000000..21c5acd117b5 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_position_y.rs @@ -0,0 +1,148 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default)] +pub struct ForcePositionY { + pub force: crate::blueprint::components::ForcePositionY, +} + +impl ::re_types_core::SizeBytes for ForcePositionY { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.force.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionYIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionYIndicator".into()]); + +impl ForcePositionY { + /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 1usize; +} + +/// Indicator component for the [`ForcePositionY`] [`::re_types_core::Archetype`] +pub type ForcePositionYIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForcePositionY { + type Indicator = ForcePositionYIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForcePositionY".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force position y" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForcePositionYIndicator = ForcePositionYIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let force = { + let array = arrays_by_name + .get("rerun.blueprint.components.ForcePositionY") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForcePositionY#force")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForcePositionY#force")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForcePositionY#force")? + }; + Ok(Self { force }) + } +} + +impl ::re_types_core::AsComponents for ForcePositionY { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + Some((&self.force as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForcePositionY {} + +impl ForcePositionY { + /// Create a new `ForcePositionY`. + #[inline] + pub fn new(force: impl Into) -> Self { + Self { + force: force.into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index 360c1b887939..12dfcac41394 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -2,6 +2,8 @@ mod background; mod dataframe_query; +mod force_position_x; +mod force_position_y; mod map_background; mod map_zoom; mod plot_legend; @@ -17,6 +19,8 @@ mod visual_bounds2d; pub use self::background::Background; pub use self::dataframe_query::DataframeQuery; +pub use self::force_position_x::ForcePositionX; +pub use self::force_position_y::ForcePositionY; pub use self::map_background::MapBackground; pub use self::map_zoom::MapZoom; pub use self::plot_legend::PlotLegend; diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index 4a1915dc979d..8eee0ecd0ee9 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -9,6 +9,8 @@ component_column_selector.rs linguist-generated=true corner2d.rs linguist-generated=true filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true +force_position_x.rs linguist-generated=true +force_position_y.rs linguist-generated=true included_content.rs linguist-generated=true interactive.rs linguist-generated=true lock_range_during_zoom.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/force_position_x.rs b/crates/store/re_types/src/blueprint/components/force_position_x.rs new file mode 100644 index 000000000000..200c6701046b --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_position_x.rs @@ -0,0 +1,103 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForcePositionX(pub crate::blueprint::datatypes::ForcePositionX); + +impl ::re_types_core::SizeBytes for ForcePositionX { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForcePositionX { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForcePositionX { + #[inline] + fn borrow(&self) -> &crate::blueprint::datatypes::ForcePositionX { + &self.0 + } +} + +impl std::ops::Deref for ForcePositionX { + type Target = crate::blueprint::datatypes::ForcePositionX; + + #[inline] + fn deref(&self) -> &crate::blueprint::datatypes::ForcePositionX { + &self.0 + } +} + +impl std::ops::DerefMut for ForcePositionX { + #[inline] + fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForcePositionX { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForcePositionX); + +impl ::re_types_core::Loggable for ForcePositionX { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::blueprint::datatypes::ForcePositionX::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::blueprint::datatypes::ForcePositionX::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::blueprint::datatypes::ForcePositionX::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl ::re_types_core::Component for ForcePositionX { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForcePositionX".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/force_position_y.rs b/crates/store/re_types/src/blueprint/components/force_position_y.rs new file mode 100644 index 000000000000..eb7e7583450d --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_position_y.rs @@ -0,0 +1,103 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForcePositionY(pub crate::blueprint::datatypes::ForcePositionY); + +impl ::re_types_core::SizeBytes for ForcePositionY { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForcePositionY { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForcePositionY { + #[inline] + fn borrow(&self) -> &crate::blueprint::datatypes::ForcePositionY { + &self.0 + } +} + +impl std::ops::Deref for ForcePositionY { + type Target = crate::blueprint::datatypes::ForcePositionY; + + #[inline] + fn deref(&self) -> &crate::blueprint::datatypes::ForcePositionY { + &self.0 + } +} + +impl std::ops::DerefMut for ForcePositionY { + #[inline] + fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForcePositionY { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForcePositionY); + +impl ::re_types_core::Loggable for ForcePositionY { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::blueprint::datatypes::ForcePositionY::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::blueprint::datatypes::ForcePositionY::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::blueprint::datatypes::ForcePositionY::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl ::re_types_core::Component for ForcePositionY { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForcePositionY".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index a915957fd392..52a97b12b40e 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -12,6 +12,8 @@ mod filter_by_range; mod filter_by_range_ext; mod filter_is_not_null; mod filter_is_not_null_ext; +mod force_position_x; +mod force_position_y; mod included_content; mod interactive; mod interactive_ext; @@ -48,6 +50,8 @@ pub use self::component_column_selector::ComponentColumnSelector; pub use self::corner2d::Corner2D; pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; +pub use self::force_position_x::ForcePositionX; +pub use self::force_position_y::ForcePositionY; pub use self::included_content::IncludedContent; pub use self::interactive::Interactive; pub use self::lock_range_during_zoom::LockRangeDuringZoom; diff --git a/crates/store/re_types/src/blueprint/datatypes/.gitattributes b/crates/store/re_types/src/blueprint/datatypes/.gitattributes index a5c2c2463632..283e7f6a3a20 100644 --- a/crates/store/re_types/src/blueprint/datatypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/datatypes/.gitattributes @@ -4,6 +4,8 @@ component_column_selector.rs linguist-generated=true filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true +force_position_x.rs linguist-generated=true +force_position_y.rs linguist-generated=true mod.rs linguist-generated=true selected_columns.rs linguist-generated=true tensor_dimension_index_slider.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs b/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs new file mode 100644 index 000000000000..9e7e0b3120d1 --- /dev/null +++ b/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs @@ -0,0 +1,284 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Datatype**: Defines a force that pulls nodes towards an `x` position. +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForcePositionX { + /// Whether the force is enabled. + pub enabled: bool, + + /// The `x` position to pull nodes towards. + pub x: f64, + + /// The strength of the force. + pub strength: f64, +} + +impl ::re_types_core::SizeBytes for ForcePositionX { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.x.heap_size_bytes() + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() && ::is_pod() && ::is_pod() + } +} + +::re_types_core::macros::impl_into_cow!(ForcePositionX); + +impl ::re_types_core::Loggable for ForcePositionX { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + #![allow(clippy::wildcard_imports)] + use arrow::datatypes::*; + DataType::Struct(Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("x", DataType::Float64, false), + Field::new("strength", DataType::Float64, false), + ])) + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + #![allow(clippy::wildcard_imports)] + #![allow(clippy::manual_is_variant_and)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::{array::*, buffer::*, datatypes::*}; + + #[allow(unused)] + fn as_array_ref(t: T) -> ArrayRef { + std::sync::Arc::new(t) as ArrayRef + } + Ok({ + let fields = Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("x", DataType::Float64, false), + Field::new("strength", DataType::Float64, false), + ]); + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(StructArray::new( + fields, + vec![ + { + let (somes, enabled): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.enabled.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let enabled_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(BooleanArray::new( + BooleanBuffer::from( + enabled + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + enabled_validity, + )) + }, + { + let (somes, x): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.x.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let x_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + x.into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + x_validity, + )) + }, + { + let (somes, strength): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.strength.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let strength_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + strength + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + strength_validity, + )) + }, + ], + validity, + )) + }) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + #![allow(clippy::wildcard_imports)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::datatypes::*; + use arrow2::{array::*, buffer::*}; + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = Self::arrow_datatype(); + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForcePositionX")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let (arrow_data_fields, arrow_data_arrays) = + (arrow_data.fields(), arrow_data.values()); + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(arrow_data_arrays) + .collect(); + let enabled = { + if !arrays_by_name.contains_key("enabled") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "enabled", + )) + .with_context("rerun.blueprint.datatypes.ForcePositionX"); + } + let arrow_data = &**arrays_by_name["enabled"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Boolean; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForcePositionX#enabled")? + .into_iter() + }; + let x = { + if !arrays_by_name.contains_key("x") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "x", + )) + .with_context("rerun.blueprint.datatypes.ForcePositionX"); + } + let arrow_data = &**arrays_by_name["x"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForcePositionX#x")? + .into_iter() + .map(|opt| opt.copied()) + }; + let strength = { + if !arrays_by_name.contains_key("strength") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "strength", + )) + .with_context("rerun.blueprint.datatypes.ForcePositionX"); + } + let arrow_data = &**arrays_by_name["strength"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForcePositionX#strength")? + .into_iter() + .map(|opt| opt.copied()) + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + ::itertools::izip!(enabled, x, strength), + arrow_data.validity(), + ) + .map(|opt| { + opt.map(|(enabled, x, strength)| { + Ok(Self { + enabled: enabled + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForcePositionX#enabled")?, + x: x.ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForcePositionX#x")?, + strength: strength + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForcePositionX#strength", + )?, + }) + }) + .transpose() + }) + .collect::>>() + .with_context("rerun.blueprint.datatypes.ForcePositionX")? + } + }) + } +} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs b/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs new file mode 100644 index 000000000000..fcdbb2e80afd --- /dev/null +++ b/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs @@ -0,0 +1,284 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Datatype**: Defines a force that pulls nodes towards an `y` position. +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForcePositionY { + /// Whether the force is enabled. + pub enabled: bool, + + /// The `y` position to pull nodes towards. + pub y: f64, + + /// The strength of the force. + pub strength: f64, +} + +impl ::re_types_core::SizeBytes for ForcePositionY { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.y.heap_size_bytes() + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() && ::is_pod() && ::is_pod() + } +} + +::re_types_core::macros::impl_into_cow!(ForcePositionY); + +impl ::re_types_core::Loggable for ForcePositionY { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + #![allow(clippy::wildcard_imports)] + use arrow::datatypes::*; + DataType::Struct(Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("y", DataType::Float64, false), + Field::new("strength", DataType::Float64, false), + ])) + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + #![allow(clippy::wildcard_imports)] + #![allow(clippy::manual_is_variant_and)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::{array::*, buffer::*, datatypes::*}; + + #[allow(unused)] + fn as_array_ref(t: T) -> ArrayRef { + std::sync::Arc::new(t) as ArrayRef + } + Ok({ + let fields = Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("y", DataType::Float64, false), + Field::new("strength", DataType::Float64, false), + ]); + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(StructArray::new( + fields, + vec![ + { + let (somes, enabled): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.enabled.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let enabled_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(BooleanArray::new( + BooleanBuffer::from( + enabled + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + enabled_validity, + )) + }, + { + let (somes, y): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.y.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let y_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + y.into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + y_validity, + )) + }, + { + let (somes, strength): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.strength.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let strength_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + strength + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + strength_validity, + )) + }, + ], + validity, + )) + }) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + #![allow(clippy::wildcard_imports)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::datatypes::*; + use arrow2::{array::*, buffer::*}; + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = Self::arrow_datatype(); + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForcePositionY")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let (arrow_data_fields, arrow_data_arrays) = + (arrow_data.fields(), arrow_data.values()); + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(arrow_data_arrays) + .collect(); + let enabled = { + if !arrays_by_name.contains_key("enabled") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "enabled", + )) + .with_context("rerun.blueprint.datatypes.ForcePositionY"); + } + let arrow_data = &**arrays_by_name["enabled"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Boolean; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForcePositionY#enabled")? + .into_iter() + }; + let y = { + if !arrays_by_name.contains_key("y") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "y", + )) + .with_context("rerun.blueprint.datatypes.ForcePositionY"); + } + let arrow_data = &**arrays_by_name["y"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForcePositionY#y")? + .into_iter() + .map(|opt| opt.copied()) + }; + let strength = { + if !arrays_by_name.contains_key("strength") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "strength", + )) + .with_context("rerun.blueprint.datatypes.ForcePositionY"); + } + let arrow_data = &**arrays_by_name["strength"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForcePositionY#strength")? + .into_iter() + .map(|opt| opt.copied()) + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + ::itertools::izip!(enabled, y, strength), + arrow_data.validity(), + ) + .map(|opt| { + opt.map(|(enabled, y, strength)| { + Ok(Self { + enabled: enabled + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForcePositionY#enabled")?, + y: y.ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForcePositionY#y")?, + strength: strength + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForcePositionY#strength", + )?, + }) + }) + .transpose() + }) + .collect::>>() + .with_context("rerun.blueprint.datatypes.ForcePositionY")? + } + }) + } +} diff --git a/crates/store/re_types/src/blueprint/datatypes/mod.rs b/crates/store/re_types/src/blueprint/datatypes/mod.rs index b60da1620294..82168480bb48 100644 --- a/crates/store/re_types/src/blueprint/datatypes/mod.rs +++ b/crates/store/re_types/src/blueprint/datatypes/mod.rs @@ -4,11 +4,15 @@ mod component_column_selector; mod component_column_selector_ext; mod filter_by_range; mod filter_is_not_null; +mod force_position_x; +mod force_position_y; mod selected_columns; mod tensor_dimension_index_slider; pub use self::component_column_selector::ComponentColumnSelector; pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; +pub use self::force_position_x::ForcePositionX; +pub use self::force_position_y::ForcePositionY; pub use self::selected_columns::SelectedColumns; pub use self::tensor_dimension_index_slider::TensorDimensionIndexSlider; diff --git a/crates/store/re_types/src/blueprint/views/graph_view.rs b/crates/store/re_types/src/blueprint/views/graph_view.rs index 505d5efd40d1..934c3e81a33a 100644 --- a/crates/store/re_types/src/blueprint/views/graph_view.rs +++ b/crates/store/re_types/src/blueprint/views/graph_view.rs @@ -25,48 +25,27 @@ pub struct GraphView { /// /// Somethings outside of these bounds may also be visible due to letterboxing. pub visual_bounds: crate::blueprint::archetypes::VisualBounds2D, + + /// Adds a force that pull nodes towards an `x` position. + pub force_position_x: crate::blueprint::archetypes::ForcePositionX, + + /// Adds a force that pull nodes towards an `y` position. + pub force_position_y: crate::blueprint::archetypes::ForcePositionY, } impl ::re_types_core::SizeBytes for GraphView { #[inline] fn heap_size_bytes(&self) -> u64 { self.visual_bounds.heap_size_bytes() + + self.force_position_x.heap_size_bytes() + + self.force_position_y.heap_size_bytes() } #[inline] fn is_pod() -> bool { ::is_pod() - } -} - -impl> From for GraphView { - fn from(v: T) -> Self { - Self { - visual_bounds: v.into(), - } - } -} - -impl std::borrow::Borrow for GraphView { - #[inline] - fn borrow(&self) -> &crate::blueprint::archetypes::VisualBounds2D { - &self.visual_bounds - } -} - -impl std::ops::Deref for GraphView { - type Target = crate::blueprint::archetypes::VisualBounds2D; - - #[inline] - fn deref(&self) -> &crate::blueprint::archetypes::VisualBounds2D { - &self.visual_bounds - } -} - -impl std::ops::DerefMut for GraphView { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::archetypes::VisualBounds2D { - &mut self.visual_bounds + && ::is_pod() + && ::is_pod() } } diff --git a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs index ac256bc847d4..6efd43c1e308 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -9,6 +9,8 @@ pub use re_types::blueprint::components::ComponentColumnSelector; pub use re_types::blueprint::components::Corner2D; pub use re_types::blueprint::components::FilterByRange; pub use re_types::blueprint::components::FilterIsNotNull; +pub use re_types::blueprint::components::ForcePositionX; +pub use re_types::blueprint::components::ForcePositionY; pub use re_types::blueprint::components::IncludedContent; pub use re_types::blueprint::components::Interactive; pub use re_types::blueprint::components::LockRangeDuringZoom; @@ -50,6 +52,8 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) + && validate_component::(blueprint) + && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 21424df3e255..f8d446505638 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -124,6 +124,22 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "", + custom_placeholder: Some(ForcePositionX::default().to_arrow2()?), + datatype: ForcePositionX::arrow2_datatype(), + }, + ), + ( + ::name(), + ComponentReflection { + docstring_md: "", + custom_placeholder: Some(ForcePositionY::default().to_arrow2()?), + datatype: ForcePositionY::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { @@ -1930,6 +1946,30 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForcePositionX"), + ArchetypeReflection { + display_name: "Force position x", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForcePositionX".into(), display_name : + "Force", docstring_md : "", is_required : false, }, + ], + }, + ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForcePositionY"), + ArchetypeReflection { + display_name: "Force position y", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForcePositionY".into(), display_name : + "Force", docstring_md : "", is_required : false, }, + ], + }, + ), ( ArchetypeName::new("rerun.blueprint.archetypes.MapBackground"), ArchetypeReflection { diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index f6830c618ed6..8acd6dd69ae7 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -11,6 +11,10 @@ A graph view to display time-variying, directed or undirected graph visualizatio Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. +### `force_position_x` +Adds a force that pull nodes towards an `x` position. +### `force_position_y` +Adds a force that pull nodes towards an `y` position. ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index 2fd779424b1f..8c3738d8b919 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -5,6 +5,8 @@ #include "blueprint/archetypes/background.hpp" #include "blueprint/archetypes/container_blueprint.hpp" #include "blueprint/archetypes/dataframe_query.hpp" +#include "blueprint/archetypes/force_position_x.hpp" +#include "blueprint/archetypes/force_position_y.hpp" #include "blueprint/archetypes/map_background.hpp" #include "blueprint/archetypes/map_zoom.hpp" #include "blueprint/archetypes/panel_blueprint.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes index 26e1a60b89a6..58d727aa8fcb 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -7,6 +7,10 @@ container_blueprint.cpp linguist-generated=true container_blueprint.hpp linguist-generated=true dataframe_query.cpp linguist-generated=true dataframe_query.hpp linguist-generated=true +force_position_x.cpp linguist-generated=true +force_position_x.hpp linguist-generated=true +force_position_y.cpp linguist-generated=true +force_position_y.hpp linguist-generated=true map_background.cpp linguist-generated=true map_background.hpp linguist-generated=true map_zoom.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.cpp new file mode 100644 index 000000000000..72d478196c45 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.cpp @@ -0,0 +1,34 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs". + +#include "force_position_x.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::ForcePositionX& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable(archetype.force); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForcePositionX::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.hpp new file mode 100644 index 000000000000..866b65507abe --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.hpp @@ -0,0 +1,50 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs". + +#pragma once + +#include "../../blueprint/components/force_position_x.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + struct ForcePositionX { + rerun::blueprint::components::ForcePositionX force; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForcePositionXIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForcePositionX() = default; + ForcePositionX(ForcePositionX&& other) = default; + + explicit ForcePositionX(rerun::blueprint::components::ForcePositionX _force) + : force(std::move(_force)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForcePositionX& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.cpp new file mode 100644 index 000000000000..ac49a68111ef --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.cpp @@ -0,0 +1,34 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs". + +#include "force_position_y.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::ForcePositionY& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable(archetype.force); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForcePositionY::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.hpp new file mode 100644 index 000000000000..ba89592584fb --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.hpp @@ -0,0 +1,50 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs". + +#pragma once + +#include "../../blueprint/components/force_position_y.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + struct ForcePositionY { + rerun::blueprint::components::ForcePositionY force; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForcePositionYIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForcePositionY() = default; + ForcePositionY(ForcePositionY&& other) = default; + + explicit ForcePositionY(rerun::blueprint::components::ForcePositionY _force) + : force(std::move(_force)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForcePositionY& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index e426e3a2b486..c8b32c1488a8 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -13,6 +13,8 @@ #include "blueprint/components/corner2d.hpp" #include "blueprint/components/filter_by_range.hpp" #include "blueprint/components/filter_is_not_null.hpp" +#include "blueprint/components/force_position_x.hpp" +#include "blueprint/components/force_position_y.hpp" #include "blueprint/components/grid_columns.hpp" #include "blueprint/components/included_content.hpp" #include "blueprint/components/interactive.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index 7b2410956aec..1dbcf1bb97ec 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -15,6 +15,8 @@ corner2d.cpp linguist-generated=true corner2d.hpp linguist-generated=true filter_by_range.hpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true +force_position_x.hpp linguist-generated=true +force_position_y.hpp linguist-generated=true grid_columns.hpp linguist-generated=true included_content.hpp linguist-generated=true interactive.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/force_position_x.hpp b/rerun_cpp/src/rerun/blueprint/components/force_position_x.hpp new file mode 100644 index 000000000000..3860416cc4eb --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_position_x.hpp @@ -0,0 +1,69 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs". + +#pragma once + +#include "../../blueprint/datatypes/force_position_x.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + struct ForcePositionX { + rerun::blueprint::datatypes::ForcePositionX position_x; + + public: + ForcePositionX() = default; + + ForcePositionX(rerun::blueprint::datatypes::ForcePositionX position_x_) + : position_x(position_x_) {} + + ForcePositionX& operator=(rerun::blueprint::datatypes::ForcePositionX position_x_) { + position_x = position_x_; + return *this; + } + + /// Cast to the underlying ForcePositionX datatype + operator rerun::blueprint::datatypes::ForcePositionX() const { + return position_x; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::blueprint::datatypes::ForcePositionX) == + sizeof(blueprint::components::ForcePositionX) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForcePositionX"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForcePositionX` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForcePositionX* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->position_x, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_position_y.hpp b/rerun_cpp/src/rerun/blueprint/components/force_position_y.hpp new file mode 100644 index 000000000000..9c73322b5e55 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_position_y.hpp @@ -0,0 +1,69 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs". + +#pragma once + +#include "../../blueprint/datatypes/force_position_y.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + struct ForcePositionY { + rerun::blueprint::datatypes::ForcePositionY position_y; + + public: + ForcePositionY() = default; + + ForcePositionY(rerun::blueprint::datatypes::ForcePositionY position_y_) + : position_y(position_y_) {} + + ForcePositionY& operator=(rerun::blueprint::datatypes::ForcePositionY position_y_) { + position_y = position_y_; + return *this; + } + + /// Cast to the underlying ForcePositionY datatype + operator rerun::blueprint::datatypes::ForcePositionY() const { + return position_y; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::blueprint::datatypes::ForcePositionY) == + sizeof(blueprint::components::ForcePositionY) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForcePositionY"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForcePositionY` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForcePositionY* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->position_y, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes.hpp b/rerun_cpp/src/rerun/blueprint/datatypes.hpp index 81af1dca9c44..ca3aeffe8d14 100644 --- a/rerun_cpp/src/rerun/blueprint/datatypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/datatypes.hpp @@ -5,6 +5,8 @@ #include "blueprint/datatypes/component_column_selector.hpp" #include "blueprint/datatypes/filter_by_range.hpp" #include "blueprint/datatypes/filter_is_not_null.hpp" +#include "blueprint/datatypes/force_position_x.hpp" +#include "blueprint/datatypes/force_position_y.hpp" #include "blueprint/datatypes/selected_columns.hpp" #include "blueprint/datatypes/tensor_dimension_index_slider.hpp" #include "blueprint/datatypes/utf8list.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes index 830bee9eb52e..7b129ffd8186 100644 --- a/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes @@ -7,6 +7,10 @@ filter_by_range.cpp linguist-generated=true filter_by_range.hpp linguist-generated=true filter_is_not_null.cpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true +force_position_x.cpp linguist-generated=true +force_position_x.hpp linguist-generated=true +force_position_y.cpp linguist-generated=true +force_position_y.hpp linguist-generated=true selected_columns.cpp linguist-generated=true selected_columns.hpp linguist-generated=true tensor_dimension_index_slider.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.cpp new file mode 100644 index 000000000000..8e5357464958 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.cpp @@ -0,0 +1,83 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs". + +#include "force_position_x.hpp" + +#include +#include + +namespace rerun::blueprint::datatypes {} + +namespace rerun { + const std::shared_ptr& + Loggable::arrow_datatype() { + static const auto datatype = arrow::struct_({ + arrow::field("enabled", arrow::boolean(), false), + arrow::field("x", arrow::float64(), false), + arrow::field("strength", arrow::float64(), false), + }); + return datatype; + } + + Result> Loggable::to_arrow( + const blueprint::datatypes::ForcePositionX* instances, size_t num_instances + ) { + // TODO(andreas): Allow configuring the memory pool. + arrow::MemoryPool* pool = arrow::default_memory_pool(); + auto datatype = arrow_datatype(); + + ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) + if (instances && num_instances > 0) { + RR_RETURN_NOT_OK( + Loggable::fill_arrow_array_builder( + static_cast(builder.get()), + instances, + num_instances + ) + ); + } + std::shared_ptr array; + ARROW_RETURN_NOT_OK(builder->Finish(&array)); + return array; + } + + rerun::Error Loggable::fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForcePositionX* elements, + size_t num_elements + ) { + if (builder == nullptr) { + return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); + } + if (elements == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Cannot serialize null pointer to arrow array." + ); + } + + { + auto field_builder = static_cast(builder->field_builder(0)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); + } + } + { + auto field_builder = static_cast(builder->field_builder(1)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].x)); + } + } + { + auto field_builder = static_cast(builder->field_builder(2)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); + } + } + ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); + + return Error::ok(); + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.hpp new file mode 100644 index 000000000000..18382cea73c9 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.hpp @@ -0,0 +1,57 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs". + +#pragma once + +#include "../../result.hpp" + +#include +#include + +namespace arrow { + class Array; + class DataType; + class StructBuilder; +} // namespace arrow + +namespace rerun::blueprint::datatypes { + /// **Datatype**: Defines a force that pulls nodes towards an `x` position. + struct ForcePositionX { + /// Whether the force is enabled. + bool enabled; + + /// The `x` position to pull nodes towards. + double x; + + /// The strength of the force. + double strength; + + public: + ForcePositionX() = default; + }; +} // namespace rerun::blueprint::datatypes + +namespace rerun { + template + struct Loggable; + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.datatypes.ForcePositionX"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype(); + + /// Serializes an array of `rerun::blueprint:: datatypes::ForcePositionX` into an arrow array. + static Result> to_arrow( + const blueprint::datatypes::ForcePositionX* instances, size_t num_instances + ); + + /// Fills an arrow array builder with an array of this type. + static rerun::Error fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForcePositionX* elements, + size_t num_elements + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.cpp new file mode 100644 index 000000000000..02a2edf3f0c6 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.cpp @@ -0,0 +1,83 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs". + +#include "force_position_y.hpp" + +#include +#include + +namespace rerun::blueprint::datatypes {} + +namespace rerun { + const std::shared_ptr& + Loggable::arrow_datatype() { + static const auto datatype = arrow::struct_({ + arrow::field("enabled", arrow::boolean(), false), + arrow::field("y", arrow::float64(), false), + arrow::field("strength", arrow::float64(), false), + }); + return datatype; + } + + Result> Loggable::to_arrow( + const blueprint::datatypes::ForcePositionY* instances, size_t num_instances + ) { + // TODO(andreas): Allow configuring the memory pool. + arrow::MemoryPool* pool = arrow::default_memory_pool(); + auto datatype = arrow_datatype(); + + ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) + if (instances && num_instances > 0) { + RR_RETURN_NOT_OK( + Loggable::fill_arrow_array_builder( + static_cast(builder.get()), + instances, + num_instances + ) + ); + } + std::shared_ptr array; + ARROW_RETURN_NOT_OK(builder->Finish(&array)); + return array; + } + + rerun::Error Loggable::fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForcePositionY* elements, + size_t num_elements + ) { + if (builder == nullptr) { + return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); + } + if (elements == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Cannot serialize null pointer to arrow array." + ); + } + + { + auto field_builder = static_cast(builder->field_builder(0)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); + } + } + { + auto field_builder = static_cast(builder->field_builder(1)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].y)); + } + } + { + auto field_builder = static_cast(builder->field_builder(2)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); + } + } + ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); + + return Error::ok(); + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.hpp new file mode 100644 index 000000000000..87e274d236c7 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.hpp @@ -0,0 +1,57 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs". + +#pragma once + +#include "../../result.hpp" + +#include +#include + +namespace arrow { + class Array; + class DataType; + class StructBuilder; +} // namespace arrow + +namespace rerun::blueprint::datatypes { + /// **Datatype**: Defines a force that pulls nodes towards an `y` position. + struct ForcePositionY { + /// Whether the force is enabled. + bool enabled; + + /// The `y` position to pull nodes towards. + double y; + + /// The strength of the force. + double strength; + + public: + ForcePositionY() = default; + }; +} // namespace rerun::blueprint::datatypes + +namespace rerun { + template + struct Loggable; + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.datatypes.ForcePositionY"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype(); + + /// Serializes an array of `rerun::blueprint:: datatypes::ForcePositionY` into an arrow array. + static Result> to_arrow( + const blueprint::datatypes::ForcePositionY* instances, size_t num_instances + ); + + /// Fills an arrow array builder with an array of this type. + static rerun::Error fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForcePositionY* elements, + size_t num_elements + ); + }; +} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index bb528bfbaf9a..6a9888f843df 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -5,6 +5,8 @@ __init__.py linguist-generated=true background.py linguist-generated=true container_blueprint.py linguist-generated=true dataframe_query.py linguist-generated=true +force_position_x.py linguist-generated=true +force_position_y.py linguist-generated=true map_background.py linguist-generated=true map_zoom.py linguist-generated=true panel_blueprint.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py index 018ec6c34d5e..2603ef2d487e 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -5,6 +5,8 @@ from .background import Background from .container_blueprint import ContainerBlueprint from .dataframe_query import DataframeQuery +from .force_position_x import ForcePositionX +from .force_position_y import ForcePositionY from .map_background import MapBackground from .map_zoom import MapZoom from .panel_blueprint import PanelBlueprint @@ -23,6 +25,8 @@ "Background", "ContainerBlueprint", "DataframeQuery", + "ForcePositionX", + "ForcePositionY", "MapBackground", "MapZoom", "PanelBlueprint", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_x.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_x.py new file mode 100644 index 000000000000..24785d5ad001 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_x.py @@ -0,0 +1,50 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs". + +# You can extend this class by creating a "ForcePositionXExt" class in "force_position_x_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForcePositionX"] + + +@define(str=False, repr=False, init=False) +class ForcePositionX(Archetype): + def __init__(self: Any, force: blueprint_datatypes.ForcePositionXLike): + """Create a new instance of the ForcePositionX archetype.""" + + # You can define your own __init__ function as a member of ForcePositionXExt in force_position_x_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(force=force) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + force=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForcePositionX: + """Produce an empty ForcePositionX, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + force: blueprint_components.ForcePositionXBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ForcePositionXBatch._required, # type: ignore[misc] + ) + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_y.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_y.py new file mode 100644 index 000000000000..155769a5c0a4 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_y.py @@ -0,0 +1,50 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs". + +# You can extend this class by creating a "ForcePositionYExt" class in "force_position_y_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForcePositionY"] + + +@define(str=False, repr=False, init=False) +class ForcePositionY(Archetype): + def __init__(self: Any, force: blueprint_datatypes.ForcePositionYLike): + """Create a new instance of the ForcePositionY archetype.""" + + # You can define your own __init__ function as a member of ForcePositionYExt in force_position_y_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(force=force) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + force=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForcePositionY: + """Produce an empty ForcePositionY, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + force: blueprint_components.ForcePositionYBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ForcePositionYBatch._required, # type: ignore[misc] + ) + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes index 57164211651c..131a216d4781 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -13,6 +13,8 @@ container_kind.py linguist-generated=true corner2d.py linguist-generated=true filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true +force_position_x.py linguist-generated=true +force_position_y.py linguist-generated=true grid_columns.py linguist-generated=true included_content.py linguist-generated=true interactive.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py index 2f4943b58c8d..f2b20c813511 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py @@ -13,6 +13,8 @@ from .corner2d import Corner2D, Corner2DArrayLike, Corner2DBatch, Corner2DLike from .filter_by_range import FilterByRange, FilterByRangeBatch from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullBatch +from .force_position_x import ForcePositionX, ForcePositionXBatch +from .force_position_y import ForcePositionY, ForcePositionYBatch from .grid_columns import GridColumns, GridColumnsBatch from .included_content import IncludedContent, IncludedContentBatch from .interactive import Interactive, InteractiveBatch @@ -65,6 +67,10 @@ "FilterByRangeBatch", "FilterIsNotNull", "FilterIsNotNullBatch", + "ForcePositionX", + "ForcePositionXBatch", + "ForcePositionY", + "ForcePositionYBatch", "GridColumns", "GridColumnsBatch", "IncludedContent", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_x.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_x.py new file mode 100644 index 000000000000..78561530806b --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_x.py @@ -0,0 +1,30 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs". + +# You can extend this class by creating a "ForcePositionXExt" class in "force_position_x_ext.py". + +from __future__ import annotations + +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) +from ...blueprint import datatypes as blueprint_datatypes + +__all__ = ["ForcePositionX", "ForcePositionXBatch"] + + +class ForcePositionX(blueprint_datatypes.ForcePositionX, ComponentMixin): + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForcePositionXExt in force_position_x_ext.py + + # Note: there are no fields here because ForcePositionX delegates to datatypes.ForcePositionX + pass + + +class ForcePositionXBatch(blueprint_datatypes.ForcePositionXBatch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForcePositionX" + + +# This is patched in late to avoid circular dependencies. +ForcePositionX._BATCH_TYPE = ForcePositionXBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_y.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_y.py new file mode 100644 index 000000000000..b22409fe5b22 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_y.py @@ -0,0 +1,30 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs". + +# You can extend this class by creating a "ForcePositionYExt" class in "force_position_y_ext.py". + +from __future__ import annotations + +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) +from ...blueprint import datatypes as blueprint_datatypes + +__all__ = ["ForcePositionY", "ForcePositionYBatch"] + + +class ForcePositionY(blueprint_datatypes.ForcePositionY, ComponentMixin): + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForcePositionYExt in force_position_y_ext.py + + # Note: there are no fields here because ForcePositionY delegates to datatypes.ForcePositionY + pass + + +class ForcePositionYBatch(blueprint_datatypes.ForcePositionYBatch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForcePositionY" + + +# This is patched in late to avoid circular dependencies. +ForcePositionY._BATCH_TYPE = ForcePositionYBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes index cfee973ea804..4c62fdd6bd89 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes @@ -5,6 +5,8 @@ __init__.py linguist-generated=true component_column_selector.py linguist-generated=true filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true +force_position_x.py linguist-generated=true +force_position_y.py linguist-generated=true selected_columns.py linguist-generated=true tensor_dimension_index_slider.py linguist-generated=true utf8list.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py index 7672cd09deef..3b6cc940266c 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py @@ -10,6 +10,8 @@ ) from .filter_by_range import FilterByRange, FilterByRangeArrayLike, FilterByRangeBatch, FilterByRangeLike from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullArrayLike, FilterIsNotNullBatch, FilterIsNotNullLike +from .force_position_x import ForcePositionX, ForcePositionXArrayLike, ForcePositionXBatch, ForcePositionXLike +from .force_position_y import ForcePositionY, ForcePositionYArrayLike, ForcePositionYBatch, ForcePositionYLike from .selected_columns import SelectedColumns, SelectedColumnsArrayLike, SelectedColumnsBatch, SelectedColumnsLike from .tensor_dimension_index_slider import ( TensorDimensionIndexSlider, @@ -32,6 +34,14 @@ "FilterIsNotNullArrayLike", "FilterIsNotNullBatch", "FilterIsNotNullLike", + "ForcePositionX", + "ForcePositionXArrayLike", + "ForcePositionXBatch", + "ForcePositionXLike", + "ForcePositionY", + "ForcePositionYArrayLike", + "ForcePositionYBatch", + "ForcePositionYLike", "SelectedColumns", "SelectedColumnsArrayLike", "SelectedColumnsBatch", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_x.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_x.py new file mode 100644 index 000000000000..3b3f9a8e7a17 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_x.py @@ -0,0 +1,85 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs". + +# You can extend this class by creating a "ForcePositionXExt" class in "force_position_x_ext.py". + +from __future__ import annotations + +from typing import Any, Sequence, Union + +import numpy as np +import pyarrow as pa +from attrs import define, field + +from ..._baseclasses import ( + BaseBatch, +) + +__all__ = ["ForcePositionX", "ForcePositionXArrayLike", "ForcePositionXBatch", "ForcePositionXLike"] + + +@define(init=False) +class ForcePositionX: + """**Datatype**: Defines a force that pulls nodes towards an `x` position.""" + + def __init__(self: Any, enabled: bool, x: float, strength: float): + """ + Create a new instance of the ForcePositionX datatype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + x: + The `x` position to pull nodes towards. + strength: + The strength of the force. + + """ + + # You can define your own __init__ function as a member of ForcePositionXExt in force_position_x_ext.py + self.__attrs_init__(enabled=enabled, x=x, strength=strength) + + enabled: bool = field(converter=bool) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + x: float = field(converter=float) + # The `x` position to pull nodes towards. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: float = field(converter=float) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + +ForcePositionXLike = ForcePositionX +ForcePositionXArrayLike = Union[ + ForcePositionX, + Sequence[ForcePositionXLike], +] + + +class ForcePositionXBatch(BaseBatch[ForcePositionXArrayLike]): + _ARROW_DATATYPE = pa.struct([ + pa.field("enabled", pa.bool_(), nullable=False, metadata={}), + pa.field("x", pa.float64(), nullable=False, metadata={}), + pa.field("strength", pa.float64(), nullable=False, metadata={}), + ]) + + @staticmethod + def _native_to_pa_array(data: ForcePositionXArrayLike, data_type: pa.DataType) -> pa.Array: + if isinstance(data, ForcePositionX): + data = [data] + + return pa.StructArray.from_arrays( + [ + pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), + pa.array(np.asarray([x.x for x in data], dtype=np.float64)), + pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), + ], + fields=list(data_type), + ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_y.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_y.py new file mode 100644 index 000000000000..e0cbb63ee53d --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_y.py @@ -0,0 +1,85 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs". + +# You can extend this class by creating a "ForcePositionYExt" class in "force_position_y_ext.py". + +from __future__ import annotations + +from typing import Any, Sequence, Union + +import numpy as np +import pyarrow as pa +from attrs import define, field + +from ..._baseclasses import ( + BaseBatch, +) + +__all__ = ["ForcePositionY", "ForcePositionYArrayLike", "ForcePositionYBatch", "ForcePositionYLike"] + + +@define(init=False) +class ForcePositionY: + """**Datatype**: Defines a force that pulls nodes towards an `y` position.""" + + def __init__(self: Any, enabled: bool, y: float, strength: float): + """ + Create a new instance of the ForcePositionY datatype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + y: + The `y` position to pull nodes towards. + strength: + The strength of the force. + + """ + + # You can define your own __init__ function as a member of ForcePositionYExt in force_position_y_ext.py + self.__attrs_init__(enabled=enabled, y=y, strength=strength) + + enabled: bool = field(converter=bool) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + y: float = field(converter=float) + # The `y` position to pull nodes towards. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: float = field(converter=float) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + +ForcePositionYLike = ForcePositionY +ForcePositionYArrayLike = Union[ + ForcePositionY, + Sequence[ForcePositionYLike], +] + + +class ForcePositionYBatch(BaseBatch[ForcePositionYArrayLike]): + _ARROW_DATATYPE = pa.struct([ + pa.field("enabled", pa.bool_(), nullable=False, metadata={}), + pa.field("y", pa.float64(), nullable=False, metadata={}), + pa.field("strength", pa.float64(), nullable=False, metadata={}), + ]) + + @staticmethod + def _native_to_pa_array(data: ForcePositionYArrayLike, data_type: pa.DataType) -> pa.Array: + if isinstance(data, ForcePositionY): + data = [data] + + return pa.StructArray.from_arrays( + [ + pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), + pa.array(np.asarray([x.y for x in data], dtype=np.float64)), + pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), + ], + fields=list(data_type), + ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py index 4c43bc8e055d..67cae4e6b353 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py @@ -70,6 +70,8 @@ def __init__( defaults: list[Union[AsComponents, ComponentBatchLike]] = [], overrides: dict[EntityPathLike, list[ComponentBatchLike]] = {}, visual_bounds: blueprint_archetypes.VisualBounds2D | None = None, + force_position_x: blueprint_archetypes.ForcePositionX | None = None, + force_position_y: blueprint_archetypes.ForcePositionY | None = None, ) -> None: """ Construct a blueprint for a new GraphView view. @@ -104,6 +106,10 @@ def __init__( Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. + force_position_x: + Adds a force that pull nodes towards an `x` position. + force_position_y: + Adds a force that pull nodes towards an `y` position. """ @@ -113,6 +119,16 @@ def __init__( visual_bounds = blueprint_archetypes.VisualBounds2D(visual_bounds) properties["VisualBounds2D"] = visual_bounds + if force_position_x is not None: + if not isinstance(force_position_x, blueprint_archetypes.ForcePositionX): + force_position_x = blueprint_archetypes.ForcePositionX(force_position_x) + properties["ForcePositionX"] = force_position_x + + if force_position_y is not None: + if not isinstance(force_position_y, blueprint_archetypes.ForcePositionY): + force_position_y = blueprint_archetypes.ForcePositionY(force_position_y) + properties["ForcePositionY"] = force_position_y + super().__init__( class_identifier="Graph", origin=origin, From 56de0228897fb2ea61d7a9d65cd4511e5e9228f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 3 Dec 2024 16:40:40 +0100 Subject: [PATCH 04/44] Add `ForceCenter` and `ForceCollideRadius` [skip ci] --- .../blueprint/archetypes/force_center.fbs | 8 +++++++ .../archetypes/force_collide_radius.fbs | 8 +++++++ .../blueprint/components/force_center.fbs | 8 +++++++ .../components/force_collide_radius.fbs | 8 +++++++ .../blueprint/datatypes/force_center.fbs | 19 +++++++++++++++++ .../datatypes/force_collide_radius.fbs | 21 +++++++++++++++++++ .../rerun/blueprint/views/graph.fbs | 6 ++++++ 7 files changed, 78 insertions(+) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs new file mode 100644 index 000000000000..49f7bfb79b49 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.archetypes; + +struct ForceCenter ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default" +) { + force: rerun.blueprint.components.ForceCenter (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs new file mode 100644 index 000000000000..14d6fda3238d --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.archetypes; + +struct ForceCollideRadius ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default" +) { + force: rerun.blueprint.components.ForceCollideRadius (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs new file mode 100644 index 000000000000..e26db379c0e8 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.components; + +struct ForceCenter ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default, Clone, PartialEq, Eq" +) { + center: rerun.blueprint.datatypes.ForceCenter (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs new file mode 100644 index 000000000000..60450490414b --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.components; + +struct ForceCollideRadius ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default, Clone, PartialEq, Eq" +) { + center: rerun.blueprint.datatypes.ForceCollideRadius (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs new file mode 100644 index 000000000000..225df5c470c8 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs @@ -0,0 +1,19 @@ +namespace rerun.blueprint.datatypes; + +/// Defines a force that globally centers a graph by moving its center of mass towards a given position. +struct ForceCenter ( + "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rerun.scope": "blueprint" +) { + /// Whether the force is enabled. + enabled: bool (order: 100); + + /// The `x` position to pull nodes towards. + x: double (order: 200); + + /// The `y` position to pull nodes towards. + y: double (order: 200); + + /// The strength of the force. + strength: double (order: 300); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs new file mode 100644 index 000000000000..3d337b15d649 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs @@ -0,0 +1,21 @@ +namespace rerun.blueprint.datatypes; + +// TODO: Not sure about this one. In `d3` the collision radius can either be constant or dependent on the node. + +/// Defines a force that resolves collisions between the radii of `GraphNodes`. +struct ForceCollideRadius ( + "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rerun.scope": "blueprint" +) { + /// Whether the force is enabled. + enabled: bool (order: 100); + + /// The number of iterations to resolve collisions. + iterations: u32 (order: 200); + + /// The strength of the force. + strength: double (order: 300); + + /// An additional padding to apply to each node radius. + padding: double (order: 400); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index d244948e21e7..09da6494698a 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -17,4 +17,10 @@ table GraphView ( /// Adds a force that pull nodes towards an `y` position. force_position_y: rerun.blueprint.archetypes.ForcePositionY (order: 2100); + + /// Adds a force that moves the center of mass of all nodes to a given position. + force_center: rerun.blueprint.archetypes.ForcePositionX (order: 3000); + + /// Adds a force that resolves collisions between graph nodes. + force_collide_radius: rerun.blueprint.archetypes.ForceCollideRadius (order: 4000); } From 77c3e7587efecf39617a10118d50b94a7569d41c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 3 Dec 2024 18:26:48 +0100 Subject: [PATCH 05/44] Finish initial version of forces [skip ci] --- .../rerun/blueprint/archetypes.fbs | 4 + .../rerun/blueprint/archetypes/force_link.fbs | 8 + .../blueprint/archetypes/force_many_body.fbs | 8 + .../rerun/blueprint/components.fbs | 4 + .../rerun/blueprint/components/force_link.fbs | 8 + .../blueprint/components/force_many_body.fbs | 8 + .../definitions/rerun/blueprint/datatypes.fbs | 4 + .../blueprint/datatypes/force_center.fbs | 4 +- .../datatypes/force_collide_radius.fbs | 2 +- .../rerun/blueprint/datatypes/force_link.fbs | 19 + .../blueprint/datatypes/force_many_body.fbs | 15 + .../rerun/blueprint/views/graph.fbs | 6 + .../src/blueprint/archetypes/.gitattributes | 4 + .../src/blueprint/archetypes/force_center.rs | 148 ++++++++ .../archetypes/force_collide_radius.rs | 152 ++++++++ .../src/blueprint/archetypes/force_link.rs | 148 ++++++++ .../blueprint/archetypes/force_many_body.rs | 148 ++++++++ .../re_types/src/blueprint/archetypes/mod.rs | 8 + .../src/blueprint/components/.gitattributes | 4 + .../src/blueprint/components/force_center.rs | 103 ++++++ .../components/force_collide_radius.rs | 105 ++++++ .../src/blueprint/components/force_link.rs | 103 ++++++ .../blueprint/components/force_many_body.rs | 103 ++++++ .../re_types/src/blueprint/components/mod.rs | 8 + .../src/blueprint/datatypes/.gitattributes | 4 + .../src/blueprint/datatypes/force_center.rs | 334 +++++++++++++++++ .../datatypes/force_collide_radius.rs | 346 ++++++++++++++++++ .../src/blueprint/datatypes/force_link.rs | 340 +++++++++++++++++ .../blueprint/datatypes/force_many_body.rs | 235 ++++++++++++ .../re_types/src/blueprint/datatypes/mod.rs | 8 + .../src/blueprint/views/graph_view.rs | 20 + .../src/blueprint/validation_gen/mod.rs | 8 + crates/viewer/re_viewer/src/reflection/mod.rs | 80 ++++ .../reference/types/views/graph_view.md | 8 + rerun_cpp/src/rerun/blueprint/archetypes.hpp | 4 + .../rerun/blueprint/archetypes/.gitattributes | 8 + .../blueprint/archetypes/force_center.cpp | 33 ++ .../blueprint/archetypes/force_center.hpp | 50 +++ .../archetypes/force_collide_radius.cpp | 34 ++ .../archetypes/force_collide_radius.hpp | 50 +++ .../rerun/blueprint/archetypes/force_link.cpp | 33 ++ .../rerun/blueprint/archetypes/force_link.hpp | 50 +++ .../blueprint/archetypes/force_many_body.cpp | 34 ++ .../blueprint/archetypes/force_many_body.hpp | 50 +++ rerun_cpp/src/rerun/blueprint/components.hpp | 4 + .../rerun/blueprint/components/.gitattributes | 4 + .../blueprint/components/force_center.hpp | 68 ++++ .../components/force_collide_radius.hpp | 72 ++++ .../rerun/blueprint/components/force_link.hpp | 67 ++++ .../blueprint/components/force_many_body.hpp | 68 ++++ rerun_cpp/src/rerun/blueprint/datatypes.hpp | 4 + .../rerun/blueprint/datatypes/.gitattributes | 8 + .../blueprint/datatypes/force_center.cpp | 89 +++++ .../blueprint/datatypes/force_center.hpp | 60 +++ .../datatypes/force_collide_radius.cpp | 92 +++++ .../datatypes/force_collide_radius.hpp | 60 +++ .../rerun/blueprint/datatypes/force_link.cpp | 89 +++++ .../rerun/blueprint/datatypes/force_link.hpp | 60 +++ .../blueprint/datatypes/force_many_body.cpp | 75 ++++ .../blueprint/datatypes/force_many_body.hpp | 56 +++ .../rerun/blueprint/archetypes/.gitattributes | 4 + .../rerun/blueprint/archetypes/__init__.py | 8 + .../blueprint/archetypes/force_center.py | 50 +++ .../archetypes/force_collide_radius.py | 50 +++ .../rerun/blueprint/archetypes/force_link.py | 50 +++ .../blueprint/archetypes/force_many_body.py | 50 +++ .../rerun/blueprint/components/.gitattributes | 4 + .../rerun/blueprint/components/__init__.py | 12 + .../blueprint/components/force_center.py | 30 ++ .../components/force_collide_radius.py | 30 ++ .../rerun/blueprint/components/force_link.py | 30 ++ .../blueprint/components/force_many_body.py | 30 ++ .../rerun/blueprint/datatypes/.gitattributes | 4 + .../rerun/blueprint/datatypes/__init__.py | 25 ++ .../rerun/blueprint/datatypes/force_center.py | 94 +++++ .../datatypes/force_collide_radius.py | 94 +++++ .../rerun/blueprint/datatypes/force_link.py | 94 +++++ .../blueprint/datatypes/force_many_body.py | 80 ++++ .../rerun/blueprint/views/graph_view.py | 32 ++ 79 files changed, 4497 insertions(+), 3 deletions(-) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_center.rs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_collide_radius.rs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_link.rs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_many_body.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_center.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_collide_radius.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_link.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_many_body.rs create mode 100644 crates/store/re_types/src/blueprint/datatypes/force_center.rs create mode 100644 crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs create mode 100644 crates/store/re_types/src/blueprint/datatypes/force_link.rs create mode 100644 crates/store/re_types/src/blueprint/datatypes/force_many_body.rs create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_center.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_collide_radius.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_link.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_many_body.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_center.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_center.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_link.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_link.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.hpp create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collide_radius.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_center.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_collide_radius.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_link.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_many_body.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_center.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_collide_radius.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_link.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_many_body.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index ed0928b1e019..146c1f1ace39 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -3,6 +3,10 @@ include "./archetypes/background.fbs"; include "./archetypes/container_blueprint.fbs"; include "./archetypes/dataframe_query.fbs"; +include "./archetypes/force_center.fbs"; +include "./archetypes/force_collide_radius.fbs"; +include "./archetypes/force_link.fbs"; +include "./archetypes/force_many_body.fbs"; include "./archetypes/force_position_x.fbs"; include "./archetypes/force_position_y.fbs"; include "./archetypes/map_background.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs new file mode 100644 index 000000000000..606dbb6cd027 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.archetypes; + +struct ForceLink ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default" +) { + force: rerun.blueprint.components.ForceLink (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs new file mode 100644 index 000000000000..9573c32ceaf2 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.archetypes; + +struct ForceManyBody ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default" +) { + force: rerun.blueprint.components.ForceManyBody (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components.fbs b/crates/store/re_types/definitions/rerun/blueprint/components.fbs index 8afd142e19cf..46b58b82a360 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -11,6 +11,10 @@ include "./components/container_kind.fbs"; include "./components/corner_2d.fbs"; include "./components/filter_by_range.fbs"; include "./components/filter_is_not_null.fbs"; +include "./components/force_center.fbs"; +include "./components/force_collide_radius.fbs"; +include "./components/force_link.fbs"; +include "./components/force_many_body.fbs"; include "./components/force_position_x.fbs"; include "./components/force_position_y.fbs"; include "./components/grid_columns.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs new file mode 100644 index 000000000000..2adc86abccc2 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.components; + +struct ForceLink ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default, Clone, PartialEq, Eq" +) { + center: rerun.blueprint.datatypes.ForceLink (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs new file mode 100644 index 000000000000..f05a4df41714 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.components; + +struct ForceManyBody ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default, Clone, PartialEq, Eq" +) { + center: rerun.blueprint.datatypes.ForceManyBody (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs index 315d9dd7e08c..a67c41d12553 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs @@ -3,6 +3,10 @@ include "./datatypes/component_column_selector.fbs"; include "./datatypes/filter_by_range.fbs"; include "./datatypes/filter_is_not_null.fbs"; +include "./datatypes/force_center.fbs"; +include "./datatypes/force_collide_radius.fbs"; +include "./datatypes/force_link.fbs"; +include "./datatypes/force_many_body.fbs"; include "./datatypes/force_position_x.fbs"; include "./datatypes/force_position_y.fbs"; include "./datatypes/selected_columns.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs index 225df5c470c8..55f319cdc3fc 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs @@ -12,8 +12,8 @@ struct ForceCenter ( x: double (order: 200); /// The `y` position to pull nodes towards. - y: double (order: 200); + y: double (order: 300); /// The strength of the force. - strength: double (order: 300); + strength: double (order: 400); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs index 3d337b15d649..412c27393f36 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs @@ -11,7 +11,7 @@ struct ForceCollideRadius ( enabled: bool (order: 100); /// The number of iterations to resolve collisions. - iterations: u32 (order: 200); + iterations: uint32 (order: 200); /// The strength of the force. strength: double (order: 300); diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs new file mode 100644 index 000000000000..92d60aec67fa --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs @@ -0,0 +1,19 @@ +namespace rerun.blueprint.datatypes; + +/// Defines a force that acts similar to a spring between nodes. +struct ForceLink ( + "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rerun.scope": "blueprint" +) { + /// Whether the force is enabled. + enabled: bool (order: 100); + + /// The number of iterations. + iterations: uint32 (order: 200); + + /// The distance between nodes at which the force is zero. + distance: double (order: 300); + + /// The strength of the force. + strength: double (order: 400); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs new file mode 100644 index 000000000000..8cd2711f615b --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs @@ -0,0 +1,15 @@ +namespace rerun.blueprint.datatypes; + +/// Defines a force that is similar to an electric charge between nodes. +/// +/// Positive strengths will push nodes apart, while negative strengths will pull nodes together. +struct ForceManyBody ( + "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rerun.scope": "blueprint" +) { + /// Whether the force is enabled. + enabled: bool (order: 100); + + /// The strength of the force. + strength: double (order: 200); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index 09da6494698a..59cf273953f3 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -23,4 +23,10 @@ table GraphView ( /// Adds a force that resolves collisions between graph nodes. force_collide_radius: rerun.blueprint.archetypes.ForceCollideRadius (order: 4000); + + /// Adds a force that acts like an electric charge between nodes. + force_many_body: rerun.blueprint.archetypes.ForceManyBody (order: 5000); + + /// Adds a force that acts like a spring between nodes. + force_link: rerun.blueprint.archetypes.ForceLink (order: 6000); } diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index f982b7a0d3f2..dadae0d258d7 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -3,6 +3,10 @@ .gitattributes linguist-generated=true background.rs linguist-generated=true dataframe_query.rs linguist-generated=true +force_center.rs linguist-generated=true +force_collide_radius.rs linguist-generated=true +force_link.rs linguist-generated=true +force_many_body.rs linguist-generated=true force_position_x.rs linguist-generated=true force_position_y.rs linguist-generated=true map_background.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/archetypes/force_center.rs b/crates/store/re_types/src/blueprint/archetypes/force_center.rs new file mode 100644 index 000000000000..bc567d6df2bb --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_center.rs @@ -0,0 +1,148 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default)] +pub struct ForceCenter { + pub force: crate::blueprint::components::ForceCenter, +} + +impl ::re_types_core::SizeBytes for ForceCenter { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.force.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceCenterIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceCenterIndicator".into()]); + +impl ForceCenter { + /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 1usize; +} + +/// Indicator component for the [`ForceCenter`] [`::re_types_core::Archetype`] +pub type ForceCenterIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceCenter { + type Indicator = ForceCenterIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceCenter".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force center" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceCenterIndicator = ForceCenterIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let force = { + let array = arrays_by_name + .get("rerun.blueprint.components.ForceCenter") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceCenter#force")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceCenter#force")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceCenter#force")? + }; + Ok(Self { force }) + } +} + +impl ::re_types_core::AsComponents for ForceCenter { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + Some((&self.force as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceCenter {} + +impl ForceCenter { + /// Create a new `ForceCenter`. + #[inline] + pub fn new(force: impl Into) -> Self { + Self { + force: force.into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collide_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collide_radius.rs new file mode 100644 index 000000000000..8fb0973744c4 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_collide_radius.rs @@ -0,0 +1,152 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default)] +pub struct ForceCollideRadius { + pub force: crate::blueprint::components::ForceCollideRadius, +} + +impl ::re_types_core::SizeBytes for ForceCollideRadius { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.force.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new( + || ["rerun.blueprint.components.ForceCollideRadiusIndicator".into()], + ); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = once_cell::sync::Lazy::new( + || ["rerun.blueprint.components.ForceCollideRadiusIndicator".into()], +); + +impl ForceCollideRadius { + /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 1usize; +} + +/// Indicator component for the [`ForceCollideRadius`] [`::re_types_core::Archetype`] +pub type ForceCollideRadiusIndicator = + ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceCollideRadius { + type Indicator = ForceCollideRadiusIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceCollideRadius".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force collide radius" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceCollideRadiusIndicator = ForceCollideRadiusIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let force = { + let array = arrays_by_name + .get("rerun.blueprint.components.ForceCollideRadius") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceCollideRadius#force")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceCollideRadius#force")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceCollideRadius#force")? + }; + Ok(Self { force }) + } +} + +impl ::re_types_core::AsComponents for ForceCollideRadius { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + Some((&self.force as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceCollideRadius {} + +impl ForceCollideRadius { + /// Create a new `ForceCollideRadius`. + #[inline] + pub fn new(force: impl Into) -> Self { + Self { + force: force.into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs new file mode 100644 index 000000000000..1771f8d5faa5 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -0,0 +1,148 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default)] +pub struct ForceLink { + pub force: crate::blueprint::components::ForceLink, +} + +impl ::re_types_core::SizeBytes for ForceLink { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.force.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); + +impl ForceLink { + /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 1usize; +} + +/// Indicator component for the [`ForceLink`] [`::re_types_core::Archetype`] +pub type ForceLinkIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceLink { + type Indicator = ForceLinkIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceLink".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force link" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceLinkIndicator = ForceLinkIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let force = { + let array = arrays_by_name + .get("rerun.blueprint.components.ForceLink") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceLink#force")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceLink#force")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceLink#force")? + }; + Ok(Self { force }) + } +} + +impl ::re_types_core::AsComponents for ForceLink { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + Some((&self.force as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceLink {} + +impl ForceLink { + /// Create a new `ForceLink`. + #[inline] + pub fn new(force: impl Into) -> Self { + Self { + force: force.into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs new file mode 100644 index 000000000000..01625d3ca3c6 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs @@ -0,0 +1,148 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default)] +pub struct ForceManyBody { + pub force: crate::blueprint::components::ForceManyBody, +} + +impl ::re_types_core::SizeBytes for ForceManyBody { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.force.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceManyBodyIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceManyBodyIndicator".into()]); + +impl ForceManyBody { + /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 1usize; +} + +/// Indicator component for the [`ForceManyBody`] [`::re_types_core::Archetype`] +pub type ForceManyBodyIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceManyBody { + type Indicator = ForceManyBodyIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceManyBody".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force many body" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceManyBodyIndicator = ForceManyBodyIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let force = { + let array = arrays_by_name + .get("rerun.blueprint.components.ForceManyBody") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceManyBody#force")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceManyBody#force")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceManyBody#force")? + }; + Ok(Self { force }) + } +} + +impl ::re_types_core::AsComponents for ForceManyBody { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + Some((&self.force as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceManyBody {} + +impl ForceManyBody { + /// Create a new `ForceManyBody`. + #[inline] + pub fn new(force: impl Into) -> Self { + Self { + force: force.into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index 12dfcac41394..e940c3734798 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -2,6 +2,10 @@ mod background; mod dataframe_query; +mod force_center; +mod force_collide_radius; +mod force_link; +mod force_many_body; mod force_position_x; mod force_position_y; mod map_background; @@ -19,6 +23,10 @@ mod visual_bounds2d; pub use self::background::Background; pub use self::dataframe_query::DataframeQuery; +pub use self::force_center::ForceCenter; +pub use self::force_collide_radius::ForceCollideRadius; +pub use self::force_link::ForceLink; +pub use self::force_many_body::ForceManyBody; pub use self::force_position_x::ForcePositionX; pub use self::force_position_y::ForcePositionY; pub use self::map_background::MapBackground; diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index 8eee0ecd0ee9..6ee24a97b4ec 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -9,6 +9,10 @@ component_column_selector.rs linguist-generated=true corner2d.rs linguist-generated=true filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true +force_center.rs linguist-generated=true +force_collide_radius.rs linguist-generated=true +force_link.rs linguist-generated=true +force_many_body.rs linguist-generated=true force_position_x.rs linguist-generated=true force_position_y.rs linguist-generated=true included_content.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/force_center.rs b/crates/store/re_types/src/blueprint/components/force_center.rs new file mode 100644 index 000000000000..055009881650 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_center.rs @@ -0,0 +1,103 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceCenter(pub crate::blueprint::datatypes::ForceCenter); + +impl ::re_types_core::SizeBytes for ForceCenter { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForceCenter { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceCenter { + #[inline] + fn borrow(&self) -> &crate::blueprint::datatypes::ForceCenter { + &self.0 + } +} + +impl std::ops::Deref for ForceCenter { + type Target = crate::blueprint::datatypes::ForceCenter; + + #[inline] + fn deref(&self) -> &crate::blueprint::datatypes::ForceCenter { + &self.0 + } +} + +impl std::ops::DerefMut for ForceCenter { + #[inline] + fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceCenter { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForceCenter); + +impl ::re_types_core::Loggable for ForceCenter { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::blueprint::datatypes::ForceCenter::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::blueprint::datatypes::ForceCenter::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::blueprint::datatypes::ForceCenter::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl ::re_types_core::Component for ForceCenter { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForceCenter".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/force_collide_radius.rs b/crates/store/re_types/src/blueprint/components/force_collide_radius.rs new file mode 100644 index 000000000000..66cfa77ee2cb --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_collide_radius.rs @@ -0,0 +1,105 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceCollideRadius(pub crate::blueprint::datatypes::ForceCollideRadius); + +impl ::re_types_core::SizeBytes for ForceCollideRadius { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForceCollideRadius { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceCollideRadius { + #[inline] + fn borrow(&self) -> &crate::blueprint::datatypes::ForceCollideRadius { + &self.0 + } +} + +impl std::ops::Deref for ForceCollideRadius { + type Target = crate::blueprint::datatypes::ForceCollideRadius; + + #[inline] + fn deref(&self) -> &crate::blueprint::datatypes::ForceCollideRadius { + &self.0 + } +} + +impl std::ops::DerefMut for ForceCollideRadius { + #[inline] + fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceCollideRadius { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForceCollideRadius); + +impl ::re_types_core::Loggable for ForceCollideRadius { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::blueprint::datatypes::ForceCollideRadius::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::blueprint::datatypes::ForceCollideRadius::to_arrow_opt(data.into_iter().map( + |datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + }, + )) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::blueprint::datatypes::ForceCollideRadius::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl ::re_types_core::Component for ForceCollideRadius { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForceCollideRadius".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/force_link.rs b/crates/store/re_types/src/blueprint/components/force_link.rs new file mode 100644 index 000000000000..3a71f305a607 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_link.rs @@ -0,0 +1,103 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceLink(pub crate::blueprint::datatypes::ForceLink); + +impl ::re_types_core::SizeBytes for ForceLink { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForceLink { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceLink { + #[inline] + fn borrow(&self) -> &crate::blueprint::datatypes::ForceLink { + &self.0 + } +} + +impl std::ops::Deref for ForceLink { + type Target = crate::blueprint::datatypes::ForceLink; + + #[inline] + fn deref(&self) -> &crate::blueprint::datatypes::ForceLink { + &self.0 + } +} + +impl std::ops::DerefMut for ForceLink { + #[inline] + fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceLink { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForceLink); + +impl ::re_types_core::Loggable for ForceLink { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::blueprint::datatypes::ForceLink::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::blueprint::datatypes::ForceLink::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::blueprint::datatypes::ForceLink::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl ::re_types_core::Component for ForceLink { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForceLink".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/force_many_body.rs b/crates/store/re_types/src/blueprint/components/force_many_body.rs new file mode 100644 index 000000000000..d0aff07034c2 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_many_body.rs @@ -0,0 +1,103 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceManyBody(pub crate::blueprint::datatypes::ForceManyBody); + +impl ::re_types_core::SizeBytes for ForceManyBody { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForceManyBody { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceManyBody { + #[inline] + fn borrow(&self) -> &crate::blueprint::datatypes::ForceManyBody { + &self.0 + } +} + +impl std::ops::Deref for ForceManyBody { + type Target = crate::blueprint::datatypes::ForceManyBody; + + #[inline] + fn deref(&self) -> &crate::blueprint::datatypes::ForceManyBody { + &self.0 + } +} + +impl std::ops::DerefMut for ForceManyBody { + #[inline] + fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceManyBody { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForceManyBody); + +impl ::re_types_core::Loggable for ForceManyBody { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::blueprint::datatypes::ForceManyBody::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::blueprint::datatypes::ForceManyBody::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::blueprint::datatypes::ForceManyBody::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl ::re_types_core::Component for ForceManyBody { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForceManyBody".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index 52a97b12b40e..395c130b273f 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -12,6 +12,10 @@ mod filter_by_range; mod filter_by_range_ext; mod filter_is_not_null; mod filter_is_not_null_ext; +mod force_center; +mod force_collide_radius; +mod force_link; +mod force_many_body; mod force_position_x; mod force_position_y; mod included_content; @@ -50,6 +54,10 @@ pub use self::component_column_selector::ComponentColumnSelector; pub use self::corner2d::Corner2D; pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; +pub use self::force_center::ForceCenter; +pub use self::force_collide_radius::ForceCollideRadius; +pub use self::force_link::ForceLink; +pub use self::force_many_body::ForceManyBody; pub use self::force_position_x::ForcePositionX; pub use self::force_position_y::ForcePositionY; pub use self::included_content::IncludedContent; diff --git a/crates/store/re_types/src/blueprint/datatypes/.gitattributes b/crates/store/re_types/src/blueprint/datatypes/.gitattributes index 283e7f6a3a20..e58a2258e81e 100644 --- a/crates/store/re_types/src/blueprint/datatypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/datatypes/.gitattributes @@ -4,6 +4,10 @@ component_column_selector.rs linguist-generated=true filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true +force_center.rs linguist-generated=true +force_collide_radius.rs linguist-generated=true +force_link.rs linguist-generated=true +force_many_body.rs linguist-generated=true force_position_x.rs linguist-generated=true force_position_y.rs linguist-generated=true mod.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/datatypes/force_center.rs b/crates/store/re_types/src/blueprint/datatypes/force_center.rs new file mode 100644 index 000000000000..27f377e283a9 --- /dev/null +++ b/crates/store/re_types/src/blueprint/datatypes/force_center.rs @@ -0,0 +1,334 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Datatype**: Defines a force that globally centers a graph by moving its center of mass towards a given position. +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceCenter { + /// Whether the force is enabled. + pub enabled: bool, + + /// The `x` position to pull nodes towards. + pub x: f64, + + /// The `y` position to pull nodes towards. + pub y: f64, + + /// The strength of the force. + pub strength: f64, +} + +impl ::re_types_core::SizeBytes for ForceCenter { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + + self.x.heap_size_bytes() + + self.y.heap_size_bytes() + + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() + } +} + +::re_types_core::macros::impl_into_cow!(ForceCenter); + +impl ::re_types_core::Loggable for ForceCenter { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + #![allow(clippy::wildcard_imports)] + use arrow::datatypes::*; + DataType::Struct(Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("x", DataType::Float64, false), + Field::new("y", DataType::Float64, false), + Field::new("strength", DataType::Float64, false), + ])) + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + #![allow(clippy::wildcard_imports)] + #![allow(clippy::manual_is_variant_and)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::{array::*, buffer::*, datatypes::*}; + + #[allow(unused)] + fn as_array_ref(t: T) -> ArrayRef { + std::sync::Arc::new(t) as ArrayRef + } + Ok({ + let fields = Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("x", DataType::Float64, false), + Field::new("y", DataType::Float64, false), + Field::new("strength", DataType::Float64, false), + ]); + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(StructArray::new( + fields, + vec![ + { + let (somes, enabled): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.enabled.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let enabled_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(BooleanArray::new( + BooleanBuffer::from( + enabled + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + enabled_validity, + )) + }, + { + let (somes, x): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.x.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let x_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + x.into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + x_validity, + )) + }, + { + let (somes, y): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.y.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let y_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + y.into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + y_validity, + )) + }, + { + let (somes, strength): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.strength.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let strength_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + strength + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + strength_validity, + )) + }, + ], + validity, + )) + }) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + #![allow(clippy::wildcard_imports)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::datatypes::*; + use arrow2::{array::*, buffer::*}; + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = Self::arrow_datatype(); + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCenter")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let (arrow_data_fields, arrow_data_arrays) = + (arrow_data.fields(), arrow_data.values()); + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(arrow_data_arrays) + .collect(); + let enabled = { + if !arrays_by_name.contains_key("enabled") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "enabled", + )) + .with_context("rerun.blueprint.datatypes.ForceCenter"); + } + let arrow_data = &**arrays_by_name["enabled"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Boolean; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCenter#enabled")? + .into_iter() + }; + let x = { + if !arrays_by_name.contains_key("x") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "x", + )) + .with_context("rerun.blueprint.datatypes.ForceCenter"); + } + let arrow_data = &**arrays_by_name["x"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCenter#x")? + .into_iter() + .map(|opt| opt.copied()) + }; + let y = { + if !arrays_by_name.contains_key("y") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "y", + )) + .with_context("rerun.blueprint.datatypes.ForceCenter"); + } + let arrow_data = &**arrays_by_name["y"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCenter#y")? + .into_iter() + .map(|opt| opt.copied()) + }; + let strength = { + if !arrays_by_name.contains_key("strength") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "strength", + )) + .with_context("rerun.blueprint.datatypes.ForceCenter"); + } + let arrow_data = &**arrays_by_name["strength"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCenter#strength")? + .into_iter() + .map(|opt| opt.copied()) + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + ::itertools::izip!(enabled, x, y, strength), + arrow_data.validity(), + ) + .map(|opt| { + opt.map(|(enabled, x, y, strength)| { + Ok(Self { + enabled: enabled + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceCenter#enabled")?, + x: x.ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceCenter#x")?, + y: y.ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceCenter#y")?, + strength: strength + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceCenter#strength")?, + }) + }) + .transpose() + }) + .collect::>>() + .with_context("rerun.blueprint.datatypes.ForceCenter")? + } + }) + } +} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs b/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs new file mode 100644 index 000000000000..dec28047c1a6 --- /dev/null +++ b/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs @@ -0,0 +1,346 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Datatype**: Defines a force that resolves collisions between the radii of `GraphNodes`. +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceCollideRadius { + /// Whether the force is enabled. + pub enabled: bool, + + /// The number of iterations to resolve collisions. + pub iterations: u32, + + /// The strength of the force. + pub strength: f64, + + /// An additional padding to apply to each node radius. + pub padding: f64, +} + +impl ::re_types_core::SizeBytes for ForceCollideRadius { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + + self.iterations.heap_size_bytes() + + self.strength.heap_size_bytes() + + self.padding.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() + } +} + +::re_types_core::macros::impl_into_cow!(ForceCollideRadius); + +impl ::re_types_core::Loggable for ForceCollideRadius { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + #![allow(clippy::wildcard_imports)] + use arrow::datatypes::*; + DataType::Struct(Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("iterations", DataType::UInt32, false), + Field::new("strength", DataType::Float64, false), + Field::new("padding", DataType::Float64, false), + ])) + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + #![allow(clippy::wildcard_imports)] + #![allow(clippy::manual_is_variant_and)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::{array::*, buffer::*, datatypes::*}; + + #[allow(unused)] + fn as_array_ref(t: T) -> ArrayRef { + std::sync::Arc::new(t) as ArrayRef + } + Ok({ + let fields = Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("iterations", DataType::UInt32, false), + Field::new("strength", DataType::Float64, false), + Field::new("padding", DataType::Float64, false), + ]); + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(StructArray::new( + fields, + vec![ + { + let (somes, enabled): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.enabled.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let enabled_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(BooleanArray::new( + BooleanBuffer::from( + enabled + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + enabled_validity, + )) + }, + { + let (somes, iterations): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.iterations.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let iterations_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + iterations + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + iterations_validity, + )) + }, + { + let (somes, strength): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.strength.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let strength_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + strength + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + strength_validity, + )) + }, + { + let (somes, padding): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.padding.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let padding_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + padding + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + padding_validity, + )) + }, + ], + validity, + )) + }) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + #![allow(clippy::wildcard_imports)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::datatypes::*; + use arrow2::{array::*, buffer::*}; + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = Self::arrow_datatype(); + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let (arrow_data_fields, arrow_data_arrays) = + (arrow_data.fields(), arrow_data.values()); + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(arrow_data_arrays) + .collect(); + let enabled = { + if !arrays_by_name.contains_key("enabled") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "enabled", + )) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius"); + } + let arrow_data = &**arrays_by_name["enabled"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Boolean; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius#enabled")? + .into_iter() + }; + let iterations = { + if !arrays_by_name.contains_key("iterations") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "iterations", + )) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius"); + } + let arrow_data = &**arrays_by_name["iterations"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::UInt32; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius#iterations")? + .into_iter() + .map(|opt| opt.copied()) + }; + let strength = { + if !arrays_by_name.contains_key("strength") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "strength", + )) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius"); + } + let arrow_data = &**arrays_by_name["strength"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius#strength")? + .into_iter() + .map(|opt| opt.copied()) + }; + let padding = { + if !arrays_by_name.contains_key("padding") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "padding", + )) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius"); + } + let arrow_data = &**arrays_by_name["padding"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceCollideRadius#padding")? + .into_iter() + .map(|opt| opt.copied()) + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + ::itertools::izip!(enabled, iterations, strength, padding), + arrow_data.validity(), + ) + .map(|opt| { + opt.map(|(enabled, iterations, strength, padding)| { + Ok(Self { + enabled: enabled + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceCollideRadius#enabled", + )?, + iterations: iterations + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceCollideRadius#iterations", + )?, + strength: strength + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceCollideRadius#strength", + )?, + padding: padding + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceCollideRadius#padding", + )?, + }) + }) + .transpose() + }) + .collect::>>() + .with_context("rerun.blueprint.datatypes.ForceCollideRadius")? + } + }) + } +} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_link.rs b/crates/store/re_types/src/blueprint/datatypes/force_link.rs new file mode 100644 index 000000000000..b7ed2ee8d54c --- /dev/null +++ b/crates/store/re_types/src/blueprint/datatypes/force_link.rs @@ -0,0 +1,340 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Datatype**: Defines a force that acts similar to a spring between nodes. +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceLink { + /// Whether the force is enabled. + pub enabled: bool, + + /// The number of iterations. + pub iterations: u32, + + /// The distance between nodes at which the force is zero. + pub distance: f64, + + /// The strength of the force. + pub strength: f64, +} + +impl ::re_types_core::SizeBytes for ForceLink { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + + self.iterations.heap_size_bytes() + + self.distance.heap_size_bytes() + + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() + } +} + +::re_types_core::macros::impl_into_cow!(ForceLink); + +impl ::re_types_core::Loggable for ForceLink { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + #![allow(clippy::wildcard_imports)] + use arrow::datatypes::*; + DataType::Struct(Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("iterations", DataType::UInt32, false), + Field::new("distance", DataType::Float64, false), + Field::new("strength", DataType::Float64, false), + ])) + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + #![allow(clippy::wildcard_imports)] + #![allow(clippy::manual_is_variant_and)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::{array::*, buffer::*, datatypes::*}; + + #[allow(unused)] + fn as_array_ref(t: T) -> ArrayRef { + std::sync::Arc::new(t) as ArrayRef + } + Ok({ + let fields = Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("iterations", DataType::UInt32, false), + Field::new("distance", DataType::Float64, false), + Field::new("strength", DataType::Float64, false), + ]); + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(StructArray::new( + fields, + vec![ + { + let (somes, enabled): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.enabled.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let enabled_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(BooleanArray::new( + BooleanBuffer::from( + enabled + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + enabled_validity, + )) + }, + { + let (somes, iterations): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.iterations.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let iterations_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + iterations + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + iterations_validity, + )) + }, + { + let (somes, distance): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.distance.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let distance_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + distance + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + distance_validity, + )) + }, + { + let (somes, strength): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.strength.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let strength_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + strength + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + strength_validity, + )) + }, + ], + validity, + )) + }) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + #![allow(clippy::wildcard_imports)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::datatypes::*; + use arrow2::{array::*, buffer::*}; + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = Self::arrow_datatype(); + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceLink")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let (arrow_data_fields, arrow_data_arrays) = + (arrow_data.fields(), arrow_data.values()); + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(arrow_data_arrays) + .collect(); + let enabled = { + if !arrays_by_name.contains_key("enabled") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "enabled", + )) + .with_context("rerun.blueprint.datatypes.ForceLink"); + } + let arrow_data = &**arrays_by_name["enabled"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Boolean; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceLink#enabled")? + .into_iter() + }; + let iterations = { + if !arrays_by_name.contains_key("iterations") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "iterations", + )) + .with_context("rerun.blueprint.datatypes.ForceLink"); + } + let arrow_data = &**arrays_by_name["iterations"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::UInt32; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceLink#iterations")? + .into_iter() + .map(|opt| opt.copied()) + }; + let distance = { + if !arrays_by_name.contains_key("distance") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "distance", + )) + .with_context("rerun.blueprint.datatypes.ForceLink"); + } + let arrow_data = &**arrays_by_name["distance"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceLink#distance")? + .into_iter() + .map(|opt| opt.copied()) + }; + let strength = { + if !arrays_by_name.contains_key("strength") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "strength", + )) + .with_context("rerun.blueprint.datatypes.ForceLink"); + } + let arrow_data = &**arrays_by_name["strength"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceLink#strength")? + .into_iter() + .map(|opt| opt.copied()) + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + ::itertools::izip!(enabled, iterations, distance, strength), + arrow_data.validity(), + ) + .map(|opt| { + opt.map(|(enabled, iterations, distance, strength)| { + Ok(Self { + enabled: enabled + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceLink#enabled")?, + iterations: iterations + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceLink#iterations", + )?, + distance: distance + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceLink#distance")?, + strength: strength + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceLink#strength")?, + }) + }) + .transpose() + }) + .collect::>>() + .with_context("rerun.blueprint.datatypes.ForceLink")? + } + }) + } +} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs b/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs new file mode 100644 index 000000000000..a8378a55aa87 --- /dev/null +++ b/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs @@ -0,0 +1,235 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Datatype**: Defines a force that is similar to an electric charge between nodes. +/// +/// Positive strengths will push nodes apart, while negative strengths will pull nodes together. +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceManyBody { + /// Whether the force is enabled. + pub enabled: bool, + + /// The strength of the force. + pub strength: f64, +} + +impl ::re_types_core::SizeBytes for ForceManyBody { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() && ::is_pod() + } +} + +::re_types_core::macros::impl_into_cow!(ForceManyBody); + +impl ::re_types_core::Loggable for ForceManyBody { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + #![allow(clippy::wildcard_imports)] + use arrow::datatypes::*; + DataType::Struct(Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("strength", DataType::Float64, false), + ])) + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + #![allow(clippy::wildcard_imports)] + #![allow(clippy::manual_is_variant_and)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::{array::*, buffer::*, datatypes::*}; + + #[allow(unused)] + fn as_array_ref(t: T) -> ArrayRef { + std::sync::Arc::new(t) as ArrayRef + } + Ok({ + let fields = Fields::from(vec![ + Field::new("enabled", DataType::Boolean, false), + Field::new("strength", DataType::Float64, false), + ]); + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(StructArray::new( + fields, + vec![ + { + let (somes, enabled): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.enabled.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let enabled_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(BooleanArray::new( + BooleanBuffer::from( + enabled + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + enabled_validity, + )) + }, + { + let (somes, strength): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.strength.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let strength_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + strength + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + strength_validity, + )) + }, + ], + validity, + )) + }) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + #![allow(clippy::wildcard_imports)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::datatypes::*; + use arrow2::{array::*, buffer::*}; + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = Self::arrow_datatype(); + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceManyBody")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let (arrow_data_fields, arrow_data_arrays) = + (arrow_data.fields(), arrow_data.values()); + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(arrow_data_arrays) + .collect(); + let enabled = { + if !arrays_by_name.contains_key("enabled") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "enabled", + )) + .with_context("rerun.blueprint.datatypes.ForceManyBody"); + } + let arrow_data = &**arrays_by_name["enabled"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Boolean; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceManyBody#enabled")? + .into_iter() + }; + let strength = { + if !arrays_by_name.contains_key("strength") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "strength", + )) + .with_context("rerun.blueprint.datatypes.ForceManyBody"); + } + let arrow_data = &**arrays_by_name["strength"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceManyBody#strength")? + .into_iter() + .map(|opt| opt.copied()) + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + ::itertools::izip!(enabled, strength), + arrow_data.validity(), + ) + .map(|opt| { + opt.map(|(enabled, strength)| { + Ok(Self { + enabled: enabled + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceManyBody#enabled")?, + strength: strength + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.datatypes.ForceManyBody#strength")?, + }) + }) + .transpose() + }) + .collect::>>() + .with_context("rerun.blueprint.datatypes.ForceManyBody")? + } + }) + } +} diff --git a/crates/store/re_types/src/blueprint/datatypes/mod.rs b/crates/store/re_types/src/blueprint/datatypes/mod.rs index 82168480bb48..a085ea4fafd1 100644 --- a/crates/store/re_types/src/blueprint/datatypes/mod.rs +++ b/crates/store/re_types/src/blueprint/datatypes/mod.rs @@ -4,6 +4,10 @@ mod component_column_selector; mod component_column_selector_ext; mod filter_by_range; mod filter_is_not_null; +mod force_center; +mod force_collide_radius; +mod force_link; +mod force_many_body; mod force_position_x; mod force_position_y; mod selected_columns; @@ -12,6 +16,10 @@ mod tensor_dimension_index_slider; pub use self::component_column_selector::ComponentColumnSelector; pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; +pub use self::force_center::ForceCenter; +pub use self::force_collide_radius::ForceCollideRadius; +pub use self::force_link::ForceLink; +pub use self::force_many_body::ForceManyBody; pub use self::force_position_x::ForcePositionX; pub use self::force_position_y::ForcePositionY; pub use self::selected_columns::SelectedColumns; diff --git a/crates/store/re_types/src/blueprint/views/graph_view.rs b/crates/store/re_types/src/blueprint/views/graph_view.rs index 934c3e81a33a..449cf2cf9644 100644 --- a/crates/store/re_types/src/blueprint/views/graph_view.rs +++ b/crates/store/re_types/src/blueprint/views/graph_view.rs @@ -31,6 +31,18 @@ pub struct GraphView { /// Adds a force that pull nodes towards an `y` position. pub force_position_y: crate::blueprint::archetypes::ForcePositionY, + + /// Adds a force that moves the center of mass of all nodes to a given position. + pub force_center: crate::blueprint::archetypes::ForcePositionX, + + /// Adds a force that resolves collisions between graph nodes. + pub force_collide_radius: crate::blueprint::archetypes::ForceCollideRadius, + + /// Adds a force that acts like an electric charge between nodes. + pub force_many_body: crate::blueprint::archetypes::ForceManyBody, + + /// Adds a force that acts like a spring between nodes. + pub force_link: crate::blueprint::archetypes::ForceLink, } impl ::re_types_core::SizeBytes for GraphView { @@ -39,6 +51,10 @@ impl ::re_types_core::SizeBytes for GraphView { self.visual_bounds.heap_size_bytes() + self.force_position_x.heap_size_bytes() + self.force_position_y.heap_size_bytes() + + self.force_center.heap_size_bytes() + + self.force_collide_radius.heap_size_bytes() + + self.force_many_body.heap_size_bytes() + + self.force_link.heap_size_bytes() } #[inline] @@ -46,6 +62,10 @@ impl ::re_types_core::SizeBytes for GraphView { ::is_pod() && ::is_pod() && ::is_pod() + && ::is_pod() + && ::is_pod() + && ::is_pod() + && ::is_pod() } } diff --git a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs index 6efd43c1e308..2c3c4dae7727 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -9,6 +9,10 @@ pub use re_types::blueprint::components::ComponentColumnSelector; pub use re_types::blueprint::components::Corner2D; pub use re_types::blueprint::components::FilterByRange; pub use re_types::blueprint::components::FilterIsNotNull; +pub use re_types::blueprint::components::ForceCenter; +pub use re_types::blueprint::components::ForceCollideRadius; +pub use re_types::blueprint::components::ForceLink; +pub use re_types::blueprint::components::ForceManyBody; pub use re_types::blueprint::components::ForcePositionX; pub use re_types::blueprint::components::ForcePositionY; pub use re_types::blueprint::components::IncludedContent; @@ -52,6 +56,10 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) + && validate_component::(blueprint) + && validate_component::(blueprint) + && validate_component::(blueprint) + && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index f8d446505638..671bf8d5404d 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -124,6 +124,38 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "", + custom_placeholder: Some(ForceCenter::default().to_arrow2()?), + datatype: ForceCenter::arrow2_datatype(), + }, + ), + ( + ::name(), + ComponentReflection { + docstring_md: "", + custom_placeholder: Some(ForceCollideRadius::default().to_arrow2()?), + datatype: ForceCollideRadius::arrow2_datatype(), + }, + ), + ( + ::name(), + ComponentReflection { + docstring_md: "", + custom_placeholder: Some(ForceLink::default().to_arrow2()?), + datatype: ForceLink::arrow2_datatype(), + }, + ), + ( + ::name(), + ComponentReflection { + docstring_md: "", + custom_placeholder: Some(ForceManyBody::default().to_arrow2()?), + datatype: ForceManyBody::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { @@ -1946,6 +1978,54 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceCenter"), + ArchetypeReflection { + display_name: "Force center", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceCenter".into(), display_name : + "Force", docstring_md : "", is_required : false, }, + ], + }, + ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceCollideRadius"), + ArchetypeReflection { + display_name: "Force collide radius", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceCollideRadius".into(), display_name + : "Force", docstring_md : "", is_required : false, }, + ], + }, + ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceLink"), + ArchetypeReflection { + display_name: "Force link", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceLink".into(), display_name : + "Force", docstring_md : "", is_required : false, }, + ], + }, + ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceManyBody"), + ArchetypeReflection { + display_name: "Force many body", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceManyBody".into(), display_name : + "Force", docstring_md : "", is_required : false, }, + ], + }, + ), ( ArchetypeName::new("rerun.blueprint.archetypes.ForcePositionX"), ArchetypeReflection { diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 8acd6dd69ae7..7cbf549e112a 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -15,6 +15,14 @@ Somethings outside of these bounds may also be visible due to letterboxing. Adds a force that pull nodes towards an `x` position. ### `force_position_y` Adds a force that pull nodes towards an `y` position. +### `force_center` +Adds a force that moves the center of mass of all nodes to a given position. +### `force_collide_radius` +Adds a force that resolves collisions between graph nodes. +### `force_many_body` +Adds a force that acts like an electric charge between nodes. +### `force_link` +Adds a force that acts like a spring between nodes. ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index 8c3738d8b919..44405ee4b0b0 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -5,6 +5,10 @@ #include "blueprint/archetypes/background.hpp" #include "blueprint/archetypes/container_blueprint.hpp" #include "blueprint/archetypes/dataframe_query.hpp" +#include "blueprint/archetypes/force_center.hpp" +#include "blueprint/archetypes/force_collide_radius.hpp" +#include "blueprint/archetypes/force_link.hpp" +#include "blueprint/archetypes/force_many_body.hpp" #include "blueprint/archetypes/force_position_x.hpp" #include "blueprint/archetypes/force_position_y.hpp" #include "blueprint/archetypes/map_background.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes index 58d727aa8fcb..723548d2fe93 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -7,6 +7,14 @@ container_blueprint.cpp linguist-generated=true container_blueprint.hpp linguist-generated=true dataframe_query.cpp linguist-generated=true dataframe_query.hpp linguist-generated=true +force_center.cpp linguist-generated=true +force_center.hpp linguist-generated=true +force_collide_radius.cpp linguist-generated=true +force_collide_radius.hpp linguist-generated=true +force_link.cpp linguist-generated=true +force_link.hpp linguist-generated=true +force_many_body.cpp linguist-generated=true +force_many_body.hpp linguist-generated=true force_position_x.cpp linguist-generated=true force_position_x.hpp linguist-generated=true force_position_y.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp new file mode 100644 index 000000000000..76ee0cda2745 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp @@ -0,0 +1,33 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". + +#include "force_center.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> AsComponents::serialize( + const blueprint::archetypes::ForceCenter& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable(archetype.force); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceCenter::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp new file mode 100644 index 000000000000..682f29c27a68 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp @@ -0,0 +1,50 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". + +#pragma once + +#include "../../blueprint/components/force_center.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + struct ForceCenter { + rerun::blueprint::components::ForceCenter force; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceCenterIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceCenter() = default; + ForceCenter(ForceCenter&& other) = default; + + explicit ForceCenter(rerun::blueprint::components::ForceCenter _force) + : force(std::move(_force)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceCenter& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.cpp new file mode 100644 index 000000000000..47cd8635ed09 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.cpp @@ -0,0 +1,34 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs". + +#include "force_collide_radius.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::ForceCollideRadius& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable(archetype.force); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceCollideRadius::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.hpp new file mode 100644 index 000000000000..11286320734f --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.hpp @@ -0,0 +1,50 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs". + +#pragma once + +#include "../../blueprint/components/force_collide_radius.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + struct ForceCollideRadius { + rerun::blueprint::components::ForceCollideRadius force; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceCollideRadiusIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceCollideRadius() = default; + ForceCollideRadius(ForceCollideRadius&& other) = default; + + explicit ForceCollideRadius(rerun::blueprint::components::ForceCollideRadius _force) + : force(std::move(_force)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceCollideRadius& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp new file mode 100644 index 000000000000..124d9688b5bf --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp @@ -0,0 +1,33 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". + +#include "force_link.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> AsComponents::serialize( + const blueprint::archetypes::ForceLink& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable(archetype.force); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceLink::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp new file mode 100644 index 000000000000..a2b1b9a96528 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp @@ -0,0 +1,50 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". + +#pragma once + +#include "../../blueprint/components/force_link.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + struct ForceLink { + rerun::blueprint::components::ForceLink force; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceLinkIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceLink() = default; + ForceLink(ForceLink&& other) = default; + + explicit ForceLink(rerun::blueprint::components::ForceLink _force) + : force(std::move(_force)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceLink& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp new file mode 100644 index 000000000000..7d966596883c --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp @@ -0,0 +1,34 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". + +#include "force_many_body.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::ForceManyBody& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable(archetype.force); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceManyBody::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp new file mode 100644 index 000000000000..d7521d498126 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp @@ -0,0 +1,50 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". + +#pragma once + +#include "../../blueprint/components/force_many_body.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + struct ForceManyBody { + rerun::blueprint::components::ForceManyBody force; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceManyBodyIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceManyBody() = default; + ForceManyBody(ForceManyBody&& other) = default; + + explicit ForceManyBody(rerun::blueprint::components::ForceManyBody _force) + : force(std::move(_force)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceManyBody& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index c8b32c1488a8..da4a321694bb 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -13,6 +13,10 @@ #include "blueprint/components/corner2d.hpp" #include "blueprint/components/filter_by_range.hpp" #include "blueprint/components/filter_is_not_null.hpp" +#include "blueprint/components/force_center.hpp" +#include "blueprint/components/force_collide_radius.hpp" +#include "blueprint/components/force_link.hpp" +#include "blueprint/components/force_many_body.hpp" #include "blueprint/components/force_position_x.hpp" #include "blueprint/components/force_position_y.hpp" #include "blueprint/components/grid_columns.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index 1dbcf1bb97ec..3850141d63e8 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -15,6 +15,10 @@ corner2d.cpp linguist-generated=true corner2d.hpp linguist-generated=true filter_by_range.hpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true +force_center.hpp linguist-generated=true +force_collide_radius.hpp linguist-generated=true +force_link.hpp linguist-generated=true +force_many_body.hpp linguist-generated=true force_position_x.hpp linguist-generated=true force_position_y.hpp linguist-generated=true grid_columns.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/force_center.hpp b/rerun_cpp/src/rerun/blueprint/components/force_center.hpp new file mode 100644 index 000000000000..03f2cbe5c30c --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_center.hpp @@ -0,0 +1,68 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs". + +#pragma once + +#include "../../blueprint/datatypes/force_center.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + struct ForceCenter { + rerun::blueprint::datatypes::ForceCenter center; + + public: + ForceCenter() = default; + + ForceCenter(rerun::blueprint::datatypes::ForceCenter center_) : center(center_) {} + + ForceCenter& operator=(rerun::blueprint::datatypes::ForceCenter center_) { + center = center_; + return *this; + } + + /// Cast to the underlying ForceCenter datatype + operator rerun::blueprint::datatypes::ForceCenter() const { + return center; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::blueprint::datatypes::ForceCenter) == + sizeof(blueprint::components::ForceCenter) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForceCenter"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForceCenter` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForceCenter* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->center, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_collide_radius.hpp b/rerun_cpp/src/rerun/blueprint/components/force_collide_radius.hpp new file mode 100644 index 000000000000..c500504ad0c3 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_collide_radius.hpp @@ -0,0 +1,72 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs". + +#pragma once + +#include "../../blueprint/datatypes/force_collide_radius.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + struct ForceCollideRadius { + rerun::blueprint::datatypes::ForceCollideRadius center; + + public: + ForceCollideRadius() = default; + + ForceCollideRadius(rerun::blueprint::datatypes::ForceCollideRadius center_) + : center(center_) {} + + ForceCollideRadius& operator=(rerun::blueprint::datatypes::ForceCollideRadius center_) { + center = center_; + return *this; + } + + /// Cast to the underlying ForceCollideRadius datatype + operator rerun::blueprint::datatypes::ForceCollideRadius() const { + return center; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::blueprint::datatypes::ForceCollideRadius) == + sizeof(blueprint::components::ForceCollideRadius) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForceCollideRadius"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForceCollideRadius` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForceCollideRadius* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow( + nullptr, + 0 + ); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->center, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_link.hpp b/rerun_cpp/src/rerun/blueprint/components/force_link.hpp new file mode 100644 index 000000000000..417be516ba2e --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_link.hpp @@ -0,0 +1,67 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs". + +#pragma once + +#include "../../blueprint/datatypes/force_link.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + struct ForceLink { + rerun::blueprint::datatypes::ForceLink center; + + public: + ForceLink() = default; + + ForceLink(rerun::blueprint::datatypes::ForceLink center_) : center(center_) {} + + ForceLink& operator=(rerun::blueprint::datatypes::ForceLink center_) { + center = center_; + return *this; + } + + /// Cast to the underlying ForceLink datatype + operator rerun::blueprint::datatypes::ForceLink() const { + return center; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::blueprint::datatypes::ForceLink) == sizeof(blueprint::components::ForceLink) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForceLink"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForceLink` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForceLink* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->center, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/components/force_many_body.hpp new file mode 100644 index 000000000000..b5bf4499713e --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_many_body.hpp @@ -0,0 +1,68 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs". + +#pragma once + +#include "../../blueprint/datatypes/force_many_body.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + struct ForceManyBody { + rerun::blueprint::datatypes::ForceManyBody center; + + public: + ForceManyBody() = default; + + ForceManyBody(rerun::blueprint::datatypes::ForceManyBody center_) : center(center_) {} + + ForceManyBody& operator=(rerun::blueprint::datatypes::ForceManyBody center_) { + center = center_; + return *this; + } + + /// Cast to the underlying ForceManyBody datatype + operator rerun::blueprint::datatypes::ForceManyBody() const { + return center; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::blueprint::datatypes::ForceManyBody) == + sizeof(blueprint::components::ForceManyBody) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForceManyBody"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForceManyBody` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForceManyBody* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->center, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes.hpp b/rerun_cpp/src/rerun/blueprint/datatypes.hpp index ca3aeffe8d14..b7fef16a4b0c 100644 --- a/rerun_cpp/src/rerun/blueprint/datatypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/datatypes.hpp @@ -5,6 +5,10 @@ #include "blueprint/datatypes/component_column_selector.hpp" #include "blueprint/datatypes/filter_by_range.hpp" #include "blueprint/datatypes/filter_is_not_null.hpp" +#include "blueprint/datatypes/force_center.hpp" +#include "blueprint/datatypes/force_collide_radius.hpp" +#include "blueprint/datatypes/force_link.hpp" +#include "blueprint/datatypes/force_many_body.hpp" #include "blueprint/datatypes/force_position_x.hpp" #include "blueprint/datatypes/force_position_y.hpp" #include "blueprint/datatypes/selected_columns.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes index 7b129ffd8186..ff2c298f422c 100644 --- a/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes @@ -7,6 +7,14 @@ filter_by_range.cpp linguist-generated=true filter_by_range.hpp linguist-generated=true filter_is_not_null.cpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true +force_center.cpp linguist-generated=true +force_center.hpp linguist-generated=true +force_collide_radius.cpp linguist-generated=true +force_collide_radius.hpp linguist-generated=true +force_link.cpp linguist-generated=true +force_link.hpp linguist-generated=true +force_many_body.cpp linguist-generated=true +force_many_body.hpp linguist-generated=true force_position_x.cpp linguist-generated=true force_position_x.hpp linguist-generated=true force_position_y.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_center.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_center.cpp new file mode 100644 index 000000000000..6a8eecd1ac59 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_center.cpp @@ -0,0 +1,89 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs". + +#include "force_center.hpp" + +#include +#include + +namespace rerun::blueprint::datatypes {} + +namespace rerun { + const std::shared_ptr& + Loggable::arrow_datatype() { + static const auto datatype = arrow::struct_({ + arrow::field("enabled", arrow::boolean(), false), + arrow::field("x", arrow::float64(), false), + arrow::field("y", arrow::float64(), false), + arrow::field("strength", arrow::float64(), false), + }); + return datatype; + } + + Result> Loggable::to_arrow( + const blueprint::datatypes::ForceCenter* instances, size_t num_instances + ) { + // TODO(andreas): Allow configuring the memory pool. + arrow::MemoryPool* pool = arrow::default_memory_pool(); + auto datatype = arrow_datatype(); + + ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) + if (instances && num_instances > 0) { + RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( + static_cast(builder.get()), + instances, + num_instances + )); + } + std::shared_ptr array; + ARROW_RETURN_NOT_OK(builder->Finish(&array)); + return array; + } + + rerun::Error Loggable::fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceCenter* elements, + size_t num_elements + ) { + if (builder == nullptr) { + return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); + } + if (elements == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Cannot serialize null pointer to arrow array." + ); + } + + { + auto field_builder = static_cast(builder->field_builder(0)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); + } + } + { + auto field_builder = static_cast(builder->field_builder(1)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].x)); + } + } + { + auto field_builder = static_cast(builder->field_builder(2)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].y)); + } + } + { + auto field_builder = static_cast(builder->field_builder(3)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); + } + } + ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); + + return Error::ok(); + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_center.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_center.hpp new file mode 100644 index 000000000000..6dc2faa4807b --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_center.hpp @@ -0,0 +1,60 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs". + +#pragma once + +#include "../../result.hpp" + +#include +#include + +namespace arrow { + class Array; + class DataType; + class StructBuilder; +} // namespace arrow + +namespace rerun::blueprint::datatypes { + /// **Datatype**: Defines a force that globally centers a graph by moving its center of mass towards a given position. + struct ForceCenter { + /// Whether the force is enabled. + bool enabled; + + /// The `x` position to pull nodes towards. + double x; + + /// The `y` position to pull nodes towards. + double y; + + /// The strength of the force. + double strength; + + public: + ForceCenter() = default; + }; +} // namespace rerun::blueprint::datatypes + +namespace rerun { + template + struct Loggable; + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceCenter"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype(); + + /// Serializes an array of `rerun::blueprint:: datatypes::ForceCenter` into an arrow array. + static Result> to_arrow( + const blueprint::datatypes::ForceCenter* instances, size_t num_instances + ); + + /// Fills an arrow array builder with an array of this type. + static rerun::Error fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceCenter* elements, + size_t num_elements + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.cpp new file mode 100644 index 000000000000..47e16a5300cb --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.cpp @@ -0,0 +1,92 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs". + +#include "force_collide_radius.hpp" + +#include +#include + +namespace rerun::blueprint::datatypes {} + +namespace rerun { + const std::shared_ptr& + Loggable::arrow_datatype() { + static const auto datatype = arrow::struct_({ + arrow::field("enabled", arrow::boolean(), false), + arrow::field("iterations", arrow::uint32(), false), + arrow::field("strength", arrow::float64(), false), + arrow::field("padding", arrow::float64(), false), + }); + return datatype; + } + + Result> + Loggable::to_arrow( + const blueprint::datatypes::ForceCollideRadius* instances, size_t num_instances + ) { + // TODO(andreas): Allow configuring the memory pool. + arrow::MemoryPool* pool = arrow::default_memory_pool(); + auto datatype = arrow_datatype(); + + ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) + if (instances && num_instances > 0) { + RR_RETURN_NOT_OK( + Loggable::fill_arrow_array_builder( + static_cast(builder.get()), + instances, + num_instances + ) + ); + } + std::shared_ptr array; + ARROW_RETURN_NOT_OK(builder->Finish(&array)); + return array; + } + + rerun::Error Loggable::fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceCollideRadius* elements, + size_t num_elements + ) { + if (builder == nullptr) { + return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); + } + if (elements == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Cannot serialize null pointer to arrow array." + ); + } + + { + auto field_builder = static_cast(builder->field_builder(0)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); + } + } + { + auto field_builder = static_cast(builder->field_builder(1)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].iterations)); + } + } + { + auto field_builder = static_cast(builder->field_builder(2)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); + } + } + { + auto field_builder = static_cast(builder->field_builder(3)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].padding)); + } + } + ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); + + return Error::ok(); + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.hpp new file mode 100644 index 000000000000..43176631abae --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.hpp @@ -0,0 +1,60 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs". + +#pragma once + +#include "../../result.hpp" + +#include +#include + +namespace arrow { + class Array; + class DataType; + class StructBuilder; +} // namespace arrow + +namespace rerun::blueprint::datatypes { + /// **Datatype**: Defines a force that resolves collisions between the radii of `GraphNodes`. + struct ForceCollideRadius { + /// Whether the force is enabled. + bool enabled; + + /// The number of iterations to resolve collisions. + uint32_t iterations; + + /// The strength of the force. + double strength; + + /// An additional padding to apply to each node radius. + double padding; + + public: + ForceCollideRadius() = default; + }; +} // namespace rerun::blueprint::datatypes + +namespace rerun { + template + struct Loggable; + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceCollideRadius"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype(); + + /// Serializes an array of `rerun::blueprint:: datatypes::ForceCollideRadius` into an arrow array. + static Result> to_arrow( + const blueprint::datatypes::ForceCollideRadius* instances, size_t num_instances + ); + + /// Fills an arrow array builder with an array of this type. + static rerun::Error fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceCollideRadius* elements, + size_t num_elements + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_link.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_link.cpp new file mode 100644 index 000000000000..bb4e33208081 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_link.cpp @@ -0,0 +1,89 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs". + +#include "force_link.hpp" + +#include +#include + +namespace rerun::blueprint::datatypes {} + +namespace rerun { + const std::shared_ptr& + Loggable::arrow_datatype() { + static const auto datatype = arrow::struct_({ + arrow::field("enabled", arrow::boolean(), false), + arrow::field("iterations", arrow::uint32(), false), + arrow::field("distance", arrow::float64(), false), + arrow::field("strength", arrow::float64(), false), + }); + return datatype; + } + + Result> Loggable::to_arrow( + const blueprint::datatypes::ForceLink* instances, size_t num_instances + ) { + // TODO(andreas): Allow configuring the memory pool. + arrow::MemoryPool* pool = arrow::default_memory_pool(); + auto datatype = arrow_datatype(); + + ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) + if (instances && num_instances > 0) { + RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( + static_cast(builder.get()), + instances, + num_instances + )); + } + std::shared_ptr array; + ARROW_RETURN_NOT_OK(builder->Finish(&array)); + return array; + } + + rerun::Error Loggable::fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceLink* elements, + size_t num_elements + ) { + if (builder == nullptr) { + return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); + } + if (elements == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Cannot serialize null pointer to arrow array." + ); + } + + { + auto field_builder = static_cast(builder->field_builder(0)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); + } + } + { + auto field_builder = static_cast(builder->field_builder(1)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].iterations)); + } + } + { + auto field_builder = static_cast(builder->field_builder(2)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].distance)); + } + } + { + auto field_builder = static_cast(builder->field_builder(3)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); + } + } + ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); + + return Error::ok(); + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_link.hpp new file mode 100644 index 000000000000..174dd49c9e3a --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_link.hpp @@ -0,0 +1,60 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs". + +#pragma once + +#include "../../result.hpp" + +#include +#include + +namespace arrow { + class Array; + class DataType; + class StructBuilder; +} // namespace arrow + +namespace rerun::blueprint::datatypes { + /// **Datatype**: Defines a force that acts similar to a spring between nodes. + struct ForceLink { + /// Whether the force is enabled. + bool enabled; + + /// The number of iterations. + uint32_t iterations; + + /// The distance between nodes at which the force is zero. + double distance; + + /// The strength of the force. + double strength; + + public: + ForceLink() = default; + }; +} // namespace rerun::blueprint::datatypes + +namespace rerun { + template + struct Loggable; + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceLink"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype(); + + /// Serializes an array of `rerun::blueprint:: datatypes::ForceLink` into an arrow array. + static Result> to_arrow( + const blueprint::datatypes::ForceLink* instances, size_t num_instances + ); + + /// Fills an arrow array builder with an array of this type. + static rerun::Error fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceLink* elements, + size_t num_elements + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.cpp new file mode 100644 index 000000000000..2e05cff59a49 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.cpp @@ -0,0 +1,75 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs". + +#include "force_many_body.hpp" + +#include +#include + +namespace rerun::blueprint::datatypes {} + +namespace rerun { + const std::shared_ptr& + Loggable::arrow_datatype() { + static const auto datatype = arrow::struct_({ + arrow::field("enabled", arrow::boolean(), false), + arrow::field("strength", arrow::float64(), false), + }); + return datatype; + } + + Result> Loggable::to_arrow( + const blueprint::datatypes::ForceManyBody* instances, size_t num_instances + ) { + // TODO(andreas): Allow configuring the memory pool. + arrow::MemoryPool* pool = arrow::default_memory_pool(); + auto datatype = arrow_datatype(); + + ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) + if (instances && num_instances > 0) { + RR_RETURN_NOT_OK( + Loggable::fill_arrow_array_builder( + static_cast(builder.get()), + instances, + num_instances + ) + ); + } + std::shared_ptr array; + ARROW_RETURN_NOT_OK(builder->Finish(&array)); + return array; + } + + rerun::Error Loggable::fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceManyBody* elements, + size_t num_elements + ) { + if (builder == nullptr) { + return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); + } + if (elements == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Cannot serialize null pointer to arrow array." + ); + } + + { + auto field_builder = static_cast(builder->field_builder(0)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); + } + } + { + auto field_builder = static_cast(builder->field_builder(1)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); + } + } + ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); + + return Error::ok(); + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.hpp new file mode 100644 index 000000000000..02ac2e02bfd3 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.hpp @@ -0,0 +1,56 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs". + +#pragma once + +#include "../../result.hpp" + +#include +#include + +namespace arrow { + class Array; + class DataType; + class StructBuilder; +} // namespace arrow + +namespace rerun::blueprint::datatypes { + /// **Datatype**: Defines a force that is similar to an electric charge between nodes. + /// + /// Positive strengths will push nodes apart, while negative strengths will pull nodes together. + struct ForceManyBody { + /// Whether the force is enabled. + bool enabled; + + /// The strength of the force. + double strength; + + public: + ForceManyBody() = default; + }; +} // namespace rerun::blueprint::datatypes + +namespace rerun { + template + struct Loggable; + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceManyBody"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype(); + + /// Serializes an array of `rerun::blueprint:: datatypes::ForceManyBody` into an arrow array. + static Result> to_arrow( + const blueprint::datatypes::ForceManyBody* instances, size_t num_instances + ); + + /// Fills an arrow array builder with an array of this type. + static rerun::Error fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceManyBody* elements, + size_t num_elements + ); + }; +} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index 6a9888f843df..ab262019f6f6 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -5,6 +5,10 @@ __init__.py linguist-generated=true background.py linguist-generated=true container_blueprint.py linguist-generated=true dataframe_query.py linguist-generated=true +force_center.py linguist-generated=true +force_collide_radius.py linguist-generated=true +force_link.py linguist-generated=true +force_many_body.py linguist-generated=true force_position_x.py linguist-generated=true force_position_y.py linguist-generated=true map_background.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py index 2603ef2d487e..39d05eddabfd 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -5,6 +5,10 @@ from .background import Background from .container_blueprint import ContainerBlueprint from .dataframe_query import DataframeQuery +from .force_center import ForceCenter +from .force_collide_radius import ForceCollideRadius +from .force_link import ForceLink +from .force_many_body import ForceManyBody from .force_position_x import ForcePositionX from .force_position_y import ForcePositionY from .map_background import MapBackground @@ -25,6 +29,10 @@ "Background", "ContainerBlueprint", "DataframeQuery", + "ForceCenter", + "ForceCollideRadius", + "ForceLink", + "ForceManyBody", "ForcePositionX", "ForcePositionY", "MapBackground", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py new file mode 100644 index 000000000000..bf70f24175ad --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py @@ -0,0 +1,50 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". + +# You can extend this class by creating a "ForceCenterExt" class in "force_center_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceCenter"] + + +@define(str=False, repr=False, init=False) +class ForceCenter(Archetype): + def __init__(self: Any, force: blueprint_datatypes.ForceCenterLike): + """Create a new instance of the ForceCenter archetype.""" + + # You can define your own __init__ function as a member of ForceCenterExt in force_center_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(force=force) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + force=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceCenter: + """Produce an empty ForceCenter, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + force: blueprint_components.ForceCenterBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ForceCenterBatch._required, # type: ignore[misc] + ) + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collide_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collide_radius.py new file mode 100644 index 000000000000..8fd581c1358b --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collide_radius.py @@ -0,0 +1,50 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs". + +# You can extend this class by creating a "ForceCollideRadiusExt" class in "force_collide_radius_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceCollideRadius"] + + +@define(str=False, repr=False, init=False) +class ForceCollideRadius(Archetype): + def __init__(self: Any, force: blueprint_datatypes.ForceCollideRadiusLike): + """Create a new instance of the ForceCollideRadius archetype.""" + + # You can define your own __init__ function as a member of ForceCollideRadiusExt in force_collide_radius_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(force=force) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + force=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceCollideRadius: + """Produce an empty ForceCollideRadius, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + force: blueprint_components.ForceCollideRadiusBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ForceCollideRadiusBatch._required, # type: ignore[misc] + ) + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py new file mode 100644 index 000000000000..7cdff37aba59 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py @@ -0,0 +1,50 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". + +# You can extend this class by creating a "ForceLinkExt" class in "force_link_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceLink"] + + +@define(str=False, repr=False, init=False) +class ForceLink(Archetype): + def __init__(self: Any, force: blueprint_datatypes.ForceLinkLike): + """Create a new instance of the ForceLink archetype.""" + + # You can define your own __init__ function as a member of ForceLinkExt in force_link_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(force=force) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + force=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceLink: + """Produce an empty ForceLink, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + force: blueprint_components.ForceLinkBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ForceLinkBatch._required, # type: ignore[misc] + ) + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py new file mode 100644 index 000000000000..0835f93b68ed --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py @@ -0,0 +1,50 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". + +# You can extend this class by creating a "ForceManyBodyExt" class in "force_many_body_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceManyBody"] + + +@define(str=False, repr=False, init=False) +class ForceManyBody(Archetype): + def __init__(self: Any, force: blueprint_datatypes.ForceManyBodyLike): + """Create a new instance of the ForceManyBody archetype.""" + + # You can define your own __init__ function as a member of ForceManyBodyExt in force_many_body_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(force=force) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + force=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceManyBody: + """Produce an empty ForceManyBody, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + force: blueprint_components.ForceManyBodyBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ForceManyBodyBatch._required, # type: ignore[misc] + ) + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes index 131a216d4781..d44318a04dd0 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -13,6 +13,10 @@ container_kind.py linguist-generated=true corner2d.py linguist-generated=true filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true +force_center.py linguist-generated=true +force_collide_radius.py linguist-generated=true +force_link.py linguist-generated=true +force_many_body.py linguist-generated=true force_position_x.py linguist-generated=true force_position_y.py linguist-generated=true grid_columns.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py index f2b20c813511..756d64b39214 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py @@ -13,6 +13,10 @@ from .corner2d import Corner2D, Corner2DArrayLike, Corner2DBatch, Corner2DLike from .filter_by_range import FilterByRange, FilterByRangeBatch from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullBatch +from .force_center import ForceCenter, ForceCenterBatch +from .force_collide_radius import ForceCollideRadius, ForceCollideRadiusBatch +from .force_link import ForceLink, ForceLinkBatch +from .force_many_body import ForceManyBody, ForceManyBodyBatch from .force_position_x import ForcePositionX, ForcePositionXBatch from .force_position_y import ForcePositionY, ForcePositionYBatch from .grid_columns import GridColumns, GridColumnsBatch @@ -67,6 +71,14 @@ "FilterByRangeBatch", "FilterIsNotNull", "FilterIsNotNullBatch", + "ForceCenter", + "ForceCenterBatch", + "ForceCollideRadius", + "ForceCollideRadiusBatch", + "ForceLink", + "ForceLinkBatch", + "ForceManyBody", + "ForceManyBodyBatch", "ForcePositionX", "ForcePositionXBatch", "ForcePositionY", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_center.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_center.py new file mode 100644 index 000000000000..f2c83c40c677 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_center.py @@ -0,0 +1,30 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs". + +# You can extend this class by creating a "ForceCenterExt" class in "force_center_ext.py". + +from __future__ import annotations + +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) +from ...blueprint import datatypes as blueprint_datatypes + +__all__ = ["ForceCenter", "ForceCenterBatch"] + + +class ForceCenter(blueprint_datatypes.ForceCenter, ComponentMixin): + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForceCenterExt in force_center_ext.py + + # Note: there are no fields here because ForceCenter delegates to datatypes.ForceCenter + pass + + +class ForceCenterBatch(blueprint_datatypes.ForceCenterBatch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForceCenter" + + +# This is patched in late to avoid circular dependencies. +ForceCenter._BATCH_TYPE = ForceCenterBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_collide_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_collide_radius.py new file mode 100644 index 000000000000..2b79b3ffe8ad --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_collide_radius.py @@ -0,0 +1,30 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs". + +# You can extend this class by creating a "ForceCollideRadiusExt" class in "force_collide_radius_ext.py". + +from __future__ import annotations + +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) +from ...blueprint import datatypes as blueprint_datatypes + +__all__ = ["ForceCollideRadius", "ForceCollideRadiusBatch"] + + +class ForceCollideRadius(blueprint_datatypes.ForceCollideRadius, ComponentMixin): + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForceCollideRadiusExt in force_collide_radius_ext.py + + # Note: there are no fields here because ForceCollideRadius delegates to datatypes.ForceCollideRadius + pass + + +class ForceCollideRadiusBatch(blueprint_datatypes.ForceCollideRadiusBatch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForceCollideRadius" + + +# This is patched in late to avoid circular dependencies. +ForceCollideRadius._BATCH_TYPE = ForceCollideRadiusBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_link.py new file mode 100644 index 000000000000..ce5acd58cc90 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_link.py @@ -0,0 +1,30 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs". + +# You can extend this class by creating a "ForceLinkExt" class in "force_link_ext.py". + +from __future__ import annotations + +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) +from ...blueprint import datatypes as blueprint_datatypes + +__all__ = ["ForceLink", "ForceLinkBatch"] + + +class ForceLink(blueprint_datatypes.ForceLink, ComponentMixin): + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForceLinkExt in force_link_ext.py + + # Note: there are no fields here because ForceLink delegates to datatypes.ForceLink + pass + + +class ForceLinkBatch(blueprint_datatypes.ForceLinkBatch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForceLink" + + +# This is patched in late to avoid circular dependencies. +ForceLink._BATCH_TYPE = ForceLinkBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_many_body.py new file mode 100644 index 000000000000..0fe2779117a3 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_many_body.py @@ -0,0 +1,30 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs". + +# You can extend this class by creating a "ForceManyBodyExt" class in "force_many_body_ext.py". + +from __future__ import annotations + +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) +from ...blueprint import datatypes as blueprint_datatypes + +__all__ = ["ForceManyBody", "ForceManyBodyBatch"] + + +class ForceManyBody(blueprint_datatypes.ForceManyBody, ComponentMixin): + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForceManyBodyExt in force_many_body_ext.py + + # Note: there are no fields here because ForceManyBody delegates to datatypes.ForceManyBody + pass + + +class ForceManyBodyBatch(blueprint_datatypes.ForceManyBodyBatch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForceManyBody" + + +# This is patched in late to avoid circular dependencies. +ForceManyBody._BATCH_TYPE = ForceManyBodyBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes index 4c62fdd6bd89..3de5f76ec603 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes @@ -5,6 +5,10 @@ __init__.py linguist-generated=true component_column_selector.py linguist-generated=true filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true +force_center.py linguist-generated=true +force_collide_radius.py linguist-generated=true +force_link.py linguist-generated=true +force_many_body.py linguist-generated=true force_position_x.py linguist-generated=true force_position_y.py linguist-generated=true selected_columns.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py index 3b6cc940266c..2c1ad49832a5 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py @@ -10,6 +10,15 @@ ) from .filter_by_range import FilterByRange, FilterByRangeArrayLike, FilterByRangeBatch, FilterByRangeLike from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullArrayLike, FilterIsNotNullBatch, FilterIsNotNullLike +from .force_center import ForceCenter, ForceCenterArrayLike, ForceCenterBatch, ForceCenterLike +from .force_collide_radius import ( + ForceCollideRadius, + ForceCollideRadiusArrayLike, + ForceCollideRadiusBatch, + ForceCollideRadiusLike, +) +from .force_link import ForceLink, ForceLinkArrayLike, ForceLinkBatch, ForceLinkLike +from .force_many_body import ForceManyBody, ForceManyBodyArrayLike, ForceManyBodyBatch, ForceManyBodyLike from .force_position_x import ForcePositionX, ForcePositionXArrayLike, ForcePositionXBatch, ForcePositionXLike from .force_position_y import ForcePositionY, ForcePositionYArrayLike, ForcePositionYBatch, ForcePositionYLike from .selected_columns import SelectedColumns, SelectedColumnsArrayLike, SelectedColumnsBatch, SelectedColumnsLike @@ -34,6 +43,22 @@ "FilterIsNotNullArrayLike", "FilterIsNotNullBatch", "FilterIsNotNullLike", + "ForceCenter", + "ForceCenterArrayLike", + "ForceCenterBatch", + "ForceCenterLike", + "ForceCollideRadius", + "ForceCollideRadiusArrayLike", + "ForceCollideRadiusBatch", + "ForceCollideRadiusLike", + "ForceLink", + "ForceLinkArrayLike", + "ForceLinkBatch", + "ForceLinkLike", + "ForceManyBody", + "ForceManyBodyArrayLike", + "ForceManyBodyBatch", + "ForceManyBodyLike", "ForcePositionX", "ForcePositionXArrayLike", "ForcePositionXBatch", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_center.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_center.py new file mode 100644 index 000000000000..20119782dce4 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_center.py @@ -0,0 +1,94 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs". + +# You can extend this class by creating a "ForceCenterExt" class in "force_center_ext.py". + +from __future__ import annotations + +from typing import Any, Sequence, Union + +import numpy as np +import pyarrow as pa +from attrs import define, field + +from ..._baseclasses import ( + BaseBatch, +) + +__all__ = ["ForceCenter", "ForceCenterArrayLike", "ForceCenterBatch", "ForceCenterLike"] + + +@define(init=False) +class ForceCenter: + """**Datatype**: Defines a force that globally centers a graph by moving its center of mass towards a given position.""" + + def __init__(self: Any, enabled: bool, x: float, y: float, strength: float): + """ + Create a new instance of the ForceCenter datatype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + x: + The `x` position to pull nodes towards. + y: + The `y` position to pull nodes towards. + strength: + The strength of the force. + + """ + + # You can define your own __init__ function as a member of ForceCenterExt in force_center_ext.py + self.__attrs_init__(enabled=enabled, x=x, y=y, strength=strength) + + enabled: bool = field(converter=bool) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + x: float = field(converter=float) + # The `x` position to pull nodes towards. + # + # (Docstring intentionally commented out to hide this field from the docs) + + y: float = field(converter=float) + # The `y` position to pull nodes towards. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: float = field(converter=float) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + +ForceCenterLike = ForceCenter +ForceCenterArrayLike = Union[ + ForceCenter, + Sequence[ForceCenterLike], +] + + +class ForceCenterBatch(BaseBatch[ForceCenterArrayLike]): + _ARROW_DATATYPE = pa.struct([ + pa.field("enabled", pa.bool_(), nullable=False, metadata={}), + pa.field("x", pa.float64(), nullable=False, metadata={}), + pa.field("y", pa.float64(), nullable=False, metadata={}), + pa.field("strength", pa.float64(), nullable=False, metadata={}), + ]) + + @staticmethod + def _native_to_pa_array(data: ForceCenterArrayLike, data_type: pa.DataType) -> pa.Array: + if isinstance(data, ForceCenter): + data = [data] + + return pa.StructArray.from_arrays( + [ + pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), + pa.array(np.asarray([x.x for x in data], dtype=np.float64)), + pa.array(np.asarray([x.y for x in data], dtype=np.float64)), + pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), + ], + fields=list(data_type), + ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_collide_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_collide_radius.py new file mode 100644 index 000000000000..b1c08cd0fc9e --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_collide_radius.py @@ -0,0 +1,94 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs". + +# You can extend this class by creating a "ForceCollideRadiusExt" class in "force_collide_radius_ext.py". + +from __future__ import annotations + +from typing import Any, Sequence, Union + +import numpy as np +import pyarrow as pa +from attrs import define, field + +from ..._baseclasses import ( + BaseBatch, +) + +__all__ = ["ForceCollideRadius", "ForceCollideRadiusArrayLike", "ForceCollideRadiusBatch", "ForceCollideRadiusLike"] + + +@define(init=False) +class ForceCollideRadius: + """**Datatype**: Defines a force that resolves collisions between the radii of `GraphNodes`.""" + + def __init__(self: Any, enabled: bool, iterations: int, strength: float, padding: float): + """ + Create a new instance of the ForceCollideRadius datatype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + iterations: + The number of iterations to resolve collisions. + strength: + The strength of the force. + padding: + An additional padding to apply to each node radius. + + """ + + # You can define your own __init__ function as a member of ForceCollideRadiusExt in force_collide_radius_ext.py + self.__attrs_init__(enabled=enabled, iterations=iterations, strength=strength, padding=padding) + + enabled: bool = field(converter=bool) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + iterations: int = field(converter=int) + # The number of iterations to resolve collisions. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: float = field(converter=float) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + padding: float = field(converter=float) + # An additional padding to apply to each node radius. + # + # (Docstring intentionally commented out to hide this field from the docs) + + +ForceCollideRadiusLike = ForceCollideRadius +ForceCollideRadiusArrayLike = Union[ + ForceCollideRadius, + Sequence[ForceCollideRadiusLike], +] + + +class ForceCollideRadiusBatch(BaseBatch[ForceCollideRadiusArrayLike]): + _ARROW_DATATYPE = pa.struct([ + pa.field("enabled", pa.bool_(), nullable=False, metadata={}), + pa.field("iterations", pa.uint32(), nullable=False, metadata={}), + pa.field("strength", pa.float64(), nullable=False, metadata={}), + pa.field("padding", pa.float64(), nullable=False, metadata={}), + ]) + + @staticmethod + def _native_to_pa_array(data: ForceCollideRadiusArrayLike, data_type: pa.DataType) -> pa.Array: + if isinstance(data, ForceCollideRadius): + data = [data] + + return pa.StructArray.from_arrays( + [ + pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), + pa.array(np.asarray([x.iterations for x in data], dtype=np.uint32)), + pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), + pa.array(np.asarray([x.padding for x in data], dtype=np.float64)), + ], + fields=list(data_type), + ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_link.py new file mode 100644 index 000000000000..5ed1d31a1e11 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_link.py @@ -0,0 +1,94 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs". + +# You can extend this class by creating a "ForceLinkExt" class in "force_link_ext.py". + +from __future__ import annotations + +from typing import Any, Sequence, Union + +import numpy as np +import pyarrow as pa +from attrs import define, field + +from ..._baseclasses import ( + BaseBatch, +) + +__all__ = ["ForceLink", "ForceLinkArrayLike", "ForceLinkBatch", "ForceLinkLike"] + + +@define(init=False) +class ForceLink: + """**Datatype**: Defines a force that acts similar to a spring between nodes.""" + + def __init__(self: Any, enabled: bool, iterations: int, distance: float, strength: float): + """ + Create a new instance of the ForceLink datatype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + iterations: + The number of iterations. + distance: + The distance between nodes at which the force is zero. + strength: + The strength of the force. + + """ + + # You can define your own __init__ function as a member of ForceLinkExt in force_link_ext.py + self.__attrs_init__(enabled=enabled, iterations=iterations, distance=distance, strength=strength) + + enabled: bool = field(converter=bool) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + iterations: int = field(converter=int) + # The number of iterations. + # + # (Docstring intentionally commented out to hide this field from the docs) + + distance: float = field(converter=float) + # The distance between nodes at which the force is zero. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: float = field(converter=float) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + +ForceLinkLike = ForceLink +ForceLinkArrayLike = Union[ + ForceLink, + Sequence[ForceLinkLike], +] + + +class ForceLinkBatch(BaseBatch[ForceLinkArrayLike]): + _ARROW_DATATYPE = pa.struct([ + pa.field("enabled", pa.bool_(), nullable=False, metadata={}), + pa.field("iterations", pa.uint32(), nullable=False, metadata={}), + pa.field("distance", pa.float64(), nullable=False, metadata={}), + pa.field("strength", pa.float64(), nullable=False, metadata={}), + ]) + + @staticmethod + def _native_to_pa_array(data: ForceLinkArrayLike, data_type: pa.DataType) -> pa.Array: + if isinstance(data, ForceLink): + data = [data] + + return pa.StructArray.from_arrays( + [ + pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), + pa.array(np.asarray([x.iterations for x in data], dtype=np.uint32)), + pa.array(np.asarray([x.distance for x in data], dtype=np.float64)), + pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), + ], + fields=list(data_type), + ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_many_body.py new file mode 100644 index 000000000000..928919303928 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_many_body.py @@ -0,0 +1,80 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs". + +# You can extend this class by creating a "ForceManyBodyExt" class in "force_many_body_ext.py". + +from __future__ import annotations + +from typing import Any, Sequence, Union + +import numpy as np +import pyarrow as pa +from attrs import define, field + +from ..._baseclasses import ( + BaseBatch, +) + +__all__ = ["ForceManyBody", "ForceManyBodyArrayLike", "ForceManyBodyBatch", "ForceManyBodyLike"] + + +@define(init=False) +class ForceManyBody: + """ + **Datatype**: Defines a force that is similar to an electric charge between nodes. + + Positive strengths will push nodes apart, while negative strengths will pull nodes together. + """ + + def __init__(self: Any, enabled: bool, strength: float): + """ + Create a new instance of the ForceManyBody datatype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + strength: + The strength of the force. + + """ + + # You can define your own __init__ function as a member of ForceManyBodyExt in force_many_body_ext.py + self.__attrs_init__(enabled=enabled, strength=strength) + + enabled: bool = field(converter=bool) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: float = field(converter=float) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + +ForceManyBodyLike = ForceManyBody +ForceManyBodyArrayLike = Union[ + ForceManyBody, + Sequence[ForceManyBodyLike], +] + + +class ForceManyBodyBatch(BaseBatch[ForceManyBodyArrayLike]): + _ARROW_DATATYPE = pa.struct([ + pa.field("enabled", pa.bool_(), nullable=False, metadata={}), + pa.field("strength", pa.float64(), nullable=False, metadata={}), + ]) + + @staticmethod + def _native_to_pa_array(data: ForceManyBodyArrayLike, data_type: pa.DataType) -> pa.Array: + if isinstance(data, ForceManyBody): + data = [data] + + return pa.StructArray.from_arrays( + [ + pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), + pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), + ], + fields=list(data_type), + ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py index 67cae4e6b353..30ee0e625f41 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py @@ -72,6 +72,10 @@ def __init__( visual_bounds: blueprint_archetypes.VisualBounds2D | None = None, force_position_x: blueprint_archetypes.ForcePositionX | None = None, force_position_y: blueprint_archetypes.ForcePositionY | None = None, + force_center: blueprint_archetypes.ForcePositionX | None = None, + force_collide_radius: blueprint_archetypes.ForceCollideRadius | None = None, + force_many_body: blueprint_archetypes.ForceManyBody | None = None, + force_link: blueprint_archetypes.ForceLink | None = None, ) -> None: """ Construct a blueprint for a new GraphView view. @@ -110,6 +114,14 @@ def __init__( Adds a force that pull nodes towards an `x` position. force_position_y: Adds a force that pull nodes towards an `y` position. + force_center: + Adds a force that moves the center of mass of all nodes to a given position. + force_collide_radius: + Adds a force that resolves collisions between graph nodes. + force_many_body: + Adds a force that acts like an electric charge between nodes. + force_link: + Adds a force that acts like a spring between nodes. """ @@ -129,6 +141,26 @@ def __init__( force_position_y = blueprint_archetypes.ForcePositionY(force_position_y) properties["ForcePositionY"] = force_position_y + if force_center is not None: + if not isinstance(force_center, blueprint_archetypes.ForcePositionX): + force_center = blueprint_archetypes.ForcePositionX(force_center) + properties["ForcePositionX"] = force_center + + if force_collide_radius is not None: + if not isinstance(force_collide_radius, blueprint_archetypes.ForceCollideRadius): + force_collide_radius = blueprint_archetypes.ForceCollideRadius(force_collide_radius) + properties["ForceCollideRadius"] = force_collide_radius + + if force_many_body is not None: + if not isinstance(force_many_body, blueprint_archetypes.ForceManyBody): + force_many_body = blueprint_archetypes.ForceManyBody(force_many_body) + properties["ForceManyBody"] = force_many_body + + if force_link is not None: + if not isinstance(force_link, blueprint_archetypes.ForceLink): + force_link = blueprint_archetypes.ForceLink(force_link) + properties["ForceLink"] = force_link + super().__init__( class_identifier="Graph", origin=origin, From 71af44373694c7a04db5d7db27e96c935a43b707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 3 Dec 2024 18:39:20 +0100 Subject: [PATCH 06/44] Add `ForceLayoutSimulation` [skip ci] --- .../rerun/blueprint/archetypes.fbs | 1 + .../archetypes/force_layout_simulation.fbs | 8 + .../rerun/blueprint/components.fbs | 1 + .../components/force_layout_simulation.fbs | 8 + .../definitions/rerun/blueprint/datatypes.fbs | 1 + .../datatypes/force_layout_simulation.fbs | 22 + .../rerun/blueprint/views/graph.fbs | 15 +- .../src/blueprint/archetypes/.gitattributes | 1 + .../archetypes/force_layout_simulation.rs | 153 +++++++ .../re_types/src/blueprint/archetypes/mod.rs | 2 + .../src/blueprint/components/.gitattributes | 1 + .../components/force_layout_simulation.rs | 109 +++++ .../re_types/src/blueprint/components/mod.rs | 2 + .../src/blueprint/datatypes/.gitattributes | 1 + .../datatypes/force_layout_simulation.rs | 417 ++++++++++++++++++ .../re_types/src/blueprint/datatypes/mod.rs | 2 + .../src/blueprint/views/graph_view.rs | 5 + .../src/blueprint/validation_gen/mod.rs | 2 + crates/viewer/re_viewer/src/reflection/mod.rs | 21 + .../reference/types/views/graph_view.md | 2 + rerun_cpp/src/rerun/blueprint/archetypes.hpp | 1 + .../rerun/blueprint/archetypes/.gitattributes | 2 + .../archetypes/force_layout_simulation.cpp | 34 ++ .../archetypes/force_layout_simulation.hpp | 52 +++ rerun_cpp/src/rerun/blueprint/components.hpp | 1 + .../rerun/blueprint/components/.gitattributes | 1 + .../components/force_layout_simulation.hpp | 74 ++++ rerun_cpp/src/rerun/blueprint/datatypes.hpp | 1 + .../rerun/blueprint/datatypes/.gitattributes | 2 + .../datatypes/force_layout_simulation.cpp | 100 +++++ .../datatypes/force_layout_simulation.hpp | 63 +++ .../rerun/blueprint/archetypes/.gitattributes | 1 + .../rerun/blueprint/archetypes/__init__.py | 2 + .../archetypes/force_layout_simulation.py | 50 +++ .../rerun/blueprint/components/.gitattributes | 1 + .../rerun/blueprint/components/__init__.py | 3 + .../components/force_layout_simulation.py | 30 ++ .../rerun/blueprint/datatypes/.gitattributes | 1 + .../rerun/blueprint/datatypes/__init__.py | 10 + .../datatypes/force_layout_simulation.py | 116 +++++ .../rerun/blueprint/views/graph_view.py | 8 + 41 files changed, 1321 insertions(+), 6 deletions(-) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_layout_simulation.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_layout_simulation.rs create mode 100644 crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_layout_simulation.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.hpp create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_layout_simulation.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_layout_simulation.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_layout_simulation.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index 146c1f1ace39..58b4ac5b2b3c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -5,6 +5,7 @@ include "./archetypes/container_blueprint.fbs"; include "./archetypes/dataframe_query.fbs"; include "./archetypes/force_center.fbs"; include "./archetypes/force_collide_radius.fbs"; +include "./archetypes/force_layout_simulation.fbs"; include "./archetypes/force_link.fbs"; include "./archetypes/force_many_body.fbs"; include "./archetypes/force_position_x.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs new file mode 100644 index 000000000000..11ecc6e8ffbb --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.archetypes; + +struct ForceLayoutSimulation ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default" +) { + simulation: rerun.blueprint.components.ForceLayoutSimulation (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components.fbs b/crates/store/re_types/definitions/rerun/blueprint/components.fbs index 46b58b82a360..740eb89c97cc 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -13,6 +13,7 @@ include "./components/filter_by_range.fbs"; include "./components/filter_is_not_null.fbs"; include "./components/force_center.fbs"; include "./components/force_collide_radius.fbs"; +include "./components/force_layout_simulation.fbs"; include "./components/force_link.fbs"; include "./components/force_many_body.fbs"; include "./components/force_position_x.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs new file mode 100644 index 000000000000..7df1729e8868 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs @@ -0,0 +1,8 @@ +namespace rerun.blueprint.components; + +struct ForceLayoutSimulation ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Default, Clone, PartialEq, Eq" +) { + simulation: rerun.blueprint.datatypes.ForceLayoutSimulation (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs index a67c41d12553..a1281480d933 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs @@ -5,6 +5,7 @@ include "./datatypes/filter_by_range.fbs"; include "./datatypes/filter_is_not_null.fbs"; include "./datatypes/force_center.fbs"; include "./datatypes/force_collide_radius.fbs"; +include "./datatypes/force_layout_simulation.fbs"; include "./datatypes/force_link.fbs"; include "./datatypes/force_many_body.fbs"; include "./datatypes/force_position_x.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs new file mode 100644 index 000000000000..2988d93305d0 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs @@ -0,0 +1,22 @@ +namespace rerun.blueprint.datatypes; + +/// The parameters for a force layout simulation. +struct ForceLayoutSimulation ( + "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rerun.scope": "blueprint" +) { + /// Similar to the the temperature in a simulated annealing algorithm. + alpha: double (order: 100); + + /// If `alpha` drops below this value, the simulation stops. + alpha_min: double (order: 200); + + /// The rate at which `alpha` decreases after each iteration. + alpha_decay: double (order: 300); + + /// The target value for `alpha`, must be in the range `[0, 1]`. + alpha_target: double (order: 400); + + /// Acts as a damping factor for the velocity of nodes. + velocity_decay: double (order: 500); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index 59cf273953f3..04bc927f8a16 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -12,21 +12,24 @@ table GraphView ( /// Somethings outside of these bounds may also be visible due to letterboxing. visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 1000); + /// The parameters for the force layout simulation. + force_layout_simulation: rerun.blueprint.archetypes.ForceLayoutSimulation (order: 2000); + /// Adds a force that pull nodes towards an `x` position. - force_position_x: rerun.blueprint.archetypes.ForcePositionX (order: 2000); + force_position_x: rerun.blueprint.archetypes.ForcePositionX (order: 3000); /// Adds a force that pull nodes towards an `y` position. - force_position_y: rerun.blueprint.archetypes.ForcePositionY (order: 2100); + force_position_y: rerun.blueprint.archetypes.ForcePositionY (order: 3100); /// Adds a force that moves the center of mass of all nodes to a given position. - force_center: rerun.blueprint.archetypes.ForcePositionX (order: 3000); + force_center: rerun.blueprint.archetypes.ForcePositionX (order: 4000); /// Adds a force that resolves collisions between graph nodes. - force_collide_radius: rerun.blueprint.archetypes.ForceCollideRadius (order: 4000); + force_collide_radius: rerun.blueprint.archetypes.ForceCollideRadius (order: 5000); /// Adds a force that acts like an electric charge between nodes. - force_many_body: rerun.blueprint.archetypes.ForceManyBody (order: 5000); + force_many_body: rerun.blueprint.archetypes.ForceManyBody (order: 6000); /// Adds a force that acts like a spring between nodes. - force_link: rerun.blueprint.archetypes.ForceLink (order: 6000); + force_link: rerun.blueprint.archetypes.ForceLink (order: 7000); } diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index dadae0d258d7..ab70fdb1cbe8 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -5,6 +5,7 @@ background.rs linguist-generated=true dataframe_query.rs linguist-generated=true force_center.rs linguist-generated=true force_collide_radius.rs linguist-generated=true +force_layout_simulation.rs linguist-generated=true force_link.rs linguist-generated=true force_many_body.rs linguist-generated=true force_position_x.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/archetypes/force_layout_simulation.rs b/crates/store/re_types/src/blueprint/archetypes/force_layout_simulation.rs new file mode 100644 index 000000000000..57f3dbf2f057 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_layout_simulation.rs @@ -0,0 +1,153 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default)] +pub struct ForceLayoutSimulation { + pub simulation: crate::blueprint::components::ForceLayoutSimulation, +} + +impl ::re_types_core::SizeBytes for ForceLayoutSimulation { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.simulation.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| { + ["rerun.blueprint.components.ForceLayoutSimulationIndicator".into()] + }); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| { + ["rerun.blueprint.components.ForceLayoutSimulationIndicator".into()] + }); + +impl ForceLayoutSimulation { + /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 1usize; +} + +/// Indicator component for the [`ForceLayoutSimulation`] [`::re_types_core::Archetype`] +pub type ForceLayoutSimulationIndicator = + ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceLayoutSimulation { + type Indicator = ForceLayoutSimulationIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceLayoutSimulation".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force layout simulation" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceLayoutSimulationIndicator = ForceLayoutSimulationIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let simulation = { + let array = arrays_by_name + .get("rerun.blueprint.components.ForceLayoutSimulation") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceLayoutSimulation#simulation")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceLayoutSimulation#simulation")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceLayoutSimulation#simulation")? + }; + Ok(Self { simulation }) + } +} + +impl ::re_types_core::AsComponents for ForceLayoutSimulation { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + Some((&self.simulation as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceLayoutSimulation {} + +impl ForceLayoutSimulation { + /// Create a new `ForceLayoutSimulation`. + #[inline] + pub fn new(simulation: impl Into) -> Self { + Self { + simulation: simulation.into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index e940c3734798..89fc5978ec8d 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -4,6 +4,7 @@ mod background; mod dataframe_query; mod force_center; mod force_collide_radius; +mod force_layout_simulation; mod force_link; mod force_many_body; mod force_position_x; @@ -25,6 +26,7 @@ pub use self::background::Background; pub use self::dataframe_query::DataframeQuery; pub use self::force_center::ForceCenter; pub use self::force_collide_radius::ForceCollideRadius; +pub use self::force_layout_simulation::ForceLayoutSimulation; pub use self::force_link::ForceLink; pub use self::force_many_body::ForceManyBody; pub use self::force_position_x::ForcePositionX; diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index 6ee24a97b4ec..198259929ef6 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -11,6 +11,7 @@ filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true force_center.rs linguist-generated=true force_collide_radius.rs linguist-generated=true +force_layout_simulation.rs linguist-generated=true force_link.rs linguist-generated=true force_many_body.rs linguist-generated=true force_position_x.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs b/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs new file mode 100644 index 000000000000..967c8ab4c1be --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs @@ -0,0 +1,109 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceLayoutSimulation(pub crate::blueprint::datatypes::ForceLayoutSimulation); + +impl ::re_types_core::SizeBytes for ForceLayoutSimulation { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From + for ForceLayoutSimulation +{ + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow + for ForceLayoutSimulation +{ + #[inline] + fn borrow(&self) -> &crate::blueprint::datatypes::ForceLayoutSimulation { + &self.0 + } +} + +impl std::ops::Deref for ForceLayoutSimulation { + type Target = crate::blueprint::datatypes::ForceLayoutSimulation; + + #[inline] + fn deref(&self) -> &crate::blueprint::datatypes::ForceLayoutSimulation { + &self.0 + } +} + +impl std::ops::DerefMut for ForceLayoutSimulation { + #[inline] + fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceLayoutSimulation { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForceLayoutSimulation); + +impl ::re_types_core::Loggable for ForceLayoutSimulation { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::blueprint::datatypes::ForceLayoutSimulation::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::blueprint::datatypes::ForceLayoutSimulation::to_arrow_opt(data.into_iter().map( + |datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + }, + )) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::blueprint::datatypes::ForceLayoutSimulation::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl ::re_types_core::Component for ForceLayoutSimulation { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForceLayoutSimulation".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index 395c130b273f..830be804e6c8 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -14,6 +14,7 @@ mod filter_is_not_null; mod filter_is_not_null_ext; mod force_center; mod force_collide_radius; +mod force_layout_simulation; mod force_link; mod force_many_body; mod force_position_x; @@ -56,6 +57,7 @@ pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; pub use self::force_center::ForceCenter; pub use self::force_collide_radius::ForceCollideRadius; +pub use self::force_layout_simulation::ForceLayoutSimulation; pub use self::force_link::ForceLink; pub use self::force_many_body::ForceManyBody; pub use self::force_position_x::ForcePositionX; diff --git a/crates/store/re_types/src/blueprint/datatypes/.gitattributes b/crates/store/re_types/src/blueprint/datatypes/.gitattributes index e58a2258e81e..bb597be8258e 100644 --- a/crates/store/re_types/src/blueprint/datatypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/datatypes/.gitattributes @@ -6,6 +6,7 @@ filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true force_center.rs linguist-generated=true force_collide_radius.rs linguist-generated=true +force_layout_simulation.rs linguist-generated=true force_link.rs linguist-generated=true force_many_body.rs linguist-generated=true force_position_x.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs b/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs new file mode 100644 index 000000000000..14e8826c32cf --- /dev/null +++ b/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs @@ -0,0 +1,417 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Datatype**: The parameters for a force layout simulation. +#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +pub struct ForceLayoutSimulation { + /// Similar to the the temperature in a simulated annealing algorithm. + pub alpha: f64, + + /// If `alpha` drops below this value, the simulation stops. + pub alpha_min: f64, + + /// The rate at which `alpha` decreases after each iteration. + pub alpha_decay: f64, + + /// The target value for `alpha`, must be in the range `[0, 1]`. + pub alpha_target: f64, + + /// Acts as a damping factor for the velocity of nodes. + pub velocity_decay: f64, +} + +impl ::re_types_core::SizeBytes for ForceLayoutSimulation { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.alpha.heap_size_bytes() + + self.alpha_min.heap_size_bytes() + + self.alpha_decay.heap_size_bytes() + + self.alpha_target.heap_size_bytes() + + self.velocity_decay.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() + } +} + +::re_types_core::macros::impl_into_cow!(ForceLayoutSimulation); + +impl ::re_types_core::Loggable for ForceLayoutSimulation { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + #![allow(clippy::wildcard_imports)] + use arrow::datatypes::*; + DataType::Struct(Fields::from(vec![ + Field::new("alpha", DataType::Float64, false), + Field::new("alpha_min", DataType::Float64, false), + Field::new("alpha_decay", DataType::Float64, false), + Field::new("alpha_target", DataType::Float64, false), + Field::new("velocity_decay", DataType::Float64, false), + ])) + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + #![allow(clippy::wildcard_imports)] + #![allow(clippy::manual_is_variant_and)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::{array::*, buffer::*, datatypes::*}; + + #[allow(unused)] + fn as_array_ref(t: T) -> ArrayRef { + std::sync::Arc::new(t) as ArrayRef + } + Ok({ + let fields = Fields::from(vec![ + Field::new("alpha", DataType::Float64, false), + Field::new("alpha_min", DataType::Float64, false), + Field::new("alpha_decay", DataType::Float64, false), + Field::new("alpha_target", DataType::Float64, false), + Field::new("velocity_decay", DataType::Float64, false), + ]); + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(StructArray::new( + fields, + vec![ + { + let (somes, alpha): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.alpha.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let alpha_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + alpha + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + alpha_validity, + )) + }, + { + let (somes, alpha_min): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.alpha_min.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let alpha_min_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + alpha_min + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + alpha_min_validity, + )) + }, + { + let (somes, alpha_decay): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.alpha_decay.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let alpha_decay_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + alpha_decay + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + alpha_decay_validity, + )) + }, + { + let (somes, alpha_target): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| datum.alpha_target.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let alpha_target_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + alpha_target + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + alpha_target_validity, + )) + }, + { + let (somes, velocity_decay): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = + datum.as_ref().map(|datum| datum.velocity_decay.clone()); + (datum.is_some(), datum) + }) + .unzip(); + let velocity_decay_validity: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + as_array_ref(PrimitiveArray::::new( + ScalarBuffer::from( + velocity_decay + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect::>(), + ), + velocity_decay_validity, + )) + }, + ], + validity, + )) + }) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + #![allow(clippy::wildcard_imports)] + use ::re_types_core::{Loggable as _, ResultExt as _}; + use arrow::datatypes::*; + use arrow2::{array::*, buffer::*}; + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = Self::arrow_datatype(); + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let (arrow_data_fields, arrow_data_arrays) = + (arrow_data.fields(), arrow_data.values()); + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(arrow_data_arrays) + .collect(); + let alpha = { + if !arrays_by_name.contains_key("alpha") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "alpha", + )) + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); + } + let arrow_data = &**arrays_by_name["alpha"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation#alpha")? + .into_iter() + .map(|opt| opt.copied()) + }; + let alpha_min = { + if !arrays_by_name.contains_key("alpha_min") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "alpha_min", + )) + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); + } + let arrow_data = &**arrays_by_name["alpha_min"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_min")? + .into_iter() + .map(|opt| opt.copied()) + }; + let alpha_decay = { + if !arrays_by_name.contains_key("alpha_decay") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "alpha_decay", + )) + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); + } + let arrow_data = &**arrays_by_name["alpha_decay"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context( + "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_decay", + )? + .into_iter() + .map(|opt| opt.copied()) + }; + let alpha_target = { + if !arrays_by_name.contains_key("alpha_target") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "alpha_target", + )) + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); + } + let arrow_data = &**arrays_by_name["alpha_target"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context( + "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_target", + )? + .into_iter() + .map(|opt| opt.copied()) + }; + let velocity_decay = { + if !arrays_by_name.contains_key("velocity_decay") { + return Err(DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "velocity_decay", + )) + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); + } + let arrow_data = &**arrays_by_name["velocity_decay"]; + arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + let expected = DataType::Float64; + let actual = arrow_data.data_type().clone(); + DeserializationError::datatype_mismatch(expected, actual) + }) + .with_context( + "rerun.blueprint.datatypes.ForceLayoutSimulation#velocity_decay", + )? + .into_iter() + .map(|opt| opt.copied()) + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + ::itertools::izip!( + alpha, alpha_min, alpha_decay, alpha_target, velocity_decay + ), + arrow_data.validity(), + ) + .map(|opt| { + opt + .map(| + ( + alpha, + alpha_min, + alpha_decay, + alpha_target, + velocity_decay, + )| + Ok(Self { + alpha: alpha + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha", + )?, + alpha_min: alpha_min + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_min", + )?, + alpha_decay: alpha_decay + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_decay", + )?, + alpha_target: alpha_target + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_target", + )?, + velocity_decay: velocity_decay + .ok_or_else(DeserializationError::missing_data) + .with_context( + "rerun.blueprint.datatypes.ForceLayoutSimulation#velocity_decay", + )?, + })) + .transpose() + }) + .collect::>>() + .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation")? + } + }) + } +} diff --git a/crates/store/re_types/src/blueprint/datatypes/mod.rs b/crates/store/re_types/src/blueprint/datatypes/mod.rs index a085ea4fafd1..3ed7da3bcf52 100644 --- a/crates/store/re_types/src/blueprint/datatypes/mod.rs +++ b/crates/store/re_types/src/blueprint/datatypes/mod.rs @@ -6,6 +6,7 @@ mod filter_by_range; mod filter_is_not_null; mod force_center; mod force_collide_radius; +mod force_layout_simulation; mod force_link; mod force_many_body; mod force_position_x; @@ -18,6 +19,7 @@ pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; pub use self::force_center::ForceCenter; pub use self::force_collide_radius::ForceCollideRadius; +pub use self::force_layout_simulation::ForceLayoutSimulation; pub use self::force_link::ForceLink; pub use self::force_many_body::ForceManyBody; pub use self::force_position_x::ForcePositionX; diff --git a/crates/store/re_types/src/blueprint/views/graph_view.rs b/crates/store/re_types/src/blueprint/views/graph_view.rs index 449cf2cf9644..89957c94979a 100644 --- a/crates/store/re_types/src/blueprint/views/graph_view.rs +++ b/crates/store/re_types/src/blueprint/views/graph_view.rs @@ -26,6 +26,9 @@ pub struct GraphView { /// Somethings outside of these bounds may also be visible due to letterboxing. pub visual_bounds: crate::blueprint::archetypes::VisualBounds2D, + /// The parameters for the force layout simulation. + pub force_layout_simulation: crate::blueprint::archetypes::ForceLayoutSimulation, + /// Adds a force that pull nodes towards an `x` position. pub force_position_x: crate::blueprint::archetypes::ForcePositionX, @@ -49,6 +52,7 @@ impl ::re_types_core::SizeBytes for GraphView { #[inline] fn heap_size_bytes(&self) -> u64 { self.visual_bounds.heap_size_bytes() + + self.force_layout_simulation.heap_size_bytes() + self.force_position_x.heap_size_bytes() + self.force_position_y.heap_size_bytes() + self.force_center.heap_size_bytes() @@ -60,6 +64,7 @@ impl ::re_types_core::SizeBytes for GraphView { #[inline] fn is_pod() -> bool { ::is_pod() + && ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() diff --git a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs index 2c3c4dae7727..4f4d971380f8 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -11,6 +11,7 @@ pub use re_types::blueprint::components::FilterByRange; pub use re_types::blueprint::components::FilterIsNotNull; pub use re_types::blueprint::components::ForceCenter; pub use re_types::blueprint::components::ForceCollideRadius; +pub use re_types::blueprint::components::ForceLayoutSimulation; pub use re_types::blueprint::components::ForceLink; pub use re_types::blueprint::components::ForceManyBody; pub use re_types::blueprint::components::ForcePositionX; @@ -58,6 +59,7 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) + && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 671bf8d5404d..5bdcdfa3bcbd 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -140,6 +140,14 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "", + custom_placeholder: Some(ForceLayoutSimulation::default().to_arrow2()?), + datatype: ForceLayoutSimulation::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { @@ -2002,6 +2010,19 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceLayoutSimulation"), + ArchetypeReflection { + display_name: "Force layout simulation", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceLayoutSimulation".into(), + display_name : "Simulation", docstring_md : "", is_required : false, + }, + ], + }, + ), ( ArchetypeName::new("rerun.blueprint.archetypes.ForceLink"), ArchetypeReflection { diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 7cbf549e112a..b93865fb148d 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -11,6 +11,8 @@ A graph view to display time-variying, directed or undirected graph visualizatio Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. +### `force_layout_simulation` +The parameters for the force layout simulation. ### `force_position_x` Adds a force that pull nodes towards an `x` position. ### `force_position_y` diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index 44405ee4b0b0..45289449202f 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -7,6 +7,7 @@ #include "blueprint/archetypes/dataframe_query.hpp" #include "blueprint/archetypes/force_center.hpp" #include "blueprint/archetypes/force_collide_radius.hpp" +#include "blueprint/archetypes/force_layout_simulation.hpp" #include "blueprint/archetypes/force_link.hpp" #include "blueprint/archetypes/force_many_body.hpp" #include "blueprint/archetypes/force_position_x.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes index 723548d2fe93..6240a07012ac 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -11,6 +11,8 @@ force_center.cpp linguist-generated=true force_center.hpp linguist-generated=true force_collide_radius.cpp linguist-generated=true force_collide_radius.hpp linguist-generated=true +force_layout_simulation.cpp linguist-generated=true +force_layout_simulation.hpp linguist-generated=true force_link.cpp linguist-generated=true force_link.hpp linguist-generated=true force_many_body.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.cpp new file mode 100644 index 000000000000..8d5a566b40ef --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.cpp @@ -0,0 +1,34 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs". + +#include "force_layout_simulation.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::ForceLayoutSimulation& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable(archetype.simulation); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceLayoutSimulation::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.hpp new file mode 100644 index 000000000000..d371c281cc69 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.hpp @@ -0,0 +1,52 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs". + +#pragma once + +#include "../../blueprint/components/force_layout_simulation.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + struct ForceLayoutSimulation { + rerun::blueprint::components::ForceLayoutSimulation simulation; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceLayoutSimulationIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceLayoutSimulation() = default; + ForceLayoutSimulation(ForceLayoutSimulation&& other) = default; + + explicit ForceLayoutSimulation( + rerun::blueprint::components::ForceLayoutSimulation _simulation + ) + : simulation(std::move(_simulation)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceLayoutSimulation& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index da4a321694bb..09168647a239 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -15,6 +15,7 @@ #include "blueprint/components/filter_is_not_null.hpp" #include "blueprint/components/force_center.hpp" #include "blueprint/components/force_collide_radius.hpp" +#include "blueprint/components/force_layout_simulation.hpp" #include "blueprint/components/force_link.hpp" #include "blueprint/components/force_many_body.hpp" #include "blueprint/components/force_position_x.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index 3850141d63e8..f1d66bcda829 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -17,6 +17,7 @@ filter_by_range.hpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true force_center.hpp linguist-generated=true force_collide_radius.hpp linguist-generated=true +force_layout_simulation.hpp linguist-generated=true force_link.hpp linguist-generated=true force_many_body.hpp linguist-generated=true force_position_x.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/force_layout_simulation.hpp b/rerun_cpp/src/rerun/blueprint/components/force_layout_simulation.hpp new file mode 100644 index 000000000000..508dcfcd606a --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_layout_simulation.hpp @@ -0,0 +1,74 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs". + +#pragma once + +#include "../../blueprint/datatypes/force_layout_simulation.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + struct ForceLayoutSimulation { + rerun::blueprint::datatypes::ForceLayoutSimulation simulation; + + public: + ForceLayoutSimulation() = default; + + ForceLayoutSimulation(rerun::blueprint::datatypes::ForceLayoutSimulation simulation_) + : simulation(simulation_) {} + + ForceLayoutSimulation& operator=( + rerun::blueprint::datatypes::ForceLayoutSimulation simulation_ + ) { + simulation = simulation_; + return *this; + } + + /// Cast to the underlying ForceLayoutSimulation datatype + operator rerun::blueprint::datatypes::ForceLayoutSimulation() const { + return simulation; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::blueprint::datatypes::ForceLayoutSimulation) == + sizeof(blueprint::components::ForceLayoutSimulation) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForceLayoutSimulation"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForceLayoutSimulation` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForceLayoutSimulation* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow( + nullptr, + 0 + ); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->simulation, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes.hpp b/rerun_cpp/src/rerun/blueprint/datatypes.hpp index b7fef16a4b0c..03500c81543f 100644 --- a/rerun_cpp/src/rerun/blueprint/datatypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/datatypes.hpp @@ -7,6 +7,7 @@ #include "blueprint/datatypes/filter_is_not_null.hpp" #include "blueprint/datatypes/force_center.hpp" #include "blueprint/datatypes/force_collide_radius.hpp" +#include "blueprint/datatypes/force_layout_simulation.hpp" #include "blueprint/datatypes/force_link.hpp" #include "blueprint/datatypes/force_many_body.hpp" #include "blueprint/datatypes/force_position_x.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes index ff2c298f422c..a1b5cb42ff4a 100644 --- a/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes @@ -11,6 +11,8 @@ force_center.cpp linguist-generated=true force_center.hpp linguist-generated=true force_collide_radius.cpp linguist-generated=true force_collide_radius.hpp linguist-generated=true +force_layout_simulation.cpp linguist-generated=true +force_layout_simulation.hpp linguist-generated=true force_link.cpp linguist-generated=true force_link.hpp linguist-generated=true force_many_body.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.cpp new file mode 100644 index 000000000000..6470a2649912 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.cpp @@ -0,0 +1,100 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs". + +#include "force_layout_simulation.hpp" + +#include +#include + +namespace rerun::blueprint::datatypes {} + +namespace rerun { + const std::shared_ptr& + Loggable::arrow_datatype() { + static const auto datatype = arrow::struct_({ + arrow::field("alpha", arrow::float64(), false), + arrow::field("alpha_min", arrow::float64(), false), + arrow::field("alpha_decay", arrow::float64(), false), + arrow::field("alpha_target", arrow::float64(), false), + arrow::field("velocity_decay", arrow::float64(), false), + }); + return datatype; + } + + Result> + Loggable::to_arrow( + const blueprint::datatypes::ForceLayoutSimulation* instances, size_t num_instances + ) { + // TODO(andreas): Allow configuring the memory pool. + arrow::MemoryPool* pool = arrow::default_memory_pool(); + auto datatype = arrow_datatype(); + + ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) + if (instances && num_instances > 0) { + RR_RETURN_NOT_OK( + Loggable::fill_arrow_array_builder( + static_cast(builder.get()), + instances, + num_instances + ) + ); + } + std::shared_ptr array; + ARROW_RETURN_NOT_OK(builder->Finish(&array)); + return array; + } + + rerun::Error Loggable::fill_arrow_array_builder( + arrow::StructBuilder* builder, const blueprint::datatypes::ForceLayoutSimulation* elements, + size_t num_elements + ) { + if (builder == nullptr) { + return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); + } + if (elements == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Cannot serialize null pointer to arrow array." + ); + } + + { + auto field_builder = static_cast(builder->field_builder(0)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].alpha)); + } + } + { + auto field_builder = static_cast(builder->field_builder(1)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].alpha_min)); + } + } + { + auto field_builder = static_cast(builder->field_builder(2)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].alpha_decay)); + } + } + { + auto field_builder = static_cast(builder->field_builder(3)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].alpha_target)); + } + } + { + auto field_builder = static_cast(builder->field_builder(4)); + ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); + for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { + ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].velocity_decay)); + } + } + ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); + + return Error::ok(); + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.hpp new file mode 100644 index 000000000000..a9d33c3edfe3 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.hpp @@ -0,0 +1,63 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs". + +#pragma once + +#include "../../result.hpp" + +#include +#include + +namespace arrow { + class Array; + class DataType; + class StructBuilder; +} // namespace arrow + +namespace rerun::blueprint::datatypes { + /// **Datatype**: The parameters for a force layout simulation. + struct ForceLayoutSimulation { + /// Similar to the the temperature in a simulated annealing algorithm. + double alpha; + + /// If `alpha` drops below this value, the simulation stops. + double alpha_min; + + /// The rate at which `alpha` decreases after each iteration. + double alpha_decay; + + /// The target value for `alpha`, must be in the range `[0, 1]`. + double alpha_target; + + /// Acts as a damping factor for the velocity of nodes. + double velocity_decay; + + public: + ForceLayoutSimulation() = default; + }; +} // namespace rerun::blueprint::datatypes + +namespace rerun { + template + struct Loggable; + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceLayoutSimulation"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype(); + + /// Serializes an array of `rerun::blueprint:: datatypes::ForceLayoutSimulation` into an arrow array. + static Result> to_arrow( + const blueprint::datatypes::ForceLayoutSimulation* instances, size_t num_instances + ); + + /// Fills an arrow array builder with an array of this type. + static rerun::Error fill_arrow_array_builder( + arrow::StructBuilder* builder, + const blueprint::datatypes::ForceLayoutSimulation* elements, size_t num_elements + ); + }; +} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index ab262019f6f6..d312b3a88290 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -7,6 +7,7 @@ container_blueprint.py linguist-generated=true dataframe_query.py linguist-generated=true force_center.py linguist-generated=true force_collide_radius.py linguist-generated=true +force_layout_simulation.py linguist-generated=true force_link.py linguist-generated=true force_many_body.py linguist-generated=true force_position_x.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py index 39d05eddabfd..7e16a13bd41e 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -7,6 +7,7 @@ from .dataframe_query import DataframeQuery from .force_center import ForceCenter from .force_collide_radius import ForceCollideRadius +from .force_layout_simulation import ForceLayoutSimulation from .force_link import ForceLink from .force_many_body import ForceManyBody from .force_position_x import ForcePositionX @@ -31,6 +32,7 @@ "DataframeQuery", "ForceCenter", "ForceCollideRadius", + "ForceLayoutSimulation", "ForceLink", "ForceManyBody", "ForcePositionX", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_layout_simulation.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_layout_simulation.py new file mode 100644 index 000000000000..2a95f771ac58 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_layout_simulation.py @@ -0,0 +1,50 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs". + +# You can extend this class by creating a "ForceLayoutSimulationExt" class in "force_layout_simulation_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceLayoutSimulation"] + + +@define(str=False, repr=False, init=False) +class ForceLayoutSimulation(Archetype): + def __init__(self: Any, simulation: blueprint_datatypes.ForceLayoutSimulationLike): + """Create a new instance of the ForceLayoutSimulation archetype.""" + + # You can define your own __init__ function as a member of ForceLayoutSimulationExt in force_layout_simulation_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(simulation=simulation) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + simulation=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceLayoutSimulation: + """Produce an empty ForceLayoutSimulation, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + simulation: blueprint_components.ForceLayoutSimulationBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ForceLayoutSimulationBatch._required, # type: ignore[misc] + ) + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes index d44318a04dd0..57a9747e9eca 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -15,6 +15,7 @@ filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true force_center.py linguist-generated=true force_collide_radius.py linguist-generated=true +force_layout_simulation.py linguist-generated=true force_link.py linguist-generated=true force_many_body.py linguist-generated=true force_position_x.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py index 756d64b39214..7a954cf6df2d 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py @@ -15,6 +15,7 @@ from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullBatch from .force_center import ForceCenter, ForceCenterBatch from .force_collide_radius import ForceCollideRadius, ForceCollideRadiusBatch +from .force_layout_simulation import ForceLayoutSimulation, ForceLayoutSimulationBatch from .force_link import ForceLink, ForceLinkBatch from .force_many_body import ForceManyBody, ForceManyBodyBatch from .force_position_x import ForcePositionX, ForcePositionXBatch @@ -75,6 +76,8 @@ "ForceCenterBatch", "ForceCollideRadius", "ForceCollideRadiusBatch", + "ForceLayoutSimulation", + "ForceLayoutSimulationBatch", "ForceLink", "ForceLinkBatch", "ForceManyBody", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_layout_simulation.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_layout_simulation.py new file mode 100644 index 000000000000..3b1aec36d313 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_layout_simulation.py @@ -0,0 +1,30 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs". + +# You can extend this class by creating a "ForceLayoutSimulationExt" class in "force_layout_simulation_ext.py". + +from __future__ import annotations + +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) +from ...blueprint import datatypes as blueprint_datatypes + +__all__ = ["ForceLayoutSimulation", "ForceLayoutSimulationBatch"] + + +class ForceLayoutSimulation(blueprint_datatypes.ForceLayoutSimulation, ComponentMixin): + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForceLayoutSimulationExt in force_layout_simulation_ext.py + + # Note: there are no fields here because ForceLayoutSimulation delegates to datatypes.ForceLayoutSimulation + pass + + +class ForceLayoutSimulationBatch(blueprint_datatypes.ForceLayoutSimulationBatch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForceLayoutSimulation" + + +# This is patched in late to avoid circular dependencies. +ForceLayoutSimulation._BATCH_TYPE = ForceLayoutSimulationBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes index 3de5f76ec603..5b6eed2a0d0b 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes @@ -7,6 +7,7 @@ filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true force_center.py linguist-generated=true force_collide_radius.py linguist-generated=true +force_layout_simulation.py linguist-generated=true force_link.py linguist-generated=true force_many_body.py linguist-generated=true force_position_x.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py index 2c1ad49832a5..00137053830d 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py @@ -17,6 +17,12 @@ ForceCollideRadiusBatch, ForceCollideRadiusLike, ) +from .force_layout_simulation import ( + ForceLayoutSimulation, + ForceLayoutSimulationArrayLike, + ForceLayoutSimulationBatch, + ForceLayoutSimulationLike, +) from .force_link import ForceLink, ForceLinkArrayLike, ForceLinkBatch, ForceLinkLike from .force_many_body import ForceManyBody, ForceManyBodyArrayLike, ForceManyBodyBatch, ForceManyBodyLike from .force_position_x import ForcePositionX, ForcePositionXArrayLike, ForcePositionXBatch, ForcePositionXLike @@ -51,6 +57,10 @@ "ForceCollideRadiusArrayLike", "ForceCollideRadiusBatch", "ForceCollideRadiusLike", + "ForceLayoutSimulation", + "ForceLayoutSimulationArrayLike", + "ForceLayoutSimulationBatch", + "ForceLayoutSimulationLike", "ForceLink", "ForceLinkArrayLike", "ForceLinkBatch", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_layout_simulation.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_layout_simulation.py new file mode 100644 index 000000000000..e9e877da0dc2 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_layout_simulation.py @@ -0,0 +1,116 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs". + +# You can extend this class by creating a "ForceLayoutSimulationExt" class in "force_layout_simulation_ext.py". + +from __future__ import annotations + +from typing import Any, Sequence, Union + +import numpy as np +import pyarrow as pa +from attrs import define, field + +from ..._baseclasses import ( + BaseBatch, +) + +__all__ = [ + "ForceLayoutSimulation", + "ForceLayoutSimulationArrayLike", + "ForceLayoutSimulationBatch", + "ForceLayoutSimulationLike", +] + + +@define(init=False) +class ForceLayoutSimulation: + """**Datatype**: The parameters for a force layout simulation.""" + + def __init__( + self: Any, alpha: float, alpha_min: float, alpha_decay: float, alpha_target: float, velocity_decay: float + ): + """ + Create a new instance of the ForceLayoutSimulation datatype. + + Parameters + ---------- + alpha: + Similar to the the temperature in a simulated annealing algorithm. + alpha_min: + If `alpha` drops below this value, the simulation stops. + alpha_decay: + The rate at which `alpha` decreases after each iteration. + alpha_target: + The target value for `alpha`, must be in the range `[0, 1]`. + velocity_decay: + Acts as a damping factor for the velocity of nodes. + + """ + + # You can define your own __init__ function as a member of ForceLayoutSimulationExt in force_layout_simulation_ext.py + self.__attrs_init__( + alpha=alpha, + alpha_min=alpha_min, + alpha_decay=alpha_decay, + alpha_target=alpha_target, + velocity_decay=velocity_decay, + ) + + alpha: float = field(converter=float) + # Similar to the the temperature in a simulated annealing algorithm. + # + # (Docstring intentionally commented out to hide this field from the docs) + + alpha_min: float = field(converter=float) + # If `alpha` drops below this value, the simulation stops. + # + # (Docstring intentionally commented out to hide this field from the docs) + + alpha_decay: float = field(converter=float) + # The rate at which `alpha` decreases after each iteration. + # + # (Docstring intentionally commented out to hide this field from the docs) + + alpha_target: float = field(converter=float) + # The target value for `alpha`, must be in the range `[0, 1]`. + # + # (Docstring intentionally commented out to hide this field from the docs) + + velocity_decay: float = field(converter=float) + # Acts as a damping factor for the velocity of nodes. + # + # (Docstring intentionally commented out to hide this field from the docs) + + +ForceLayoutSimulationLike = ForceLayoutSimulation +ForceLayoutSimulationArrayLike = Union[ + ForceLayoutSimulation, + Sequence[ForceLayoutSimulationLike], +] + + +class ForceLayoutSimulationBatch(BaseBatch[ForceLayoutSimulationArrayLike]): + _ARROW_DATATYPE = pa.struct([ + pa.field("alpha", pa.float64(), nullable=False, metadata={}), + pa.field("alpha_min", pa.float64(), nullable=False, metadata={}), + pa.field("alpha_decay", pa.float64(), nullable=False, metadata={}), + pa.field("alpha_target", pa.float64(), nullable=False, metadata={}), + pa.field("velocity_decay", pa.float64(), nullable=False, metadata={}), + ]) + + @staticmethod + def _native_to_pa_array(data: ForceLayoutSimulationArrayLike, data_type: pa.DataType) -> pa.Array: + if isinstance(data, ForceLayoutSimulation): + data = [data] + + return pa.StructArray.from_arrays( + [ + pa.array(np.asarray([x.alpha for x in data], dtype=np.float64)), + pa.array(np.asarray([x.alpha_min for x in data], dtype=np.float64)), + pa.array(np.asarray([x.alpha_decay for x in data], dtype=np.float64)), + pa.array(np.asarray([x.alpha_target for x in data], dtype=np.float64)), + pa.array(np.asarray([x.velocity_decay for x in data], dtype=np.float64)), + ], + fields=list(data_type), + ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py index 30ee0e625f41..0a2a3fb0a938 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py @@ -70,6 +70,7 @@ def __init__( defaults: list[Union[AsComponents, ComponentBatchLike]] = [], overrides: dict[EntityPathLike, list[ComponentBatchLike]] = {}, visual_bounds: blueprint_archetypes.VisualBounds2D | None = None, + force_layout_simulation: blueprint_archetypes.ForceLayoutSimulation | None = None, force_position_x: blueprint_archetypes.ForcePositionX | None = None, force_position_y: blueprint_archetypes.ForcePositionY | None = None, force_center: blueprint_archetypes.ForcePositionX | None = None, @@ -110,6 +111,8 @@ def __init__( Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. + force_layout_simulation: + The parameters for the force layout simulation. force_position_x: Adds a force that pull nodes towards an `x` position. force_position_y: @@ -131,6 +134,11 @@ def __init__( visual_bounds = blueprint_archetypes.VisualBounds2D(visual_bounds) properties["VisualBounds2D"] = visual_bounds + if force_layout_simulation is not None: + if not isinstance(force_layout_simulation, blueprint_archetypes.ForceLayoutSimulation): + force_layout_simulation = blueprint_archetypes.ForceLayoutSimulation(force_layout_simulation) + properties["ForceLayoutSimulation"] = force_layout_simulation + if force_position_x is not None: if not isinstance(force_position_x, blueprint_archetypes.ForcePositionX): force_position_x = blueprint_archetypes.ForcePositionX(force_position_x) From 4bba07658035e1420eab90888efafe4d86a01302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 3 Dec 2024 20:00:49 +0100 Subject: [PATCH 07/44] Remove unnecessary `derives` [skip ci] --- .../definitions/rerun/blueprint/components/force_center.fbs | 2 +- .../rerun/blueprint/components/force_collide_radius.fbs | 2 +- .../rerun/blueprint/components/force_layout_simulation.fbs | 2 +- .../definitions/rerun/blueprint/components/force_link.fbs | 2 +- .../definitions/rerun/blueprint/components/force_many_body.fbs | 2 +- .../definitions/rerun/blueprint/components/force_position_x.fbs | 2 +- .../definitions/rerun/blueprint/components/force_position_y.fbs | 2 +- .../definitions/rerun/blueprint/datatypes/force_center.fbs | 2 +- .../rerun/blueprint/datatypes/force_collide_radius.fbs | 2 +- .../rerun/blueprint/datatypes/force_layout_simulation.fbs | 2 +- .../definitions/rerun/blueprint/datatypes/force_link.fbs | 2 +- .../definitions/rerun/blueprint/datatypes/force_many_body.fbs | 2 +- .../definitions/rerun/blueprint/datatypes/force_position_x.fbs | 2 +- .../definitions/rerun/blueprint/datatypes/force_position_y.fbs | 2 +- crates/store/re_types/src/blueprint/components/force_center.rs | 2 +- .../re_types/src/blueprint/components/force_collide_radius.rs | 2 +- .../src/blueprint/components/force_layout_simulation.rs | 2 +- crates/store/re_types/src/blueprint/components/force_link.rs | 2 +- .../store/re_types/src/blueprint/components/force_many_body.rs | 2 +- .../store/re_types/src/blueprint/components/force_position_x.rs | 2 +- .../store/re_types/src/blueprint/components/force_position_y.rs | 2 +- crates/store/re_types/src/blueprint/datatypes/force_center.rs | 2 +- .../re_types/src/blueprint/datatypes/force_collide_radius.rs | 2 +- .../re_types/src/blueprint/datatypes/force_layout_simulation.rs | 2 +- crates/store/re_types/src/blueprint/datatypes/force_link.rs | 2 +- .../store/re_types/src/blueprint/datatypes/force_many_body.rs | 2 +- .../store/re_types/src/blueprint/datatypes/force_position_x.rs | 2 +- .../store/re_types/src/blueprint/datatypes/force_position_y.rs | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs index e26db379c0e8..99aca1967e20 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForceCenter ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq" + "attr.rust.derive": "Default, PartialEq" ) { center: rerun.blueprint.datatypes.ForceCenter (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs index 60450490414b..0ffb135fe532 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForceCollideRadius ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq" + "attr.rust.derive": "Default, PartialEq" ) { center: rerun.blueprint.datatypes.ForceCollideRadius (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs index 7df1729e8868..fd4838648f81 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForceLayoutSimulation ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq" + "attr.rust.derive": "Default, PartialEq" ) { simulation: rerun.blueprint.datatypes.ForceLayoutSimulation (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs index 2adc86abccc2..6130d222330a 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForceLink ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq" + "attr.rust.derive": "Default, PartialEq" ) { center: rerun.blueprint.datatypes.ForceLink (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs index f05a4df41714..3ce3ae5cdc8c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForceManyBody ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq" + "attr.rust.derive": "Default, PartialEq" ) { center: rerun.blueprint.datatypes.ForceManyBody (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs index 5f114f746d9c..ad17cad98b67 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForcePositionX ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq" + "attr.rust.derive": "Default, PartialEq" ) { position_x: rerun.blueprint.datatypes.ForcePositionX (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs index f0eae5b69717..b907753415f6 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.components; struct ForcePositionY ( "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, Clone, PartialEq, Eq" + "attr.rust.derive": "Default, PartialEq" ) { position_y: rerun.blueprint.datatypes.ForcePositionY (order: 100); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs index 55f319cdc3fc..e290cd09b41e 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.datatypes; /// Defines a force that globally centers a graph by moving its center of mass towards a given position. struct ForceCenter ( - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, PartialEq", "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs index 412c27393f36..42ed6ba47ff3 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs @@ -4,7 +4,7 @@ namespace rerun.blueprint.datatypes; /// Defines a force that resolves collisions between the radii of `GraphNodes`. struct ForceCollideRadius ( - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, PartialEq", "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs index 2988d93305d0..abb8b5c89910 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.datatypes; /// The parameters for a force layout simulation. struct ForceLayoutSimulation ( - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, PartialEq", "attr.rerun.scope": "blueprint" ) { /// Similar to the the temperature in a simulated annealing algorithm. diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs index 92d60aec67fa..8c80b825b7c7 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.datatypes; /// Defines a force that acts similar to a spring between nodes. struct ForceLink ( - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, PartialEq", "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs index 8cd2711f615b..1f9ded832615 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs @@ -4,7 +4,7 @@ namespace rerun.blueprint.datatypes; /// /// Positive strengths will push nodes apart, while negative strengths will pull nodes together. struct ForceManyBody ( - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, PartialEq", "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs index 821d0ec6a0ef..f36c7dd18284 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.datatypes; /// Defines a force that pulls nodes towards an `x` position. struct ForcePositionX ( - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, PartialEq", "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs index 658de5f53703..3142d6d5fcaa 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.datatypes; /// Defines a force that pulls nodes towards an `y` position. struct ForcePositionY ( - "attr.rust.derive": "Default, Clone, PartialEq, Eq", + "attr.rust.derive": "Default, PartialEq", "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. diff --git a/crates/store/re_types/src/blueprint/components/force_center.rs b/crates/store/re_types/src/blueprint/components/force_center.rs index 055009881650..e7469fa97100 100644 --- a/crates/store/re_types/src/blueprint/components/force_center.rs +++ b/crates/store/re_types/src/blueprint/components/force_center.rs @@ -18,7 +18,7 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceCenter(pub crate::blueprint::datatypes::ForceCenter); impl ::re_types_core::SizeBytes for ForceCenter { diff --git a/crates/store/re_types/src/blueprint/components/force_collide_radius.rs b/crates/store/re_types/src/blueprint/components/force_collide_radius.rs index 66cfa77ee2cb..8190bbe8e065 100644 --- a/crates/store/re_types/src/blueprint/components/force_collide_radius.rs +++ b/crates/store/re_types/src/blueprint/components/force_collide_radius.rs @@ -18,7 +18,7 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceCollideRadius(pub crate::blueprint::datatypes::ForceCollideRadius); impl ::re_types_core::SizeBytes for ForceCollideRadius { diff --git a/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs b/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs index 967c8ab4c1be..186ba5272d43 100644 --- a/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs +++ b/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs @@ -18,7 +18,7 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceLayoutSimulation(pub crate::blueprint::datatypes::ForceLayoutSimulation); impl ::re_types_core::SizeBytes for ForceLayoutSimulation { diff --git a/crates/store/re_types/src/blueprint/components/force_link.rs b/crates/store/re_types/src/blueprint/components/force_link.rs index 3a71f305a607..a9f421799616 100644 --- a/crates/store/re_types/src/blueprint/components/force_link.rs +++ b/crates/store/re_types/src/blueprint/components/force_link.rs @@ -18,7 +18,7 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceLink(pub crate::blueprint::datatypes::ForceLink); impl ::re_types_core::SizeBytes for ForceLink { diff --git a/crates/store/re_types/src/blueprint/components/force_many_body.rs b/crates/store/re_types/src/blueprint/components/force_many_body.rs index d0aff07034c2..552ab624f9d0 100644 --- a/crates/store/re_types/src/blueprint/components/force_many_body.rs +++ b/crates/store/re_types/src/blueprint/components/force_many_body.rs @@ -18,7 +18,7 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceManyBody(pub crate::blueprint::datatypes::ForceManyBody); impl ::re_types_core::SizeBytes for ForceManyBody { diff --git a/crates/store/re_types/src/blueprint/components/force_position_x.rs b/crates/store/re_types/src/blueprint/components/force_position_x.rs index 200c6701046b..c4e67963aa45 100644 --- a/crates/store/re_types/src/blueprint/components/force_position_x.rs +++ b/crates/store/re_types/src/blueprint/components/force_position_x.rs @@ -18,7 +18,7 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForcePositionX(pub crate::blueprint::datatypes::ForcePositionX); impl ::re_types_core::SizeBytes for ForcePositionX { diff --git a/crates/store/re_types/src/blueprint/components/force_position_y.rs b/crates/store/re_types/src/blueprint/components/force_position_y.rs index eb7e7583450d..eccfe273fa94 100644 --- a/crates/store/re_types/src/blueprint/components/force_position_y.rs +++ b/crates/store/re_types/src/blueprint/components/force_position_y.rs @@ -18,7 +18,7 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForcePositionY(pub crate::blueprint::datatypes::ForcePositionY); impl ::re_types_core::SizeBytes for ForcePositionY { diff --git a/crates/store/re_types/src/blueprint/datatypes/force_center.rs b/crates/store/re_types/src/blueprint/datatypes/force_center.rs index 27f377e283a9..ef7dcf94d3fe 100644 --- a/crates/store/re_types/src/blueprint/datatypes/force_center.rs +++ b/crates/store/re_types/src/blueprint/datatypes/force_center.rs @@ -19,7 +19,7 @@ use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Datatype**: Defines a force that globally centers a graph by moving its center of mass towards a given position. -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceCenter { /// Whether the force is enabled. pub enabled: bool, diff --git a/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs b/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs index dec28047c1a6..9bdd214304e3 100644 --- a/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs +++ b/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs @@ -19,7 +19,7 @@ use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Datatype**: Defines a force that resolves collisions between the radii of `GraphNodes`. -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceCollideRadius { /// Whether the force is enabled. pub enabled: bool, diff --git a/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs b/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs index 14e8826c32cf..5a5ca60a5aa3 100644 --- a/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs +++ b/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs @@ -19,7 +19,7 @@ use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Datatype**: The parameters for a force layout simulation. -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceLayoutSimulation { /// Similar to the the temperature in a simulated annealing algorithm. pub alpha: f64, diff --git a/crates/store/re_types/src/blueprint/datatypes/force_link.rs b/crates/store/re_types/src/blueprint/datatypes/force_link.rs index b7ed2ee8d54c..3f54e7c51ad7 100644 --- a/crates/store/re_types/src/blueprint/datatypes/force_link.rs +++ b/crates/store/re_types/src/blueprint/datatypes/force_link.rs @@ -19,7 +19,7 @@ use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Datatype**: Defines a force that acts similar to a spring between nodes. -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceLink { /// Whether the force is enabled. pub enabled: bool, diff --git a/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs b/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs index a8378a55aa87..17203a291542 100644 --- a/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs +++ b/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs @@ -21,7 +21,7 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Datatype**: Defines a force that is similar to an electric charge between nodes. /// /// Positive strengths will push nodes apart, while negative strengths will pull nodes together. -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForceManyBody { /// Whether the force is enabled. pub enabled: bool, diff --git a/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs b/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs index 9e7e0b3120d1..02c28ba5c209 100644 --- a/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs +++ b/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs @@ -19,7 +19,7 @@ use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Datatype**: Defines a force that pulls nodes towards an `x` position. -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForcePositionX { /// Whether the force is enabled. pub enabled: bool, diff --git a/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs b/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs index fcdbb2e80afd..aee8e395407b 100644 --- a/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs +++ b/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs @@ -19,7 +19,7 @@ use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Datatype**: Defines a force that pulls nodes towards an `y` position. -#[derive(Clone, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct ForcePositionY { /// Whether the force is enabled. pub enabled: bool, From 891292a8bc5d3c3b897197af499b53a178b9aedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Wed, 4 Dec 2024 08:09:45 +0100 Subject: [PATCH 08/44] Experiment with `re_component` [skip ci] --- crates/viewer/re_component_ui/src/force.rs | 15 +++++++++++++++ crates/viewer/re_component_ui/src/lib.rs | 3 +++ .../viewer/re_space_view_graph/src/properties.rs | 10 ++++++++-- crates/viewer/re_space_view_graph/src/view.rs | 3 ++- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 crates/viewer/re_component_ui/src/force.rs diff --git a/crates/viewer/re_component_ui/src/force.rs b/crates/viewer/re_component_ui/src/force.rs new file mode 100644 index 000000000000..f20d1088d0ce --- /dev/null +++ b/crates/viewer/re_component_ui/src/force.rs @@ -0,0 +1,15 @@ +use re_types::blueprint::components::ForceLink; +use re_ui::UiExt as _; +use re_viewer_context::{MaybeMutRef, UiLayout, ViewerContext}; + +pub fn singleline_view_force_link( + _ctx: &ViewerContext<'_>, + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, ForceLink>, +) -> egui::Response { + UiLayout::List + .label(ui, format!("test",)) + .on_hover_ui(|ui| { + ui.markdown_ui("Toggle link force on/off"); + }) +} diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 9ee313c198b7..b527d6a758b5 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -7,6 +7,7 @@ mod color; mod datatype_uis; mod entity_path; mod fallback_ui; +mod force; mod geo_line_string; mod image_format; mod lat_lon; @@ -167,5 +168,7 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view(lat_lon::singleline_view_lat_lon); + registry.add_singleline_edit_or_view(force::singleline_view_force_link); + registry } diff --git a/crates/viewer/re_space_view_graph/src/properties.rs b/crates/viewer/re_space_view_graph/src/properties.rs index de6b0255f0ca..7b69b01950dd 100644 --- a/crates/viewer/re_space_view_graph/src/properties.rs +++ b/crates/viewer/re_space_view_graph/src/properties.rs @@ -1,4 +1,4 @@ -use re_types::blueprint::components::VisualBounds2D; +use re_types::blueprint::{components::ForceLink, components::VisualBounds2D}; use re_viewer_context::{SpaceViewStateExt as _, TypedComponentFallbackProvider}; use crate::{ui::GraphSpaceViewState, GraphSpaceView}; @@ -20,4 +20,10 @@ impl TypedComponentFallbackProvider for GraphSpaceView { } } -re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D]); +impl TypedComponentFallbackProvider for GraphSpaceView { + fn fallback_for(&self, _: &re_viewer_context::QueryContext<'_>) -> ForceLink { + ForceLink::default() + } +} + +re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D, ForceLink]); diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index 6539892a1447..adb7346b8130 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -4,7 +4,7 @@ use re_space_view::{ view_property_ui, }; use re_types::{ - blueprint::{self, archetypes::VisualBounds2D}, + blueprint::{self, archetypes::{ForceLink, VisualBounds2D}}, SpaceViewClassIdentifier, }; use re_ui::{ @@ -130,6 +130,7 @@ Display a graph of nodes and edges. }); view_property_ui::(ctx, ui, space_view_id, self, state); + view_property_ui::(ctx, ui, space_view_id, self, state); Ok(()) } From 89e0d376bc4c721009907ff57c336b11facb645e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 5 Dec 2024 09:14:00 +0100 Subject: [PATCH 09/44] Revert previous design --- .../rerun/blueprint/archetypes.fbs | 7 - .../blueprint/archetypes/force_center.fbs | 8 - .../archetypes/force_collide_radius.fbs | 8 - .../archetypes/force_layout_simulation.fbs | 8 - .../rerun/blueprint/archetypes/force_link.fbs | 8 - .../blueprint/archetypes/force_many_body.fbs | 8 - .../blueprint/archetypes/force_position_x.fbs | 8 - .../blueprint/archetypes/force_position_y.fbs | 8 - .../rerun/blueprint/components.fbs | 7 - .../blueprint/components/force_center.fbs | 8 - .../components/force_collide_radius.fbs | 8 - .../components/force_layout_simulation.fbs | 8 - .../rerun/blueprint/components/force_link.fbs | 8 - .../blueprint/components/force_many_body.fbs | 8 - .../blueprint/components/force_position_x.fbs | 8 - .../blueprint/components/force_position_y.fbs | 8 - .../definitions/rerun/blueprint/datatypes.fbs | 7 - .../blueprint/datatypes/force_center.fbs | 19 - .../datatypes/force_collide_radius.fbs | 21 - .../datatypes/force_layout_simulation.fbs | 22 - .../rerun/blueprint/datatypes/force_link.fbs | 19 - .../blueprint/datatypes/force_many_body.fbs | 15 - .../blueprint/datatypes/force_position_x.fbs | 16 - .../blueprint/datatypes/force_position_y.fbs | 16 - .../rerun/blueprint/views/graph.fbs | 21 - .../src/blueprint/archetypes/.gitattributes | 7 - .../src/blueprint/archetypes/force_center.rs | 148 ------- .../archetypes/force_collide_radius.rs | 152 ------- .../archetypes/force_layout_simulation.rs | 153 ------- .../src/blueprint/archetypes/force_link.rs | 148 ------- .../blueprint/archetypes/force_many_body.rs | 148 ------- .../blueprint/archetypes/force_position_x.rs | 148 ------- .../blueprint/archetypes/force_position_y.rs | 148 ------- .../re_types/src/blueprint/archetypes/mod.rs | 14 - .../src/blueprint/components/.gitattributes | 7 - .../src/blueprint/components/force_center.rs | 103 ----- .../components/force_collide_radius.rs | 105 ----- .../components/force_layout_simulation.rs | 109 ----- .../src/blueprint/components/force_link.rs | 103 ----- .../blueprint/components/force_many_body.rs | 103 ----- .../blueprint/components/force_position_x.rs | 103 ----- .../blueprint/components/force_position_y.rs | 103 ----- .../re_types/src/blueprint/components/mod.rs | 14 - .../src/blueprint/datatypes/.gitattributes | 7 - .../src/blueprint/datatypes/force_center.rs | 334 -------------- .../datatypes/force_collide_radius.rs | 346 --------------- .../datatypes/force_layout_simulation.rs | 417 ------------------ .../src/blueprint/datatypes/force_link.rs | 340 -------------- .../blueprint/datatypes/force_many_body.rs | 235 ---------- .../blueprint/datatypes/force_position_x.rs | 284 ------------ .../blueprint/datatypes/force_position_y.rs | 284 ------------ .../re_types/src/blueprint/datatypes/mod.rs | 14 - .../src/blueprint/views/graph_view.rs | 66 ++- crates/viewer/re_component_ui/src/force.rs | 15 - crates/viewer/re_component_ui/src/lib.rs | 3 - .../re_space_view_graph/src/properties.rs | 10 +- crates/viewer/re_space_view_graph/src/view.rs | 3 +- .../src/blueprint/validation_gen/mod.rs | 14 - crates/viewer/re_viewer/src/reflection/mod.rs | 141 ------ .../reference/types/views/graph_view.md | 14 - rerun_cpp/src/rerun/blueprint/archetypes.hpp | 7 - .../rerun/blueprint/archetypes/.gitattributes | 14 - .../blueprint/archetypes/force_center.cpp | 33 -- .../blueprint/archetypes/force_center.hpp | 50 --- .../archetypes/force_collide_radius.cpp | 34 -- .../archetypes/force_collide_radius.hpp | 50 --- .../archetypes/force_layout_simulation.cpp | 34 -- .../archetypes/force_layout_simulation.hpp | 52 --- .../rerun/blueprint/archetypes/force_link.cpp | 33 -- .../rerun/blueprint/archetypes/force_link.hpp | 50 --- .../blueprint/archetypes/force_many_body.cpp | 34 -- .../blueprint/archetypes/force_many_body.hpp | 50 --- .../blueprint/archetypes/force_position_x.cpp | 34 -- .../blueprint/archetypes/force_position_x.hpp | 50 --- .../blueprint/archetypes/force_position_y.cpp | 34 -- .../blueprint/archetypes/force_position_y.hpp | 50 --- rerun_cpp/src/rerun/blueprint/components.hpp | 7 - .../rerun/blueprint/components/.gitattributes | 7 - .../blueprint/components/force_center.hpp | 68 --- .../components/force_collide_radius.hpp | 72 --- .../components/force_layout_simulation.hpp | 74 ---- .../rerun/blueprint/components/force_link.hpp | 67 --- .../blueprint/components/force_many_body.hpp | 68 --- .../blueprint/components/force_position_x.hpp | 69 --- .../blueprint/components/force_position_y.hpp | 69 --- rerun_cpp/src/rerun/blueprint/datatypes.hpp | 7 - .../rerun/blueprint/datatypes/.gitattributes | 14 - .../blueprint/datatypes/force_center.cpp | 89 ---- .../blueprint/datatypes/force_center.hpp | 60 --- .../datatypes/force_collide_radius.cpp | 92 ---- .../datatypes/force_collide_radius.hpp | 60 --- .../datatypes/force_layout_simulation.cpp | 100 ----- .../datatypes/force_layout_simulation.hpp | 63 --- .../rerun/blueprint/datatypes/force_link.cpp | 89 ---- .../rerun/blueprint/datatypes/force_link.hpp | 60 --- .../blueprint/datatypes/force_many_body.cpp | 75 ---- .../blueprint/datatypes/force_many_body.hpp | 56 --- .../blueprint/datatypes/force_position_x.cpp | 83 ---- .../blueprint/datatypes/force_position_x.hpp | 57 --- .../blueprint/datatypes/force_position_y.cpp | 83 ---- .../blueprint/datatypes/force_position_y.hpp | 57 --- .../rerun/blueprint/archetypes/.gitattributes | 7 - .../rerun/blueprint/archetypes/__init__.py | 14 - .../blueprint/archetypes/force_center.py | 50 --- .../archetypes/force_collide_radius.py | 50 --- .../archetypes/force_layout_simulation.py | 50 --- .../rerun/blueprint/archetypes/force_link.py | 50 --- .../blueprint/archetypes/force_many_body.py | 50 --- .../blueprint/archetypes/force_position_x.py | 50 --- .../blueprint/archetypes/force_position_y.py | 50 --- .../rerun/blueprint/components/.gitattributes | 7 - .../rerun/blueprint/components/__init__.py | 21 - .../blueprint/components/force_center.py | 30 -- .../components/force_collide_radius.py | 30 -- .../components/force_layout_simulation.py | 30 -- .../rerun/blueprint/components/force_link.py | 30 -- .../blueprint/components/force_many_body.py | 30 -- .../blueprint/components/force_position_x.py | 30 -- .../blueprint/components/force_position_y.py | 30 -- .../rerun/blueprint/datatypes/.gitattributes | 7 - .../rerun/blueprint/datatypes/__init__.py | 45 -- .../rerun/blueprint/datatypes/force_center.py | 94 ---- .../datatypes/force_collide_radius.py | 94 ---- .../datatypes/force_layout_simulation.py | 116 ----- .../rerun/blueprint/datatypes/force_link.py | 94 ---- .../blueprint/datatypes/force_many_body.py | 80 ---- .../blueprint/datatypes/force_position_x.py | 85 ---- .../blueprint/datatypes/force_position_y.py | 85 ---- .../rerun/blueprint/views/graph_view.py | 56 --- 129 files changed, 34 insertions(+), 8111 deletions(-) delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs delete mode 100644 crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs delete mode 100644 crates/store/re_types/src/blueprint/archetypes/force_center.rs delete mode 100644 crates/store/re_types/src/blueprint/archetypes/force_collide_radius.rs delete mode 100644 crates/store/re_types/src/blueprint/archetypes/force_layout_simulation.rs delete mode 100644 crates/store/re_types/src/blueprint/archetypes/force_link.rs delete mode 100644 crates/store/re_types/src/blueprint/archetypes/force_many_body.rs delete mode 100644 crates/store/re_types/src/blueprint/archetypes/force_position_x.rs delete mode 100644 crates/store/re_types/src/blueprint/archetypes/force_position_y.rs delete mode 100644 crates/store/re_types/src/blueprint/components/force_center.rs delete mode 100644 crates/store/re_types/src/blueprint/components/force_collide_radius.rs delete mode 100644 crates/store/re_types/src/blueprint/components/force_layout_simulation.rs delete mode 100644 crates/store/re_types/src/blueprint/components/force_link.rs delete mode 100644 crates/store/re_types/src/blueprint/components/force_many_body.rs delete mode 100644 crates/store/re_types/src/blueprint/components/force_position_x.rs delete mode 100644 crates/store/re_types/src/blueprint/components/force_position_y.rs delete mode 100644 crates/store/re_types/src/blueprint/datatypes/force_center.rs delete mode 100644 crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs delete mode 100644 crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs delete mode 100644 crates/store/re_types/src/blueprint/datatypes/force_link.rs delete mode 100644 crates/store/re_types/src/blueprint/datatypes/force_many_body.rs delete mode 100644 crates/store/re_types/src/blueprint/datatypes/force_position_x.rs delete mode 100644 crates/store/re_types/src/blueprint/datatypes/force_position_y.rs delete mode 100644 crates/viewer/re_component_ui/src/force.rs delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/components/force_center.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/components/force_collide_radius.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/components/force_layout_simulation.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/components/force_link.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/components/force_many_body.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/components/force_position_x.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/components/force_position_y.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_center.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_center.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_link.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_link.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.hpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.cpp delete mode 100644 rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.hpp delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collide_radius.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_layout_simulation.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_x.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_y.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_center.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_collide_radius.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_layout_simulation.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_link.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_many_body.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_position_x.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_position_y.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_center.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_collide_radius.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_layout_simulation.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_link.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_many_body.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_x.py delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_y.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index 58b4ac5b2b3c..47eb842fc7c0 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -3,13 +3,6 @@ include "./archetypes/background.fbs"; include "./archetypes/container_blueprint.fbs"; include "./archetypes/dataframe_query.fbs"; -include "./archetypes/force_center.fbs"; -include "./archetypes/force_collide_radius.fbs"; -include "./archetypes/force_layout_simulation.fbs"; -include "./archetypes/force_link.fbs"; -include "./archetypes/force_many_body.fbs"; -include "./archetypes/force_position_x.fbs"; -include "./archetypes/force_position_y.fbs"; include "./archetypes/map_background.fbs"; include "./archetypes/map_zoom.fbs"; include "./archetypes/panel_blueprint.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs deleted file mode 100644 index 49f7bfb79b49..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.archetypes; - -struct ForceCenter ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default" -) { - force: rerun.blueprint.components.ForceCenter (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs deleted file mode 100644 index 14d6fda3238d..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.archetypes; - -struct ForceCollideRadius ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default" -) { - force: rerun.blueprint.components.ForceCollideRadius (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs deleted file mode 100644 index 11ecc6e8ffbb..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.archetypes; - -struct ForceLayoutSimulation ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default" -) { - simulation: rerun.blueprint.components.ForceLayoutSimulation (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs deleted file mode 100644 index 606dbb6cd027..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.archetypes; - -struct ForceLink ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default" -) { - force: rerun.blueprint.components.ForceLink (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs deleted file mode 100644 index 9573c32ceaf2..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.archetypes; - -struct ForceManyBody ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default" -) { - force: rerun.blueprint.components.ForceManyBody (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs deleted file mode 100644 index 95f196dff25f..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.archetypes; - -struct ForcePositionX ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default" -) { - force: rerun.blueprint.components.ForcePositionX (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs deleted file mode 100644 index 1c1c7a5874fd..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.archetypes; - -struct ForcePositionY ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default" -) { - force: rerun.blueprint.components.ForcePositionY (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components.fbs b/crates/store/re_types/definitions/rerun/blueprint/components.fbs index 740eb89c97cc..f52c3ae986f1 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -11,13 +11,6 @@ include "./components/container_kind.fbs"; include "./components/corner_2d.fbs"; include "./components/filter_by_range.fbs"; include "./components/filter_is_not_null.fbs"; -include "./components/force_center.fbs"; -include "./components/force_collide_radius.fbs"; -include "./components/force_layout_simulation.fbs"; -include "./components/force_link.fbs"; -include "./components/force_many_body.fbs"; -include "./components/force_position_x.fbs"; -include "./components/force_position_y.fbs"; include "./components/grid_columns.fbs"; include "./components/included_content.fbs"; include "./components/interactive.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs deleted file mode 100644 index 99aca1967e20..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.components; - -struct ForceCenter ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, PartialEq" -) { - center: rerun.blueprint.datatypes.ForceCenter (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs deleted file mode 100644 index 0ffb135fe532..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.components; - -struct ForceCollideRadius ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, PartialEq" -) { - center: rerun.blueprint.datatypes.ForceCollideRadius (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs deleted file mode 100644 index fd4838648f81..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.components; - -struct ForceLayoutSimulation ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, PartialEq" -) { - simulation: rerun.blueprint.datatypes.ForceLayoutSimulation (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs deleted file mode 100644 index 6130d222330a..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.components; - -struct ForceLink ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, PartialEq" -) { - center: rerun.blueprint.datatypes.ForceLink (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs deleted file mode 100644 index 3ce3ae5cdc8c..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.components; - -struct ForceManyBody ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, PartialEq" -) { - center: rerun.blueprint.datatypes.ForceManyBody (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs deleted file mode 100644 index ad17cad98b67..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.components; - -struct ForcePositionX ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, PartialEq" -) { - position_x: rerun.blueprint.datatypes.ForcePositionX (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs deleted file mode 100644 index b907753415f6..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs +++ /dev/null @@ -1,8 +0,0 @@ -namespace rerun.blueprint.components; - -struct ForcePositionY ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "Default, PartialEq" -) { - position_y: rerun.blueprint.datatypes.ForcePositionY (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs index a1281480d933..e08bb0e9f7d3 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/datatypes.fbs @@ -3,13 +3,6 @@ include "./datatypes/component_column_selector.fbs"; include "./datatypes/filter_by_range.fbs"; include "./datatypes/filter_is_not_null.fbs"; -include "./datatypes/force_center.fbs"; -include "./datatypes/force_collide_radius.fbs"; -include "./datatypes/force_layout_simulation.fbs"; -include "./datatypes/force_link.fbs"; -include "./datatypes/force_many_body.fbs"; -include "./datatypes/force_position_x.fbs"; -include "./datatypes/force_position_y.fbs"; include "./datatypes/selected_columns.fbs"; include "./datatypes/tensor_dimension_index_slider.fbs"; include "./datatypes/utf8_list.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs deleted file mode 100644 index e290cd09b41e..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs +++ /dev/null @@ -1,19 +0,0 @@ -namespace rerun.blueprint.datatypes; - -/// Defines a force that globally centers a graph by moving its center of mass towards a given position. -struct ForceCenter ( - "attr.rust.derive": "Default, PartialEq", - "attr.rerun.scope": "blueprint" -) { - /// Whether the force is enabled. - enabled: bool (order: 100); - - /// The `x` position to pull nodes towards. - x: double (order: 200); - - /// The `y` position to pull nodes towards. - y: double (order: 300); - - /// The strength of the force. - strength: double (order: 400); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs deleted file mode 100644 index 42ed6ba47ff3..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs +++ /dev/null @@ -1,21 +0,0 @@ -namespace rerun.blueprint.datatypes; - -// TODO: Not sure about this one. In `d3` the collision radius can either be constant or dependent on the node. - -/// Defines a force that resolves collisions between the radii of `GraphNodes`. -struct ForceCollideRadius ( - "attr.rust.derive": "Default, PartialEq", - "attr.rerun.scope": "blueprint" -) { - /// Whether the force is enabled. - enabled: bool (order: 100); - - /// The number of iterations to resolve collisions. - iterations: uint32 (order: 200); - - /// The strength of the force. - strength: double (order: 300); - - /// An additional padding to apply to each node radius. - padding: double (order: 400); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs deleted file mode 100644 index abb8b5c89910..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs +++ /dev/null @@ -1,22 +0,0 @@ -namespace rerun.blueprint.datatypes; - -/// The parameters for a force layout simulation. -struct ForceLayoutSimulation ( - "attr.rust.derive": "Default, PartialEq", - "attr.rerun.scope": "blueprint" -) { - /// Similar to the the temperature in a simulated annealing algorithm. - alpha: double (order: 100); - - /// If `alpha` drops below this value, the simulation stops. - alpha_min: double (order: 200); - - /// The rate at which `alpha` decreases after each iteration. - alpha_decay: double (order: 300); - - /// The target value for `alpha`, must be in the range `[0, 1]`. - alpha_target: double (order: 400); - - /// Acts as a damping factor for the velocity of nodes. - velocity_decay: double (order: 500); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs deleted file mode 100644 index 8c80b825b7c7..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs +++ /dev/null @@ -1,19 +0,0 @@ -namespace rerun.blueprint.datatypes; - -/// Defines a force that acts similar to a spring between nodes. -struct ForceLink ( - "attr.rust.derive": "Default, PartialEq", - "attr.rerun.scope": "blueprint" -) { - /// Whether the force is enabled. - enabled: bool (order: 100); - - /// The number of iterations. - iterations: uint32 (order: 200); - - /// The distance between nodes at which the force is zero. - distance: double (order: 300); - - /// The strength of the force. - strength: double (order: 400); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs deleted file mode 100644 index 1f9ded832615..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs +++ /dev/null @@ -1,15 +0,0 @@ -namespace rerun.blueprint.datatypes; - -/// Defines a force that is similar to an electric charge between nodes. -/// -/// Positive strengths will push nodes apart, while negative strengths will pull nodes together. -struct ForceManyBody ( - "attr.rust.derive": "Default, PartialEq", - "attr.rerun.scope": "blueprint" -) { - /// Whether the force is enabled. - enabled: bool (order: 100); - - /// The strength of the force. - strength: double (order: 200); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs deleted file mode 100644 index f36c7dd18284..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs +++ /dev/null @@ -1,16 +0,0 @@ -namespace rerun.blueprint.datatypes; - -/// Defines a force that pulls nodes towards an `x` position. -struct ForcePositionX ( - "attr.rust.derive": "Default, PartialEq", - "attr.rerun.scope": "blueprint" -) { - /// Whether the force is enabled. - enabled: bool (order: 100); - - /// The `x` position to pull nodes towards. - x: double (order: 200); - - /// The strength of the force. - strength: double (order: 300); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs b/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs deleted file mode 100644 index 3142d6d5fcaa..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs +++ /dev/null @@ -1,16 +0,0 @@ -namespace rerun.blueprint.datatypes; - -/// Defines a force that pulls nodes towards an `y` position. -struct ForcePositionY ( - "attr.rust.derive": "Default, PartialEq", - "attr.rerun.scope": "blueprint" -) { - /// Whether the force is enabled. - enabled: bool (order: 100); - - /// The `y` position to pull nodes towards. - y: double (order: 200); - - /// The strength of the force. - strength: double (order: 300); -} diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index 04bc927f8a16..2f808bb8df2a 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -11,25 +11,4 @@ table GraphView ( /// /// Somethings outside of these bounds may also be visible due to letterboxing. visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 1000); - - /// The parameters for the force layout simulation. - force_layout_simulation: rerun.blueprint.archetypes.ForceLayoutSimulation (order: 2000); - - /// Adds a force that pull nodes towards an `x` position. - force_position_x: rerun.blueprint.archetypes.ForcePositionX (order: 3000); - - /// Adds a force that pull nodes towards an `y` position. - force_position_y: rerun.blueprint.archetypes.ForcePositionY (order: 3100); - - /// Adds a force that moves the center of mass of all nodes to a given position. - force_center: rerun.blueprint.archetypes.ForcePositionX (order: 4000); - - /// Adds a force that resolves collisions between graph nodes. - force_collide_radius: rerun.blueprint.archetypes.ForceCollideRadius (order: 5000); - - /// Adds a force that acts like an electric charge between nodes. - force_many_body: rerun.blueprint.archetypes.ForceManyBody (order: 6000); - - /// Adds a force that acts like a spring between nodes. - force_link: rerun.blueprint.archetypes.ForceLink (order: 7000); } diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index ab70fdb1cbe8..158c53d4bb45 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -3,13 +3,6 @@ .gitattributes linguist-generated=true background.rs linguist-generated=true dataframe_query.rs linguist-generated=true -force_center.rs linguist-generated=true -force_collide_radius.rs linguist-generated=true -force_layout_simulation.rs linguist-generated=true -force_link.rs linguist-generated=true -force_many_body.rs linguist-generated=true -force_position_x.rs linguist-generated=true -force_position_y.rs linguist-generated=true map_background.rs linguist-generated=true map_zoom.rs linguist-generated=true mod.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/archetypes/force_center.rs b/crates/store/re_types/src/blueprint/archetypes/force_center.rs deleted file mode 100644 index bc567d6df2bb..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/force_center.rs +++ /dev/null @@ -1,148 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default)] -pub struct ForceCenter { - pub force: crate::blueprint::components::ForceCenter, -} - -impl ::re_types_core::SizeBytes for ForceCenter { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.force.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceCenterIndicator".into()]); - -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceCenterIndicator".into()]); - -impl ForceCenter { - /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 1usize; -} - -/// Indicator component for the [`ForceCenter`] [`::re_types_core::Archetype`] -pub type ForceCenterIndicator = ::re_types_core::GenericIndicatorComponent; - -impl ::re_types_core::Archetype for ForceCenter { - type Indicator = ForceCenterIndicator; - - #[inline] - fn name() -> ::re_types_core::ArchetypeName { - "rerun.blueprint.archetypes.ForceCenter".into() - } - - #[inline] - fn display_name() -> &'static str { - "Force center" - } - - #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { - static INDICATOR: ForceCenterIndicator = ForceCenterIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) - } - - #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - REQUIRED_COMPONENTS.as_slice().into() - } - - #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - RECOMMENDED_COMPONENTS.as_slice().into() - } - - #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - OPTIONAL_COMPONENTS.as_slice().into() - } - - #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - ALL_COMPONENTS.as_slice().into() - } - - #[inline] - fn from_arrow2_components( - arrow_data: impl IntoIterator)>, - ) -> DeserializationResult { - re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data - .into_iter() - .map(|(name, array)| (name.full_name(), array)) - .collect(); - let force = { - let array = arrays_by_name - .get("rerun.blueprint.components.ForceCenter") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceCenter#force")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceCenter#force")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceCenter#force")? - }; - Ok(Self { force }) - } -} - -impl ::re_types_core::AsComponents for ForceCenter { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); - use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - Some((&self.force as &dyn ComponentBatch).into()), - ] - .into_iter() - .flatten() - .collect() - } -} - -impl ::re_types_core::ArchetypeReflectionMarker for ForceCenter {} - -impl ForceCenter { - /// Create a new `ForceCenter`. - #[inline] - pub fn new(force: impl Into) -> Self { - Self { - force: force.into(), - } - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collide_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collide_radius.rs deleted file mode 100644 index 8fb0973744c4..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/force_collide_radius.rs +++ /dev/null @@ -1,152 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default)] -pub struct ForceCollideRadius { - pub force: crate::blueprint::components::ForceCollideRadius, -} - -impl ::re_types_core::SizeBytes for ForceCollideRadius { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.force.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new( - || ["rerun.blueprint.components.ForceCollideRadiusIndicator".into()], - ); - -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = once_cell::sync::Lazy::new( - || ["rerun.blueprint.components.ForceCollideRadiusIndicator".into()], -); - -impl ForceCollideRadius { - /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 1usize; -} - -/// Indicator component for the [`ForceCollideRadius`] [`::re_types_core::Archetype`] -pub type ForceCollideRadiusIndicator = - ::re_types_core::GenericIndicatorComponent; - -impl ::re_types_core::Archetype for ForceCollideRadius { - type Indicator = ForceCollideRadiusIndicator; - - #[inline] - fn name() -> ::re_types_core::ArchetypeName { - "rerun.blueprint.archetypes.ForceCollideRadius".into() - } - - #[inline] - fn display_name() -> &'static str { - "Force collide radius" - } - - #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { - static INDICATOR: ForceCollideRadiusIndicator = ForceCollideRadiusIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) - } - - #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - REQUIRED_COMPONENTS.as_slice().into() - } - - #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - RECOMMENDED_COMPONENTS.as_slice().into() - } - - #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - OPTIONAL_COMPONENTS.as_slice().into() - } - - #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - ALL_COMPONENTS.as_slice().into() - } - - #[inline] - fn from_arrow2_components( - arrow_data: impl IntoIterator)>, - ) -> DeserializationResult { - re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data - .into_iter() - .map(|(name, array)| (name.full_name(), array)) - .collect(); - let force = { - let array = arrays_by_name - .get("rerun.blueprint.components.ForceCollideRadius") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceCollideRadius#force")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceCollideRadius#force")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceCollideRadius#force")? - }; - Ok(Self { force }) - } -} - -impl ::re_types_core::AsComponents for ForceCollideRadius { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); - use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - Some((&self.force as &dyn ComponentBatch).into()), - ] - .into_iter() - .flatten() - .collect() - } -} - -impl ::re_types_core::ArchetypeReflectionMarker for ForceCollideRadius {} - -impl ForceCollideRadius { - /// Create a new `ForceCollideRadius`. - #[inline] - pub fn new(force: impl Into) -> Self { - Self { - force: force.into(), - } - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_layout_simulation.rs b/crates/store/re_types/src/blueprint/archetypes/force_layout_simulation.rs deleted file mode 100644 index 57f3dbf2f057..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/force_layout_simulation.rs +++ /dev/null @@ -1,153 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default)] -pub struct ForceLayoutSimulation { - pub simulation: crate::blueprint::components::ForceLayoutSimulation, -} - -impl ::re_types_core::SizeBytes for ForceLayoutSimulation { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.simulation.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| { - ["rerun.blueprint.components.ForceLayoutSimulationIndicator".into()] - }); - -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| { - ["rerun.blueprint.components.ForceLayoutSimulationIndicator".into()] - }); - -impl ForceLayoutSimulation { - /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 1usize; -} - -/// Indicator component for the [`ForceLayoutSimulation`] [`::re_types_core::Archetype`] -pub type ForceLayoutSimulationIndicator = - ::re_types_core::GenericIndicatorComponent; - -impl ::re_types_core::Archetype for ForceLayoutSimulation { - type Indicator = ForceLayoutSimulationIndicator; - - #[inline] - fn name() -> ::re_types_core::ArchetypeName { - "rerun.blueprint.archetypes.ForceLayoutSimulation".into() - } - - #[inline] - fn display_name() -> &'static str { - "Force layout simulation" - } - - #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { - static INDICATOR: ForceLayoutSimulationIndicator = ForceLayoutSimulationIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) - } - - #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - REQUIRED_COMPONENTS.as_slice().into() - } - - #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - RECOMMENDED_COMPONENTS.as_slice().into() - } - - #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - OPTIONAL_COMPONENTS.as_slice().into() - } - - #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - ALL_COMPONENTS.as_slice().into() - } - - #[inline] - fn from_arrow2_components( - arrow_data: impl IntoIterator)>, - ) -> DeserializationResult { - re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data - .into_iter() - .map(|(name, array)| (name.full_name(), array)) - .collect(); - let simulation = { - let array = arrays_by_name - .get("rerun.blueprint.components.ForceLayoutSimulation") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceLayoutSimulation#simulation")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceLayoutSimulation#simulation")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceLayoutSimulation#simulation")? - }; - Ok(Self { simulation }) - } -} - -impl ::re_types_core::AsComponents for ForceLayoutSimulation { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); - use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - Some((&self.simulation as &dyn ComponentBatch).into()), - ] - .into_iter() - .flatten() - .collect() - } -} - -impl ::re_types_core::ArchetypeReflectionMarker for ForceLayoutSimulation {} - -impl ForceLayoutSimulation { - /// Create a new `ForceLayoutSimulation`. - #[inline] - pub fn new(simulation: impl Into) -> Self { - Self { - simulation: simulation.into(), - } - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs deleted file mode 100644 index 1771f8d5faa5..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/force_link.rs +++ /dev/null @@ -1,148 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default)] -pub struct ForceLink { - pub force: crate::blueprint::components::ForceLink, -} - -impl ::re_types_core::SizeBytes for ForceLink { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.force.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); - -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); - -impl ForceLink { - /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 1usize; -} - -/// Indicator component for the [`ForceLink`] [`::re_types_core::Archetype`] -pub type ForceLinkIndicator = ::re_types_core::GenericIndicatorComponent; - -impl ::re_types_core::Archetype for ForceLink { - type Indicator = ForceLinkIndicator; - - #[inline] - fn name() -> ::re_types_core::ArchetypeName { - "rerun.blueprint.archetypes.ForceLink".into() - } - - #[inline] - fn display_name() -> &'static str { - "Force link" - } - - #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { - static INDICATOR: ForceLinkIndicator = ForceLinkIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) - } - - #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - REQUIRED_COMPONENTS.as_slice().into() - } - - #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - RECOMMENDED_COMPONENTS.as_slice().into() - } - - #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - OPTIONAL_COMPONENTS.as_slice().into() - } - - #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - ALL_COMPONENTS.as_slice().into() - } - - #[inline] - fn from_arrow2_components( - arrow_data: impl IntoIterator)>, - ) -> DeserializationResult { - re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data - .into_iter() - .map(|(name, array)| (name.full_name(), array)) - .collect(); - let force = { - let array = arrays_by_name - .get("rerun.blueprint.components.ForceLink") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceLink#force")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceLink#force")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceLink#force")? - }; - Ok(Self { force }) - } -} - -impl ::re_types_core::AsComponents for ForceLink { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); - use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - Some((&self.force as &dyn ComponentBatch).into()), - ] - .into_iter() - .flatten() - .collect() - } -} - -impl ::re_types_core::ArchetypeReflectionMarker for ForceLink {} - -impl ForceLink { - /// Create a new `ForceLink`. - #[inline] - pub fn new(force: impl Into) -> Self { - Self { - force: force.into(), - } - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs deleted file mode 100644 index 01625d3ca3c6..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs +++ /dev/null @@ -1,148 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default)] -pub struct ForceManyBody { - pub force: crate::blueprint::components::ForceManyBody, -} - -impl ::re_types_core::SizeBytes for ForceManyBody { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.force.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceManyBodyIndicator".into()]); - -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceManyBodyIndicator".into()]); - -impl ForceManyBody { - /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 1usize; -} - -/// Indicator component for the [`ForceManyBody`] [`::re_types_core::Archetype`] -pub type ForceManyBodyIndicator = ::re_types_core::GenericIndicatorComponent; - -impl ::re_types_core::Archetype for ForceManyBody { - type Indicator = ForceManyBodyIndicator; - - #[inline] - fn name() -> ::re_types_core::ArchetypeName { - "rerun.blueprint.archetypes.ForceManyBody".into() - } - - #[inline] - fn display_name() -> &'static str { - "Force many body" - } - - #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { - static INDICATOR: ForceManyBodyIndicator = ForceManyBodyIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) - } - - #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - REQUIRED_COMPONENTS.as_slice().into() - } - - #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - RECOMMENDED_COMPONENTS.as_slice().into() - } - - #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - OPTIONAL_COMPONENTS.as_slice().into() - } - - #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - ALL_COMPONENTS.as_slice().into() - } - - #[inline] - fn from_arrow2_components( - arrow_data: impl IntoIterator)>, - ) -> DeserializationResult { - re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data - .into_iter() - .map(|(name, array)| (name.full_name(), array)) - .collect(); - let force = { - let array = arrays_by_name - .get("rerun.blueprint.components.ForceManyBody") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceManyBody#force")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceManyBody#force")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceManyBody#force")? - }; - Ok(Self { force }) - } -} - -impl ::re_types_core::AsComponents for ForceManyBody { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); - use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - Some((&self.force as &dyn ComponentBatch).into()), - ] - .into_iter() - .flatten() - .collect() - } -} - -impl ::re_types_core::ArchetypeReflectionMarker for ForceManyBody {} - -impl ForceManyBody { - /// Create a new `ForceManyBody`. - #[inline] - pub fn new(force: impl Into) -> Self { - Self { - force: force.into(), - } - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position_x.rs b/crates/store/re_types/src/blueprint/archetypes/force_position_x.rs deleted file mode 100644 index ccc4e9b972dc..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/force_position_x.rs +++ /dev/null @@ -1,148 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default)] -pub struct ForcePositionX { - pub force: crate::blueprint::components::ForcePositionX, -} - -impl ::re_types_core::SizeBytes for ForcePositionX { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.force.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionXIndicator".into()]); - -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionXIndicator".into()]); - -impl ForcePositionX { - /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 1usize; -} - -/// Indicator component for the [`ForcePositionX`] [`::re_types_core::Archetype`] -pub type ForcePositionXIndicator = ::re_types_core::GenericIndicatorComponent; - -impl ::re_types_core::Archetype for ForcePositionX { - type Indicator = ForcePositionXIndicator; - - #[inline] - fn name() -> ::re_types_core::ArchetypeName { - "rerun.blueprint.archetypes.ForcePositionX".into() - } - - #[inline] - fn display_name() -> &'static str { - "Force position x" - } - - #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { - static INDICATOR: ForcePositionXIndicator = ForcePositionXIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) - } - - #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - REQUIRED_COMPONENTS.as_slice().into() - } - - #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - RECOMMENDED_COMPONENTS.as_slice().into() - } - - #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - OPTIONAL_COMPONENTS.as_slice().into() - } - - #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - ALL_COMPONENTS.as_slice().into() - } - - #[inline] - fn from_arrow2_components( - arrow_data: impl IntoIterator)>, - ) -> DeserializationResult { - re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data - .into_iter() - .map(|(name, array)| (name.full_name(), array)) - .collect(); - let force = { - let array = arrays_by_name - .get("rerun.blueprint.components.ForcePositionX") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForcePositionX#force")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForcePositionX#force")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForcePositionX#force")? - }; - Ok(Self { force }) - } -} - -impl ::re_types_core::AsComponents for ForcePositionX { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); - use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - Some((&self.force as &dyn ComponentBatch).into()), - ] - .into_iter() - .flatten() - .collect() - } -} - -impl ::re_types_core::ArchetypeReflectionMarker for ForcePositionX {} - -impl ForcePositionX { - /// Create a new `ForcePositionX`. - #[inline] - pub fn new(force: impl Into) -> Self { - Self { - force: force.into(), - } - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position_y.rs b/crates/store/re_types/src/blueprint/archetypes/force_position_y.rs deleted file mode 100644 index 21c5acd117b5..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/force_position_y.rs +++ /dev/null @@ -1,148 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default)] -pub struct ForcePositionY { - pub force: crate::blueprint::components::ForcePositionY, -} - -impl ::re_types_core::SizeBytes for ForcePositionY { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.force.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionYIndicator".into()]); - -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); - -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionYIndicator".into()]); - -impl ForcePositionY { - /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 1usize; -} - -/// Indicator component for the [`ForcePositionY`] [`::re_types_core::Archetype`] -pub type ForcePositionYIndicator = ::re_types_core::GenericIndicatorComponent; - -impl ::re_types_core::Archetype for ForcePositionY { - type Indicator = ForcePositionYIndicator; - - #[inline] - fn name() -> ::re_types_core::ArchetypeName { - "rerun.blueprint.archetypes.ForcePositionY".into() - } - - #[inline] - fn display_name() -> &'static str { - "Force position y" - } - - #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { - static INDICATOR: ForcePositionYIndicator = ForcePositionYIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) - } - - #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - REQUIRED_COMPONENTS.as_slice().into() - } - - #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - RECOMMENDED_COMPONENTS.as_slice().into() - } - - #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - OPTIONAL_COMPONENTS.as_slice().into() - } - - #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { - ALL_COMPONENTS.as_slice().into() - } - - #[inline] - fn from_arrow2_components( - arrow_data: impl IntoIterator)>, - ) -> DeserializationResult { - re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data - .into_iter() - .map(|(name, array)| (name.full_name(), array)) - .collect(); - let force = { - let array = arrays_by_name - .get("rerun.blueprint.components.ForcePositionY") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForcePositionY#force")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForcePositionY#force")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForcePositionY#force")? - }; - Ok(Self { force }) - } -} - -impl ::re_types_core::AsComponents for ForcePositionY { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); - use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - Some((&self.force as &dyn ComponentBatch).into()), - ] - .into_iter() - .flatten() - .collect() - } -} - -impl ::re_types_core::ArchetypeReflectionMarker for ForcePositionY {} - -impl ForcePositionY { - /// Create a new `ForcePositionY`. - #[inline] - pub fn new(force: impl Into) -> Self { - Self { - force: force.into(), - } - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index 89fc5978ec8d..360c1b887939 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -2,13 +2,6 @@ mod background; mod dataframe_query; -mod force_center; -mod force_collide_radius; -mod force_layout_simulation; -mod force_link; -mod force_many_body; -mod force_position_x; -mod force_position_y; mod map_background; mod map_zoom; mod plot_legend; @@ -24,13 +17,6 @@ mod visual_bounds2d; pub use self::background::Background; pub use self::dataframe_query::DataframeQuery; -pub use self::force_center::ForceCenter; -pub use self::force_collide_radius::ForceCollideRadius; -pub use self::force_layout_simulation::ForceLayoutSimulation; -pub use self::force_link::ForceLink; -pub use self::force_many_body::ForceManyBody; -pub use self::force_position_x::ForcePositionX; -pub use self::force_position_y::ForcePositionY; pub use self::map_background::MapBackground; pub use self::map_zoom::MapZoom; pub use self::plot_legend::PlotLegend; diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index 198259929ef6..4a1915dc979d 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -9,13 +9,6 @@ component_column_selector.rs linguist-generated=true corner2d.rs linguist-generated=true filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true -force_center.rs linguist-generated=true -force_collide_radius.rs linguist-generated=true -force_layout_simulation.rs linguist-generated=true -force_link.rs linguist-generated=true -force_many_body.rs linguist-generated=true -force_position_x.rs linguist-generated=true -force_position_y.rs linguist-generated=true included_content.rs linguist-generated=true interactive.rs linguist-generated=true lock_range_during_zoom.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/force_center.rs b/crates/store/re_types/src/blueprint/components/force_center.rs deleted file mode 100644 index e7469fa97100..000000000000 --- a/crates/store/re_types/src/blueprint/components/force_center.rs +++ /dev/null @@ -1,103 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceCenter(pub crate::blueprint::datatypes::ForceCenter); - -impl ::re_types_core::SizeBytes for ForceCenter { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForceCenter { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForceCenter { - #[inline] - fn borrow(&self) -> &crate::blueprint::datatypes::ForceCenter { - &self.0 - } -} - -impl std::ops::Deref for ForceCenter { - type Target = crate::blueprint::datatypes::ForceCenter; - - #[inline] - fn deref(&self) -> &crate::blueprint::datatypes::ForceCenter { - &self.0 - } -} - -impl std::ops::DerefMut for ForceCenter { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceCenter { - &mut self.0 - } -} - -::re_types_core::macros::impl_into_cow!(ForceCenter); - -impl ::re_types_core::Loggable for ForceCenter { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - crate::blueprint::datatypes::ForceCenter::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - crate::blueprint::datatypes::ForceCenter::to_arrow_opt(data.into_iter().map(|datum| { - datum.map(|datum| match datum.into() { - ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), - ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), - }) - })) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::blueprint::datatypes::ForceCenter::from_arrow2_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) - } -} - -impl ::re_types_core::Component for ForceCenter { - #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForceCenter".into() - } -} diff --git a/crates/store/re_types/src/blueprint/components/force_collide_radius.rs b/crates/store/re_types/src/blueprint/components/force_collide_radius.rs deleted file mode 100644 index 8190bbe8e065..000000000000 --- a/crates/store/re_types/src/blueprint/components/force_collide_radius.rs +++ /dev/null @@ -1,105 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceCollideRadius(pub crate::blueprint::datatypes::ForceCollideRadius); - -impl ::re_types_core::SizeBytes for ForceCollideRadius { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForceCollideRadius { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForceCollideRadius { - #[inline] - fn borrow(&self) -> &crate::blueprint::datatypes::ForceCollideRadius { - &self.0 - } -} - -impl std::ops::Deref for ForceCollideRadius { - type Target = crate::blueprint::datatypes::ForceCollideRadius; - - #[inline] - fn deref(&self) -> &crate::blueprint::datatypes::ForceCollideRadius { - &self.0 - } -} - -impl std::ops::DerefMut for ForceCollideRadius { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceCollideRadius { - &mut self.0 - } -} - -::re_types_core::macros::impl_into_cow!(ForceCollideRadius); - -impl ::re_types_core::Loggable for ForceCollideRadius { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - crate::blueprint::datatypes::ForceCollideRadius::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - crate::blueprint::datatypes::ForceCollideRadius::to_arrow_opt(data.into_iter().map( - |datum| { - datum.map(|datum| match datum.into() { - ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), - ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), - }) - }, - )) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::blueprint::datatypes::ForceCollideRadius::from_arrow2_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) - } -} - -impl ::re_types_core::Component for ForceCollideRadius { - #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForceCollideRadius".into() - } -} diff --git a/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs b/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs deleted file mode 100644 index 186ba5272d43..000000000000 --- a/crates/store/re_types/src/blueprint/components/force_layout_simulation.rs +++ /dev/null @@ -1,109 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceLayoutSimulation(pub crate::blueprint::datatypes::ForceLayoutSimulation); - -impl ::re_types_core::SizeBytes for ForceLayoutSimulation { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From - for ForceLayoutSimulation -{ - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow - for ForceLayoutSimulation -{ - #[inline] - fn borrow(&self) -> &crate::blueprint::datatypes::ForceLayoutSimulation { - &self.0 - } -} - -impl std::ops::Deref for ForceLayoutSimulation { - type Target = crate::blueprint::datatypes::ForceLayoutSimulation; - - #[inline] - fn deref(&self) -> &crate::blueprint::datatypes::ForceLayoutSimulation { - &self.0 - } -} - -impl std::ops::DerefMut for ForceLayoutSimulation { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceLayoutSimulation { - &mut self.0 - } -} - -::re_types_core::macros::impl_into_cow!(ForceLayoutSimulation); - -impl ::re_types_core::Loggable for ForceLayoutSimulation { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - crate::blueprint::datatypes::ForceLayoutSimulation::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - crate::blueprint::datatypes::ForceLayoutSimulation::to_arrow_opt(data.into_iter().map( - |datum| { - datum.map(|datum| match datum.into() { - ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), - ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), - }) - }, - )) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::blueprint::datatypes::ForceLayoutSimulation::from_arrow2_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) - } -} - -impl ::re_types_core::Component for ForceLayoutSimulation { - #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForceLayoutSimulation".into() - } -} diff --git a/crates/store/re_types/src/blueprint/components/force_link.rs b/crates/store/re_types/src/blueprint/components/force_link.rs deleted file mode 100644 index a9f421799616..000000000000 --- a/crates/store/re_types/src/blueprint/components/force_link.rs +++ /dev/null @@ -1,103 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceLink(pub crate::blueprint::datatypes::ForceLink); - -impl ::re_types_core::SizeBytes for ForceLink { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForceLink { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForceLink { - #[inline] - fn borrow(&self) -> &crate::blueprint::datatypes::ForceLink { - &self.0 - } -} - -impl std::ops::Deref for ForceLink { - type Target = crate::blueprint::datatypes::ForceLink; - - #[inline] - fn deref(&self) -> &crate::blueprint::datatypes::ForceLink { - &self.0 - } -} - -impl std::ops::DerefMut for ForceLink { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceLink { - &mut self.0 - } -} - -::re_types_core::macros::impl_into_cow!(ForceLink); - -impl ::re_types_core::Loggable for ForceLink { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - crate::blueprint::datatypes::ForceLink::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - crate::blueprint::datatypes::ForceLink::to_arrow_opt(data.into_iter().map(|datum| { - datum.map(|datum| match datum.into() { - ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), - ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), - }) - })) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::blueprint::datatypes::ForceLink::from_arrow2_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) - } -} - -impl ::re_types_core::Component for ForceLink { - #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForceLink".into() - } -} diff --git a/crates/store/re_types/src/blueprint/components/force_many_body.rs b/crates/store/re_types/src/blueprint/components/force_many_body.rs deleted file mode 100644 index 552ab624f9d0..000000000000 --- a/crates/store/re_types/src/blueprint/components/force_many_body.rs +++ /dev/null @@ -1,103 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceManyBody(pub crate::blueprint::datatypes::ForceManyBody); - -impl ::re_types_core::SizeBytes for ForceManyBody { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForceManyBody { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForceManyBody { - #[inline] - fn borrow(&self) -> &crate::blueprint::datatypes::ForceManyBody { - &self.0 - } -} - -impl std::ops::Deref for ForceManyBody { - type Target = crate::blueprint::datatypes::ForceManyBody; - - #[inline] - fn deref(&self) -> &crate::blueprint::datatypes::ForceManyBody { - &self.0 - } -} - -impl std::ops::DerefMut for ForceManyBody { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForceManyBody { - &mut self.0 - } -} - -::re_types_core::macros::impl_into_cow!(ForceManyBody); - -impl ::re_types_core::Loggable for ForceManyBody { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - crate::blueprint::datatypes::ForceManyBody::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - crate::blueprint::datatypes::ForceManyBody::to_arrow_opt(data.into_iter().map(|datum| { - datum.map(|datum| match datum.into() { - ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), - ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), - }) - })) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::blueprint::datatypes::ForceManyBody::from_arrow2_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) - } -} - -impl ::re_types_core::Component for ForceManyBody { - #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForceManyBody".into() - } -} diff --git a/crates/store/re_types/src/blueprint/components/force_position_x.rs b/crates/store/re_types/src/blueprint/components/force_position_x.rs deleted file mode 100644 index c4e67963aa45..000000000000 --- a/crates/store/re_types/src/blueprint/components/force_position_x.rs +++ /dev/null @@ -1,103 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForcePositionX(pub crate::blueprint::datatypes::ForcePositionX); - -impl ::re_types_core::SizeBytes for ForcePositionX { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForcePositionX { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForcePositionX { - #[inline] - fn borrow(&self) -> &crate::blueprint::datatypes::ForcePositionX { - &self.0 - } -} - -impl std::ops::Deref for ForcePositionX { - type Target = crate::blueprint::datatypes::ForcePositionX; - - #[inline] - fn deref(&self) -> &crate::blueprint::datatypes::ForcePositionX { - &self.0 - } -} - -impl std::ops::DerefMut for ForcePositionX { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForcePositionX { - &mut self.0 - } -} - -::re_types_core::macros::impl_into_cow!(ForcePositionX); - -impl ::re_types_core::Loggable for ForcePositionX { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - crate::blueprint::datatypes::ForcePositionX::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - crate::blueprint::datatypes::ForcePositionX::to_arrow_opt(data.into_iter().map(|datum| { - datum.map(|datum| match datum.into() { - ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), - ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), - }) - })) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::blueprint::datatypes::ForcePositionX::from_arrow2_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) - } -} - -impl ::re_types_core::Component for ForcePositionX { - #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForcePositionX".into() - } -} diff --git a/crates/store/re_types/src/blueprint/components/force_position_y.rs b/crates/store/re_types/src/blueprint/components/force_position_y.rs deleted file mode 100644 index eccfe273fa94..000000000000 --- a/crates/store/re_types/src/blueprint/components/force_position_y.rs +++ /dev/null @@ -1,103 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForcePositionY(pub crate::blueprint::datatypes::ForcePositionY); - -impl ::re_types_core::SizeBytes for ForcePositionY { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForcePositionY { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForcePositionY { - #[inline] - fn borrow(&self) -> &crate::blueprint::datatypes::ForcePositionY { - &self.0 - } -} - -impl std::ops::Deref for ForcePositionY { - type Target = crate::blueprint::datatypes::ForcePositionY; - - #[inline] - fn deref(&self) -> &crate::blueprint::datatypes::ForcePositionY { - &self.0 - } -} - -impl std::ops::DerefMut for ForcePositionY { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::datatypes::ForcePositionY { - &mut self.0 - } -} - -::re_types_core::macros::impl_into_cow!(ForcePositionY); - -impl ::re_types_core::Loggable for ForcePositionY { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - crate::blueprint::datatypes::ForcePositionY::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - crate::blueprint::datatypes::ForcePositionY::to_arrow_opt(data.into_iter().map(|datum| { - datum.map(|datum| match datum.into() { - ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), - ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), - }) - })) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::blueprint::datatypes::ForcePositionY::from_arrow2_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) - } -} - -impl ::re_types_core::Component for ForcePositionY { - #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForcePositionY".into() - } -} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index 830be804e6c8..a915957fd392 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -12,13 +12,6 @@ mod filter_by_range; mod filter_by_range_ext; mod filter_is_not_null; mod filter_is_not_null_ext; -mod force_center; -mod force_collide_radius; -mod force_layout_simulation; -mod force_link; -mod force_many_body; -mod force_position_x; -mod force_position_y; mod included_content; mod interactive; mod interactive_ext; @@ -55,13 +48,6 @@ pub use self::component_column_selector::ComponentColumnSelector; pub use self::corner2d::Corner2D; pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; -pub use self::force_center::ForceCenter; -pub use self::force_collide_radius::ForceCollideRadius; -pub use self::force_layout_simulation::ForceLayoutSimulation; -pub use self::force_link::ForceLink; -pub use self::force_many_body::ForceManyBody; -pub use self::force_position_x::ForcePositionX; -pub use self::force_position_y::ForcePositionY; pub use self::included_content::IncludedContent; pub use self::interactive::Interactive; pub use self::lock_range_during_zoom::LockRangeDuringZoom; diff --git a/crates/store/re_types/src/blueprint/datatypes/.gitattributes b/crates/store/re_types/src/blueprint/datatypes/.gitattributes index bb597be8258e..a5c2c2463632 100644 --- a/crates/store/re_types/src/blueprint/datatypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/datatypes/.gitattributes @@ -4,13 +4,6 @@ component_column_selector.rs linguist-generated=true filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true -force_center.rs linguist-generated=true -force_collide_radius.rs linguist-generated=true -force_layout_simulation.rs linguist-generated=true -force_link.rs linguist-generated=true -force_many_body.rs linguist-generated=true -force_position_x.rs linguist-generated=true -force_position_y.rs linguist-generated=true mod.rs linguist-generated=true selected_columns.rs linguist-generated=true tensor_dimension_index_slider.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/datatypes/force_center.rs b/crates/store/re_types/src/blueprint/datatypes/force_center.rs deleted file mode 100644 index ef7dcf94d3fe..000000000000 --- a/crates/store/re_types/src/blueprint/datatypes/force_center.rs +++ /dev/null @@ -1,334 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -/// **Datatype**: Defines a force that globally centers a graph by moving its center of mass towards a given position. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceCenter { - /// Whether the force is enabled. - pub enabled: bool, - - /// The `x` position to pull nodes towards. - pub x: f64, - - /// The `y` position to pull nodes towards. - pub y: f64, - - /// The strength of the force. - pub strength: f64, -} - -impl ::re_types_core::SizeBytes for ForceCenter { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() - + self.x.heap_size_bytes() - + self.y.heap_size_bytes() - + self.strength.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(ForceCenter); - -impl ::re_types_core::Loggable for ForceCenter { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow::datatypes::*; - DataType::Struct(Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("x", DataType::Float64, false), - Field::new("y", DataType::Float64, false), - Field::new("strength", DataType::Float64, false), - ])) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - #![allow(clippy::manual_is_variant_and)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::{array::*, buffer::*, datatypes::*}; - - #[allow(unused)] - fn as_array_ref(t: T) -> ArrayRef { - std::sync::Arc::new(t) as ArrayRef - } - Ok({ - let fields = Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("x", DataType::Float64, false), - Field::new("y", DataType::Float64, false), - Field::new("strength", DataType::Float64, false), - ]); - let (somes, data): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - (datum.is_some(), datum) - }) - .unzip(); - let validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(StructArray::new( - fields, - vec![ - { - let (somes, enabled): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.enabled.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let enabled_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(BooleanArray::new( - BooleanBuffer::from( - enabled - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - enabled_validity, - )) - }, - { - let (somes, x): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.x.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let x_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - x.into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - x_validity, - )) - }, - { - let (somes, y): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.y.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let y_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - y.into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - y_validity, - )) - }, - { - let (somes, strength): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.strength.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let strength_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - strength - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - strength_validity, - )) - }, - ], - validity, - )) - }) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::datatypes::*; - use arrow2::{array::*, buffer::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCenter")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_fields, arrow_data_arrays) = - (arrow_data.fields(), arrow_data.values()); - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields - .iter() - .map(|field| field.name.as_str()) - .zip(arrow_data_arrays) - .collect(); - let enabled = { - if !arrays_by_name.contains_key("enabled") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "enabled", - )) - .with_context("rerun.blueprint.datatypes.ForceCenter"); - } - let arrow_data = &**arrays_by_name["enabled"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Boolean; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCenter#enabled")? - .into_iter() - }; - let x = { - if !arrays_by_name.contains_key("x") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "x", - )) - .with_context("rerun.blueprint.datatypes.ForceCenter"); - } - let arrow_data = &**arrays_by_name["x"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCenter#x")? - .into_iter() - .map(|opt| opt.copied()) - }; - let y = { - if !arrays_by_name.contains_key("y") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "y", - )) - .with_context("rerun.blueprint.datatypes.ForceCenter"); - } - let arrow_data = &**arrays_by_name["y"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCenter#y")? - .into_iter() - .map(|opt| opt.copied()) - }; - let strength = { - if !arrays_by_name.contains_key("strength") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "strength", - )) - .with_context("rerun.blueprint.datatypes.ForceCenter"); - } - let arrow_data = &**arrays_by_name["strength"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCenter#strength")? - .into_iter() - .map(|opt| opt.copied()) - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - ::itertools::izip!(enabled, x, y, strength), - arrow_data.validity(), - ) - .map(|opt| { - opt.map(|(enabled, x, y, strength)| { - Ok(Self { - enabled: enabled - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceCenter#enabled")?, - x: x.ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceCenter#x")?, - y: y.ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceCenter#y")?, - strength: strength - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceCenter#strength")?, - }) - }) - .transpose() - }) - .collect::>>() - .with_context("rerun.blueprint.datatypes.ForceCenter")? - } - }) - } -} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs b/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs deleted file mode 100644 index 9bdd214304e3..000000000000 --- a/crates/store/re_types/src/blueprint/datatypes/force_collide_radius.rs +++ /dev/null @@ -1,346 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -/// **Datatype**: Defines a force that resolves collisions between the radii of `GraphNodes`. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceCollideRadius { - /// Whether the force is enabled. - pub enabled: bool, - - /// The number of iterations to resolve collisions. - pub iterations: u32, - - /// The strength of the force. - pub strength: f64, - - /// An additional padding to apply to each node radius. - pub padding: f64, -} - -impl ::re_types_core::SizeBytes for ForceCollideRadius { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() - + self.iterations.heap_size_bytes() - + self.strength.heap_size_bytes() - + self.padding.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(ForceCollideRadius); - -impl ::re_types_core::Loggable for ForceCollideRadius { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow::datatypes::*; - DataType::Struct(Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("iterations", DataType::UInt32, false), - Field::new("strength", DataType::Float64, false), - Field::new("padding", DataType::Float64, false), - ])) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - #![allow(clippy::manual_is_variant_and)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::{array::*, buffer::*, datatypes::*}; - - #[allow(unused)] - fn as_array_ref(t: T) -> ArrayRef { - std::sync::Arc::new(t) as ArrayRef - } - Ok({ - let fields = Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("iterations", DataType::UInt32, false), - Field::new("strength", DataType::Float64, false), - Field::new("padding", DataType::Float64, false), - ]); - let (somes, data): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - (datum.is_some(), datum) - }) - .unzip(); - let validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(StructArray::new( - fields, - vec![ - { - let (somes, enabled): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.enabled.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let enabled_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(BooleanArray::new( - BooleanBuffer::from( - enabled - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - enabled_validity, - )) - }, - { - let (somes, iterations): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.iterations.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let iterations_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - iterations - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - iterations_validity, - )) - }, - { - let (somes, strength): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.strength.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let strength_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - strength - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - strength_validity, - )) - }, - { - let (somes, padding): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.padding.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let padding_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - padding - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - padding_validity, - )) - }, - ], - validity, - )) - }) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::datatypes::*; - use arrow2::{array::*, buffer::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_fields, arrow_data_arrays) = - (arrow_data.fields(), arrow_data.values()); - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields - .iter() - .map(|field| field.name.as_str()) - .zip(arrow_data_arrays) - .collect(); - let enabled = { - if !arrays_by_name.contains_key("enabled") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "enabled", - )) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius"); - } - let arrow_data = &**arrays_by_name["enabled"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Boolean; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius#enabled")? - .into_iter() - }; - let iterations = { - if !arrays_by_name.contains_key("iterations") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "iterations", - )) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius"); - } - let arrow_data = &**arrays_by_name["iterations"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::UInt32; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius#iterations")? - .into_iter() - .map(|opt| opt.copied()) - }; - let strength = { - if !arrays_by_name.contains_key("strength") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "strength", - )) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius"); - } - let arrow_data = &**arrays_by_name["strength"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius#strength")? - .into_iter() - .map(|opt| opt.copied()) - }; - let padding = { - if !arrays_by_name.contains_key("padding") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "padding", - )) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius"); - } - let arrow_data = &**arrays_by_name["padding"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceCollideRadius#padding")? - .into_iter() - .map(|opt| opt.copied()) - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - ::itertools::izip!(enabled, iterations, strength, padding), - arrow_data.validity(), - ) - .map(|opt| { - opt.map(|(enabled, iterations, strength, padding)| { - Ok(Self { - enabled: enabled - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceCollideRadius#enabled", - )?, - iterations: iterations - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceCollideRadius#iterations", - )?, - strength: strength - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceCollideRadius#strength", - )?, - padding: padding - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceCollideRadius#padding", - )?, - }) - }) - .transpose() - }) - .collect::>>() - .with_context("rerun.blueprint.datatypes.ForceCollideRadius")? - } - }) - } -} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs b/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs deleted file mode 100644 index 5a5ca60a5aa3..000000000000 --- a/crates/store/re_types/src/blueprint/datatypes/force_layout_simulation.rs +++ /dev/null @@ -1,417 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -/// **Datatype**: The parameters for a force layout simulation. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceLayoutSimulation { - /// Similar to the the temperature in a simulated annealing algorithm. - pub alpha: f64, - - /// If `alpha` drops below this value, the simulation stops. - pub alpha_min: f64, - - /// The rate at which `alpha` decreases after each iteration. - pub alpha_decay: f64, - - /// The target value for `alpha`, must be in the range `[0, 1]`. - pub alpha_target: f64, - - /// Acts as a damping factor for the velocity of nodes. - pub velocity_decay: f64, -} - -impl ::re_types_core::SizeBytes for ForceLayoutSimulation { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.alpha.heap_size_bytes() - + self.alpha_min.heap_size_bytes() - + self.alpha_decay.heap_size_bytes() - + self.alpha_target.heap_size_bytes() - + self.velocity_decay.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(ForceLayoutSimulation); - -impl ::re_types_core::Loggable for ForceLayoutSimulation { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow::datatypes::*; - DataType::Struct(Fields::from(vec![ - Field::new("alpha", DataType::Float64, false), - Field::new("alpha_min", DataType::Float64, false), - Field::new("alpha_decay", DataType::Float64, false), - Field::new("alpha_target", DataType::Float64, false), - Field::new("velocity_decay", DataType::Float64, false), - ])) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - #![allow(clippy::manual_is_variant_and)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::{array::*, buffer::*, datatypes::*}; - - #[allow(unused)] - fn as_array_ref(t: T) -> ArrayRef { - std::sync::Arc::new(t) as ArrayRef - } - Ok({ - let fields = Fields::from(vec![ - Field::new("alpha", DataType::Float64, false), - Field::new("alpha_min", DataType::Float64, false), - Field::new("alpha_decay", DataType::Float64, false), - Field::new("alpha_target", DataType::Float64, false), - Field::new("velocity_decay", DataType::Float64, false), - ]); - let (somes, data): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - (datum.is_some(), datum) - }) - .unzip(); - let validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(StructArray::new( - fields, - vec![ - { - let (somes, alpha): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.alpha.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let alpha_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - alpha - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - alpha_validity, - )) - }, - { - let (somes, alpha_min): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.alpha_min.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let alpha_min_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - alpha_min - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - alpha_min_validity, - )) - }, - { - let (somes, alpha_decay): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.alpha_decay.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let alpha_decay_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - alpha_decay - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - alpha_decay_validity, - )) - }, - { - let (somes, alpha_target): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.alpha_target.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let alpha_target_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - alpha_target - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - alpha_target_validity, - )) - }, - { - let (somes, velocity_decay): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = - datum.as_ref().map(|datum| datum.velocity_decay.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let velocity_decay_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - velocity_decay - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - velocity_decay_validity, - )) - }, - ], - validity, - )) - }) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::datatypes::*; - use arrow2::{array::*, buffer::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_fields, arrow_data_arrays) = - (arrow_data.fields(), arrow_data.values()); - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields - .iter() - .map(|field| field.name.as_str()) - .zip(arrow_data_arrays) - .collect(); - let alpha = { - if !arrays_by_name.contains_key("alpha") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "alpha", - )) - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); - } - let arrow_data = &**arrays_by_name["alpha"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation#alpha")? - .into_iter() - .map(|opt| opt.copied()) - }; - let alpha_min = { - if !arrays_by_name.contains_key("alpha_min") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "alpha_min", - )) - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); - } - let arrow_data = &**arrays_by_name["alpha_min"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_min")? - .into_iter() - .map(|opt| opt.copied()) - }; - let alpha_decay = { - if !arrays_by_name.contains_key("alpha_decay") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "alpha_decay", - )) - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); - } - let arrow_data = &**arrays_by_name["alpha_decay"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context( - "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_decay", - )? - .into_iter() - .map(|opt| opt.copied()) - }; - let alpha_target = { - if !arrays_by_name.contains_key("alpha_target") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "alpha_target", - )) - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); - } - let arrow_data = &**arrays_by_name["alpha_target"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context( - "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_target", - )? - .into_iter() - .map(|opt| opt.copied()) - }; - let velocity_decay = { - if !arrays_by_name.contains_key("velocity_decay") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "velocity_decay", - )) - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation"); - } - let arrow_data = &**arrays_by_name["velocity_decay"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context( - "rerun.blueprint.datatypes.ForceLayoutSimulation#velocity_decay", - )? - .into_iter() - .map(|opt| opt.copied()) - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - ::itertools::izip!( - alpha, alpha_min, alpha_decay, alpha_target, velocity_decay - ), - arrow_data.validity(), - ) - .map(|opt| { - opt - .map(| - ( - alpha, - alpha_min, - alpha_decay, - alpha_target, - velocity_decay, - )| - Ok(Self { - alpha: alpha - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha", - )?, - alpha_min: alpha_min - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_min", - )?, - alpha_decay: alpha_decay - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_decay", - )?, - alpha_target: alpha_target - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceLayoutSimulation#alpha_target", - )?, - velocity_decay: velocity_decay - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceLayoutSimulation#velocity_decay", - )?, - })) - .transpose() - }) - .collect::>>() - .with_context("rerun.blueprint.datatypes.ForceLayoutSimulation")? - } - }) - } -} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_link.rs b/crates/store/re_types/src/blueprint/datatypes/force_link.rs deleted file mode 100644 index 3f54e7c51ad7..000000000000 --- a/crates/store/re_types/src/blueprint/datatypes/force_link.rs +++ /dev/null @@ -1,340 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -/// **Datatype**: Defines a force that acts similar to a spring between nodes. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceLink { - /// Whether the force is enabled. - pub enabled: bool, - - /// The number of iterations. - pub iterations: u32, - - /// The distance between nodes at which the force is zero. - pub distance: f64, - - /// The strength of the force. - pub strength: f64, -} - -impl ::re_types_core::SizeBytes for ForceLink { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() - + self.iterations.heap_size_bytes() - + self.distance.heap_size_bytes() - + self.strength.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() && ::is_pod() && ::is_pod() && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(ForceLink); - -impl ::re_types_core::Loggable for ForceLink { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow::datatypes::*; - DataType::Struct(Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("iterations", DataType::UInt32, false), - Field::new("distance", DataType::Float64, false), - Field::new("strength", DataType::Float64, false), - ])) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - #![allow(clippy::manual_is_variant_and)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::{array::*, buffer::*, datatypes::*}; - - #[allow(unused)] - fn as_array_ref(t: T) -> ArrayRef { - std::sync::Arc::new(t) as ArrayRef - } - Ok({ - let fields = Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("iterations", DataType::UInt32, false), - Field::new("distance", DataType::Float64, false), - Field::new("strength", DataType::Float64, false), - ]); - let (somes, data): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - (datum.is_some(), datum) - }) - .unzip(); - let validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(StructArray::new( - fields, - vec![ - { - let (somes, enabled): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.enabled.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let enabled_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(BooleanArray::new( - BooleanBuffer::from( - enabled - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - enabled_validity, - )) - }, - { - let (somes, iterations): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.iterations.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let iterations_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - iterations - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - iterations_validity, - )) - }, - { - let (somes, distance): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.distance.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let distance_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - distance - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - distance_validity, - )) - }, - { - let (somes, strength): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.strength.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let strength_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - strength - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - strength_validity, - )) - }, - ], - validity, - )) - }) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::datatypes::*; - use arrow2::{array::*, buffer::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceLink")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_fields, arrow_data_arrays) = - (arrow_data.fields(), arrow_data.values()); - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields - .iter() - .map(|field| field.name.as_str()) - .zip(arrow_data_arrays) - .collect(); - let enabled = { - if !arrays_by_name.contains_key("enabled") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "enabled", - )) - .with_context("rerun.blueprint.datatypes.ForceLink"); - } - let arrow_data = &**arrays_by_name["enabled"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Boolean; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceLink#enabled")? - .into_iter() - }; - let iterations = { - if !arrays_by_name.contains_key("iterations") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "iterations", - )) - .with_context("rerun.blueprint.datatypes.ForceLink"); - } - let arrow_data = &**arrays_by_name["iterations"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::UInt32; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceLink#iterations")? - .into_iter() - .map(|opt| opt.copied()) - }; - let distance = { - if !arrays_by_name.contains_key("distance") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "distance", - )) - .with_context("rerun.blueprint.datatypes.ForceLink"); - } - let arrow_data = &**arrays_by_name["distance"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceLink#distance")? - .into_iter() - .map(|opt| opt.copied()) - }; - let strength = { - if !arrays_by_name.contains_key("strength") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "strength", - )) - .with_context("rerun.blueprint.datatypes.ForceLink"); - } - let arrow_data = &**arrays_by_name["strength"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceLink#strength")? - .into_iter() - .map(|opt| opt.copied()) - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - ::itertools::izip!(enabled, iterations, distance, strength), - arrow_data.validity(), - ) - .map(|opt| { - opt.map(|(enabled, iterations, distance, strength)| { - Ok(Self { - enabled: enabled - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceLink#enabled")?, - iterations: iterations - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForceLink#iterations", - )?, - distance: distance - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceLink#distance")?, - strength: strength - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceLink#strength")?, - }) - }) - .transpose() - }) - .collect::>>() - .with_context("rerun.blueprint.datatypes.ForceLink")? - } - }) - } -} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs b/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs deleted file mode 100644 index 17203a291542..000000000000 --- a/crates/store/re_types/src/blueprint/datatypes/force_many_body.rs +++ /dev/null @@ -1,235 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -/// **Datatype**: Defines a force that is similar to an electric charge between nodes. -/// -/// Positive strengths will push nodes apart, while negative strengths will pull nodes together. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForceManyBody { - /// Whether the force is enabled. - pub enabled: bool, - - /// The strength of the force. - pub strength: f64, -} - -impl ::re_types_core::SizeBytes for ForceManyBody { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(ForceManyBody); - -impl ::re_types_core::Loggable for ForceManyBody { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow::datatypes::*; - DataType::Struct(Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("strength", DataType::Float64, false), - ])) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - #![allow(clippy::manual_is_variant_and)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::{array::*, buffer::*, datatypes::*}; - - #[allow(unused)] - fn as_array_ref(t: T) -> ArrayRef { - std::sync::Arc::new(t) as ArrayRef - } - Ok({ - let fields = Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("strength", DataType::Float64, false), - ]); - let (somes, data): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - (datum.is_some(), datum) - }) - .unzip(); - let validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(StructArray::new( - fields, - vec![ - { - let (somes, enabled): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.enabled.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let enabled_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(BooleanArray::new( - BooleanBuffer::from( - enabled - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - enabled_validity, - )) - }, - { - let (somes, strength): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.strength.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let strength_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - strength - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - strength_validity, - )) - }, - ], - validity, - )) - }) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::datatypes::*; - use arrow2::{array::*, buffer::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceManyBody")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_fields, arrow_data_arrays) = - (arrow_data.fields(), arrow_data.values()); - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields - .iter() - .map(|field| field.name.as_str()) - .zip(arrow_data_arrays) - .collect(); - let enabled = { - if !arrays_by_name.contains_key("enabled") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "enabled", - )) - .with_context("rerun.blueprint.datatypes.ForceManyBody"); - } - let arrow_data = &**arrays_by_name["enabled"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Boolean; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceManyBody#enabled")? - .into_iter() - }; - let strength = { - if !arrays_by_name.contains_key("strength") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "strength", - )) - .with_context("rerun.blueprint.datatypes.ForceManyBody"); - } - let arrow_data = &**arrays_by_name["strength"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForceManyBody#strength")? - .into_iter() - .map(|opt| opt.copied()) - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - ::itertools::izip!(enabled, strength), - arrow_data.validity(), - ) - .map(|opt| { - opt.map(|(enabled, strength)| { - Ok(Self { - enabled: enabled - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceManyBody#enabled")?, - strength: strength - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForceManyBody#strength")?, - }) - }) - .transpose() - }) - .collect::>>() - .with_context("rerun.blueprint.datatypes.ForceManyBody")? - } - }) - } -} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs b/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs deleted file mode 100644 index 02c28ba5c209..000000000000 --- a/crates/store/re_types/src/blueprint/datatypes/force_position_x.rs +++ /dev/null @@ -1,284 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -/// **Datatype**: Defines a force that pulls nodes towards an `x` position. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForcePositionX { - /// Whether the force is enabled. - pub enabled: bool, - - /// The `x` position to pull nodes towards. - pub x: f64, - - /// The strength of the force. - pub strength: f64, -} - -impl ::re_types_core::SizeBytes for ForcePositionX { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() + self.x.heap_size_bytes() + self.strength.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() && ::is_pod() && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(ForcePositionX); - -impl ::re_types_core::Loggable for ForcePositionX { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow::datatypes::*; - DataType::Struct(Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("x", DataType::Float64, false), - Field::new("strength", DataType::Float64, false), - ])) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - #![allow(clippy::manual_is_variant_and)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::{array::*, buffer::*, datatypes::*}; - - #[allow(unused)] - fn as_array_ref(t: T) -> ArrayRef { - std::sync::Arc::new(t) as ArrayRef - } - Ok({ - let fields = Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("x", DataType::Float64, false), - Field::new("strength", DataType::Float64, false), - ]); - let (somes, data): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - (datum.is_some(), datum) - }) - .unzip(); - let validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(StructArray::new( - fields, - vec![ - { - let (somes, enabled): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.enabled.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let enabled_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(BooleanArray::new( - BooleanBuffer::from( - enabled - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - enabled_validity, - )) - }, - { - let (somes, x): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.x.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let x_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - x.into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - x_validity, - )) - }, - { - let (somes, strength): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.strength.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let strength_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - strength - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - strength_validity, - )) - }, - ], - validity, - )) - }) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::datatypes::*; - use arrow2::{array::*, buffer::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForcePositionX")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_fields, arrow_data_arrays) = - (arrow_data.fields(), arrow_data.values()); - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields - .iter() - .map(|field| field.name.as_str()) - .zip(arrow_data_arrays) - .collect(); - let enabled = { - if !arrays_by_name.contains_key("enabled") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "enabled", - )) - .with_context("rerun.blueprint.datatypes.ForcePositionX"); - } - let arrow_data = &**arrays_by_name["enabled"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Boolean; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForcePositionX#enabled")? - .into_iter() - }; - let x = { - if !arrays_by_name.contains_key("x") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "x", - )) - .with_context("rerun.blueprint.datatypes.ForcePositionX"); - } - let arrow_data = &**arrays_by_name["x"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForcePositionX#x")? - .into_iter() - .map(|opt| opt.copied()) - }; - let strength = { - if !arrays_by_name.contains_key("strength") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "strength", - )) - .with_context("rerun.blueprint.datatypes.ForcePositionX"); - } - let arrow_data = &**arrays_by_name["strength"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForcePositionX#strength")? - .into_iter() - .map(|opt| opt.copied()) - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - ::itertools::izip!(enabled, x, strength), - arrow_data.validity(), - ) - .map(|opt| { - opt.map(|(enabled, x, strength)| { - Ok(Self { - enabled: enabled - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForcePositionX#enabled")?, - x: x.ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForcePositionX#x")?, - strength: strength - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForcePositionX#strength", - )?, - }) - }) - .transpose() - }) - .collect::>>() - .with_context("rerun.blueprint.datatypes.ForcePositionX")? - } - }) - } -} diff --git a/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs b/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs deleted file mode 100644 index aee8e395407b..000000000000 --- a/crates/store/re_types/src/blueprint/datatypes/force_position_y.rs +++ /dev/null @@ -1,284 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs". - -#![allow(unused_imports)] -#![allow(unused_parens)] -#![allow(clippy::clone_on_copy)] -#![allow(clippy::cloned_instead_of_copied)] -#![allow(clippy::map_flatten)] -#![allow(clippy::needless_question_mark)] -#![allow(clippy::new_without_default)] -#![allow(clippy::redundant_closure)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::too_many_lines)] - -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; - -/// **Datatype**: Defines a force that pulls nodes towards an `y` position. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ForcePositionY { - /// Whether the force is enabled. - pub enabled: bool, - - /// The `y` position to pull nodes towards. - pub y: f64, - - /// The strength of the force. - pub strength: f64, -} - -impl ::re_types_core::SizeBytes for ForcePositionY { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() + self.y.heap_size_bytes() + self.strength.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() && ::is_pod() && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(ForcePositionY); - -impl ::re_types_core::Loggable for ForcePositionY { - #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow::datatypes::*; - DataType::Struct(Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("y", DataType::Float64, false), - Field::new("strength", DataType::Float64, false), - ])) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - #![allow(clippy::manual_is_variant_and)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::{array::*, buffer::*, datatypes::*}; - - #[allow(unused)] - fn as_array_ref(t: T) -> ArrayRef { - std::sync::Arc::new(t) as ArrayRef - } - Ok({ - let fields = Fields::from(vec![ - Field::new("enabled", DataType::Boolean, false), - Field::new("y", DataType::Float64, false), - Field::new("strength", DataType::Float64, false), - ]); - let (somes, data): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - (datum.is_some(), datum) - }) - .unzip(); - let validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(StructArray::new( - fields, - vec![ - { - let (somes, enabled): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.enabled.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let enabled_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(BooleanArray::new( - BooleanBuffer::from( - enabled - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - enabled_validity, - )) - }, - { - let (somes, y): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.y.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let y_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - y.into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - y_validity, - )) - }, - { - let (somes, strength): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.strength.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let strength_validity: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - as_array_ref(PrimitiveArray::::new( - ScalarBuffer::from( - strength - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect::>(), - ), - strength_validity, - )) - }, - ], - validity, - )) - }) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow::datatypes::*; - use arrow2::{array::*, buffer::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForcePositionY")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_fields, arrow_data_arrays) = - (arrow_data.fields(), arrow_data.values()); - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields - .iter() - .map(|field| field.name.as_str()) - .zip(arrow_data_arrays) - .collect(); - let enabled = { - if !arrays_by_name.contains_key("enabled") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "enabled", - )) - .with_context("rerun.blueprint.datatypes.ForcePositionY"); - } - let arrow_data = &**arrays_by_name["enabled"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Boolean; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForcePositionY#enabled")? - .into_iter() - }; - let y = { - if !arrays_by_name.contains_key("y") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "y", - )) - .with_context("rerun.blueprint.datatypes.ForcePositionY"); - } - let arrow_data = &**arrays_by_name["y"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForcePositionY#y")? - .into_iter() - .map(|opt| opt.copied()) - }; - let strength = { - if !arrays_by_name.contains_key("strength") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "strength", - )) - .with_context("rerun.blueprint.datatypes.ForcePositionY"); - } - let arrow_data = &**arrays_by_name["strength"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float64; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.blueprint.datatypes.ForcePositionY#strength")? - .into_iter() - .map(|opt| opt.copied()) - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - ::itertools::izip!(enabled, y, strength), - arrow_data.validity(), - ) - .map(|opt| { - opt.map(|(enabled, y, strength)| { - Ok(Self { - enabled: enabled - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForcePositionY#enabled")?, - y: y.ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.datatypes.ForcePositionY#y")?, - strength: strength - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.blueprint.datatypes.ForcePositionY#strength", - )?, - }) - }) - .transpose() - }) - .collect::>>() - .with_context("rerun.blueprint.datatypes.ForcePositionY")? - } - }) - } -} diff --git a/crates/store/re_types/src/blueprint/datatypes/mod.rs b/crates/store/re_types/src/blueprint/datatypes/mod.rs index 3ed7da3bcf52..b60da1620294 100644 --- a/crates/store/re_types/src/blueprint/datatypes/mod.rs +++ b/crates/store/re_types/src/blueprint/datatypes/mod.rs @@ -4,25 +4,11 @@ mod component_column_selector; mod component_column_selector_ext; mod filter_by_range; mod filter_is_not_null; -mod force_center; -mod force_collide_radius; -mod force_layout_simulation; -mod force_link; -mod force_many_body; -mod force_position_x; -mod force_position_y; mod selected_columns; mod tensor_dimension_index_slider; pub use self::component_column_selector::ComponentColumnSelector; pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; -pub use self::force_center::ForceCenter; -pub use self::force_collide_radius::ForceCollideRadius; -pub use self::force_layout_simulation::ForceLayoutSimulation; -pub use self::force_link::ForceLink; -pub use self::force_many_body::ForceManyBody; -pub use self::force_position_x::ForcePositionX; -pub use self::force_position_y::ForcePositionY; pub use self::selected_columns::SelectedColumns; pub use self::tensor_dimension_index_slider::TensorDimensionIndexSlider; diff --git a/crates/store/re_types/src/blueprint/views/graph_view.rs b/crates/store/re_types/src/blueprint/views/graph_view.rs index 89957c94979a..505d5efd40d1 100644 --- a/crates/store/re_types/src/blueprint/views/graph_view.rs +++ b/crates/store/re_types/src/blueprint/views/graph_view.rs @@ -25,52 +25,48 @@ pub struct GraphView { /// /// Somethings outside of these bounds may also be visible due to letterboxing. pub visual_bounds: crate::blueprint::archetypes::VisualBounds2D, - - /// The parameters for the force layout simulation. - pub force_layout_simulation: crate::blueprint::archetypes::ForceLayoutSimulation, - - /// Adds a force that pull nodes towards an `x` position. - pub force_position_x: crate::blueprint::archetypes::ForcePositionX, - - /// Adds a force that pull nodes towards an `y` position. - pub force_position_y: crate::blueprint::archetypes::ForcePositionY, - - /// Adds a force that moves the center of mass of all nodes to a given position. - pub force_center: crate::blueprint::archetypes::ForcePositionX, - - /// Adds a force that resolves collisions between graph nodes. - pub force_collide_radius: crate::blueprint::archetypes::ForceCollideRadius, - - /// Adds a force that acts like an electric charge between nodes. - pub force_many_body: crate::blueprint::archetypes::ForceManyBody, - - /// Adds a force that acts like a spring between nodes. - pub force_link: crate::blueprint::archetypes::ForceLink, } impl ::re_types_core::SizeBytes for GraphView { #[inline] fn heap_size_bytes(&self) -> u64 { self.visual_bounds.heap_size_bytes() - + self.force_layout_simulation.heap_size_bytes() - + self.force_position_x.heap_size_bytes() - + self.force_position_y.heap_size_bytes() - + self.force_center.heap_size_bytes() - + self.force_collide_radius.heap_size_bytes() - + self.force_many_body.heap_size_bytes() - + self.force_link.heap_size_bytes() } #[inline] fn is_pod() -> bool { ::is_pod() - && ::is_pod() - && ::is_pod() - && ::is_pod() - && ::is_pod() - && ::is_pod() - && ::is_pod() - && ::is_pod() + } +} + +impl> From for GraphView { + fn from(v: T) -> Self { + Self { + visual_bounds: v.into(), + } + } +} + +impl std::borrow::Borrow for GraphView { + #[inline] + fn borrow(&self) -> &crate::blueprint::archetypes::VisualBounds2D { + &self.visual_bounds + } +} + +impl std::ops::Deref for GraphView { + type Target = crate::blueprint::archetypes::VisualBounds2D; + + #[inline] + fn deref(&self) -> &crate::blueprint::archetypes::VisualBounds2D { + &self.visual_bounds + } +} + +impl std::ops::DerefMut for GraphView { + #[inline] + fn deref_mut(&mut self) -> &mut crate::blueprint::archetypes::VisualBounds2D { + &mut self.visual_bounds } } diff --git a/crates/viewer/re_component_ui/src/force.rs b/crates/viewer/re_component_ui/src/force.rs deleted file mode 100644 index f20d1088d0ce..000000000000 --- a/crates/viewer/re_component_ui/src/force.rs +++ /dev/null @@ -1,15 +0,0 @@ -use re_types::blueprint::components::ForceLink; -use re_ui::UiExt as _; -use re_viewer_context::{MaybeMutRef, UiLayout, ViewerContext}; - -pub fn singleline_view_force_link( - _ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - value: &mut MaybeMutRef<'_, ForceLink>, -) -> egui::Response { - UiLayout::List - .label(ui, format!("test",)) - .on_hover_ui(|ui| { - ui.markdown_ui("Toggle link force on/off"); - }) -} diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index b527d6a758b5..9ee313c198b7 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -7,7 +7,6 @@ mod color; mod datatype_uis; mod entity_path; mod fallback_ui; -mod force; mod geo_line_string; mod image_format; mod lat_lon; @@ -168,7 +167,5 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view(lat_lon::singleline_view_lat_lon); - registry.add_singleline_edit_or_view(force::singleline_view_force_link); - registry } diff --git a/crates/viewer/re_space_view_graph/src/properties.rs b/crates/viewer/re_space_view_graph/src/properties.rs index 7b69b01950dd..de6b0255f0ca 100644 --- a/crates/viewer/re_space_view_graph/src/properties.rs +++ b/crates/viewer/re_space_view_graph/src/properties.rs @@ -1,4 +1,4 @@ -use re_types::blueprint::{components::ForceLink, components::VisualBounds2D}; +use re_types::blueprint::components::VisualBounds2D; use re_viewer_context::{SpaceViewStateExt as _, TypedComponentFallbackProvider}; use crate::{ui::GraphSpaceViewState, GraphSpaceView}; @@ -20,10 +20,4 @@ impl TypedComponentFallbackProvider for GraphSpaceView { } } -impl TypedComponentFallbackProvider for GraphSpaceView { - fn fallback_for(&self, _: &re_viewer_context::QueryContext<'_>) -> ForceLink { - ForceLink::default() - } -} - -re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D, ForceLink]); +re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D]); diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index adb7346b8130..6539892a1447 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -4,7 +4,7 @@ use re_space_view::{ view_property_ui, }; use re_types::{ - blueprint::{self, archetypes::{ForceLink, VisualBounds2D}}, + blueprint::{self, archetypes::VisualBounds2D}, SpaceViewClassIdentifier, }; use re_ui::{ @@ -130,7 +130,6 @@ Display a graph of nodes and edges. }); view_property_ui::(ctx, ui, space_view_id, self, state); - view_property_ui::(ctx, ui, space_view_id, self, state); Ok(()) } diff --git a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs index 4f4d971380f8..ac256bc847d4 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -9,13 +9,6 @@ pub use re_types::blueprint::components::ComponentColumnSelector; pub use re_types::blueprint::components::Corner2D; pub use re_types::blueprint::components::FilterByRange; pub use re_types::blueprint::components::FilterIsNotNull; -pub use re_types::blueprint::components::ForceCenter; -pub use re_types::blueprint::components::ForceCollideRadius; -pub use re_types::blueprint::components::ForceLayoutSimulation; -pub use re_types::blueprint::components::ForceLink; -pub use re_types::blueprint::components::ForceManyBody; -pub use re_types::blueprint::components::ForcePositionX; -pub use re_types::blueprint::components::ForcePositionY; pub use re_types::blueprint::components::IncludedContent; pub use re_types::blueprint::components::Interactive; pub use re_types::blueprint::components::LockRangeDuringZoom; @@ -57,13 +50,6 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) - && validate_component::(blueprint) - && validate_component::(blueprint) - && validate_component::(blueprint) - && validate_component::(blueprint) - && validate_component::(blueprint) - && validate_component::(blueprint) - && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 5bdcdfa3bcbd..21424df3e255 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -124,62 +124,6 @@ fn generate_component_reflection() -> Result::name(), - ComponentReflection { - docstring_md: "", - custom_placeholder: Some(ForceCenter::default().to_arrow2()?), - datatype: ForceCenter::arrow2_datatype(), - }, - ), - ( - ::name(), - ComponentReflection { - docstring_md: "", - custom_placeholder: Some(ForceCollideRadius::default().to_arrow2()?), - datatype: ForceCollideRadius::arrow2_datatype(), - }, - ), - ( - ::name(), - ComponentReflection { - docstring_md: "", - custom_placeholder: Some(ForceLayoutSimulation::default().to_arrow2()?), - datatype: ForceLayoutSimulation::arrow2_datatype(), - }, - ), - ( - ::name(), - ComponentReflection { - docstring_md: "", - custom_placeholder: Some(ForceLink::default().to_arrow2()?), - datatype: ForceLink::arrow2_datatype(), - }, - ), - ( - ::name(), - ComponentReflection { - docstring_md: "", - custom_placeholder: Some(ForceManyBody::default().to_arrow2()?), - datatype: ForceManyBody::arrow2_datatype(), - }, - ), - ( - ::name(), - ComponentReflection { - docstring_md: "", - custom_placeholder: Some(ForcePositionX::default().to_arrow2()?), - datatype: ForcePositionX::arrow2_datatype(), - }, - ), - ( - ::name(), - ComponentReflection { - docstring_md: "", - custom_placeholder: Some(ForcePositionY::default().to_arrow2()?), - datatype: ForcePositionY::arrow2_datatype(), - }, - ), ( ::name(), ComponentReflection { @@ -1986,91 +1930,6 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), - ( - ArchetypeName::new("rerun.blueprint.archetypes.ForceCenter"), - ArchetypeReflection { - display_name: "Force center", - view_types: &[], - fields: vec![ - ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ForceCenter".into(), display_name : - "Force", docstring_md : "", is_required : false, }, - ], - }, - ), - ( - ArchetypeName::new("rerun.blueprint.archetypes.ForceCollideRadius"), - ArchetypeReflection { - display_name: "Force collide radius", - view_types: &[], - fields: vec![ - ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ForceCollideRadius".into(), display_name - : "Force", docstring_md : "", is_required : false, }, - ], - }, - ), - ( - ArchetypeName::new("rerun.blueprint.archetypes.ForceLayoutSimulation"), - ArchetypeReflection { - display_name: "Force layout simulation", - view_types: &[], - fields: vec![ - ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ForceLayoutSimulation".into(), - display_name : "Simulation", docstring_md : "", is_required : false, - }, - ], - }, - ), - ( - ArchetypeName::new("rerun.blueprint.archetypes.ForceLink"), - ArchetypeReflection { - display_name: "Force link", - view_types: &[], - fields: vec![ - ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ForceLink".into(), display_name : - "Force", docstring_md : "", is_required : false, }, - ], - }, - ), - ( - ArchetypeName::new("rerun.blueprint.archetypes.ForceManyBody"), - ArchetypeReflection { - display_name: "Force many body", - view_types: &[], - fields: vec![ - ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ForceManyBody".into(), display_name : - "Force", docstring_md : "", is_required : false, }, - ], - }, - ), - ( - ArchetypeName::new("rerun.blueprint.archetypes.ForcePositionX"), - ArchetypeReflection { - display_name: "Force position x", - view_types: &[], - fields: vec![ - ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ForcePositionX".into(), display_name : - "Force", docstring_md : "", is_required : false, }, - ], - }, - ), - ( - ArchetypeName::new("rerun.blueprint.archetypes.ForcePositionY"), - ArchetypeReflection { - display_name: "Force position y", - view_types: &[], - fields: vec![ - ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ForcePositionY".into(), display_name : - "Force", docstring_md : "", is_required : false, }, - ], - }, - ), ( ArchetypeName::new("rerun.blueprint.archetypes.MapBackground"), ArchetypeReflection { diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index b93865fb148d..f6830c618ed6 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -11,20 +11,6 @@ A graph view to display time-variying, directed or undirected graph visualizatio Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. -### `force_layout_simulation` -The parameters for the force layout simulation. -### `force_position_x` -Adds a force that pull nodes towards an `x` position. -### `force_position_y` -Adds a force that pull nodes towards an `y` position. -### `force_center` -Adds a force that moves the center of mass of all nodes to a given position. -### `force_collide_radius` -Adds a force that resolves collisions between graph nodes. -### `force_many_body` -Adds a force that acts like an electric charge between nodes. -### `force_link` -Adds a force that acts like a spring between nodes. ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index 45289449202f..2fd779424b1f 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -5,13 +5,6 @@ #include "blueprint/archetypes/background.hpp" #include "blueprint/archetypes/container_blueprint.hpp" #include "blueprint/archetypes/dataframe_query.hpp" -#include "blueprint/archetypes/force_center.hpp" -#include "blueprint/archetypes/force_collide_radius.hpp" -#include "blueprint/archetypes/force_layout_simulation.hpp" -#include "blueprint/archetypes/force_link.hpp" -#include "blueprint/archetypes/force_many_body.hpp" -#include "blueprint/archetypes/force_position_x.hpp" -#include "blueprint/archetypes/force_position_y.hpp" #include "blueprint/archetypes/map_background.hpp" #include "blueprint/archetypes/map_zoom.hpp" #include "blueprint/archetypes/panel_blueprint.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes index 6240a07012ac..26e1a60b89a6 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -7,20 +7,6 @@ container_blueprint.cpp linguist-generated=true container_blueprint.hpp linguist-generated=true dataframe_query.cpp linguist-generated=true dataframe_query.hpp linguist-generated=true -force_center.cpp linguist-generated=true -force_center.hpp linguist-generated=true -force_collide_radius.cpp linguist-generated=true -force_collide_radius.hpp linguist-generated=true -force_layout_simulation.cpp linguist-generated=true -force_layout_simulation.hpp linguist-generated=true -force_link.cpp linguist-generated=true -force_link.hpp linguist-generated=true -force_many_body.cpp linguist-generated=true -force_many_body.hpp linguist-generated=true -force_position_x.cpp linguist-generated=true -force_position_x.hpp linguist-generated=true -force_position_y.cpp linguist-generated=true -force_position_y.hpp linguist-generated=true map_background.cpp linguist-generated=true map_background.hpp linguist-generated=true map_zoom.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp deleted file mode 100644 index 76ee0cda2745..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". - -#include "force_center.hpp" - -#include "../../collection_adapter_builtins.hpp" - -namespace rerun::blueprint::archetypes {} - -namespace rerun { - - Result> AsComponents::serialize( - const blueprint::archetypes::ForceCenter& archetype - ) { - using namespace blueprint::archetypes; - std::vector cells; - cells.reserve(2); - - { - auto result = ComponentBatch::from_loggable(archetype.force); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - { - auto indicator = ForceCenter::IndicatorComponent(); - auto result = ComponentBatch::from_loggable(indicator); - RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value)); - } - - return cells; - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp deleted file mode 100644 index 682f29c27a68..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". - -#pragma once - -#include "../../blueprint/components/force_center.hpp" -#include "../../collection.hpp" -#include "../../component_batch.hpp" -#include "../../indicator_component.hpp" -#include "../../result.hpp" - -#include -#include -#include - -namespace rerun::blueprint::archetypes { - struct ForceCenter { - rerun::blueprint::components::ForceCenter force; - - public: - static constexpr const char IndicatorComponentName[] = - "rerun.blueprint.components.ForceCenterIndicator"; - - /// Indicator component, used to identify the archetype when converting to a list of components. - using IndicatorComponent = rerun::components::IndicatorComponent; - - public: - ForceCenter() = default; - ForceCenter(ForceCenter&& other) = default; - - explicit ForceCenter(rerun::blueprint::components::ForceCenter _force) - : force(std::move(_force)) {} - }; - -} // namespace rerun::blueprint::archetypes - -namespace rerun { - /// \private - template - struct AsComponents; - - /// \private - template <> - struct AsComponents { - /// Serialize all set component batches. - static Result> serialize( - const blueprint::archetypes::ForceCenter& archetype - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.cpp deleted file mode 100644 index 47cd8635ed09..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs". - -#include "force_collide_radius.hpp" - -#include "../../collection_adapter_builtins.hpp" - -namespace rerun::blueprint::archetypes {} - -namespace rerun { - - Result> - AsComponents::serialize( - const blueprint::archetypes::ForceCollideRadius& archetype - ) { - using namespace blueprint::archetypes; - std::vector cells; - cells.reserve(2); - - { - auto result = ComponentBatch::from_loggable(archetype.force); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - { - auto indicator = ForceCollideRadius::IndicatorComponent(); - auto result = ComponentBatch::from_loggable(indicator); - RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value)); - } - - return cells; - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.hpp deleted file mode 100644 index 11286320734f..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_collide_radius.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs". - -#pragma once - -#include "../../blueprint/components/force_collide_radius.hpp" -#include "../../collection.hpp" -#include "../../component_batch.hpp" -#include "../../indicator_component.hpp" -#include "../../result.hpp" - -#include -#include -#include - -namespace rerun::blueprint::archetypes { - struct ForceCollideRadius { - rerun::blueprint::components::ForceCollideRadius force; - - public: - static constexpr const char IndicatorComponentName[] = - "rerun.blueprint.components.ForceCollideRadiusIndicator"; - - /// Indicator component, used to identify the archetype when converting to a list of components. - using IndicatorComponent = rerun::components::IndicatorComponent; - - public: - ForceCollideRadius() = default; - ForceCollideRadius(ForceCollideRadius&& other) = default; - - explicit ForceCollideRadius(rerun::blueprint::components::ForceCollideRadius _force) - : force(std::move(_force)) {} - }; - -} // namespace rerun::blueprint::archetypes - -namespace rerun { - /// \private - template - struct AsComponents; - - /// \private - template <> - struct AsComponents { - /// Serialize all set component batches. - static Result> serialize( - const blueprint::archetypes::ForceCollideRadius& archetype - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.cpp deleted file mode 100644 index 8d5a566b40ef..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs". - -#include "force_layout_simulation.hpp" - -#include "../../collection_adapter_builtins.hpp" - -namespace rerun::blueprint::archetypes {} - -namespace rerun { - - Result> - AsComponents::serialize( - const blueprint::archetypes::ForceLayoutSimulation& archetype - ) { - using namespace blueprint::archetypes; - std::vector cells; - cells.reserve(2); - - { - auto result = ComponentBatch::from_loggable(archetype.simulation); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - { - auto indicator = ForceLayoutSimulation::IndicatorComponent(); - auto result = ComponentBatch::from_loggable(indicator); - RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value)); - } - - return cells; - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.hpp deleted file mode 100644 index d371c281cc69..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_layout_simulation.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs". - -#pragma once - -#include "../../blueprint/components/force_layout_simulation.hpp" -#include "../../collection.hpp" -#include "../../component_batch.hpp" -#include "../../indicator_component.hpp" -#include "../../result.hpp" - -#include -#include -#include - -namespace rerun::blueprint::archetypes { - struct ForceLayoutSimulation { - rerun::blueprint::components::ForceLayoutSimulation simulation; - - public: - static constexpr const char IndicatorComponentName[] = - "rerun.blueprint.components.ForceLayoutSimulationIndicator"; - - /// Indicator component, used to identify the archetype when converting to a list of components. - using IndicatorComponent = rerun::components::IndicatorComponent; - - public: - ForceLayoutSimulation() = default; - ForceLayoutSimulation(ForceLayoutSimulation&& other) = default; - - explicit ForceLayoutSimulation( - rerun::blueprint::components::ForceLayoutSimulation _simulation - ) - : simulation(std::move(_simulation)) {} - }; - -} // namespace rerun::blueprint::archetypes - -namespace rerun { - /// \private - template - struct AsComponents; - - /// \private - template <> - struct AsComponents { - /// Serialize all set component batches. - static Result> serialize( - const blueprint::archetypes::ForceLayoutSimulation& archetype - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp deleted file mode 100644 index 124d9688b5bf..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". - -#include "force_link.hpp" - -#include "../../collection_adapter_builtins.hpp" - -namespace rerun::blueprint::archetypes {} - -namespace rerun { - - Result> AsComponents::serialize( - const blueprint::archetypes::ForceLink& archetype - ) { - using namespace blueprint::archetypes; - std::vector cells; - cells.reserve(2); - - { - auto result = ComponentBatch::from_loggable(archetype.force); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - { - auto indicator = ForceLink::IndicatorComponent(); - auto result = ComponentBatch::from_loggable(indicator); - RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value)); - } - - return cells; - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp deleted file mode 100644 index a2b1b9a96528..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". - -#pragma once - -#include "../../blueprint/components/force_link.hpp" -#include "../../collection.hpp" -#include "../../component_batch.hpp" -#include "../../indicator_component.hpp" -#include "../../result.hpp" - -#include -#include -#include - -namespace rerun::blueprint::archetypes { - struct ForceLink { - rerun::blueprint::components::ForceLink force; - - public: - static constexpr const char IndicatorComponentName[] = - "rerun.blueprint.components.ForceLinkIndicator"; - - /// Indicator component, used to identify the archetype when converting to a list of components. - using IndicatorComponent = rerun::components::IndicatorComponent; - - public: - ForceLink() = default; - ForceLink(ForceLink&& other) = default; - - explicit ForceLink(rerun::blueprint::components::ForceLink _force) - : force(std::move(_force)) {} - }; - -} // namespace rerun::blueprint::archetypes - -namespace rerun { - /// \private - template - struct AsComponents; - - /// \private - template <> - struct AsComponents { - /// Serialize all set component batches. - static Result> serialize( - const blueprint::archetypes::ForceLink& archetype - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp deleted file mode 100644 index 7d966596883c..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". - -#include "force_many_body.hpp" - -#include "../../collection_adapter_builtins.hpp" - -namespace rerun::blueprint::archetypes {} - -namespace rerun { - - Result> - AsComponents::serialize( - const blueprint::archetypes::ForceManyBody& archetype - ) { - using namespace blueprint::archetypes; - std::vector cells; - cells.reserve(2); - - { - auto result = ComponentBatch::from_loggable(archetype.force); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - { - auto indicator = ForceManyBody::IndicatorComponent(); - auto result = ComponentBatch::from_loggable(indicator); - RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value)); - } - - return cells; - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp deleted file mode 100644 index d7521d498126..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". - -#pragma once - -#include "../../blueprint/components/force_many_body.hpp" -#include "../../collection.hpp" -#include "../../component_batch.hpp" -#include "../../indicator_component.hpp" -#include "../../result.hpp" - -#include -#include -#include - -namespace rerun::blueprint::archetypes { - struct ForceManyBody { - rerun::blueprint::components::ForceManyBody force; - - public: - static constexpr const char IndicatorComponentName[] = - "rerun.blueprint.components.ForceManyBodyIndicator"; - - /// Indicator component, used to identify the archetype when converting to a list of components. - using IndicatorComponent = rerun::components::IndicatorComponent; - - public: - ForceManyBody() = default; - ForceManyBody(ForceManyBody&& other) = default; - - explicit ForceManyBody(rerun::blueprint::components::ForceManyBody _force) - : force(std::move(_force)) {} - }; - -} // namespace rerun::blueprint::archetypes - -namespace rerun { - /// \private - template - struct AsComponents; - - /// \private - template <> - struct AsComponents { - /// Serialize all set component batches. - static Result> serialize( - const blueprint::archetypes::ForceManyBody& archetype - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.cpp deleted file mode 100644 index 72d478196c45..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs". - -#include "force_position_x.hpp" - -#include "../../collection_adapter_builtins.hpp" - -namespace rerun::blueprint::archetypes {} - -namespace rerun { - - Result> - AsComponents::serialize( - const blueprint::archetypes::ForcePositionX& archetype - ) { - using namespace blueprint::archetypes; - std::vector cells; - cells.reserve(2); - - { - auto result = ComponentBatch::from_loggable(archetype.force); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - { - auto indicator = ForcePositionX::IndicatorComponent(); - auto result = ComponentBatch::from_loggable(indicator); - RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value)); - } - - return cells; - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.hpp deleted file mode 100644 index 866b65507abe..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_x.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs". - -#pragma once - -#include "../../blueprint/components/force_position_x.hpp" -#include "../../collection.hpp" -#include "../../component_batch.hpp" -#include "../../indicator_component.hpp" -#include "../../result.hpp" - -#include -#include -#include - -namespace rerun::blueprint::archetypes { - struct ForcePositionX { - rerun::blueprint::components::ForcePositionX force; - - public: - static constexpr const char IndicatorComponentName[] = - "rerun.blueprint.components.ForcePositionXIndicator"; - - /// Indicator component, used to identify the archetype when converting to a list of components. - using IndicatorComponent = rerun::components::IndicatorComponent; - - public: - ForcePositionX() = default; - ForcePositionX(ForcePositionX&& other) = default; - - explicit ForcePositionX(rerun::blueprint::components::ForcePositionX _force) - : force(std::move(_force)) {} - }; - -} // namespace rerun::blueprint::archetypes - -namespace rerun { - /// \private - template - struct AsComponents; - - /// \private - template <> - struct AsComponents { - /// Serialize all set component batches. - static Result> serialize( - const blueprint::archetypes::ForcePositionX& archetype - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.cpp deleted file mode 100644 index ac49a68111ef..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs". - -#include "force_position_y.hpp" - -#include "../../collection_adapter_builtins.hpp" - -namespace rerun::blueprint::archetypes {} - -namespace rerun { - - Result> - AsComponents::serialize( - const blueprint::archetypes::ForcePositionY& archetype - ) { - using namespace blueprint::archetypes; - std::vector cells; - cells.reserve(2); - - { - auto result = ComponentBatch::from_loggable(archetype.force); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - { - auto indicator = ForcePositionY::IndicatorComponent(); - auto result = ComponentBatch::from_loggable(indicator); - RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value)); - } - - return cells; - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.hpp deleted file mode 100644 index ba89592584fb..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_position_y.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs". - -#pragma once - -#include "../../blueprint/components/force_position_y.hpp" -#include "../../collection.hpp" -#include "../../component_batch.hpp" -#include "../../indicator_component.hpp" -#include "../../result.hpp" - -#include -#include -#include - -namespace rerun::blueprint::archetypes { - struct ForcePositionY { - rerun::blueprint::components::ForcePositionY force; - - public: - static constexpr const char IndicatorComponentName[] = - "rerun.blueprint.components.ForcePositionYIndicator"; - - /// Indicator component, used to identify the archetype when converting to a list of components. - using IndicatorComponent = rerun::components::IndicatorComponent; - - public: - ForcePositionY() = default; - ForcePositionY(ForcePositionY&& other) = default; - - explicit ForcePositionY(rerun::blueprint::components::ForcePositionY _force) - : force(std::move(_force)) {} - }; - -} // namespace rerun::blueprint::archetypes - -namespace rerun { - /// \private - template - struct AsComponents; - - /// \private - template <> - struct AsComponents { - /// Serialize all set component batches. - static Result> serialize( - const blueprint::archetypes::ForcePositionY& archetype - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index 09168647a239..e426e3a2b486 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -13,13 +13,6 @@ #include "blueprint/components/corner2d.hpp" #include "blueprint/components/filter_by_range.hpp" #include "blueprint/components/filter_is_not_null.hpp" -#include "blueprint/components/force_center.hpp" -#include "blueprint/components/force_collide_radius.hpp" -#include "blueprint/components/force_layout_simulation.hpp" -#include "blueprint/components/force_link.hpp" -#include "blueprint/components/force_many_body.hpp" -#include "blueprint/components/force_position_x.hpp" -#include "blueprint/components/force_position_y.hpp" #include "blueprint/components/grid_columns.hpp" #include "blueprint/components/included_content.hpp" #include "blueprint/components/interactive.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index f1d66bcda829..7b2410956aec 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -15,13 +15,6 @@ corner2d.cpp linguist-generated=true corner2d.hpp linguist-generated=true filter_by_range.hpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true -force_center.hpp linguist-generated=true -force_collide_radius.hpp linguist-generated=true -force_layout_simulation.hpp linguist-generated=true -force_link.hpp linguist-generated=true -force_many_body.hpp linguist-generated=true -force_position_x.hpp linguist-generated=true -force_position_y.hpp linguist-generated=true grid_columns.hpp linguist-generated=true included_content.hpp linguist-generated=true interactive.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/force_center.hpp b/rerun_cpp/src/rerun/blueprint/components/force_center.hpp deleted file mode 100644 index 03f2cbe5c30c..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/force_center.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs". - -#pragma once - -#include "../../blueprint/datatypes/force_center.hpp" -#include "../../result.hpp" - -#include -#include - -namespace rerun::blueprint::components { - struct ForceCenter { - rerun::blueprint::datatypes::ForceCenter center; - - public: - ForceCenter() = default; - - ForceCenter(rerun::blueprint::datatypes::ForceCenter center_) : center(center_) {} - - ForceCenter& operator=(rerun::blueprint::datatypes::ForceCenter center_) { - center = center_; - return *this; - } - - /// Cast to the underlying ForceCenter datatype - operator rerun::blueprint::datatypes::ForceCenter() const { - return center; - } - }; -} // namespace rerun::blueprint::components - -namespace rerun { - static_assert( - sizeof(rerun::blueprint::datatypes::ForceCenter) == - sizeof(blueprint::components::ForceCenter) - ); - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForceCenter"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype() { - return Loggable::arrow_datatype(); - } - - /// Serializes an array of `rerun::blueprint:: components::ForceCenter` into an arrow array. - static Result> to_arrow( - const blueprint::components::ForceCenter* instances, size_t num_instances - ) { - if (num_instances == 0) { - return Loggable::to_arrow(nullptr, 0); - } else if (instances == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Passed array instances is null when num_elements> 0." - ); - } else { - return Loggable::to_arrow( - &instances->center, - num_instances - ); - } - } - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_collide_radius.hpp b/rerun_cpp/src/rerun/blueprint/components/force_collide_radius.hpp deleted file mode 100644 index c500504ad0c3..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/force_collide_radius.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs". - -#pragma once - -#include "../../blueprint/datatypes/force_collide_radius.hpp" -#include "../../result.hpp" - -#include -#include - -namespace rerun::blueprint::components { - struct ForceCollideRadius { - rerun::blueprint::datatypes::ForceCollideRadius center; - - public: - ForceCollideRadius() = default; - - ForceCollideRadius(rerun::blueprint::datatypes::ForceCollideRadius center_) - : center(center_) {} - - ForceCollideRadius& operator=(rerun::blueprint::datatypes::ForceCollideRadius center_) { - center = center_; - return *this; - } - - /// Cast to the underlying ForceCollideRadius datatype - operator rerun::blueprint::datatypes::ForceCollideRadius() const { - return center; - } - }; -} // namespace rerun::blueprint::components - -namespace rerun { - static_assert( - sizeof(rerun::blueprint::datatypes::ForceCollideRadius) == - sizeof(blueprint::components::ForceCollideRadius) - ); - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForceCollideRadius"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype() { - return Loggable::arrow_datatype(); - } - - /// Serializes an array of `rerun::blueprint:: components::ForceCollideRadius` into an arrow array. - static Result> to_arrow( - const blueprint::components::ForceCollideRadius* instances, size_t num_instances - ) { - if (num_instances == 0) { - return Loggable::to_arrow( - nullptr, - 0 - ); - } else if (instances == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Passed array instances is null when num_elements> 0." - ); - } else { - return Loggable::to_arrow( - &instances->center, - num_instances - ); - } - } - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_layout_simulation.hpp b/rerun_cpp/src/rerun/blueprint/components/force_layout_simulation.hpp deleted file mode 100644 index 508dcfcd606a..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/force_layout_simulation.hpp +++ /dev/null @@ -1,74 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs". - -#pragma once - -#include "../../blueprint/datatypes/force_layout_simulation.hpp" -#include "../../result.hpp" - -#include -#include - -namespace rerun::blueprint::components { - struct ForceLayoutSimulation { - rerun::blueprint::datatypes::ForceLayoutSimulation simulation; - - public: - ForceLayoutSimulation() = default; - - ForceLayoutSimulation(rerun::blueprint::datatypes::ForceLayoutSimulation simulation_) - : simulation(simulation_) {} - - ForceLayoutSimulation& operator=( - rerun::blueprint::datatypes::ForceLayoutSimulation simulation_ - ) { - simulation = simulation_; - return *this; - } - - /// Cast to the underlying ForceLayoutSimulation datatype - operator rerun::blueprint::datatypes::ForceLayoutSimulation() const { - return simulation; - } - }; -} // namespace rerun::blueprint::components - -namespace rerun { - static_assert( - sizeof(rerun::blueprint::datatypes::ForceLayoutSimulation) == - sizeof(blueprint::components::ForceLayoutSimulation) - ); - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForceLayoutSimulation"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype() { - return Loggable::arrow_datatype(); - } - - /// Serializes an array of `rerun::blueprint:: components::ForceLayoutSimulation` into an arrow array. - static Result> to_arrow( - const blueprint::components::ForceLayoutSimulation* instances, size_t num_instances - ) { - if (num_instances == 0) { - return Loggable::to_arrow( - nullptr, - 0 - ); - } else if (instances == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Passed array instances is null when num_elements> 0." - ); - } else { - return Loggable::to_arrow( - &instances->simulation, - num_instances - ); - } - } - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_link.hpp b/rerun_cpp/src/rerun/blueprint/components/force_link.hpp deleted file mode 100644 index 417be516ba2e..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/force_link.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs". - -#pragma once - -#include "../../blueprint/datatypes/force_link.hpp" -#include "../../result.hpp" - -#include -#include - -namespace rerun::blueprint::components { - struct ForceLink { - rerun::blueprint::datatypes::ForceLink center; - - public: - ForceLink() = default; - - ForceLink(rerun::blueprint::datatypes::ForceLink center_) : center(center_) {} - - ForceLink& operator=(rerun::blueprint::datatypes::ForceLink center_) { - center = center_; - return *this; - } - - /// Cast to the underlying ForceLink datatype - operator rerun::blueprint::datatypes::ForceLink() const { - return center; - } - }; -} // namespace rerun::blueprint::components - -namespace rerun { - static_assert( - sizeof(rerun::blueprint::datatypes::ForceLink) == sizeof(blueprint::components::ForceLink) - ); - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForceLink"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype() { - return Loggable::arrow_datatype(); - } - - /// Serializes an array of `rerun::blueprint:: components::ForceLink` into an arrow array. - static Result> to_arrow( - const blueprint::components::ForceLink* instances, size_t num_instances - ) { - if (num_instances == 0) { - return Loggable::to_arrow(nullptr, 0); - } else if (instances == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Passed array instances is null when num_elements> 0." - ); - } else { - return Loggable::to_arrow( - &instances->center, - num_instances - ); - } - } - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/components/force_many_body.hpp deleted file mode 100644 index b5bf4499713e..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/force_many_body.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs". - -#pragma once - -#include "../../blueprint/datatypes/force_many_body.hpp" -#include "../../result.hpp" - -#include -#include - -namespace rerun::blueprint::components { - struct ForceManyBody { - rerun::blueprint::datatypes::ForceManyBody center; - - public: - ForceManyBody() = default; - - ForceManyBody(rerun::blueprint::datatypes::ForceManyBody center_) : center(center_) {} - - ForceManyBody& operator=(rerun::blueprint::datatypes::ForceManyBody center_) { - center = center_; - return *this; - } - - /// Cast to the underlying ForceManyBody datatype - operator rerun::blueprint::datatypes::ForceManyBody() const { - return center; - } - }; -} // namespace rerun::blueprint::components - -namespace rerun { - static_assert( - sizeof(rerun::blueprint::datatypes::ForceManyBody) == - sizeof(blueprint::components::ForceManyBody) - ); - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForceManyBody"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype() { - return Loggable::arrow_datatype(); - } - - /// Serializes an array of `rerun::blueprint:: components::ForceManyBody` into an arrow array. - static Result> to_arrow( - const blueprint::components::ForceManyBody* instances, size_t num_instances - ) { - if (num_instances == 0) { - return Loggable::to_arrow(nullptr, 0); - } else if (instances == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Passed array instances is null when num_elements> 0." - ); - } else { - return Loggable::to_arrow( - &instances->center, - num_instances - ); - } - } - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_position_x.hpp b/rerun_cpp/src/rerun/blueprint/components/force_position_x.hpp deleted file mode 100644 index 3860416cc4eb..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/force_position_x.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs". - -#pragma once - -#include "../../blueprint/datatypes/force_position_x.hpp" -#include "../../result.hpp" - -#include -#include - -namespace rerun::blueprint::components { - struct ForcePositionX { - rerun::blueprint::datatypes::ForcePositionX position_x; - - public: - ForcePositionX() = default; - - ForcePositionX(rerun::blueprint::datatypes::ForcePositionX position_x_) - : position_x(position_x_) {} - - ForcePositionX& operator=(rerun::blueprint::datatypes::ForcePositionX position_x_) { - position_x = position_x_; - return *this; - } - - /// Cast to the underlying ForcePositionX datatype - operator rerun::blueprint::datatypes::ForcePositionX() const { - return position_x; - } - }; -} // namespace rerun::blueprint::components - -namespace rerun { - static_assert( - sizeof(rerun::blueprint::datatypes::ForcePositionX) == - sizeof(blueprint::components::ForcePositionX) - ); - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForcePositionX"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype() { - return Loggable::arrow_datatype(); - } - - /// Serializes an array of `rerun::blueprint:: components::ForcePositionX` into an arrow array. - static Result> to_arrow( - const blueprint::components::ForcePositionX* instances, size_t num_instances - ) { - if (num_instances == 0) { - return Loggable::to_arrow(nullptr, 0); - } else if (instances == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Passed array instances is null when num_elements> 0." - ); - } else { - return Loggable::to_arrow( - &instances->position_x, - num_instances - ); - } - } - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_position_y.hpp b/rerun_cpp/src/rerun/blueprint/components/force_position_y.hpp deleted file mode 100644 index 9c73322b5e55..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/force_position_y.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs". - -#pragma once - -#include "../../blueprint/datatypes/force_position_y.hpp" -#include "../../result.hpp" - -#include -#include - -namespace rerun::blueprint::components { - struct ForcePositionY { - rerun::blueprint::datatypes::ForcePositionY position_y; - - public: - ForcePositionY() = default; - - ForcePositionY(rerun::blueprint::datatypes::ForcePositionY position_y_) - : position_y(position_y_) {} - - ForcePositionY& operator=(rerun::blueprint::datatypes::ForcePositionY position_y_) { - position_y = position_y_; - return *this; - } - - /// Cast to the underlying ForcePositionY datatype - operator rerun::blueprint::datatypes::ForcePositionY() const { - return position_y; - } - }; -} // namespace rerun::blueprint::components - -namespace rerun { - static_assert( - sizeof(rerun::blueprint::datatypes::ForcePositionY) == - sizeof(blueprint::components::ForcePositionY) - ); - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForcePositionY"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype() { - return Loggable::arrow_datatype(); - } - - /// Serializes an array of `rerun::blueprint:: components::ForcePositionY` into an arrow array. - static Result> to_arrow( - const blueprint::components::ForcePositionY* instances, size_t num_instances - ) { - if (num_instances == 0) { - return Loggable::to_arrow(nullptr, 0); - } else if (instances == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Passed array instances is null when num_elements> 0." - ); - } else { - return Loggable::to_arrow( - &instances->position_y, - num_instances - ); - } - } - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes.hpp b/rerun_cpp/src/rerun/blueprint/datatypes.hpp index 03500c81543f..81af1dca9c44 100644 --- a/rerun_cpp/src/rerun/blueprint/datatypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/datatypes.hpp @@ -5,13 +5,6 @@ #include "blueprint/datatypes/component_column_selector.hpp" #include "blueprint/datatypes/filter_by_range.hpp" #include "blueprint/datatypes/filter_is_not_null.hpp" -#include "blueprint/datatypes/force_center.hpp" -#include "blueprint/datatypes/force_collide_radius.hpp" -#include "blueprint/datatypes/force_layout_simulation.hpp" -#include "blueprint/datatypes/force_link.hpp" -#include "blueprint/datatypes/force_many_body.hpp" -#include "blueprint/datatypes/force_position_x.hpp" -#include "blueprint/datatypes/force_position_y.hpp" #include "blueprint/datatypes/selected_columns.hpp" #include "blueprint/datatypes/tensor_dimension_index_slider.hpp" #include "blueprint/datatypes/utf8list.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes index a1b5cb42ff4a..830bee9eb52e 100644 --- a/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/datatypes/.gitattributes @@ -7,20 +7,6 @@ filter_by_range.cpp linguist-generated=true filter_by_range.hpp linguist-generated=true filter_is_not_null.cpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true -force_center.cpp linguist-generated=true -force_center.hpp linguist-generated=true -force_collide_radius.cpp linguist-generated=true -force_collide_radius.hpp linguist-generated=true -force_layout_simulation.cpp linguist-generated=true -force_layout_simulation.hpp linguist-generated=true -force_link.cpp linguist-generated=true -force_link.hpp linguist-generated=true -force_many_body.cpp linguist-generated=true -force_many_body.hpp linguist-generated=true -force_position_x.cpp linguist-generated=true -force_position_x.hpp linguist-generated=true -force_position_y.cpp linguist-generated=true -force_position_y.hpp linguist-generated=true selected_columns.cpp linguist-generated=true selected_columns.hpp linguist-generated=true tensor_dimension_index_slider.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_center.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_center.cpp deleted file mode 100644 index 6a8eecd1ac59..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_center.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs". - -#include "force_center.hpp" - -#include -#include - -namespace rerun::blueprint::datatypes {} - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::struct_({ - arrow::field("enabled", arrow::boolean(), false), - arrow::field("x", arrow::float64(), false), - arrow::field("y", arrow::float64(), false), - arrow::field("strength", arrow::float64(), false), - }); - return datatype; - } - - Result> Loggable::to_arrow( - const blueprint::datatypes::ForceCenter* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - )); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceCenter* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - { - auto field_builder = static_cast(builder->field_builder(0)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); - } - } - { - auto field_builder = static_cast(builder->field_builder(1)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].x)); - } - } - { - auto field_builder = static_cast(builder->field_builder(2)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].y)); - } - } - { - auto field_builder = static_cast(builder->field_builder(3)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); - } - } - ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_center.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_center.hpp deleted file mode 100644 index 6dc2faa4807b..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_center.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs". - -#pragma once - -#include "../../result.hpp" - -#include -#include - -namespace arrow { - class Array; - class DataType; - class StructBuilder; -} // namespace arrow - -namespace rerun::blueprint::datatypes { - /// **Datatype**: Defines a force that globally centers a graph by moving its center of mass towards a given position. - struct ForceCenter { - /// Whether the force is enabled. - bool enabled; - - /// The `x` position to pull nodes towards. - double x; - - /// The `y` position to pull nodes towards. - double y; - - /// The strength of the force. - double strength; - - public: - ForceCenter() = default; - }; -} // namespace rerun::blueprint::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceCenter"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::blueprint:: datatypes::ForceCenter` into an arrow array. - static Result> to_arrow( - const blueprint::datatypes::ForceCenter* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceCenter* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.cpp deleted file mode 100644 index 47e16a5300cb..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs". - -#include "force_collide_radius.hpp" - -#include -#include - -namespace rerun::blueprint::datatypes {} - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::struct_({ - arrow::field("enabled", arrow::boolean(), false), - arrow::field("iterations", arrow::uint32(), false), - arrow::field("strength", arrow::float64(), false), - arrow::field("padding", arrow::float64(), false), - }); - return datatype; - } - - Result> - Loggable::to_arrow( - const blueprint::datatypes::ForceCollideRadius* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK( - Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - ) - ); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceCollideRadius* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - { - auto field_builder = static_cast(builder->field_builder(0)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); - } - } - { - auto field_builder = static_cast(builder->field_builder(1)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].iterations)); - } - } - { - auto field_builder = static_cast(builder->field_builder(2)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); - } - } - { - auto field_builder = static_cast(builder->field_builder(3)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].padding)); - } - } - ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.hpp deleted file mode 100644 index 43176631abae..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_collide_radius.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs". - -#pragma once - -#include "../../result.hpp" - -#include -#include - -namespace arrow { - class Array; - class DataType; - class StructBuilder; -} // namespace arrow - -namespace rerun::blueprint::datatypes { - /// **Datatype**: Defines a force that resolves collisions between the radii of `GraphNodes`. - struct ForceCollideRadius { - /// Whether the force is enabled. - bool enabled; - - /// The number of iterations to resolve collisions. - uint32_t iterations; - - /// The strength of the force. - double strength; - - /// An additional padding to apply to each node radius. - double padding; - - public: - ForceCollideRadius() = default; - }; -} // namespace rerun::blueprint::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceCollideRadius"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::blueprint:: datatypes::ForceCollideRadius` into an arrow array. - static Result> to_arrow( - const blueprint::datatypes::ForceCollideRadius* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceCollideRadius* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.cpp deleted file mode 100644 index 6470a2649912..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs". - -#include "force_layout_simulation.hpp" - -#include -#include - -namespace rerun::blueprint::datatypes {} - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::struct_({ - arrow::field("alpha", arrow::float64(), false), - arrow::field("alpha_min", arrow::float64(), false), - arrow::field("alpha_decay", arrow::float64(), false), - arrow::field("alpha_target", arrow::float64(), false), - arrow::field("velocity_decay", arrow::float64(), false), - }); - return datatype; - } - - Result> - Loggable::to_arrow( - const blueprint::datatypes::ForceLayoutSimulation* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK( - Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - ) - ); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceLayoutSimulation* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - { - auto field_builder = static_cast(builder->field_builder(0)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].alpha)); - } - } - { - auto field_builder = static_cast(builder->field_builder(1)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].alpha_min)); - } - } - { - auto field_builder = static_cast(builder->field_builder(2)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].alpha_decay)); - } - } - { - auto field_builder = static_cast(builder->field_builder(3)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].alpha_target)); - } - } - { - auto field_builder = static_cast(builder->field_builder(4)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].velocity_decay)); - } - } - ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.hpp deleted file mode 100644 index a9d33c3edfe3..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_layout_simulation.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs". - -#pragma once - -#include "../../result.hpp" - -#include -#include - -namespace arrow { - class Array; - class DataType; - class StructBuilder; -} // namespace arrow - -namespace rerun::blueprint::datatypes { - /// **Datatype**: The parameters for a force layout simulation. - struct ForceLayoutSimulation { - /// Similar to the the temperature in a simulated annealing algorithm. - double alpha; - - /// If `alpha` drops below this value, the simulation stops. - double alpha_min; - - /// The rate at which `alpha` decreases after each iteration. - double alpha_decay; - - /// The target value for `alpha`, must be in the range `[0, 1]`. - double alpha_target; - - /// Acts as a damping factor for the velocity of nodes. - double velocity_decay; - - public: - ForceLayoutSimulation() = default; - }; -} // namespace rerun::blueprint::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceLayoutSimulation"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::blueprint:: datatypes::ForceLayoutSimulation` into an arrow array. - static Result> to_arrow( - const blueprint::datatypes::ForceLayoutSimulation* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::StructBuilder* builder, - const blueprint::datatypes::ForceLayoutSimulation* elements, size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_link.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_link.cpp deleted file mode 100644 index bb4e33208081..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_link.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs". - -#include "force_link.hpp" - -#include -#include - -namespace rerun::blueprint::datatypes {} - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::struct_({ - arrow::field("enabled", arrow::boolean(), false), - arrow::field("iterations", arrow::uint32(), false), - arrow::field("distance", arrow::float64(), false), - arrow::field("strength", arrow::float64(), false), - }); - return datatype; - } - - Result> Loggable::to_arrow( - const blueprint::datatypes::ForceLink* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - )); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceLink* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - { - auto field_builder = static_cast(builder->field_builder(0)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); - } - } - { - auto field_builder = static_cast(builder->field_builder(1)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].iterations)); - } - } - { - auto field_builder = static_cast(builder->field_builder(2)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].distance)); - } - } - { - auto field_builder = static_cast(builder->field_builder(3)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); - } - } - ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_link.hpp deleted file mode 100644 index 174dd49c9e3a..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_link.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs". - -#pragma once - -#include "../../result.hpp" - -#include -#include - -namespace arrow { - class Array; - class DataType; - class StructBuilder; -} // namespace arrow - -namespace rerun::blueprint::datatypes { - /// **Datatype**: Defines a force that acts similar to a spring between nodes. - struct ForceLink { - /// Whether the force is enabled. - bool enabled; - - /// The number of iterations. - uint32_t iterations; - - /// The distance between nodes at which the force is zero. - double distance; - - /// The strength of the force. - double strength; - - public: - ForceLink() = default; - }; -} // namespace rerun::blueprint::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceLink"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::blueprint:: datatypes::ForceLink` into an arrow array. - static Result> to_arrow( - const blueprint::datatypes::ForceLink* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceLink* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.cpp deleted file mode 100644 index 2e05cff59a49..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs". - -#include "force_many_body.hpp" - -#include -#include - -namespace rerun::blueprint::datatypes {} - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::struct_({ - arrow::field("enabled", arrow::boolean(), false), - arrow::field("strength", arrow::float64(), false), - }); - return datatype; - } - - Result> Loggable::to_arrow( - const blueprint::datatypes::ForceManyBody* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK( - Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - ) - ); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceManyBody* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - { - auto field_builder = static_cast(builder->field_builder(0)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); - } - } - { - auto field_builder = static_cast(builder->field_builder(1)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); - } - } - ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.hpp deleted file mode 100644 index 02ac2e02bfd3..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_many_body.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs". - -#pragma once - -#include "../../result.hpp" - -#include -#include - -namespace arrow { - class Array; - class DataType; - class StructBuilder; -} // namespace arrow - -namespace rerun::blueprint::datatypes { - /// **Datatype**: Defines a force that is similar to an electric charge between nodes. - /// - /// Positive strengths will push nodes apart, while negative strengths will pull nodes together. - struct ForceManyBody { - /// Whether the force is enabled. - bool enabled; - - /// The strength of the force. - double strength; - - public: - ForceManyBody() = default; - }; -} // namespace rerun::blueprint::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.datatypes.ForceManyBody"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::blueprint:: datatypes::ForceManyBody` into an arrow array. - static Result> to_arrow( - const blueprint::datatypes::ForceManyBody* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForceManyBody* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.cpp deleted file mode 100644 index 8e5357464958..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs". - -#include "force_position_x.hpp" - -#include -#include - -namespace rerun::blueprint::datatypes {} - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::struct_({ - arrow::field("enabled", arrow::boolean(), false), - arrow::field("x", arrow::float64(), false), - arrow::field("strength", arrow::float64(), false), - }); - return datatype; - } - - Result> Loggable::to_arrow( - const blueprint::datatypes::ForcePositionX* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK( - Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - ) - ); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForcePositionX* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - { - auto field_builder = static_cast(builder->field_builder(0)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); - } - } - { - auto field_builder = static_cast(builder->field_builder(1)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].x)); - } - } - { - auto field_builder = static_cast(builder->field_builder(2)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); - } - } - ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.hpp deleted file mode 100644 index 18382cea73c9..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_x.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs". - -#pragma once - -#include "../../result.hpp" - -#include -#include - -namespace arrow { - class Array; - class DataType; - class StructBuilder; -} // namespace arrow - -namespace rerun::blueprint::datatypes { - /// **Datatype**: Defines a force that pulls nodes towards an `x` position. - struct ForcePositionX { - /// Whether the force is enabled. - bool enabled; - - /// The `x` position to pull nodes towards. - double x; - - /// The strength of the force. - double strength; - - public: - ForcePositionX() = default; - }; -} // namespace rerun::blueprint::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.datatypes.ForcePositionX"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::blueprint:: datatypes::ForcePositionX` into an arrow array. - static Result> to_arrow( - const blueprint::datatypes::ForcePositionX* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForcePositionX* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.cpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.cpp deleted file mode 100644 index 02a2edf3f0c6..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs". - -#include "force_position_y.hpp" - -#include -#include - -namespace rerun::blueprint::datatypes {} - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::struct_({ - arrow::field("enabled", arrow::boolean(), false), - arrow::field("y", arrow::float64(), false), - arrow::field("strength", arrow::float64(), false), - }); - return datatype; - } - - Result> Loggable::to_arrow( - const blueprint::datatypes::ForcePositionY* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK( - Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - ) - ); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForcePositionY* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - { - auto field_builder = static_cast(builder->field_builder(0)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].enabled)); - } - } - { - auto field_builder = static_cast(builder->field_builder(1)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].y)); - } - } - { - auto field_builder = static_cast(builder->field_builder(2)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].strength)); - } - } - ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.hpp b/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.hpp deleted file mode 100644 index 87e274d236c7..000000000000 --- a/rerun_cpp/src/rerun/blueprint/datatypes/force_position_y.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs". - -#pragma once - -#include "../../result.hpp" - -#include -#include - -namespace arrow { - class Array; - class DataType; - class StructBuilder; -} // namespace arrow - -namespace rerun::blueprint::datatypes { - /// **Datatype**: Defines a force that pulls nodes towards an `y` position. - struct ForcePositionY { - /// Whether the force is enabled. - bool enabled; - - /// The `y` position to pull nodes towards. - double y; - - /// The strength of the force. - double strength; - - public: - ForcePositionY() = default; - }; -} // namespace rerun::blueprint::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.datatypes.ForcePositionY"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::blueprint:: datatypes::ForcePositionY` into an arrow array. - static Result> to_arrow( - const blueprint::datatypes::ForcePositionY* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::StructBuilder* builder, const blueprint::datatypes::ForcePositionY* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index d312b3a88290..bb528bfbaf9a 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -5,13 +5,6 @@ __init__.py linguist-generated=true background.py linguist-generated=true container_blueprint.py linguist-generated=true dataframe_query.py linguist-generated=true -force_center.py linguist-generated=true -force_collide_radius.py linguist-generated=true -force_layout_simulation.py linguist-generated=true -force_link.py linguist-generated=true -force_many_body.py linguist-generated=true -force_position_x.py linguist-generated=true -force_position_y.py linguist-generated=true map_background.py linguist-generated=true map_zoom.py linguist-generated=true panel_blueprint.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py index 7e16a13bd41e..018ec6c34d5e 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -5,13 +5,6 @@ from .background import Background from .container_blueprint import ContainerBlueprint from .dataframe_query import DataframeQuery -from .force_center import ForceCenter -from .force_collide_radius import ForceCollideRadius -from .force_layout_simulation import ForceLayoutSimulation -from .force_link import ForceLink -from .force_many_body import ForceManyBody -from .force_position_x import ForcePositionX -from .force_position_y import ForcePositionY from .map_background import MapBackground from .map_zoom import MapZoom from .panel_blueprint import PanelBlueprint @@ -30,13 +23,6 @@ "Background", "ContainerBlueprint", "DataframeQuery", - "ForceCenter", - "ForceCollideRadius", - "ForceLayoutSimulation", - "ForceLink", - "ForceManyBody", - "ForcePositionX", - "ForcePositionY", "MapBackground", "MapZoom", "PanelBlueprint", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py deleted file mode 100644 index bf70f24175ad..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py +++ /dev/null @@ -1,50 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". - -# You can extend this class by creating a "ForceCenterExt" class in "force_center_ext.py". - -from __future__ import annotations - -from typing import Any - -from attrs import define, field - -from ..._baseclasses import ( - Archetype, -) -from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes -from ...error_utils import catch_and_log_exceptions - -__all__ = ["ForceCenter"] - - -@define(str=False, repr=False, init=False) -class ForceCenter(Archetype): - def __init__(self: Any, force: blueprint_datatypes.ForceCenterLike): - """Create a new instance of the ForceCenter archetype.""" - - # You can define your own __init__ function as a member of ForceCenterExt in force_center_ext.py - with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(force=force) - return - self.__attrs_clear__() - - def __attrs_clear__(self) -> None: - """Convenience method for calling `__attrs_init__` with all `None`s.""" - self.__attrs_init__( - force=None, # type: ignore[arg-type] - ) - - @classmethod - def _clear(cls) -> ForceCenter: - """Produce an empty ForceCenter, bypassing `__init__`.""" - inst = cls.__new__(cls) - inst.__attrs_clear__() - return inst - - force: blueprint_components.ForceCenterBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.ForceCenterBatch._required, # type: ignore[misc] - ) - __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collide_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collide_radius.py deleted file mode 100644 index 8fd581c1358b..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collide_radius.py +++ /dev/null @@ -1,50 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collide_radius.fbs". - -# You can extend this class by creating a "ForceCollideRadiusExt" class in "force_collide_radius_ext.py". - -from __future__ import annotations - -from typing import Any - -from attrs import define, field - -from ..._baseclasses import ( - Archetype, -) -from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes -from ...error_utils import catch_and_log_exceptions - -__all__ = ["ForceCollideRadius"] - - -@define(str=False, repr=False, init=False) -class ForceCollideRadius(Archetype): - def __init__(self: Any, force: blueprint_datatypes.ForceCollideRadiusLike): - """Create a new instance of the ForceCollideRadius archetype.""" - - # You can define your own __init__ function as a member of ForceCollideRadiusExt in force_collide_radius_ext.py - with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(force=force) - return - self.__attrs_clear__() - - def __attrs_clear__(self) -> None: - """Convenience method for calling `__attrs_init__` with all `None`s.""" - self.__attrs_init__( - force=None, # type: ignore[arg-type] - ) - - @classmethod - def _clear(cls) -> ForceCollideRadius: - """Produce an empty ForceCollideRadius, bypassing `__init__`.""" - inst = cls.__new__(cls) - inst.__attrs_clear__() - return inst - - force: blueprint_components.ForceCollideRadiusBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.ForceCollideRadiusBatch._required, # type: ignore[misc] - ) - __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_layout_simulation.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_layout_simulation.py deleted file mode 100644 index 2a95f771ac58..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_layout_simulation.py +++ /dev/null @@ -1,50 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_layout_simulation.fbs". - -# You can extend this class by creating a "ForceLayoutSimulationExt" class in "force_layout_simulation_ext.py". - -from __future__ import annotations - -from typing import Any - -from attrs import define, field - -from ..._baseclasses import ( - Archetype, -) -from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes -from ...error_utils import catch_and_log_exceptions - -__all__ = ["ForceLayoutSimulation"] - - -@define(str=False, repr=False, init=False) -class ForceLayoutSimulation(Archetype): - def __init__(self: Any, simulation: blueprint_datatypes.ForceLayoutSimulationLike): - """Create a new instance of the ForceLayoutSimulation archetype.""" - - # You can define your own __init__ function as a member of ForceLayoutSimulationExt in force_layout_simulation_ext.py - with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(simulation=simulation) - return - self.__attrs_clear__() - - def __attrs_clear__(self) -> None: - """Convenience method for calling `__attrs_init__` with all `None`s.""" - self.__attrs_init__( - simulation=None, # type: ignore[arg-type] - ) - - @classmethod - def _clear(cls) -> ForceLayoutSimulation: - """Produce an empty ForceLayoutSimulation, bypassing `__init__`.""" - inst = cls.__new__(cls) - inst.__attrs_clear__() - return inst - - simulation: blueprint_components.ForceLayoutSimulationBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.ForceLayoutSimulationBatch._required, # type: ignore[misc] - ) - __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py deleted file mode 100644 index 7cdff37aba59..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py +++ /dev/null @@ -1,50 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". - -# You can extend this class by creating a "ForceLinkExt" class in "force_link_ext.py". - -from __future__ import annotations - -from typing import Any - -from attrs import define, field - -from ..._baseclasses import ( - Archetype, -) -from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes -from ...error_utils import catch_and_log_exceptions - -__all__ = ["ForceLink"] - - -@define(str=False, repr=False, init=False) -class ForceLink(Archetype): - def __init__(self: Any, force: blueprint_datatypes.ForceLinkLike): - """Create a new instance of the ForceLink archetype.""" - - # You can define your own __init__ function as a member of ForceLinkExt in force_link_ext.py - with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(force=force) - return - self.__attrs_clear__() - - def __attrs_clear__(self) -> None: - """Convenience method for calling `__attrs_init__` with all `None`s.""" - self.__attrs_init__( - force=None, # type: ignore[arg-type] - ) - - @classmethod - def _clear(cls) -> ForceLink: - """Produce an empty ForceLink, bypassing `__init__`.""" - inst = cls.__new__(cls) - inst.__attrs_clear__() - return inst - - force: blueprint_components.ForceLinkBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.ForceLinkBatch._required, # type: ignore[misc] - ) - __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py deleted file mode 100644 index 0835f93b68ed..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py +++ /dev/null @@ -1,50 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". - -# You can extend this class by creating a "ForceManyBodyExt" class in "force_many_body_ext.py". - -from __future__ import annotations - -from typing import Any - -from attrs import define, field - -from ..._baseclasses import ( - Archetype, -) -from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes -from ...error_utils import catch_and_log_exceptions - -__all__ = ["ForceManyBody"] - - -@define(str=False, repr=False, init=False) -class ForceManyBody(Archetype): - def __init__(self: Any, force: blueprint_datatypes.ForceManyBodyLike): - """Create a new instance of the ForceManyBody archetype.""" - - # You can define your own __init__ function as a member of ForceManyBodyExt in force_many_body_ext.py - with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(force=force) - return - self.__attrs_clear__() - - def __attrs_clear__(self) -> None: - """Convenience method for calling `__attrs_init__` with all `None`s.""" - self.__attrs_init__( - force=None, # type: ignore[arg-type] - ) - - @classmethod - def _clear(cls) -> ForceManyBody: - """Produce an empty ForceManyBody, bypassing `__init__`.""" - inst = cls.__new__(cls) - inst.__attrs_clear__() - return inst - - force: blueprint_components.ForceManyBodyBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.ForceManyBodyBatch._required, # type: ignore[misc] - ) - __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_x.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_x.py deleted file mode 100644 index 24785d5ad001..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_x.py +++ /dev/null @@ -1,50 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_x.fbs". - -# You can extend this class by creating a "ForcePositionXExt" class in "force_position_x_ext.py". - -from __future__ import annotations - -from typing import Any - -from attrs import define, field - -from ..._baseclasses import ( - Archetype, -) -from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes -from ...error_utils import catch_and_log_exceptions - -__all__ = ["ForcePositionX"] - - -@define(str=False, repr=False, init=False) -class ForcePositionX(Archetype): - def __init__(self: Any, force: blueprint_datatypes.ForcePositionXLike): - """Create a new instance of the ForcePositionX archetype.""" - - # You can define your own __init__ function as a member of ForcePositionXExt in force_position_x_ext.py - with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(force=force) - return - self.__attrs_clear__() - - def __attrs_clear__(self) -> None: - """Convenience method for calling `__attrs_init__` with all `None`s.""" - self.__attrs_init__( - force=None, # type: ignore[arg-type] - ) - - @classmethod - def _clear(cls) -> ForcePositionX: - """Produce an empty ForcePositionX, bypassing `__init__`.""" - inst = cls.__new__(cls) - inst.__attrs_clear__() - return inst - - force: blueprint_components.ForcePositionXBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.ForcePositionXBatch._required, # type: ignore[misc] - ) - __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_y.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_y.py deleted file mode 100644 index 155769a5c0a4..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position_y.py +++ /dev/null @@ -1,50 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position_y.fbs". - -# You can extend this class by creating a "ForcePositionYExt" class in "force_position_y_ext.py". - -from __future__ import annotations - -from typing import Any - -from attrs import define, field - -from ..._baseclasses import ( - Archetype, -) -from ...blueprint import components as blueprint_components, datatypes as blueprint_datatypes -from ...error_utils import catch_and_log_exceptions - -__all__ = ["ForcePositionY"] - - -@define(str=False, repr=False, init=False) -class ForcePositionY(Archetype): - def __init__(self: Any, force: blueprint_datatypes.ForcePositionYLike): - """Create a new instance of the ForcePositionY archetype.""" - - # You can define your own __init__ function as a member of ForcePositionYExt in force_position_y_ext.py - with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(force=force) - return - self.__attrs_clear__() - - def __attrs_clear__(self) -> None: - """Convenience method for calling `__attrs_init__` with all `None`s.""" - self.__attrs_init__( - force=None, # type: ignore[arg-type] - ) - - @classmethod - def _clear(cls) -> ForcePositionY: - """Produce an empty ForcePositionY, bypassing `__init__`.""" - inst = cls.__new__(cls) - inst.__attrs_clear__() - return inst - - force: blueprint_components.ForcePositionYBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.ForcePositionYBatch._required, # type: ignore[misc] - ) - __str__ = Archetype.__str__ - __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes index 57a9747e9eca..57164211651c 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -13,13 +13,6 @@ container_kind.py linguist-generated=true corner2d.py linguist-generated=true filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true -force_center.py linguist-generated=true -force_collide_radius.py linguist-generated=true -force_layout_simulation.py linguist-generated=true -force_link.py linguist-generated=true -force_many_body.py linguist-generated=true -force_position_x.py linguist-generated=true -force_position_y.py linguist-generated=true grid_columns.py linguist-generated=true included_content.py linguist-generated=true interactive.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py index 7a954cf6df2d..2f4943b58c8d 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py @@ -13,13 +13,6 @@ from .corner2d import Corner2D, Corner2DArrayLike, Corner2DBatch, Corner2DLike from .filter_by_range import FilterByRange, FilterByRangeBatch from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullBatch -from .force_center import ForceCenter, ForceCenterBatch -from .force_collide_radius import ForceCollideRadius, ForceCollideRadiusBatch -from .force_layout_simulation import ForceLayoutSimulation, ForceLayoutSimulationBatch -from .force_link import ForceLink, ForceLinkBatch -from .force_many_body import ForceManyBody, ForceManyBodyBatch -from .force_position_x import ForcePositionX, ForcePositionXBatch -from .force_position_y import ForcePositionY, ForcePositionYBatch from .grid_columns import GridColumns, GridColumnsBatch from .included_content import IncludedContent, IncludedContentBatch from .interactive import Interactive, InteractiveBatch @@ -72,20 +65,6 @@ "FilterByRangeBatch", "FilterIsNotNull", "FilterIsNotNullBatch", - "ForceCenter", - "ForceCenterBatch", - "ForceCollideRadius", - "ForceCollideRadiusBatch", - "ForceLayoutSimulation", - "ForceLayoutSimulationBatch", - "ForceLink", - "ForceLinkBatch", - "ForceManyBody", - "ForceManyBodyBatch", - "ForcePositionX", - "ForcePositionXBatch", - "ForcePositionY", - "ForcePositionYBatch", "GridColumns", "GridColumnsBatch", "IncludedContent", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_center.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_center.py deleted file mode 100644 index f2c83c40c677..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_center.py +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_center.fbs". - -# You can extend this class by creating a "ForceCenterExt" class in "force_center_ext.py". - -from __future__ import annotations - -from ..._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) -from ...blueprint import datatypes as blueprint_datatypes - -__all__ = ["ForceCenter", "ForceCenterBatch"] - - -class ForceCenter(blueprint_datatypes.ForceCenter, ComponentMixin): - _BATCH_TYPE = None - # You can define your own __init__ function as a member of ForceCenterExt in force_center_ext.py - - # Note: there are no fields here because ForceCenter delegates to datatypes.ForceCenter - pass - - -class ForceCenterBatch(blueprint_datatypes.ForceCenterBatch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForceCenter" - - -# This is patched in late to avoid circular dependencies. -ForceCenter._BATCH_TYPE = ForceCenterBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_collide_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_collide_radius.py deleted file mode 100644 index 2b79b3ffe8ad..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_collide_radius.py +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_collide_radius.fbs". - -# You can extend this class by creating a "ForceCollideRadiusExt" class in "force_collide_radius_ext.py". - -from __future__ import annotations - -from ..._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) -from ...blueprint import datatypes as blueprint_datatypes - -__all__ = ["ForceCollideRadius", "ForceCollideRadiusBatch"] - - -class ForceCollideRadius(blueprint_datatypes.ForceCollideRadius, ComponentMixin): - _BATCH_TYPE = None - # You can define your own __init__ function as a member of ForceCollideRadiusExt in force_collide_radius_ext.py - - # Note: there are no fields here because ForceCollideRadius delegates to datatypes.ForceCollideRadius - pass - - -class ForceCollideRadiusBatch(blueprint_datatypes.ForceCollideRadiusBatch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForceCollideRadius" - - -# This is patched in late to avoid circular dependencies. -ForceCollideRadius._BATCH_TYPE = ForceCollideRadiusBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_layout_simulation.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_layout_simulation.py deleted file mode 100644 index 3b1aec36d313..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_layout_simulation.py +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_layout_simulation.fbs". - -# You can extend this class by creating a "ForceLayoutSimulationExt" class in "force_layout_simulation_ext.py". - -from __future__ import annotations - -from ..._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) -from ...blueprint import datatypes as blueprint_datatypes - -__all__ = ["ForceLayoutSimulation", "ForceLayoutSimulationBatch"] - - -class ForceLayoutSimulation(blueprint_datatypes.ForceLayoutSimulation, ComponentMixin): - _BATCH_TYPE = None - # You can define your own __init__ function as a member of ForceLayoutSimulationExt in force_layout_simulation_ext.py - - # Note: there are no fields here because ForceLayoutSimulation delegates to datatypes.ForceLayoutSimulation - pass - - -class ForceLayoutSimulationBatch(blueprint_datatypes.ForceLayoutSimulationBatch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForceLayoutSimulation" - - -# This is patched in late to avoid circular dependencies. -ForceLayoutSimulation._BATCH_TYPE = ForceLayoutSimulationBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_link.py deleted file mode 100644 index ce5acd58cc90..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_link.py +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_link.fbs". - -# You can extend this class by creating a "ForceLinkExt" class in "force_link_ext.py". - -from __future__ import annotations - -from ..._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) -from ...blueprint import datatypes as blueprint_datatypes - -__all__ = ["ForceLink", "ForceLinkBatch"] - - -class ForceLink(blueprint_datatypes.ForceLink, ComponentMixin): - _BATCH_TYPE = None - # You can define your own __init__ function as a member of ForceLinkExt in force_link_ext.py - - # Note: there are no fields here because ForceLink delegates to datatypes.ForceLink - pass - - -class ForceLinkBatch(blueprint_datatypes.ForceLinkBatch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForceLink" - - -# This is patched in late to avoid circular dependencies. -ForceLink._BATCH_TYPE = ForceLinkBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_many_body.py deleted file mode 100644 index 0fe2779117a3..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_many_body.py +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_many_body.fbs". - -# You can extend this class by creating a "ForceManyBodyExt" class in "force_many_body_ext.py". - -from __future__ import annotations - -from ..._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) -from ...blueprint import datatypes as blueprint_datatypes - -__all__ = ["ForceManyBody", "ForceManyBodyBatch"] - - -class ForceManyBody(blueprint_datatypes.ForceManyBody, ComponentMixin): - _BATCH_TYPE = None - # You can define your own __init__ function as a member of ForceManyBodyExt in force_many_body_ext.py - - # Note: there are no fields here because ForceManyBody delegates to datatypes.ForceManyBody - pass - - -class ForceManyBodyBatch(blueprint_datatypes.ForceManyBodyBatch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForceManyBody" - - -# This is patched in late to avoid circular dependencies. -ForceManyBody._BATCH_TYPE = ForceManyBodyBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_x.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_x.py deleted file mode 100644 index 78561530806b..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_x.py +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_x.fbs". - -# You can extend this class by creating a "ForcePositionXExt" class in "force_position_x_ext.py". - -from __future__ import annotations - -from ..._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) -from ...blueprint import datatypes as blueprint_datatypes - -__all__ = ["ForcePositionX", "ForcePositionXBatch"] - - -class ForcePositionX(blueprint_datatypes.ForcePositionX, ComponentMixin): - _BATCH_TYPE = None - # You can define your own __init__ function as a member of ForcePositionXExt in force_position_x_ext.py - - # Note: there are no fields here because ForcePositionX delegates to datatypes.ForcePositionX - pass - - -class ForcePositionXBatch(blueprint_datatypes.ForcePositionXBatch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForcePositionX" - - -# This is patched in late to avoid circular dependencies. -ForcePositionX._BATCH_TYPE = ForcePositionXBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_y.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_y.py deleted file mode 100644 index b22409fe5b22..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_position_y.py +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_position_y.fbs". - -# You can extend this class by creating a "ForcePositionYExt" class in "force_position_y_ext.py". - -from __future__ import annotations - -from ..._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) -from ...blueprint import datatypes as blueprint_datatypes - -__all__ = ["ForcePositionY", "ForcePositionYBatch"] - - -class ForcePositionY(blueprint_datatypes.ForcePositionY, ComponentMixin): - _BATCH_TYPE = None - # You can define your own __init__ function as a member of ForcePositionYExt in force_position_y_ext.py - - # Note: there are no fields here because ForcePositionY delegates to datatypes.ForcePositionY - pass - - -class ForcePositionYBatch(blueprint_datatypes.ForcePositionYBatch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForcePositionY" - - -# This is patched in late to avoid circular dependencies. -ForcePositionY._BATCH_TYPE = ForcePositionYBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes index 5b6eed2a0d0b..cfee973ea804 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/.gitattributes @@ -5,13 +5,6 @@ __init__.py linguist-generated=true component_column_selector.py linguist-generated=true filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true -force_center.py linguist-generated=true -force_collide_radius.py linguist-generated=true -force_layout_simulation.py linguist-generated=true -force_link.py linguist-generated=true -force_many_body.py linguist-generated=true -force_position_x.py linguist-generated=true -force_position_y.py linguist-generated=true selected_columns.py linguist-generated=true tensor_dimension_index_slider.py linguist-generated=true utf8list.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py index 00137053830d..7672cd09deef 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/__init__.py @@ -10,23 +10,6 @@ ) from .filter_by_range import FilterByRange, FilterByRangeArrayLike, FilterByRangeBatch, FilterByRangeLike from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullArrayLike, FilterIsNotNullBatch, FilterIsNotNullLike -from .force_center import ForceCenter, ForceCenterArrayLike, ForceCenterBatch, ForceCenterLike -from .force_collide_radius import ( - ForceCollideRadius, - ForceCollideRadiusArrayLike, - ForceCollideRadiusBatch, - ForceCollideRadiusLike, -) -from .force_layout_simulation import ( - ForceLayoutSimulation, - ForceLayoutSimulationArrayLike, - ForceLayoutSimulationBatch, - ForceLayoutSimulationLike, -) -from .force_link import ForceLink, ForceLinkArrayLike, ForceLinkBatch, ForceLinkLike -from .force_many_body import ForceManyBody, ForceManyBodyArrayLike, ForceManyBodyBatch, ForceManyBodyLike -from .force_position_x import ForcePositionX, ForcePositionXArrayLike, ForcePositionXBatch, ForcePositionXLike -from .force_position_y import ForcePositionY, ForcePositionYArrayLike, ForcePositionYBatch, ForcePositionYLike from .selected_columns import SelectedColumns, SelectedColumnsArrayLike, SelectedColumnsBatch, SelectedColumnsLike from .tensor_dimension_index_slider import ( TensorDimensionIndexSlider, @@ -49,34 +32,6 @@ "FilterIsNotNullArrayLike", "FilterIsNotNullBatch", "FilterIsNotNullLike", - "ForceCenter", - "ForceCenterArrayLike", - "ForceCenterBatch", - "ForceCenterLike", - "ForceCollideRadius", - "ForceCollideRadiusArrayLike", - "ForceCollideRadiusBatch", - "ForceCollideRadiusLike", - "ForceLayoutSimulation", - "ForceLayoutSimulationArrayLike", - "ForceLayoutSimulationBatch", - "ForceLayoutSimulationLike", - "ForceLink", - "ForceLinkArrayLike", - "ForceLinkBatch", - "ForceLinkLike", - "ForceManyBody", - "ForceManyBodyArrayLike", - "ForceManyBodyBatch", - "ForceManyBodyLike", - "ForcePositionX", - "ForcePositionXArrayLike", - "ForcePositionXBatch", - "ForcePositionXLike", - "ForcePositionY", - "ForcePositionYArrayLike", - "ForcePositionYBatch", - "ForcePositionYLike", "SelectedColumns", "SelectedColumnsArrayLike", "SelectedColumnsBatch", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_center.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_center.py deleted file mode 100644 index 20119782dce4..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_center.py +++ /dev/null @@ -1,94 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_center.fbs". - -# You can extend this class by creating a "ForceCenterExt" class in "force_center_ext.py". - -from __future__ import annotations - -from typing import Any, Sequence, Union - -import numpy as np -import pyarrow as pa -from attrs import define, field - -from ..._baseclasses import ( - BaseBatch, -) - -__all__ = ["ForceCenter", "ForceCenterArrayLike", "ForceCenterBatch", "ForceCenterLike"] - - -@define(init=False) -class ForceCenter: - """**Datatype**: Defines a force that globally centers a graph by moving its center of mass towards a given position.""" - - def __init__(self: Any, enabled: bool, x: float, y: float, strength: float): - """ - Create a new instance of the ForceCenter datatype. - - Parameters - ---------- - enabled: - Whether the force is enabled. - x: - The `x` position to pull nodes towards. - y: - The `y` position to pull nodes towards. - strength: - The strength of the force. - - """ - - # You can define your own __init__ function as a member of ForceCenterExt in force_center_ext.py - self.__attrs_init__(enabled=enabled, x=x, y=y, strength=strength) - - enabled: bool = field(converter=bool) - # Whether the force is enabled. - # - # (Docstring intentionally commented out to hide this field from the docs) - - x: float = field(converter=float) - # The `x` position to pull nodes towards. - # - # (Docstring intentionally commented out to hide this field from the docs) - - y: float = field(converter=float) - # The `y` position to pull nodes towards. - # - # (Docstring intentionally commented out to hide this field from the docs) - - strength: float = field(converter=float) - # The strength of the force. - # - # (Docstring intentionally commented out to hide this field from the docs) - - -ForceCenterLike = ForceCenter -ForceCenterArrayLike = Union[ - ForceCenter, - Sequence[ForceCenterLike], -] - - -class ForceCenterBatch(BaseBatch[ForceCenterArrayLike]): - _ARROW_DATATYPE = pa.struct([ - pa.field("enabled", pa.bool_(), nullable=False, metadata={}), - pa.field("x", pa.float64(), nullable=False, metadata={}), - pa.field("y", pa.float64(), nullable=False, metadata={}), - pa.field("strength", pa.float64(), nullable=False, metadata={}), - ]) - - @staticmethod - def _native_to_pa_array(data: ForceCenterArrayLike, data_type: pa.DataType) -> pa.Array: - if isinstance(data, ForceCenter): - data = [data] - - return pa.StructArray.from_arrays( - [ - pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), - pa.array(np.asarray([x.x for x in data], dtype=np.float64)), - pa.array(np.asarray([x.y for x in data], dtype=np.float64)), - pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), - ], - fields=list(data_type), - ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_collide_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_collide_radius.py deleted file mode 100644 index b1c08cd0fc9e..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_collide_radius.py +++ /dev/null @@ -1,94 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_collide_radius.fbs". - -# You can extend this class by creating a "ForceCollideRadiusExt" class in "force_collide_radius_ext.py". - -from __future__ import annotations - -from typing import Any, Sequence, Union - -import numpy as np -import pyarrow as pa -from attrs import define, field - -from ..._baseclasses import ( - BaseBatch, -) - -__all__ = ["ForceCollideRadius", "ForceCollideRadiusArrayLike", "ForceCollideRadiusBatch", "ForceCollideRadiusLike"] - - -@define(init=False) -class ForceCollideRadius: - """**Datatype**: Defines a force that resolves collisions between the radii of `GraphNodes`.""" - - def __init__(self: Any, enabled: bool, iterations: int, strength: float, padding: float): - """ - Create a new instance of the ForceCollideRadius datatype. - - Parameters - ---------- - enabled: - Whether the force is enabled. - iterations: - The number of iterations to resolve collisions. - strength: - The strength of the force. - padding: - An additional padding to apply to each node radius. - - """ - - # You can define your own __init__ function as a member of ForceCollideRadiusExt in force_collide_radius_ext.py - self.__attrs_init__(enabled=enabled, iterations=iterations, strength=strength, padding=padding) - - enabled: bool = field(converter=bool) - # Whether the force is enabled. - # - # (Docstring intentionally commented out to hide this field from the docs) - - iterations: int = field(converter=int) - # The number of iterations to resolve collisions. - # - # (Docstring intentionally commented out to hide this field from the docs) - - strength: float = field(converter=float) - # The strength of the force. - # - # (Docstring intentionally commented out to hide this field from the docs) - - padding: float = field(converter=float) - # An additional padding to apply to each node radius. - # - # (Docstring intentionally commented out to hide this field from the docs) - - -ForceCollideRadiusLike = ForceCollideRadius -ForceCollideRadiusArrayLike = Union[ - ForceCollideRadius, - Sequence[ForceCollideRadiusLike], -] - - -class ForceCollideRadiusBatch(BaseBatch[ForceCollideRadiusArrayLike]): - _ARROW_DATATYPE = pa.struct([ - pa.field("enabled", pa.bool_(), nullable=False, metadata={}), - pa.field("iterations", pa.uint32(), nullable=False, metadata={}), - pa.field("strength", pa.float64(), nullable=False, metadata={}), - pa.field("padding", pa.float64(), nullable=False, metadata={}), - ]) - - @staticmethod - def _native_to_pa_array(data: ForceCollideRadiusArrayLike, data_type: pa.DataType) -> pa.Array: - if isinstance(data, ForceCollideRadius): - data = [data] - - return pa.StructArray.from_arrays( - [ - pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), - pa.array(np.asarray([x.iterations for x in data], dtype=np.uint32)), - pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), - pa.array(np.asarray([x.padding for x in data], dtype=np.float64)), - ], - fields=list(data_type), - ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_layout_simulation.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_layout_simulation.py deleted file mode 100644 index e9e877da0dc2..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_layout_simulation.py +++ /dev/null @@ -1,116 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_layout_simulation.fbs". - -# You can extend this class by creating a "ForceLayoutSimulationExt" class in "force_layout_simulation_ext.py". - -from __future__ import annotations - -from typing import Any, Sequence, Union - -import numpy as np -import pyarrow as pa -from attrs import define, field - -from ..._baseclasses import ( - BaseBatch, -) - -__all__ = [ - "ForceLayoutSimulation", - "ForceLayoutSimulationArrayLike", - "ForceLayoutSimulationBatch", - "ForceLayoutSimulationLike", -] - - -@define(init=False) -class ForceLayoutSimulation: - """**Datatype**: The parameters for a force layout simulation.""" - - def __init__( - self: Any, alpha: float, alpha_min: float, alpha_decay: float, alpha_target: float, velocity_decay: float - ): - """ - Create a new instance of the ForceLayoutSimulation datatype. - - Parameters - ---------- - alpha: - Similar to the the temperature in a simulated annealing algorithm. - alpha_min: - If `alpha` drops below this value, the simulation stops. - alpha_decay: - The rate at which `alpha` decreases after each iteration. - alpha_target: - The target value for `alpha`, must be in the range `[0, 1]`. - velocity_decay: - Acts as a damping factor for the velocity of nodes. - - """ - - # You can define your own __init__ function as a member of ForceLayoutSimulationExt in force_layout_simulation_ext.py - self.__attrs_init__( - alpha=alpha, - alpha_min=alpha_min, - alpha_decay=alpha_decay, - alpha_target=alpha_target, - velocity_decay=velocity_decay, - ) - - alpha: float = field(converter=float) - # Similar to the the temperature in a simulated annealing algorithm. - # - # (Docstring intentionally commented out to hide this field from the docs) - - alpha_min: float = field(converter=float) - # If `alpha` drops below this value, the simulation stops. - # - # (Docstring intentionally commented out to hide this field from the docs) - - alpha_decay: float = field(converter=float) - # The rate at which `alpha` decreases after each iteration. - # - # (Docstring intentionally commented out to hide this field from the docs) - - alpha_target: float = field(converter=float) - # The target value for `alpha`, must be in the range `[0, 1]`. - # - # (Docstring intentionally commented out to hide this field from the docs) - - velocity_decay: float = field(converter=float) - # Acts as a damping factor for the velocity of nodes. - # - # (Docstring intentionally commented out to hide this field from the docs) - - -ForceLayoutSimulationLike = ForceLayoutSimulation -ForceLayoutSimulationArrayLike = Union[ - ForceLayoutSimulation, - Sequence[ForceLayoutSimulationLike], -] - - -class ForceLayoutSimulationBatch(BaseBatch[ForceLayoutSimulationArrayLike]): - _ARROW_DATATYPE = pa.struct([ - pa.field("alpha", pa.float64(), nullable=False, metadata={}), - pa.field("alpha_min", pa.float64(), nullable=False, metadata={}), - pa.field("alpha_decay", pa.float64(), nullable=False, metadata={}), - pa.field("alpha_target", pa.float64(), nullable=False, metadata={}), - pa.field("velocity_decay", pa.float64(), nullable=False, metadata={}), - ]) - - @staticmethod - def _native_to_pa_array(data: ForceLayoutSimulationArrayLike, data_type: pa.DataType) -> pa.Array: - if isinstance(data, ForceLayoutSimulation): - data = [data] - - return pa.StructArray.from_arrays( - [ - pa.array(np.asarray([x.alpha for x in data], dtype=np.float64)), - pa.array(np.asarray([x.alpha_min for x in data], dtype=np.float64)), - pa.array(np.asarray([x.alpha_decay for x in data], dtype=np.float64)), - pa.array(np.asarray([x.alpha_target for x in data], dtype=np.float64)), - pa.array(np.asarray([x.velocity_decay for x in data], dtype=np.float64)), - ], - fields=list(data_type), - ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_link.py deleted file mode 100644 index 5ed1d31a1e11..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_link.py +++ /dev/null @@ -1,94 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_link.fbs". - -# You can extend this class by creating a "ForceLinkExt" class in "force_link_ext.py". - -from __future__ import annotations - -from typing import Any, Sequence, Union - -import numpy as np -import pyarrow as pa -from attrs import define, field - -from ..._baseclasses import ( - BaseBatch, -) - -__all__ = ["ForceLink", "ForceLinkArrayLike", "ForceLinkBatch", "ForceLinkLike"] - - -@define(init=False) -class ForceLink: - """**Datatype**: Defines a force that acts similar to a spring between nodes.""" - - def __init__(self: Any, enabled: bool, iterations: int, distance: float, strength: float): - """ - Create a new instance of the ForceLink datatype. - - Parameters - ---------- - enabled: - Whether the force is enabled. - iterations: - The number of iterations. - distance: - The distance between nodes at which the force is zero. - strength: - The strength of the force. - - """ - - # You can define your own __init__ function as a member of ForceLinkExt in force_link_ext.py - self.__attrs_init__(enabled=enabled, iterations=iterations, distance=distance, strength=strength) - - enabled: bool = field(converter=bool) - # Whether the force is enabled. - # - # (Docstring intentionally commented out to hide this field from the docs) - - iterations: int = field(converter=int) - # The number of iterations. - # - # (Docstring intentionally commented out to hide this field from the docs) - - distance: float = field(converter=float) - # The distance between nodes at which the force is zero. - # - # (Docstring intentionally commented out to hide this field from the docs) - - strength: float = field(converter=float) - # The strength of the force. - # - # (Docstring intentionally commented out to hide this field from the docs) - - -ForceLinkLike = ForceLink -ForceLinkArrayLike = Union[ - ForceLink, - Sequence[ForceLinkLike], -] - - -class ForceLinkBatch(BaseBatch[ForceLinkArrayLike]): - _ARROW_DATATYPE = pa.struct([ - pa.field("enabled", pa.bool_(), nullable=False, metadata={}), - pa.field("iterations", pa.uint32(), nullable=False, metadata={}), - pa.field("distance", pa.float64(), nullable=False, metadata={}), - pa.field("strength", pa.float64(), nullable=False, metadata={}), - ]) - - @staticmethod - def _native_to_pa_array(data: ForceLinkArrayLike, data_type: pa.DataType) -> pa.Array: - if isinstance(data, ForceLink): - data = [data] - - return pa.StructArray.from_arrays( - [ - pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), - pa.array(np.asarray([x.iterations for x in data], dtype=np.uint32)), - pa.array(np.asarray([x.distance for x in data], dtype=np.float64)), - pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), - ], - fields=list(data_type), - ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_many_body.py deleted file mode 100644 index 928919303928..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_many_body.py +++ /dev/null @@ -1,80 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_many_body.fbs". - -# You can extend this class by creating a "ForceManyBodyExt" class in "force_many_body_ext.py". - -from __future__ import annotations - -from typing import Any, Sequence, Union - -import numpy as np -import pyarrow as pa -from attrs import define, field - -from ..._baseclasses import ( - BaseBatch, -) - -__all__ = ["ForceManyBody", "ForceManyBodyArrayLike", "ForceManyBodyBatch", "ForceManyBodyLike"] - - -@define(init=False) -class ForceManyBody: - """ - **Datatype**: Defines a force that is similar to an electric charge between nodes. - - Positive strengths will push nodes apart, while negative strengths will pull nodes together. - """ - - def __init__(self: Any, enabled: bool, strength: float): - """ - Create a new instance of the ForceManyBody datatype. - - Parameters - ---------- - enabled: - Whether the force is enabled. - strength: - The strength of the force. - - """ - - # You can define your own __init__ function as a member of ForceManyBodyExt in force_many_body_ext.py - self.__attrs_init__(enabled=enabled, strength=strength) - - enabled: bool = field(converter=bool) - # Whether the force is enabled. - # - # (Docstring intentionally commented out to hide this field from the docs) - - strength: float = field(converter=float) - # The strength of the force. - # - # (Docstring intentionally commented out to hide this field from the docs) - - -ForceManyBodyLike = ForceManyBody -ForceManyBodyArrayLike = Union[ - ForceManyBody, - Sequence[ForceManyBodyLike], -] - - -class ForceManyBodyBatch(BaseBatch[ForceManyBodyArrayLike]): - _ARROW_DATATYPE = pa.struct([ - pa.field("enabled", pa.bool_(), nullable=False, metadata={}), - pa.field("strength", pa.float64(), nullable=False, metadata={}), - ]) - - @staticmethod - def _native_to_pa_array(data: ForceManyBodyArrayLike, data_type: pa.DataType) -> pa.Array: - if isinstance(data, ForceManyBody): - data = [data] - - return pa.StructArray.from_arrays( - [ - pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), - pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), - ], - fields=list(data_type), - ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_x.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_x.py deleted file mode 100644 index 3b3f9a8e7a17..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_x.py +++ /dev/null @@ -1,85 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_x.fbs". - -# You can extend this class by creating a "ForcePositionXExt" class in "force_position_x_ext.py". - -from __future__ import annotations - -from typing import Any, Sequence, Union - -import numpy as np -import pyarrow as pa -from attrs import define, field - -from ..._baseclasses import ( - BaseBatch, -) - -__all__ = ["ForcePositionX", "ForcePositionXArrayLike", "ForcePositionXBatch", "ForcePositionXLike"] - - -@define(init=False) -class ForcePositionX: - """**Datatype**: Defines a force that pulls nodes towards an `x` position.""" - - def __init__(self: Any, enabled: bool, x: float, strength: float): - """ - Create a new instance of the ForcePositionX datatype. - - Parameters - ---------- - enabled: - Whether the force is enabled. - x: - The `x` position to pull nodes towards. - strength: - The strength of the force. - - """ - - # You can define your own __init__ function as a member of ForcePositionXExt in force_position_x_ext.py - self.__attrs_init__(enabled=enabled, x=x, strength=strength) - - enabled: bool = field(converter=bool) - # Whether the force is enabled. - # - # (Docstring intentionally commented out to hide this field from the docs) - - x: float = field(converter=float) - # The `x` position to pull nodes towards. - # - # (Docstring intentionally commented out to hide this field from the docs) - - strength: float = field(converter=float) - # The strength of the force. - # - # (Docstring intentionally commented out to hide this field from the docs) - - -ForcePositionXLike = ForcePositionX -ForcePositionXArrayLike = Union[ - ForcePositionX, - Sequence[ForcePositionXLike], -] - - -class ForcePositionXBatch(BaseBatch[ForcePositionXArrayLike]): - _ARROW_DATATYPE = pa.struct([ - pa.field("enabled", pa.bool_(), nullable=False, metadata={}), - pa.field("x", pa.float64(), nullable=False, metadata={}), - pa.field("strength", pa.float64(), nullable=False, metadata={}), - ]) - - @staticmethod - def _native_to_pa_array(data: ForcePositionXArrayLike, data_type: pa.DataType) -> pa.Array: - if isinstance(data, ForcePositionX): - data = [data] - - return pa.StructArray.from_arrays( - [ - pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), - pa.array(np.asarray([x.x for x in data], dtype=np.float64)), - pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), - ], - fields=list(data_type), - ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_y.py b/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_y.py deleted file mode 100644 index e0cbb63ee53d..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/datatypes/force_position_y.py +++ /dev/null @@ -1,85 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/datatypes/force_position_y.fbs". - -# You can extend this class by creating a "ForcePositionYExt" class in "force_position_y_ext.py". - -from __future__ import annotations - -from typing import Any, Sequence, Union - -import numpy as np -import pyarrow as pa -from attrs import define, field - -from ..._baseclasses import ( - BaseBatch, -) - -__all__ = ["ForcePositionY", "ForcePositionYArrayLike", "ForcePositionYBatch", "ForcePositionYLike"] - - -@define(init=False) -class ForcePositionY: - """**Datatype**: Defines a force that pulls nodes towards an `y` position.""" - - def __init__(self: Any, enabled: bool, y: float, strength: float): - """ - Create a new instance of the ForcePositionY datatype. - - Parameters - ---------- - enabled: - Whether the force is enabled. - y: - The `y` position to pull nodes towards. - strength: - The strength of the force. - - """ - - # You can define your own __init__ function as a member of ForcePositionYExt in force_position_y_ext.py - self.__attrs_init__(enabled=enabled, y=y, strength=strength) - - enabled: bool = field(converter=bool) - # Whether the force is enabled. - # - # (Docstring intentionally commented out to hide this field from the docs) - - y: float = field(converter=float) - # The `y` position to pull nodes towards. - # - # (Docstring intentionally commented out to hide this field from the docs) - - strength: float = field(converter=float) - # The strength of the force. - # - # (Docstring intentionally commented out to hide this field from the docs) - - -ForcePositionYLike = ForcePositionY -ForcePositionYArrayLike = Union[ - ForcePositionY, - Sequence[ForcePositionYLike], -] - - -class ForcePositionYBatch(BaseBatch[ForcePositionYArrayLike]): - _ARROW_DATATYPE = pa.struct([ - pa.field("enabled", pa.bool_(), nullable=False, metadata={}), - pa.field("y", pa.float64(), nullable=False, metadata={}), - pa.field("strength", pa.float64(), nullable=False, metadata={}), - ]) - - @staticmethod - def _native_to_pa_array(data: ForcePositionYArrayLike, data_type: pa.DataType) -> pa.Array: - if isinstance(data, ForcePositionY): - data = [data] - - return pa.StructArray.from_arrays( - [ - pa.array(np.asarray([x.enabled for x in data], dtype=np.bool_)), - pa.array(np.asarray([x.y for x in data], dtype=np.float64)), - pa.array(np.asarray([x.strength for x in data], dtype=np.float64)), - ], - fields=list(data_type), - ) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py index 0a2a3fb0a938..4c43bc8e055d 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py @@ -70,13 +70,6 @@ def __init__( defaults: list[Union[AsComponents, ComponentBatchLike]] = [], overrides: dict[EntityPathLike, list[ComponentBatchLike]] = {}, visual_bounds: blueprint_archetypes.VisualBounds2D | None = None, - force_layout_simulation: blueprint_archetypes.ForceLayoutSimulation | None = None, - force_position_x: blueprint_archetypes.ForcePositionX | None = None, - force_position_y: blueprint_archetypes.ForcePositionY | None = None, - force_center: blueprint_archetypes.ForcePositionX | None = None, - force_collide_radius: blueprint_archetypes.ForceCollideRadius | None = None, - force_many_body: blueprint_archetypes.ForceManyBody | None = None, - force_link: blueprint_archetypes.ForceLink | None = None, ) -> None: """ Construct a blueprint for a new GraphView view. @@ -111,20 +104,6 @@ def __init__( Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. - force_layout_simulation: - The parameters for the force layout simulation. - force_position_x: - Adds a force that pull nodes towards an `x` position. - force_position_y: - Adds a force that pull nodes towards an `y` position. - force_center: - Adds a force that moves the center of mass of all nodes to a given position. - force_collide_radius: - Adds a force that resolves collisions between graph nodes. - force_many_body: - Adds a force that acts like an electric charge between nodes. - force_link: - Adds a force that acts like a spring between nodes. """ @@ -134,41 +113,6 @@ def __init__( visual_bounds = blueprint_archetypes.VisualBounds2D(visual_bounds) properties["VisualBounds2D"] = visual_bounds - if force_layout_simulation is not None: - if not isinstance(force_layout_simulation, blueprint_archetypes.ForceLayoutSimulation): - force_layout_simulation = blueprint_archetypes.ForceLayoutSimulation(force_layout_simulation) - properties["ForceLayoutSimulation"] = force_layout_simulation - - if force_position_x is not None: - if not isinstance(force_position_x, blueprint_archetypes.ForcePositionX): - force_position_x = blueprint_archetypes.ForcePositionX(force_position_x) - properties["ForcePositionX"] = force_position_x - - if force_position_y is not None: - if not isinstance(force_position_y, blueprint_archetypes.ForcePositionY): - force_position_y = blueprint_archetypes.ForcePositionY(force_position_y) - properties["ForcePositionY"] = force_position_y - - if force_center is not None: - if not isinstance(force_center, blueprint_archetypes.ForcePositionX): - force_center = blueprint_archetypes.ForcePositionX(force_center) - properties["ForcePositionX"] = force_center - - if force_collide_radius is not None: - if not isinstance(force_collide_radius, blueprint_archetypes.ForceCollideRadius): - force_collide_radius = blueprint_archetypes.ForceCollideRadius(force_collide_radius) - properties["ForceCollideRadius"] = force_collide_radius - - if force_many_body is not None: - if not isinstance(force_many_body, blueprint_archetypes.ForceManyBody): - force_many_body = blueprint_archetypes.ForceManyBody(force_many_body) - properties["ForceManyBody"] = force_many_body - - if force_link is not None: - if not isinstance(force_link, blueprint_archetypes.ForceLink): - force_link = blueprint_archetypes.ForceLink(force_link) - properties["ForceLink"] = force_link - super().__init__( class_identifier="Graph", origin=origin, From 6e885ee568c9d762fae9d07c9aa1aad72f75c678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 5 Dec 2024 10:01:07 +0100 Subject: [PATCH 10/44] Add `ForceLink` [skip ci] --- .../rerun/blueprint/archetypes.fbs | 1 + .../rerun/blueprint/archetypes/force_link.fbs | 13 ++ .../rerun/blueprint/components.fbs | 2 + .../rerun/blueprint/components/enabled.fbs | 15 ++ .../blueprint/components/force_distance.fbs | 14 ++ .../rerun/blueprint/views/graph.fbs | 3 + .../src/blueprint/archetypes/.gitattributes | 1 + .../src/blueprint/archetypes/force_link.rs | 172 ++++++++++++++++++ .../blueprint/archetypes/force_link_ext.rs | 10 + .../re_types/src/blueprint/archetypes/mod.rs | 3 + .../src/blueprint/components/.gitattributes | 2 + .../src/blueprint/components/enabled.rs | 105 +++++++++++ .../blueprint/components/force_distance.rs | 116 ++++++++++++ .../re_types/src/blueprint/components/mod.rs | 4 + .../src/blueprint/views/graph_view.rs | 37 +--- .../src/blueprint/validation_gen/mod.rs | 4 + crates/viewer/re_viewer/src/reflection/mod.rs | 32 ++++ .../reference/types/views/graph_view.md | 5 + rerun_cpp/src/rerun/blueprint/archetypes.hpp | 1 + .../rerun/blueprint/archetypes/.gitattributes | 2 + .../rerun/blueprint/archetypes/force_link.cpp | 38 ++++ .../rerun/blueprint/archetypes/force_link.hpp | 59 ++++++ rerun_cpp/src/rerun/blueprint/components.hpp | 2 + .../rerun/blueprint/components/.gitattributes | 2 + .../rerun/blueprint/components/enabled.hpp | 73 ++++++++ .../blueprint/components/force_distance.hpp | 77 ++++++++ .../rerun/blueprint/archetypes/.gitattributes | 1 + .../rerun/blueprint/archetypes/__init__.py | 2 + .../rerun/blueprint/archetypes/force_link.py | 76 ++++++++ .../rerun/blueprint/components/.gitattributes | 2 + .../rerun/blueprint/components/__init__.py | 6 + .../rerun/blueprint/components/enabled.py | 32 ++++ .../blueprint/components/force_distance.py | 36 ++++ .../rerun/blueprint/views/graph_view.py | 8 + 34 files changed, 924 insertions(+), 32 deletions(-) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_link.rs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_link_ext.rs create mode 100644 crates/store/re_types/src/blueprint/components/enabled.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_distance.rs create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/enabled.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_distance.hpp create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/enabled.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_distance.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index 47eb842fc7c0..b378d9d3e816 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -3,6 +3,7 @@ include "./archetypes/background.fbs"; include "./archetypes/container_blueprint.fbs"; include "./archetypes/dataframe_query.fbs"; +include "./archetypes/force_link.fbs"; include "./archetypes/map_background.fbs"; include "./archetypes/map_zoom.fbs"; include "./archetypes/panel_blueprint.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs new file mode 100644 index 000000000000..32fd0f2428af --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs @@ -0,0 +1,13 @@ +namespace rerun.blueprint.archetypes; + +/// The link force pushes linked nodes together or apart according to a desired distance. +struct ForceLink ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "PartialEq" +) { + /// Whether the force is enabled. + enabled: rerun.blueprint.components.Enabled (order: 100); + + /// The target distance between two nodes. + distance: rerun.blueprint.components.ForceDistance (order: 200); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components.fbs b/crates/store/re_types/definitions/rerun/blueprint/components.fbs index f52c3ae986f1..731466b4d4a5 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -9,8 +9,10 @@ include "./components/column_share.fbs"; include "./components/component_column_selector.fbs"; include "./components/container_kind.fbs"; include "./components/corner_2d.fbs"; +include "./components/enabled.fbs"; include "./components/filter_by_range.fbs"; include "./components/filter_is_not_null.fbs"; +include "./components/force_distance.fbs"; include "./components/grid_columns.fbs"; include "./components/included_content.fbs"; include "./components/interactive.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs new file mode 100644 index 000000000000..5b2babd7e033 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs @@ -0,0 +1,15 @@ +namespace rerun.blueprint.components; + +// --- + +/// Whether a procedure is enabled. +struct Enabled ( + "attr.arrow.transparent", + "attr.rerun.scope": "blueprint", + "attr.python.aliases": "bool", + "attr.rust.derive": "Copy, PartialEq, Eq, PartialOrd, Ord", + "attr.rust.repr": "transparent", + "attr.rust.tuple_struct" +) { + visible: rerun.datatypes.Bool (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs new file mode 100644 index 000000000000..28a165c70b5a --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs @@ -0,0 +1,14 @@ + +namespace rerun.blueprint.components; + +/// The target distance between two nodes. +/// +/// This is helpful to scale the layout, for example if long labels are involved. +struct ForceDistance ( + "attr.arrow.transparent", + "attr.rust.derive": "Default, PartialEq", + "attr.rust.repr": "transparent", + "attr.rerun.scope": "blueprint" +) { + distance: rerun.datatypes.Float64 (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index 2f808bb8df2a..e4e933c0e567 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -11,4 +11,7 @@ table GraphView ( /// /// Somethings outside of these bounds may also be visible due to letterboxing. visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 1000); + + /// A link force between nodes in the graph. + force_link: rerun.blueprint.archetypes.ForceLink (order: 2000); } diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index 158c53d4bb45..8bd7fde9abfc 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -3,6 +3,7 @@ .gitattributes linguist-generated=true background.rs linguist-generated=true dataframe_query.rs linguist-generated=true +force_link.rs linguist-generated=true map_background.rs linguist-generated=true map_zoom.rs linguist-generated=true mod.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs new file mode 100644 index 000000000000..5f2c2510c6f0 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -0,0 +1,172 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +#[derive(Clone, Debug, PartialEq)] +pub struct ForceLink { + /// Whether the force is enabled. + pub enabled: crate::blueprint::components::Enabled, + + /// The target distance between two nodes. + pub distance: crate::blueprint::components::ForceDistance, +} + +impl ::re_types_core::SizeBytes for ForceLink { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.distance.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + && ::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); + +impl ForceLink { + /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 1usize; +} + +/// Indicator component for the [`ForceLink`] [`::re_types_core::Archetype`] +pub type ForceLinkIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceLink { + type Indicator = ForceLinkIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceLink".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force link" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceLinkIndicator = ForceLinkIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let enabled = { + let array = arrays_by_name + .get("rerun.blueprint.components.Enabled") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceLink#enabled")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceLink#enabled")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceLink#enabled")? + }; + let distance = { + let array = arrays_by_name + .get("rerun.blueprint.components.ForceDistance") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceLink#distance")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceLink#distance")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.ForceLink#distance")? + }; + Ok(Self { enabled, distance }) + } +} + +impl ::re_types_core::AsComponents for ForceLink { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + Some((&self.enabled as &dyn ComponentBatch).into()), + Some((&self.distance as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceLink {} + +impl ForceLink { + /// Create a new `ForceLink`. + #[inline] + pub fn new( + enabled: impl Into, + distance: impl Into, + ) -> Self { + Self { + enabled: enabled.into(), + distance: distance.into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link_ext.rs b/crates/store/re_types/src/blueprint/archetypes/force_link_ext.rs new file mode 100644 index 000000000000..5287b6f46f4f --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_link_ext.rs @@ -0,0 +1,10 @@ +use super::ForceLink; + +impl Default for ForceLink { + fn default() -> Self { + Self { + enabled: true.into(), + distance: (30.).into(), + } + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index 360c1b887939..b58e25595349 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -2,6 +2,8 @@ mod background; mod dataframe_query; +mod force_link_ext; +mod force_link; mod map_background; mod map_zoom; mod plot_legend; @@ -17,6 +19,7 @@ mod visual_bounds2d; pub use self::background::Background; pub use self::dataframe_query::DataframeQuery; +pub use self::force_link::ForceLink; pub use self::map_background::MapBackground; pub use self::map_zoom::MapZoom; pub use self::plot_legend::PlotLegend; diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index 4a1915dc979d..e3193321b5e4 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -7,8 +7,10 @@ background_kind.rs linguist-generated=true column_share.rs linguist-generated=true component_column_selector.rs linguist-generated=true corner2d.rs linguist-generated=true +enabled.rs linguist-generated=true filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true +force_distance.rs linguist-generated=true included_content.rs linguist-generated=true interactive.rs linguist-generated=true lock_range_during_zoom.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/enabled.rs b/crates/store/re_types/src/blueprint/components/enabled.rs new file mode 100644 index 000000000000..e762ed65d1e3 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/enabled.rs @@ -0,0 +1,105 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Component**: Whether a procedure is enabled. +#[derive(Clone, Debug, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[repr(transparent)] +pub struct Enabled(pub crate::datatypes::Bool); + +impl ::re_types_core::SizeBytes for Enabled { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for Enabled { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for Enabled { + #[inline] + fn borrow(&self) -> &crate::datatypes::Bool { + &self.0 + } +} + +impl std::ops::Deref for Enabled { + type Target = crate::datatypes::Bool; + + #[inline] + fn deref(&self) -> &crate::datatypes::Bool { + &self.0 + } +} + +impl std::ops::DerefMut for Enabled { + #[inline] + fn deref_mut(&mut self) -> &mut crate::datatypes::Bool { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(Enabled); + +impl ::re_types_core::Loggable for Enabled { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::datatypes::Bool::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::datatypes::Bool::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::datatypes::Bool::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl ::re_types_core::Component for Enabled { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.Enabled".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/force_distance.rs b/crates/store/re_types/src/blueprint/components/force_distance.rs new file mode 100644 index 000000000000..09d1e756fbe1 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_distance.rs @@ -0,0 +1,116 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Component**: The target distance between two nodes. +/// +/// This is helpful to scale the layout, for example if long labels are involved. +#[derive(Clone, Debug, Default, PartialEq)] +#[repr(transparent)] +pub struct ForceDistance(pub crate::datatypes::Float64); + +impl ::re_types_core::SizeBytes for ForceDistance { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForceDistance { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceDistance { + #[inline] + fn borrow(&self) -> &crate::datatypes::Float64 { + &self.0 + } +} + +impl std::ops::Deref for ForceDistance { + type Target = crate::datatypes::Float64; + + #[inline] + fn deref(&self) -> &crate::datatypes::Float64 { + &self.0 + } +} + +impl std::ops::DerefMut for ForceDistance { + #[inline] + fn deref_mut(&mut self) -> &mut crate::datatypes::Float64 { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForceDistance); + +impl ::re_types_core::Loggable for ForceDistance { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::datatypes::Float64::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::datatypes::Float64::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::datatypes::Float64::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } + + #[inline] + fn from_arrow2(arrow_data: &dyn arrow2::array::Array) -> DeserializationResult> + where + Self: Sized, + { + crate::datatypes::Float64::from_arrow2(arrow_data) + .map(|v| v.into_iter().map(Self).collect()) + } +} + +impl ::re_types_core::Component for ForceDistance { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForceDistance".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index a915957fd392..9767a3ce305f 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -8,10 +8,12 @@ mod component_column_selector; mod component_column_selector_ext; mod corner2d; mod corner2d_ext; +mod enabled; mod filter_by_range; mod filter_by_range_ext; mod filter_is_not_null; mod filter_is_not_null_ext; +mod force_distance; mod included_content; mod interactive; mod interactive_ext; @@ -46,8 +48,10 @@ pub use self::background_kind::BackgroundKind; pub use self::column_share::ColumnShare; pub use self::component_column_selector::ComponentColumnSelector; pub use self::corner2d::Corner2D; +pub use self::enabled::Enabled; pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; +pub use self::force_distance::ForceDistance; pub use self::included_content::IncludedContent; pub use self::interactive::Interactive; pub use self::lock_range_during_zoom::LockRangeDuringZoom; diff --git a/crates/store/re_types/src/blueprint/views/graph_view.rs b/crates/store/re_types/src/blueprint/views/graph_view.rs index 505d5efd40d1..b251dd8606eb 100644 --- a/crates/store/re_types/src/blueprint/views/graph_view.rs +++ b/crates/store/re_types/src/blueprint/views/graph_view.rs @@ -25,48 +25,21 @@ pub struct GraphView { /// /// Somethings outside of these bounds may also be visible due to letterboxing. pub visual_bounds: crate::blueprint::archetypes::VisualBounds2D, + + /// A link force between nodes in the graph. + pub force_link: crate::blueprint::archetypes::ForceLink, } impl ::re_types_core::SizeBytes for GraphView { #[inline] fn heap_size_bytes(&self) -> u64 { - self.visual_bounds.heap_size_bytes() + self.visual_bounds.heap_size_bytes() + self.force_link.heap_size_bytes() } #[inline] fn is_pod() -> bool { ::is_pod() - } -} - -impl> From for GraphView { - fn from(v: T) -> Self { - Self { - visual_bounds: v.into(), - } - } -} - -impl std::borrow::Borrow for GraphView { - #[inline] - fn borrow(&self) -> &crate::blueprint::archetypes::VisualBounds2D { - &self.visual_bounds - } -} - -impl std::ops::Deref for GraphView { - type Target = crate::blueprint::archetypes::VisualBounds2D; - - #[inline] - fn deref(&self) -> &crate::blueprint::archetypes::VisualBounds2D { - &self.visual_bounds - } -} - -impl std::ops::DerefMut for GraphView { - #[inline] - fn deref_mut(&mut self) -> &mut crate::blueprint::archetypes::VisualBounds2D { - &mut self.visual_bounds + && ::is_pod() } } diff --git a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs index ac256bc847d4..d0b058316a64 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -7,8 +7,10 @@ pub use re_types::blueprint::components::BackgroundKind; pub use re_types::blueprint::components::ColumnShare; pub use re_types::blueprint::components::ComponentColumnSelector; pub use re_types::blueprint::components::Corner2D; +pub use re_types::blueprint::components::Enabled; pub use re_types::blueprint::components::FilterByRange; pub use re_types::blueprint::components::FilterIsNotNull; +pub use re_types::blueprint::components::ForceDistance; pub use re_types::blueprint::components::IncludedContent; pub use re_types::blueprint::components::Interactive; pub use re_types::blueprint::components::LockRangeDuringZoom; @@ -48,8 +50,10 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) + && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) + && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 21424df3e255..607148e385f7 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -108,6 +108,14 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "Whether a procedure is enabled.", + custom_placeholder: None, + datatype: Enabled::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { @@ -124,6 +132,14 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "The target distance between two nodes.\n\nThis is helpful to scale the layout, for example if long labels are involved.", + custom_placeholder: Some(ForceDistance::default().to_arrow2()?), + datatype: ForceDistance::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { @@ -1930,6 +1946,22 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceLink"), + ArchetypeReflection { + display_name: "Force link", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.Enabled".into(), display_name : + "Enabled", docstring_md : "Whether the force is enabled.", + is_required : false, }, ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceDistance".into(), display_name : + "Distance", docstring_md : "The target distance between two nodes.", + is_required : false, }, + ], + }, + ), ( ArchetypeName::new("rerun.blueprint.archetypes.MapBackground"), ArchetypeReflection { diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index f6830c618ed6..cd01187c0d83 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -11,6 +11,11 @@ A graph view to display time-variying, directed or undirected graph visualizatio Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. +### `force_link` +A link force between nodes in the graph. + +* `enabled`: Whether the force is enabled. +* `distance`: The target distance between two nodes. ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index 2fd779424b1f..f3544ad39e7e 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -5,6 +5,7 @@ #include "blueprint/archetypes/background.hpp" #include "blueprint/archetypes/container_blueprint.hpp" #include "blueprint/archetypes/dataframe_query.hpp" +#include "blueprint/archetypes/force_link.hpp" #include "blueprint/archetypes/map_background.hpp" #include "blueprint/archetypes/map_zoom.hpp" #include "blueprint/archetypes/panel_blueprint.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes index 26e1a60b89a6..2cb221a27d4c 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -7,6 +7,8 @@ container_blueprint.cpp linguist-generated=true container_blueprint.hpp linguist-generated=true dataframe_query.cpp linguist-generated=true dataframe_query.hpp linguist-generated=true +force_link.cpp linguist-generated=true +force_link.hpp linguist-generated=true map_background.cpp linguist-generated=true map_background.hpp linguist-generated=true map_zoom.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp new file mode 100644 index 000000000000..11323da449b1 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp @@ -0,0 +1,38 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". + +#include "force_link.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> AsComponents::serialize( + const blueprint::archetypes::ForceLink& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(3); + + { + auto result = ComponentBatch::from_loggable(archetype.enabled); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto result = ComponentBatch::from_loggable(archetype.distance); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceLink::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp new file mode 100644 index 000000000000..e53f6dbd37fa --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp @@ -0,0 +1,59 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". + +#pragma once + +#include "../../blueprint/components/enabled.hpp" +#include "../../blueprint/components/force_distance.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + struct ForceLink { + /// Whether the force is enabled. + rerun::blueprint::components::Enabled enabled; + + /// The target distance between two nodes. + rerun::blueprint::components::ForceDistance distance; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceLinkIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceLink() = default; + ForceLink(ForceLink&& other) = default; + + explicit ForceLink( + rerun::blueprint::components::Enabled _enabled, + rerun::blueprint::components::ForceDistance _distance + ) + : enabled(std::move(_enabled)), distance(std::move(_distance)) {} + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceLink& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index e426e3a2b486..5e2de65ed1bd 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -11,8 +11,10 @@ #include "blueprint/components/component_column_selector.hpp" #include "blueprint/components/container_kind.hpp" #include "blueprint/components/corner2d.hpp" +#include "blueprint/components/enabled.hpp" #include "blueprint/components/filter_by_range.hpp" #include "blueprint/components/filter_is_not_null.hpp" +#include "blueprint/components/force_distance.hpp" #include "blueprint/components/grid_columns.hpp" #include "blueprint/components/included_content.hpp" #include "blueprint/components/interactive.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index 7b2410956aec..b7d9cc635dce 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -13,8 +13,10 @@ container_kind.cpp linguist-generated=true container_kind.hpp linguist-generated=true corner2d.cpp linguist-generated=true corner2d.hpp linguist-generated=true +enabled.hpp linguist-generated=true filter_by_range.hpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true +force_distance.hpp linguist-generated=true grid_columns.hpp linguist-generated=true included_content.hpp linguist-generated=true interactive.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/enabled.hpp b/rerun_cpp/src/rerun/blueprint/components/enabled.hpp new file mode 100644 index 000000000000..54d26c9f3c6a --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/enabled.hpp @@ -0,0 +1,73 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs". + +#pragma once + +#include "../../datatypes/bool.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + /// **Component**: Whether a procedure is enabled. + struct Enabled { + rerun::datatypes::Bool visible; + + public: + Enabled() = default; + + Enabled(rerun::datatypes::Bool visible_) : visible(visible_) {} + + Enabled& operator=(rerun::datatypes::Bool visible_) { + visible = visible_; + return *this; + } + + Enabled(bool value_) : visible(value_) {} + + Enabled& operator=(bool value_) { + visible = value_; + return *this; + } + + /// Cast to the underlying Bool datatype + operator rerun::datatypes::Bool() const { + return visible; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert(sizeof(rerun::datatypes::Bool) == sizeof(blueprint::components::Enabled)); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.Enabled"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::Enabled` into an arrow array. + static Result> to_arrow( + const blueprint::components::Enabled* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->visible, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_distance.hpp b/rerun_cpp/src/rerun/blueprint/components/force_distance.hpp new file mode 100644 index 000000000000..95a388b11ed8 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_distance.hpp @@ -0,0 +1,77 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs". + +#pragma once + +#include "../../datatypes/float64.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + /// **Component**: The target distance between two nodes. + /// + /// This is helpful to scale the layout, for example if long labels are involved. + struct ForceDistance { + rerun::datatypes::Float64 distance; + + public: + ForceDistance() = default; + + ForceDistance(rerun::datatypes::Float64 distance_) : distance(distance_) {} + + ForceDistance& operator=(rerun::datatypes::Float64 distance_) { + distance = distance_; + return *this; + } + + ForceDistance(double value_) : distance(value_) {} + + ForceDistance& operator=(double value_) { + distance = value_; + return *this; + } + + /// Cast to the underlying Float64 datatype + operator rerun::datatypes::Float64() const { + return distance; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::datatypes::Float64) == sizeof(blueprint::components::ForceDistance) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForceDistance"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForceDistance` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForceDistance* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->distance, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index bb528bfbaf9a..2e5d54577d98 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -5,6 +5,7 @@ __init__.py linguist-generated=true background.py linguist-generated=true container_blueprint.py linguist-generated=true dataframe_query.py linguist-generated=true +force_link.py linguist-generated=true map_background.py linguist-generated=true map_zoom.py linguist-generated=true panel_blueprint.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py index 018ec6c34d5e..a7d1938aba3a 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -5,6 +5,7 @@ from .background import Background from .container_blueprint import ContainerBlueprint from .dataframe_query import DataframeQuery +from .force_link import ForceLink from .map_background import MapBackground from .map_zoom import MapZoom from .panel_blueprint import PanelBlueprint @@ -23,6 +24,7 @@ "Background", "ContainerBlueprint", "DataframeQuery", + "ForceLink", "MapBackground", "MapZoom", "PanelBlueprint", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py new file mode 100644 index 000000000000..d5143f721061 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py @@ -0,0 +1,76 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs". + +# You can extend this class by creating a "ForceLinkExt" class in "force_link_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ... import datatypes +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceLink"] + + +@define(str=False, repr=False, init=False) +class ForceLink(Archetype): + """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + + def __init__(self: Any, enabled: datatypes.BoolLike, distance: datatypes.Float64Like): + """ + Create a new instance of the ForceLink archetype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + distance: + The target distance between two nodes. + + """ + + # You can define your own __init__ function as a member of ForceLinkExt in force_link_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(enabled=enabled, distance=distance) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + enabled=None, # type: ignore[arg-type] + distance=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceLink: + """Produce an empty ForceLink, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + enabled: blueprint_components.EnabledBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.EnabledBatch._required, # type: ignore[misc] + ) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + distance: blueprint_components.ForceDistanceBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ForceDistanceBatch._required, # type: ignore[misc] + ) + # The target distance between two nodes. + # + # (Docstring intentionally commented out to hide this field from the docs) + + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes index 57164211651c..27fceb4efb37 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -11,8 +11,10 @@ column_share.py linguist-generated=true component_column_selector.py linguist-generated=true container_kind.py linguist-generated=true corner2d.py linguist-generated=true +enabled.py linguist-generated=true filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true +force_distance.py linguist-generated=true grid_columns.py linguist-generated=true included_content.py linguist-generated=true interactive.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py index 2f4943b58c8d..15d3de279c54 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py @@ -11,8 +11,10 @@ from .component_column_selector import ComponentColumnSelector, ComponentColumnSelectorBatch from .container_kind import ContainerKind, ContainerKindArrayLike, ContainerKindBatch, ContainerKindLike from .corner2d import Corner2D, Corner2DArrayLike, Corner2DBatch, Corner2DLike +from .enabled import Enabled, EnabledBatch from .filter_by_range import FilterByRange, FilterByRangeBatch from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullBatch +from .force_distance import ForceDistance, ForceDistanceBatch from .grid_columns import GridColumns, GridColumnsBatch from .included_content import IncludedContent, IncludedContentBatch from .interactive import Interactive, InteractiveBatch @@ -61,10 +63,14 @@ "Corner2DArrayLike", "Corner2DBatch", "Corner2DLike", + "Enabled", + "EnabledBatch", "FilterByRange", "FilterByRangeBatch", "FilterIsNotNull", "FilterIsNotNullBatch", + "ForceDistance", + "ForceDistanceBatch", "GridColumns", "GridColumnsBatch", "IncludedContent", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/enabled.py b/rerun_py/rerun_sdk/rerun/blueprint/components/enabled.py new file mode 100644 index 000000000000..8c53284c0b57 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/enabled.py @@ -0,0 +1,32 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs". + +# You can extend this class by creating a "EnabledExt" class in "enabled_ext.py". + +from __future__ import annotations + +from ... import datatypes +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) + +__all__ = ["Enabled", "EnabledBatch"] + + +class Enabled(datatypes.Bool, ComponentMixin): + """**Component**: Whether a procedure is enabled.""" + + _BATCH_TYPE = None + # You can define your own __init__ function as a member of EnabledExt in enabled_ext.py + + # Note: there are no fields here because Enabled delegates to datatypes.Bool + pass + + +class EnabledBatch(datatypes.BoolBatch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.Enabled" + + +# This is patched in late to avoid circular dependencies. +Enabled._BATCH_TYPE = EnabledBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_distance.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_distance.py new file mode 100644 index 000000000000..b8bdbe282bd5 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_distance.py @@ -0,0 +1,36 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs". + +# You can extend this class by creating a "ForceDistanceExt" class in "force_distance_ext.py". + +from __future__ import annotations + +from ... import datatypes +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) + +__all__ = ["ForceDistance", "ForceDistanceBatch"] + + +class ForceDistance(datatypes.Float64, ComponentMixin): + """ + **Component**: The target distance between two nodes. + + This is helpful to scale the layout, for example if long labels are involved. + """ + + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForceDistanceExt in force_distance_ext.py + + # Note: there are no fields here because ForceDistance delegates to datatypes.Float64 + pass + + +class ForceDistanceBatch(datatypes.Float64Batch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForceDistance" + + +# This is patched in late to avoid circular dependencies. +ForceDistance._BATCH_TYPE = ForceDistanceBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py index 4c43bc8e055d..17d7552fbb18 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py @@ -70,6 +70,7 @@ def __init__( defaults: list[Union[AsComponents, ComponentBatchLike]] = [], overrides: dict[EntityPathLike, list[ComponentBatchLike]] = {}, visual_bounds: blueprint_archetypes.VisualBounds2D | None = None, + force_link: blueprint_archetypes.ForceLink | None = None, ) -> None: """ Construct a blueprint for a new GraphView view. @@ -104,6 +105,8 @@ def __init__( Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. + force_link: + A link force between nodes in the graph. """ @@ -113,6 +116,11 @@ def __init__( visual_bounds = blueprint_archetypes.VisualBounds2D(visual_bounds) properties["VisualBounds2D"] = visual_bounds + if force_link is not None: + if not isinstance(force_link, blueprint_archetypes.ForceLink): + force_link = blueprint_archetypes.ForceLink(force_link) + properties["ForceLink"] = force_link + super().__init__( class_identifier="Graph", origin=origin, From 3e906ab09953c7705ba76a1caa01358297b28b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 5 Dec 2024 11:14:49 +0100 Subject: [PATCH 11/44] Add force-related entries to registry --- .../src/datatype_uis/float_drag.rs | 23 +++++++++++++++++++ .../re_component_ui/src/datatype_uis/mod.rs | 2 +- crates/viewer/re_component_ui/src/lib.rs | 11 +++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs b/crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs index 4ab88fe24ce8..a37f8cfbc3d3 100644 --- a/crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs +++ b/crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs @@ -89,6 +89,29 @@ fn edit_f32_zero_to_one_raw(ui: &mut egui::Ui, value: &mut MaybeMutRef<'_, f32>) // --- +/// Generic editor for a [`re_types::datatypes::Float64`] value from zero to max float. +pub fn edit_f64_zero_to_max( + _ctx: &re_viewer_context::ViewerContext<'_>, + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, impl std::ops::DerefMut>, +) -> egui::Response { + let mut value: MaybeMutRef<'_, f64> = match value { + MaybeMutRef::Ref(value) => MaybeMutRef::Ref(value), + MaybeMutRef::MutRef(value) => MaybeMutRef::MutRef(&mut value.deref_mut().0), + }; + edit_f64_float_raw_impl(ui, &mut value, 0.0..=f64::MAX) +} + +/// Non monomorphized implementation for f64 float editing. +pub fn edit_f64_float_raw_impl( + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, f64>, + range: RangeInclusive, +) -> egui::Response { + let speed = (value.abs() * 0.01).at_least(0.001); + edit_f64_float_raw_with_speed_impl(ui, value, range, speed) +} + /// Non monomorphized implementation for f64 float editing with a given speed. pub fn edit_f64_float_raw_with_speed_impl( ui: &mut egui::Ui, diff --git a/crates/viewer/re_component_ui/src/datatype_uis/mod.rs b/crates/viewer/re_component_ui/src/datatype_uis/mod.rs index 54d66fbacfd3..d5eb8036bff4 100644 --- a/crates/viewer/re_component_ui/src/datatype_uis/mod.rs +++ b/crates/viewer/re_component_ui/src/datatype_uis/mod.rs @@ -14,7 +14,7 @@ pub use enum_combobox::{ }; pub use float_drag::{ edit_f32_min_to_max_float, edit_f32_zero_to_max, edit_f32_zero_to_one, - edit_f64_float_raw_with_speed_impl, + edit_f64_float_raw_with_speed_impl, edit_f64_zero_to_max, }; pub use range1d::edit_view_range1d; pub use singleline_string::{ diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 9ee313c198b7..22018af6e2e3 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -27,14 +27,15 @@ mod zoom_level; use datatype_uis::{ display_name_ui, display_text_ui, edit_bool, edit_f32_min_to_max_float, edit_f32_zero_to_max, - edit_f32_zero_to_one, edit_multiline_string, edit_or_view_vec3d, edit_singleline_string, - edit_view_enum, edit_view_enum_with_variant_available, edit_view_range1d, view_uuid, - view_view_id, + edit_f32_zero_to_one, edit_f64_zero_to_max, edit_multiline_string, edit_or_view_vec3d, + edit_singleline_string, edit_view_enum, edit_view_enum_with_variant_available, + edit_view_range1d, view_uuid, view_view_id, }; use re_types::{ blueprint::components::{ - BackgroundKind, Corner2D, LockRangeDuringZoom, MapProvider, ViewFit, Visible, ZoomLevel, + BackgroundKind, Corner2D, Enabled, ForceDistance, LockRangeDuringZoom, MapProvider, + ViewFit, Visible, ZoomLevel, }, components::{ AggregationPolicy, AlbedoFactor, AxisLength, Color, DepthMeter, DrawOrder, FillMode, @@ -70,6 +71,7 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); + registry.add_singleline_edit_or_view::(edit_f64_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); @@ -87,6 +89,7 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view::(edit_bool); registry.add_singleline_edit_or_view::(edit_bool); registry.add_singleline_edit_or_view::(edit_bool); + registry.add_singleline_edit_or_view::(edit_bool); // Text components: registry.add_legacy_display_ui(Text::name(), Box::new(display_text_ui)); // TODO(andreas): Why is there a display ui? From 8b4214c7ed52c0a29b66e078dfcd9b2f322c3fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 5 Dec 2024 11:26:49 +0100 Subject: [PATCH 12/44] Remove dups --- crates/viewer/re_component_ui/src/lib.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 22018af6e2e3..8830dcf96afa 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -85,11 +85,10 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view::(edit_f32_zero_to_one); // Bool components: - registry.add_singleline_edit_or_view::(edit_bool); + registry.add_singleline_edit_or_view::(edit_bool); registry.add_singleline_edit_or_view::(edit_bool); registry.add_singleline_edit_or_view::(edit_bool); registry.add_singleline_edit_or_view::(edit_bool); - registry.add_singleline_edit_or_view::(edit_bool); // Text components: registry.add_legacy_display_ui(Text::name(), Box::new(display_text_ui)); // TODO(andreas): Why is there a display ui? @@ -151,11 +150,6 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view(radius::edit_radius_ui); registry.add_singleline_edit_or_view(marker_shape::edit_marker_shape_ui); - registry.add_multiline_edit_or_view(visual_bounds2d::multiline_edit_visual_bounds2d); - registry.add_singleline_edit_or_view(visual_bounds2d::singleline_edit_visual_bounds2d); - registry.add_multiline_edit_or_view(visual_bounds2d::multiline_edit_visual_bounds2d); - registry.add_singleline_edit_or_view(visual_bounds2d::singleline_edit_visual_bounds2d); - registry.add_singleline_edit_or_view(pinhole::singleline_view_pinhole); registry.add_multiline_edit_or_view(pinhole::multiline_view_pinhole); From 21304c78b8f950c3d26eb5b7bd050d2f92c46968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 5 Dec 2024 12:43:02 +0100 Subject: [PATCH 13/44] Minor cleanup --- crates/viewer/re_space_view_spatial/src/view_3d_properties.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/viewer/re_space_view_spatial/src/view_3d_properties.rs b/crates/viewer/re_space_view_spatial/src/view_3d_properties.rs index 949fc00e1f65..da90c350702c 100644 --- a/crates/viewer/re_space_view_spatial/src/view_3d_properties.rs +++ b/crates/viewer/re_space_view_spatial/src/view_3d_properties.rs @@ -1,7 +1,7 @@ use re_types::{ blueprint::{archetypes::Background, components::BackgroundKind}, components::Color, - Archetype, + Archetype as _, }; use re_viewer_context::TypedComponentFallbackProvider; From a2aa9bd61dcc23a5f4c8dc4ab7a6452ce3870c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 5 Dec 2024 12:58:43 +0100 Subject: [PATCH 14/44] WIP [skip ci] --- .../blueprint/components/force_distance.fbs | 2 +- .../blueprint/archetypes/force_link_ext.rs | 10 -------- .../re_types/src/blueprint/archetypes/mod.rs | 1 - .../src/blueprint/components/enabled_ext.rs | 17 +++++++++++++ .../blueprint/components/force_distance.rs | 2 +- .../re_types/src/blueprint/components/mod.rs | 1 + .../re_space_view_graph/src/properties.rs | 25 +++++++++++++++++-- .../re_space_view_graph/src/ui/state.rs | 2 +- crates/viewer/re_space_view_graph/src/view.rs | 24 ++++++++++++++---- 9 files changed, 63 insertions(+), 21 deletions(-) delete mode 100644 crates/store/re_types/src/blueprint/archetypes/force_link_ext.rs create mode 100644 crates/store/re_types/src/blueprint/components/enabled_ext.rs diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs index 28a165c70b5a..49d728662e03 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_distance.fbs @@ -6,7 +6,7 @@ namespace rerun.blueprint.components; /// This is helpful to scale the layout, for example if long labels are involved. struct ForceDistance ( "attr.arrow.transparent", - "attr.rust.derive": "Default, PartialEq", + "attr.rust.derive": "Default, Copy, PartialEq", "attr.rust.repr": "transparent", "attr.rerun.scope": "blueprint" ) { diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link_ext.rs b/crates/store/re_types/src/blueprint/archetypes/force_link_ext.rs deleted file mode 100644 index 5287b6f46f4f..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/force_link_ext.rs +++ /dev/null @@ -1,10 +0,0 @@ -use super::ForceLink; - -impl Default for ForceLink { - fn default() -> Self { - Self { - enabled: true.into(), - distance: (30.).into(), - } - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index b58e25595349..b66da0bccc2a 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -2,7 +2,6 @@ mod background; mod dataframe_query; -mod force_link_ext; mod force_link; mod map_background; mod map_zoom; diff --git a/crates/store/re_types/src/blueprint/components/enabled_ext.rs b/crates/store/re_types/src/blueprint/components/enabled_ext.rs new file mode 100644 index 000000000000..62e72b4e082b --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/enabled_ext.rs @@ -0,0 +1,17 @@ +use re_types_core::datatypes::Bool; + +use super::Enabled; + +impl Default for Enabled { + #[inline] + fn default() -> Self { + Self(Bool(false)) + } +} + +impl From for bool { + #[inline] + fn from(v: Enabled) -> Self { + v.0.into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/force_distance.rs b/crates/store/re_types/src/blueprint/components/force_distance.rs index 09d1e756fbe1..da755bae96f6 100644 --- a/crates/store/re_types/src/blueprint/components/force_distance.rs +++ b/crates/store/re_types/src/blueprint/components/force_distance.rs @@ -21,7 +21,7 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Component**: The target distance between two nodes. /// /// This is helpful to scale the layout, for example if long labels are involved. -#[derive(Clone, Debug, Default, PartialEq)] +#[derive(Clone, Debug, Default, Copy, PartialEq)] #[repr(transparent)] pub struct ForceDistance(pub crate::datatypes::Float64); diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index 9767a3ce305f..9686fef21aa0 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -9,6 +9,7 @@ mod component_column_selector_ext; mod corner2d; mod corner2d_ext; mod enabled; +mod enabled_ext; mod filter_by_range; mod filter_by_range_ext; mod filter_is_not_null; diff --git a/crates/viewer/re_space_view_graph/src/properties.rs b/crates/viewer/re_space_view_graph/src/properties.rs index de6b0255f0ca..84656feea7e5 100644 --- a/crates/viewer/re_space_view_graph/src/properties.rs +++ b/crates/viewer/re_space_view_graph/src/properties.rs @@ -1,4 +1,10 @@ -use re_types::blueprint::components::VisualBounds2D; +use re_types::{ + blueprint::{ + archetypes, + components::{Enabled, ForceDistance, VisualBounds2D}, + }, + Archetype as _, +}; use re_viewer_context::{SpaceViewStateExt as _, TypedComponentFallbackProvider}; use crate::{ui::GraphSpaceViewState, GraphSpaceView}; @@ -20,4 +26,19 @@ impl TypedComponentFallbackProvider for GraphSpaceView { } } -re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D]); +impl TypedComponentFallbackProvider for GraphSpaceView { + fn fallback_for(&self, ctx: &re_viewer_context::QueryContext<'_>) -> Enabled { + match ctx.archetype_name { + Some(name) if name == archetypes::ForceLink::name() => true.into(), + _ => false.into(), + } + } +} + +impl TypedComponentFallbackProvider for GraphSpaceView { + fn fallback_for(&self, _ctx: &re_viewer_context::QueryContext<'_>) -> ForceDistance { + (50.).into() + } +} + +re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D, Enabled, ForceDistance]); diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index 749e3720f937..3e2511411aa3 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -1,6 +1,6 @@ use egui::Rect; use re_format::format_f32; -use re_types::blueprint::components::VisualBounds2D; +use re_types::blueprint::{self, components::VisualBounds2D}; use re_ui::UiExt; use re_viewer_context::SpaceViewState; diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index 6539892a1447..cf0cf4d04a82 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -4,7 +4,10 @@ use re_space_view::{ view_property_ui, }; use re_types::{ - blueprint::{self, archetypes::VisualBounds2D}, + blueprint::{ + self, + archetypes::{ForceLink, VisualBounds2D}, + }, SpaceViewClassIdentifier, }; use re_ui::{ @@ -13,10 +16,11 @@ use re_ui::{ ModifiersMarkdown, MouseButtonMarkdown, UiExt as _, }; use re_viewer_context::{ - IdentifiedViewSystem as _, RecommendedSpaceView, SpaceViewClass, SpaceViewClassLayoutPriority, - SpaceViewClassRegistryError, SpaceViewId, SpaceViewSpawnHeuristics, SpaceViewState, - SpaceViewStateExt as _, SpaceViewSystemExecutionError, SpaceViewSystemRegistrator, - SystemExecutionOutput, ViewQuery, ViewerContext, + ComponentFallbackProvider, IdentifiedViewSystem as _, RecommendedSpaceView, SpaceViewClass, + SpaceViewClassLayoutPriority, SpaceViewClassRegistryError, SpaceViewId, + SpaceViewSpawnHeuristics, SpaceViewState, SpaceViewStateExt as _, + SpaceViewSystemExecutionError, SpaceViewSystemRegistrator, SystemExecutionOutput, ViewQuery, + ViewerContext, }; use re_viewport_blueprint::ViewProperty; @@ -130,6 +134,7 @@ Display a graph of nodes and edges. }); view_property_ui::(ctx, ui, space_view_id, self, state); + view_property_ui::(ctx, ui, space_view_id, self, state); Ok(()) } @@ -164,6 +169,15 @@ Display a graph of nodes and edges. let rect_in_scene: blueprint::components::VisualBounds2D = bounds_property.component_or_fallback(ctx, self, state)?; + let force_link_property = ViewProperty::from_archetype::( + ctx.blueprint_db(), + ctx.blueprint_query, + query.space_view_id, + ); + let force_enabled: blueprint::components::Enabled = + force_link_property.component_or_fallback(ctx, self, state)?; + dbg!(force_enabled); + let rect_in_ui = ui.max_rect(); let request = LayoutRequest::from_graphs(graphs.iter()); From b8a3082f44755e8096064a2d607c7af81a890bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 5 Dec 2024 14:13:06 +0100 Subject: [PATCH 15/44] Stash --- crates/viewer/re_space_view_graph/src/properties.rs | 2 +- crates/viewer/re_space_view_graph/src/view.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/viewer/re_space_view_graph/src/properties.rs b/crates/viewer/re_space_view_graph/src/properties.rs index 84656feea7e5..8096660bbf64 100644 --- a/crates/viewer/re_space_view_graph/src/properties.rs +++ b/crates/viewer/re_space_view_graph/src/properties.rs @@ -37,7 +37,7 @@ impl TypedComponentFallbackProvider for GraphSpaceView { impl TypedComponentFallbackProvider for GraphSpaceView { fn fallback_for(&self, _ctx: &re_viewer_context::QueryContext<'_>) -> ForceDistance { - (50.).into() + (42.).into() } } diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index cf0cf4d04a82..bd34af37797a 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -133,8 +133,10 @@ Display a graph of nodes and edges. state.debug_ui(ui); }); - view_property_ui::(ctx, ui, space_view_id, self, state); - view_property_ui::(ctx, ui, space_view_id, self, state); + re_ui::list_item::list_item_scope(ui, "graph_selection_ui", |ui| { + view_property_ui::(ctx, ui, space_view_id, self, state); + view_property_ui::(ctx, ui, space_view_id, self, state); + }); Ok(()) } From 5644d3152984a28373c136ec69a5e3def9c08bb8 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Thu, 5 Dec 2024 14:48:28 +0100 Subject: [PATCH 16/44] Fix `ForceLink` archetype --- .../rerun/blueprint/archetypes/force_link.fbs | 7 +- .../src/blueprint/archetypes/force_link.rs | 102 +++++++++++------- crates/viewer/re_space_view_graph/src/view.rs | 4 +- crates/viewer/re_viewer/src/reflection/mod.rs | 2 +- .../rerun/blueprint/archetypes/force_link.cpp | 8 +- .../rerun/blueprint/archetypes/force_link.hpp | 24 +++-- .../rerun/blueprint/archetypes/force_link.py | 18 ++-- 7 files changed, 102 insertions(+), 63 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs index 32fd0f2428af..95cbda704489 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs @@ -2,12 +2,11 @@ namespace rerun.blueprint.archetypes; /// The link force pushes linked nodes together or apart according to a desired distance. struct ForceLink ( - "attr.rerun.scope": "blueprint", - "attr.rust.derive": "PartialEq" + "attr.rerun.scope": "blueprint" ) { /// Whether the force is enabled. - enabled: rerun.blueprint.components.Enabled (order: 100); + enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100); /// The target distance between two nodes. - distance: rerun.blueprint.components.ForceDistance (order: 200); + distance: rerun.blueprint.components.ForceDistance ("attr.rerun.component_optional", nullable, order: 200); } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs index 5f2c2510c6f0..c3ed0667d5d1 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_link.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -19,13 +19,13 @@ use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug)] pub struct ForceLink { /// Whether the force is enabled. - pub enabled: crate::blueprint::components::Enabled, + pub enabled: Option, /// The target distance between two nodes. - pub distance: crate::blueprint::components::ForceDistance, + pub distance: Option, } impl ::re_types_core::SizeBytes for ForceLink { @@ -36,8 +36,8 @@ impl ::re_types_core::SizeBytes for ForceLink { #[inline] fn is_pod() -> bool { - ::is_pod() - && ::is_pod() + >::is_pod() + && >::is_pod() } } @@ -47,15 +47,26 @@ static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceDistance".into(), + ] + }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.ForceLinkIndicator".into(), + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceDistance".into(), + ] + }); impl ForceLink { - /// The total number of components in the archetype: 0 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 1usize; + /// The total number of components in the archetype: 0 required, 1 recommended, 2 optional + pub const NUM_COMPONENTS: usize = 3usize; } /// Indicator component for the [`ForceLink`] [`::re_types_core::Archetype`] @@ -110,32 +121,26 @@ impl ::re_types_core::Archetype for ForceLink { .into_iter() .map(|(name, array)| (name.full_name(), array)) .collect(); - let enabled = { - let array = arrays_by_name - .get("rerun.blueprint.components.Enabled") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceLink#enabled")?; + let enabled = if let Some(array) = arrays_by_name.get("rerun.blueprint.components.Enabled") + { ::from_arrow2_opt(&**array) .with_context("rerun.blueprint.archetypes.ForceLink#enabled")? .into_iter() .next() .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceLink#enabled")? - }; - let distance = { - let array = arrays_by_name - .get("rerun.blueprint.components.ForceDistance") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceLink#distance")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.ForceLink#distance")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.ForceLink#distance")? + } else { + None }; + let distance = + if let Some(array) = arrays_by_name.get("rerun.blueprint.components.ForceDistance") { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceLink#distance")? + .into_iter() + .next() + .flatten() + } else { + None + }; Ok(Self { enabled, distance }) } } @@ -146,8 +151,12 @@ impl ::re_types_core::AsComponents for ForceLink { use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.enabled as &dyn ComponentBatch).into()), - Some((&self.distance as &dyn ComponentBatch).into()), + self.enabled + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + self.distance + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), ] .into_iter() .flatten() @@ -160,13 +169,30 @@ impl ::re_types_core::ArchetypeReflectionMarker for ForceLink {} impl ForceLink { /// Create a new `ForceLink`. #[inline] - pub fn new( + pub fn new() -> Self { + Self { + enabled: None, + distance: None, + } + } + + /// Whether the force is enabled. + #[inline] + pub fn with_enabled( + mut self, enabled: impl Into, + ) -> Self { + self.enabled = Some(enabled.into()); + self + } + + /// The target distance between two nodes. + #[inline] + pub fn with_distance( + mut self, distance: impl Into, ) -> Self { - Self { - enabled: enabled.into(), - distance: distance.into(), - } + self.distance = Some(distance.into()); + self } } diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index bd34af37797a..ace171c95481 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -176,8 +176,8 @@ Display a graph of nodes and edges. ctx.blueprint_query, query.space_view_id, ); - let force_enabled: blueprint::components::Enabled = - force_link_property.component_or_fallback(ctx, self, state)?; + let force_enabled: Result, _> = + force_link_property.component_or_empty(); dbg!(force_enabled); let rect_in_ui = ui.max_rect(); diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 607148e385f7..31cf57d6bdc8 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -112,7 +112,7 @@ fn generate_component_reflection() -> Result::name(), ComponentReflection { docstring_md: "Whether a procedure is enabled.", - custom_placeholder: None, + custom_placeholder: Some(Enabled::default().to_arrow2()?), datatype: Enabled::arrow2_datatype(), }, ), diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp index 11323da449b1..229d9d558bf2 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp @@ -16,13 +16,13 @@ namespace rerun { std::vector cells; cells.reserve(3); - { - auto result = ComponentBatch::from_loggable(archetype.enabled); + if (archetype.enabled.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.enabled.value()); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } - { - auto result = ComponentBatch::from_loggable(archetype.distance); + if (archetype.distance.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.distance.value()); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp index e53f6dbd37fa..391928a569b9 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp @@ -6,11 +6,13 @@ #include "../../blueprint/components/enabled.hpp" #include "../../blueprint/components/force_distance.hpp" #include "../../collection.hpp" +#include "../../compiler_utils.hpp" #include "../../component_batch.hpp" #include "../../indicator_component.hpp" #include "../../result.hpp" #include +#include #include #include @@ -18,10 +20,10 @@ namespace rerun::blueprint::archetypes { /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. struct ForceLink { /// Whether the force is enabled. - rerun::blueprint::components::Enabled enabled; + std::optional enabled; /// The target distance between two nodes. - rerun::blueprint::components::ForceDistance distance; + std::optional distance; public: static constexpr const char IndicatorComponentName[] = @@ -34,11 +36,19 @@ namespace rerun::blueprint::archetypes { ForceLink() = default; ForceLink(ForceLink&& other) = default; - explicit ForceLink( - rerun::blueprint::components::Enabled _enabled, - rerun::blueprint::components::ForceDistance _distance - ) - : enabled(std::move(_enabled)), distance(std::move(_distance)) {} + /// Whether the force is enabled. + ForceLink with_enabled(rerun::blueprint::components::Enabled _enabled) && { + enabled = std::move(_enabled); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + + /// The target distance between two nodes. + ForceLink with_distance(rerun::blueprint::components::ForceDistance _distance) && { + distance = std::move(_distance); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } }; } // namespace rerun::blueprint::archetypes diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py index d5143f721061..9dee65a56941 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py @@ -23,7 +23,9 @@ class ForceLink(Archetype): """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" - def __init__(self: Any, enabled: datatypes.BoolLike, distance: datatypes.Float64Like): + def __init__( + self: Any, *, enabled: datatypes.BoolLike | None = None, distance: datatypes.Float64Like | None = None + ): """ Create a new instance of the ForceLink archetype. @@ -56,17 +58,19 @@ def _clear(cls) -> ForceLink: inst.__attrs_clear__() return inst - enabled: blueprint_components.EnabledBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.EnabledBatch._required, # type: ignore[misc] + enabled: blueprint_components.EnabledBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.EnabledBatch._optional, # type: ignore[misc] ) # Whether the force is enabled. # # (Docstring intentionally commented out to hide this field from the docs) - distance: blueprint_components.ForceDistanceBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.ForceDistanceBatch._required, # type: ignore[misc] + distance: blueprint_components.ForceDistanceBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.ForceDistanceBatch._optional, # type: ignore[misc] ) # The target distance between two nodes. # From f5cbe55162c62cee58aa94ddd98b1d2bf35e35b3 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Thu, 5 Dec 2024 14:49:07 +0100 Subject: [PATCH 17/44] Fail codegen when archetype fields don't have one of the required attributes --- .../re_types_builder/src/codegen/rust/api.rs | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/crates/build/re_types_builder/src/codegen/rust/api.rs b/crates/build/re_types_builder/src/codegen/rust/api.rs index 3c10c6260b76..be4c36a3e17d 100644 --- a/crates/build/re_types_builder/src/codegen/rust/api.rs +++ b/crates/build/re_types_builder/src/codegen/rust/api.rs @@ -1047,6 +1047,23 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream { assert_eq!(kind, &ObjectKind::Archetype); + // sanity check that each field has one of the rerun component type attributes + for field in &obj.fields { + assert!( + [ + ATTR_RERUN_COMPONENT_OPTIONAL, + ATTR_RERUN_COMPONENT_RECOMMENDED, + ATTR_RERUN_COMPONENT_REQUIRED + ] + .iter() + .any(|attr| field.try_get_attr::(attr).is_some()), + "archetype `{}` must add one of the \"attr.rerun.component_{{required|recommended|\ + optional}}\" attributes to field `{}`", + obj.name, + field.name + ); + } + let display_name = re_case::to_human_case(name); let name = format_ident!("{name}"); @@ -1078,7 +1095,7 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream { compute_components(obj, ATTR_RERUN_COMPONENT_RECOMMENDED, [indicator_fqname]); let (num_optional, optional) = compute_components(obj, ATTR_RERUN_COMPONENT_OPTIONAL, []); - let num_components_docstring = quote_doc_line(&format!( + let num_components_docstring = quote_doc_line(&format!( "The total number of components in the archetype: {num_required} required, {num_recommended} recommended, {num_optional} optional" )); let num_all = num_required + num_recommended + num_optional; @@ -1090,7 +1107,7 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream { .collect::>(); let all_component_batches = { - std::iter::once(quote!{ + std::iter::once(quote! { Some(Self::indicator()) }).chain(obj.fields.iter().map(|obj_field| { let field_name = format_ident!("{}", obj_field.name); @@ -1104,7 +1121,7 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream { if is_plural { // Always log Option> as Vec, mapping None to empty batch let component_type = quote_field_type_from_typ(&obj_field.typ, false).0; - quote!{ + quote! { Some(( if let Some(comp_batch) = &self.#field_name { (comp_batch as &dyn ComponentBatch) @@ -1118,20 +1135,20 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream { } } else { // Always log Option, mapping None to empty batch - quote!{ Some((&self.#field_name as &dyn ComponentBatch).into()) } + quote! { Some((&self.#field_name as &dyn ComponentBatch).into()) } } } else { if is_plural { // Maybe logging an Option> - quote!{ self.#field_name.as_ref().map(|comp_batch| (comp_batch as &dyn ComponentBatch).into()) } + quote! { self.#field_name.as_ref().map(|comp_batch| (comp_batch as &dyn ComponentBatch).into()) } } else { // Maybe logging an Option - quote!{ self.#field_name.as_ref().map(|comp| (comp as &dyn ComponentBatch).into()) } + quote! { self.#field_name.as_ref().map(|comp| (comp as &dyn ComponentBatch).into()) } } } } else { // Always logging a Vec or C - quote!{ Some((&self.#field_name as &dyn ComponentBatch).into()) } + quote! { Some((&self.#field_name as &dyn ComponentBatch).into()) } } })) }; @@ -1168,7 +1185,7 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream { // NOTE: An archetype cannot have overlapped component types by definition, so use the // component's fqname to do the mapping. - let quoted_deser = if is_nullable && !is_plural{ + let quoted_deser = if is_nullable && !is_plural { // For a nullable mono-component, it's valid for data to be missing // after a clear. let quoted_collection = From 50701ff3e03e3a02138eff98764d453a4bbfbd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 08:47:18 +0100 Subject: [PATCH 18/44] WIP --- .../re_space_view_graph/src/layout/mod.rs | 2 + .../re_space_view_graph/src/layout/params.rs | 40 +++++++++++++ .../src/layout/provider.rs | 56 ++++++++++++------- .../re_space_view_graph/src/ui/state.rs | 16 +++--- crates/viewer/re_space_view_graph/src/view.rs | 13 +---- 5 files changed, 90 insertions(+), 37 deletions(-) create mode 100644 crates/viewer/re_space_view_graph/src/layout/params.rs diff --git a/crates/viewer/re_space_view_graph/src/layout/mod.rs b/crates/viewer/re_space_view_graph/src/layout/mod.rs index a06d3748be2f..52cbf8fa094b 100644 --- a/crates/viewer/re_space_view_graph/src/layout/mod.rs +++ b/crates/viewer/re_space_view_graph/src/layout/mod.rs @@ -1,10 +1,12 @@ mod geometry; +mod params; mod provider; mod request; mod result; mod slots; pub use geometry::{EdgeGeometry, PathGeometry}; +pub use params::ForceLayoutParams; pub use provider::ForceLayoutProvider; pub use request::{EdgeTemplate, LayoutRequest}; pub use result::Layout; diff --git a/crates/viewer/re_space_view_graph/src/layout/params.rs b/crates/viewer/re_space_view_graph/src/layout/params.rs new file mode 100644 index 000000000000..5b14d173360c --- /dev/null +++ b/crates/viewer/re_space_view_graph/src/layout/params.rs @@ -0,0 +1,40 @@ +use re_types::blueprint::{ + archetypes::ForceLink, + components::{Enabled, ForceDistance}, +}; +use re_viewer_context::{ComponentFallbackProvider, SpaceViewState, ViewQuery, ViewerContext}; +use re_viewport_blueprint::{ViewProperty, ViewPropertyQueryError}; + +#[derive(Debug)] +pub struct ForceLayoutParams { + pub(super) force_link_enabled: Enabled, + pub(super) force_link_distance: ForceDistance, +} + +impl ForceLayoutParams { + pub fn get( + ctx: &ViewerContext<'_>, + query: &ViewQuery<'_>, + fallback_provider: &dyn ComponentFallbackProvider, + view_state: &dyn SpaceViewState, + ) -> Result { + let force_link_property = ViewProperty::from_archetype::( + ctx.blueprint_db(), + ctx.blueprint_query, + query.space_view_id, + ); + + Ok(Self { + force_link_enabled: force_link_property.component_or_fallback( + ctx, + fallback_provider, + view_state, + )?, + force_link_distance: force_link_property.component_or_fallback( + ctx, + fallback_provider, + view_state, + )?, + }) + } +} diff --git a/crates/viewer/re_space_view_graph/src/layout/provider.rs b/crates/viewer/re_space_view_graph/src/layout/provider.rs index 1036a2b20797..bd5df8355dac 100644 --- a/crates/viewer/re_space_view_graph/src/layout/provider.rs +++ b/crates/viewer/re_space_view_graph/src/layout/provider.rs @@ -11,7 +11,8 @@ use fjadra::{self as fj}; use crate::graph::{EdgeId, NodeId}; use super::{ - request::NodeTemplate, + params::{self, ForceLayoutParams}, + request::{self, NodeTemplate}, slots::{slotted_edges, Slot, SlotKind}, EdgeGeometry, EdgeTemplate, Layout, LayoutRequest, PathGeometry, }; @@ -32,17 +33,25 @@ pub struct ForceLayoutProvider { } impl ForceLayoutProvider { - pub fn new(request: LayoutRequest) -> Self { - Self::new_impl(request, None) + pub fn new(request: LayoutRequest, parameters: ForceLayoutParams) -> Self { + Self::new_impl(request, None, parameters) } - pub fn new_with_previous(request: LayoutRequest, layout: &Layout) -> Self { - Self::new_impl(request, Some(layout)) + pub fn new_with_previous( + request: LayoutRequest, + layout: &Layout, + parameters: ForceLayoutParams, + ) -> Self { + Self::new_impl(request, Some(layout), parameters) } // TODO(grtlr): Consider consuming the old layout to avoid re-allocating the extents. // That logic has to be revised when adding the blueprints anyways. - fn new_impl(request: LayoutRequest, layout: Option<&Layout>) -> Self { + fn new_impl( + request: LayoutRequest, + layout: Option<&Layout>, + parameters: ForceLayoutParams, + ) -> Self { let nodes = request.graphs.iter().flat_map(|(_, graph_template)| { graph_template.nodes.iter().map(|n| { let mut fj_node = fj::Node::from(n.1); @@ -69,24 +78,31 @@ impl ForceLayoutProvider { .iter() .flat_map(|(_, graph_template)| graph_template.edges.iter()); - // Looking at self-edges does not make sense in a force-based layout, so we filter those out. - let considered_edges = all_edges_iter - .clone() - .filter(|(id, _)| !id.is_self_edge()) - .map(|(id, _)| (node_index[&id.source], node_index[&id.target])); - // TODO(grtlr): Currently we guesstimate good forces. Eventually these should be exposed as blueprints. - let simulation = fj::SimulationBuilder::default() + let mut simulation = fj::SimulationBuilder::default() .with_alpha_decay(0.01) // TODO(grtlr): slows down the simulation for demo - .build(all_nodes) - .add_force( + .build(all_nodes); + + simulation = if **parameters.force_link_enabled { + // Looking at self-edges does not make sense in a force-based layout, so we filter those out. + let considered_edges = all_edges_iter + .clone() + .filter(|(id, _)| !id.is_self_edge()) + .map(|(id, _)| (node_index[&id.source], node_index[&id.target])); + + simulation.add_force( "link", - fj::Link::new(considered_edges).distance(50.0).iterations(2), + fj::Link::new(considered_edges) + .distance(parameters.force_link_distance.0 .0) + .iterations(2), ) - .add_force("charge", fj::ManyBody::new()) - // TODO(grtlr): This is a small stop-gap until we have blueprints to prevent nodes from flying away. - .add_force("x", fj::PositionX::new().strength(0.01)) - .add_force("y", fj::PositionY::new().strength(0.01)); + } else { + simulation + } + .add_force("charge", fj::ManyBody::new()) + // TODO(grtlr): This is a small stop-gap until we have blueprints to prevent nodes from flying away. + .add_force("x", fj::PositionX::new().strength(0.01)) + .add_force("y", fj::PositionY::new().strength(0.01)); Self { simulation, diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index 3e2511411aa3..2af4a992f070 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -4,7 +4,7 @@ use re_types::blueprint::{self, components::VisualBounds2D}; use re_ui::UiExt; use re_viewer_context::SpaceViewState; -use crate::layout::{ForceLayoutProvider, Layout, LayoutRequest}; +use crate::layout::{ForceLayoutParams, ForceLayoutProvider, Layout, LayoutRequest}; /// Space view state for the custom space view. /// @@ -97,7 +97,7 @@ impl LayoutState { } /// A simple state machine that keeps track of the different stages and if the layout needs to be recomputed. - fn update(self, new_request: LayoutRequest) -> Self { + fn update(self, new_request: LayoutRequest, params: ForceLayoutParams) -> Self { match self { // Layout is up to date, nothing to do here. Self::Finished { ref provider, .. } if provider.request == new_request => { @@ -105,13 +105,14 @@ impl LayoutState { } // We need to recompute the layout. Self::None => { - let provider = ForceLayoutProvider::new(new_request); + let provider = ForceLayoutProvider::new(new_request, params); let layout = provider.init(); Self::InProgress { layout, provider } } Self::Finished { layout, .. } => { - let mut provider = ForceLayoutProvider::new_with_previous(new_request, &layout); + let mut provider = + ForceLayoutProvider::new_with_previous(new_request, &layout, params); let mut layout = provider.init(); provider.tick(&mut layout); @@ -120,7 +121,8 @@ impl LayoutState { Self::InProgress { layout, provider, .. } if provider.request != new_request => { - let mut provider = ForceLayoutProvider::new_with_previous(new_request, &layout); + let mut provider = + ForceLayoutProvider::new_with_previous(new_request, &layout, params); let mut layout = provider.init(); provider.tick(&mut layout); @@ -138,8 +140,8 @@ impl LayoutState { } /// This method is lazy. A new layout is only computed if the current timestamp requires it. - pub fn get(&mut self, request: LayoutRequest) -> &mut Layout { - *self = std::mem::take(self).update(request); + pub fn get(&mut self, request: LayoutRequest, params: ForceLayoutParams) -> &mut Layout { + *self = std::mem::take(self).update(request, params); match self { Self::Finished { layout, .. } | Self::InProgress { layout, .. } => layout, diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index ace171c95481..31a2e57732f7 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -26,7 +26,7 @@ use re_viewport_blueprint::ViewProperty; use crate::{ graph::Graph, - layout::LayoutRequest, + layout::{ForceLayoutParams, LayoutRequest}, ui::{draw_debug, draw_graph, GraphSpaceViewState}, visualizers::{merge, EdgesVisualizer, NodeVisualizer}, }; @@ -171,20 +171,13 @@ Display a graph of nodes and edges. let rect_in_scene: blueprint::components::VisualBounds2D = bounds_property.component_or_fallback(ctx, self, state)?; - let force_link_property = ViewProperty::from_archetype::( - ctx.blueprint_db(), - ctx.blueprint_query, - query.space_view_id, - ); - let force_enabled: Result, _> = - force_link_property.component_or_empty(); - dbg!(force_enabled); + let params = ForceLayoutParams::get(ctx, query, self, state)?; let rect_in_ui = ui.max_rect(); let request = LayoutRequest::from_graphs(graphs.iter()); let layout_was_empty = state.layout_state.is_none(); - let layout = state.layout_state.get(request); + let layout = state.layout_state.get(request, params); let mut ui_from_world = fit_to_rect_in_scene(rect_in_ui, rect_in_scene.into()); From db56814d24d3d71b583f6265e4b6005e06d4cdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 09:44:25 +0100 Subject: [PATCH 19/44] Helper functions --- .../re_space_view_graph/src/layout/request.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/viewer/re_space_view_graph/src/layout/request.rs b/crates/viewer/re_space_view_graph/src/layout/request.rs index 177d05fbec15..85416f03f95a 100644 --- a/crates/viewer/re_space_view_graph/src/layout/request.rs +++ b/crates/viewer/re_space_view_graph/src/layout/request.rs @@ -78,4 +78,18 @@ impl LayoutRequest { request } + + /// Returns all nodes from all graphs in this request. + pub(super) fn all_nodes(&self) -> impl Iterator + '_ { + self.graphs + .iter() + .flat_map(|(_, graph)| graph.nodes.iter().map(|(k, v)| (*k, v))) + } + + /// Returns all edges from all graphs in this request. + pub(super) fn all_edges(&self) -> impl Iterator + '_ { + self.graphs + .iter() + .flat_map(|(_, graph)| graph.edges.iter().map(|(k, v)| (*k, v.as_slice()))) + } } From 112d8c6a8d27b7bedb949a8a43d49bca73c3c463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 09:44:25 +0100 Subject: [PATCH 20/44] Helper functions --- .../re_space_view_graph/src/layout/request.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/viewer/re_space_view_graph/src/layout/request.rs b/crates/viewer/re_space_view_graph/src/layout/request.rs index 177d05fbec15..85416f03f95a 100644 --- a/crates/viewer/re_space_view_graph/src/layout/request.rs +++ b/crates/viewer/re_space_view_graph/src/layout/request.rs @@ -78,4 +78,18 @@ impl LayoutRequest { request } + + /// Returns all nodes from all graphs in this request. + pub(super) fn all_nodes(&self) -> impl Iterator + '_ { + self.graphs + .iter() + .flat_map(|(_, graph)| graph.nodes.iter().map(|(k, v)| (*k, v))) + } + + /// Returns all edges from all graphs in this request. + pub(super) fn all_edges(&self) -> impl Iterator + '_ { + self.graphs + .iter() + .flat_map(|(_, graph)| graph.edges.iter().map(|(k, v)| (*k, v.as_slice()))) + } } From 4c0be0c7b2856ae87f39989b91770c4d0b55da84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 11:13:27 +0100 Subject: [PATCH 21/44] Remove `node_index` --- .../src/layout/provider.rs | 135 ++++++++---------- .../re_space_view_graph/src/layout/result.rs | 9 ++ .../re_space_view_graph/src/ui/state.rs | 21 ++- 3 files changed, 78 insertions(+), 87 deletions(-) diff --git a/crates/viewer/re_space_view_graph/src/layout/provider.rs b/crates/viewer/re_space_view_graph/src/layout/provider.rs index 1036a2b20797..2328300b5021 100644 --- a/crates/viewer/re_space_view_graph/src/layout/provider.rs +++ b/crates/viewer/re_space_view_graph/src/layout/provider.rs @@ -27,62 +27,32 @@ impl<'a> From<&'a NodeTemplate> for fj::Node { pub struct ForceLayoutProvider { simulation: fj::Simulation, - node_index: ahash::HashMap, pub request: LayoutRequest, } +fn considered_edges(request: &LayoutRequest) -> Vec<(usize, usize)> { + let node_index: ahash::HashMap = request + .all_nodes() + .enumerate() + .map(|(i, (id, _))| (id, i)) + .collect(); + request + .all_edges() + .filter(|(id, _)| !id.is_self_edge()) + .map(|(id, _)| (node_index[&id.source], node_index[&id.target])) + .collect() +} + impl ForceLayoutProvider { pub fn new(request: LayoutRequest) -> Self { - Self::new_impl(request, None) - } - - pub fn new_with_previous(request: LayoutRequest, layout: &Layout) -> Self { - Self::new_impl(request, Some(layout)) - } - - // TODO(grtlr): Consider consuming the old layout to avoid re-allocating the extents. - // That logic has to be revised when adding the blueprints anyways. - fn new_impl(request: LayoutRequest, layout: Option<&Layout>) -> Self { - let nodes = request.graphs.iter().flat_map(|(_, graph_template)| { - graph_template.nodes.iter().map(|n| { - let mut fj_node = fj::Node::from(n.1); - if let Some(rect) = layout.and_then(|l| l.get_node(n.0)) { - let pos = rect.center(); - fj_node = fj_node.position(pos.x as f64, pos.y as f64); - } - - (n.0, fj_node) - }) - }); - - let mut node_index = ahash::HashMap::default(); - let all_nodes: Vec = nodes - .enumerate() - .map(|(i, n)| { - node_index.insert(*n.0, i); - n.1 - }) - .collect(); - - let all_edges_iter = request - .graphs - .iter() - .flat_map(|(_, graph_template)| graph_template.edges.iter()); - - // Looking at self-edges does not make sense in a force-based layout, so we filter those out. - let considered_edges = all_edges_iter - .clone() - .filter(|(id, _)| !id.is_self_edge()) - .map(|(id, _)| (node_index[&id.source], node_index[&id.target])); + let nodes = request.all_nodes().map(|(_, v)| fj::Node::from(v)); + let edges = considered_edges(&request); // TODO(grtlr): Currently we guesstimate good forces. Eventually these should be exposed as blueprints. let simulation = fj::SimulationBuilder::default() .with_alpha_decay(0.01) // TODO(grtlr): slows down the simulation for demo - .build(all_nodes) - .add_force( - "link", - fj::Link::new(considered_edges).distance(50.0).iterations(2), - ) + .build(nodes) + .add_force("link", fj::Link::new(edges).distance(50.0).iterations(2)) .add_force("charge", fj::ManyBody::new()) // TODO(grtlr): This is a small stop-gap until we have blueprints to prevent nodes from flying away. .add_force("x", fj::PositionX::new().strength(0.01)) @@ -90,52 +60,55 @@ impl ForceLayoutProvider { Self { simulation, - node_index, request, } } - pub fn init(&self) -> Layout { - let positions = self.simulation.positions().collect::>(); - let mut extents = ahash::HashMap::default(); - - for graph in self.request.graphs.values() { - for (id, node) in &graph.nodes { - let i = self.node_index[id]; - let [x, y] = positions[i]; - let pos = Pos2::new(x as f32, y as f32); - extents.insert(*id, Rect::from_center_size(pos, node.size)); + pub fn new_with_previous(request: LayoutRequest, layout: &Layout) -> Self { + let nodes = request.all_nodes().map(|(id, v)| { + if let Some(rect) = layout.get_node(&id) { + let pos = rect.center(); + fj::Node::from(v).position(pos.x as f64, pos.y as f64) + } else { + fj::Node::from(v) } - } + }); + let edges = considered_edges(&request); + + // TODO(grtlr): Currently we guesstimate good forces. Eventually these should be exposed as blueprints. + let simulation = fj::SimulationBuilder::default() + .with_alpha_decay(0.01) // TODO(grtlr): slows down the simulation for demo + .build(nodes) + .add_force("link", fj::Link::new(edges).distance(50.0).iterations(2)) + .add_force("charge", fj::ManyBody::new()) + // TODO(grtlr): This is a small stop-gap until we have blueprints to prevent nodes from flying away. + .add_force("x", fj::PositionX::new().strength(0.01)) + .add_force("y", fj::PositionY::new().strength(0.01)); - Layout { - nodes: extents, - // Without any real node positions, we probably don't want to draw edges either. - edges: ahash::HashMap::default(), - entities: Vec::new(), + Self { + simulation, + request, } } - /// Returns `true` if finished. - pub fn tick(&mut self, layout: &mut Layout) -> bool { - self.simulation.tick(1); - + fn layout(&self) -> Layout { + // We make use of the fact here that the simulation is stable, i.e. the + // order of the nodes is the same as in the request. + let mut i = 0..; let positions = self.simulation.positions().collect::>(); - // We clear all unnecessary data from the previous layout, but keep its space allocated. - layout.entities.clear(); - layout.edges.clear(); + let mut layout = Layout::empty(); for (entity, graph) in &self.request.graphs { let mut current_rect = Rect::NOTHING; - for node in graph.nodes.keys() { - let extent = layout.nodes.get_mut(node).expect("node has to be present"); - let i = self.node_index[node]; + for (node, template) in &graph.nodes { + let i = i.next().expect("can never happen"); let [x, y] = positions[i]; let pos = Pos2::new(x as f32, y as f32); - extent.set_center(pos); - current_rect = current_rect.union(*extent); + let extent = Rect::from_center_size(pos, template.size); + current_rect = current_rect.union(extent); + layout.nodes.insert(*node, extent); } layout.entities.push((entity.clone(), current_rect)); @@ -248,6 +221,16 @@ impl ForceLayoutProvider { } } + layout + } + + /// Returns `true` if finished. + pub fn tick(&mut self) -> Layout { + self.simulation.tick(1); + self.layout() + } + + pub fn is_finished(&self) -> bool { self.simulation.finished() } } diff --git a/crates/viewer/re_space_view_graph/src/layout/result.rs b/crates/viewer/re_space_view_graph/src/layout/result.rs index 31a9219b909c..85c03a5d33fb 100644 --- a/crates/viewer/re_space_view_graph/src/layout/result.rs +++ b/crates/viewer/re_space_view_graph/src/layout/result.rs @@ -19,6 +19,15 @@ fn bounding_rect_from_iter(rectangles: impl Iterator) -> egui } impl Layout { + /// Creates an empty layout + pub fn empty() -> Self { + Self { + nodes: ahash::HashMap::default(), + edges: ahash::HashMap::default(), + entities: Vec::new(), + } + } + /// Returns the bounding rectangle of the layout. pub fn bounding_rect(&self) -> Rect { // TODO(grtlr): We mostly use this for debugging, but we should probably diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index 749e3720f937..4f22ca995c53 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -105,34 +105,33 @@ impl LayoutState { } // We need to recompute the layout. Self::None => { - let provider = ForceLayoutProvider::new(new_request); - let layout = provider.init(); - + let mut provider = ForceLayoutProvider::new(new_request); + let layout = provider.tick(); Self::InProgress { layout, provider } } Self::Finished { layout, .. } => { let mut provider = ForceLayoutProvider::new_with_previous(new_request, &layout); - let mut layout = provider.init(); - provider.tick(&mut layout); - + let layout = provider.tick(); Self::InProgress { layout, provider } } Self::InProgress { layout, provider, .. } if provider.request != new_request => { let mut provider = ForceLayoutProvider::new_with_previous(new_request, &layout); - let mut layout = provider.init(); - provider.tick(&mut layout); + let layout = provider.tick(); Self::InProgress { layout, provider } } // We keep iterating on the layout until it is stable. Self::InProgress { - mut layout, mut provider, - } => match provider.tick(&mut layout) { + layout, + } => match provider.is_finished() { true => Self::Finished { layout, provider }, - false => Self::InProgress { layout, provider }, + false => Self::InProgress { + layout: provider.tick(), + provider, + }, }, } } From 428510accb8f1404535d8d7c6f8baad6549a35f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 11:47:37 +0100 Subject: [PATCH 22/44] Implement `zip` on positions --- .../re_space_view_graph/src/layout/provider.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/viewer/re_space_view_graph/src/layout/provider.rs b/crates/viewer/re_space_view_graph/src/layout/provider.rs index 2328300b5021..ab03eb03461c 100644 --- a/crates/viewer/re_space_view_graph/src/layout/provider.rs +++ b/crates/viewer/re_space_view_graph/src/layout/provider.rs @@ -92,19 +92,19 @@ impl ForceLayoutProvider { } fn layout(&self) -> Layout { + let mut layout = Layout::empty(); + // We make use of the fact here that the simulation is stable, i.e. the // order of the nodes is the same as in the request. - let mut i = 0..; let positions = self.simulation.positions().collect::>(); - - let mut layout = Layout::empty(); + let mut graph_offset = 0; for (entity, graph) in &self.request.graphs { let mut current_rect = Rect::NOTHING; - for (node, template) in &graph.nodes { - let i = i.next().expect("can never happen"); - let [x, y] = positions[i]; + for ((node, template), &[x, y]) in + graph.nodes.iter().zip(positions[graph_offset..].iter()) + { let pos = Pos2::new(x as f32, y as f32); let extent = Rect::from_center_size(pos, template.size); current_rect = current_rect.union(extent); @@ -219,6 +219,7 @@ impl ForceLayoutProvider { } } } + graph_offset += graph.nodes.len(); } layout From e9546b338e68a4766b1eeff5b0266ec4e78d5953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 11:53:24 +0100 Subject: [PATCH 23/44] Avoid allocation --- .../re_space_view_graph/src/layout/provider.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/viewer/re_space_view_graph/src/layout/provider.rs b/crates/viewer/re_space_view_graph/src/layout/provider.rs index ab03eb03461c..f4af4f5409d5 100644 --- a/crates/viewer/re_space_view_graph/src/layout/provider.rs +++ b/crates/viewer/re_space_view_graph/src/layout/provider.rs @@ -92,19 +92,17 @@ impl ForceLayoutProvider { } fn layout(&self) -> Layout { - let mut layout = Layout::empty(); - // We make use of the fact here that the simulation is stable, i.e. the - // order of the nodes is the same as in the request. - let positions = self.simulation.positions().collect::>(); - let mut graph_offset = 0; + // order of the nodes is the same as in the `request`. + let mut positions = self.simulation.positions(); + + let mut layout = Layout::empty(); for (entity, graph) in &self.request.graphs { let mut current_rect = Rect::NOTHING; - for ((node, template), &[x, y]) in - graph.nodes.iter().zip(positions[graph_offset..].iter()) - { + for (node, template) in &graph.nodes { + let [x, y] = positions.next().expect("positions has to match the layout"); let pos = Pos2::new(x as f32, y as f32); let extent = Rect::from_center_size(pos, template.size); current_rect = current_rect.union(extent); @@ -219,7 +217,6 @@ impl ForceLayoutProvider { } } } - graph_offset += graph.nodes.len(); } layout From 15bedd4b73aacfc58b4805069145ba48b277f97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 12:29:01 +0100 Subject: [PATCH 24/44] Adaptive blueprints --- .../re_space_view_graph/src/layout/params.rs | 2 +- .../src/layout/provider.rs | 35 ++++++++++--- .../re_space_view_graph/src/ui/state.rs | 51 +++++++++++++++---- 3 files changed, 72 insertions(+), 16 deletions(-) diff --git a/crates/viewer/re_space_view_graph/src/layout/params.rs b/crates/viewer/re_space_view_graph/src/layout/params.rs index 5b14d173360c..befe053d7712 100644 --- a/crates/viewer/re_space_view_graph/src/layout/params.rs +++ b/crates/viewer/re_space_view_graph/src/layout/params.rs @@ -5,7 +5,7 @@ use re_types::blueprint::{ use re_viewer_context::{ComponentFallbackProvider, SpaceViewState, ViewQuery, ViewerContext}; use re_viewport_blueprint::{ViewProperty, ViewPropertyQueryError}; -#[derive(Debug)] +#[derive(Debug, PartialEq)] pub struct ForceLayoutParams { pub(super) force_link_enabled: Enabled, pub(super) force_link_distance: ForceDistance, diff --git a/crates/viewer/re_space_view_graph/src/layout/provider.rs b/crates/viewer/re_space_view_graph/src/layout/provider.rs index 3bb7de57fdb7..3daa4b80f3dc 100644 --- a/crates/viewer/re_space_view_graph/src/layout/provider.rs +++ b/crates/viewer/re_space_view_graph/src/layout/provider.rs @@ -6,7 +6,7 @@ // layouts, such as `dot` from `graphviz`. use egui::{Pos2, Rect, Vec2}; -use fjadra::{self as fj}; +use fjadra::{self as fj, Simulation}; use crate::graph::{EdgeId, NodeId}; @@ -26,6 +26,23 @@ impl<'a> From<&'a NodeTemplate> for fj::Node { } } +// TODO(grtlr): Do this more efficiently, as this currently rebuilds all helper functions. +pub fn update_simulation( + mut simulation: fj::Simulation, + params: &ForceLayoutParams, + edges: Vec<(usize, usize)>, +) -> Simulation { + if **params.force_link_enabled { + simulation = simulation.add_force( + "link", + fj::Link::new(edges) + .distance(params.force_link_distance.0 .0) + .iterations(2), + ); + } + simulation +} + pub struct ForceLayoutProvider { simulation: fj::Simulation, pub request: LayoutRequest, @@ -45,27 +62,32 @@ fn considered_edges(request: &LayoutRequest) -> Vec<(usize, usize)> { } impl ForceLayoutProvider { - pub fn new(request: LayoutRequest) -> Self { + pub fn new(request: LayoutRequest, params: &ForceLayoutParams) -> Self { let nodes = request.all_nodes().map(|(_, v)| fj::Node::from(v)); let edges = considered_edges(&request); // TODO(grtlr): Currently we guesstimate good forces. Eventually these should be exposed as blueprints. - let mut simulation = fj::SimulationBuilder::default() + let simulation = fj::SimulationBuilder::default() .with_alpha_decay(0.01) // TODO(grtlr): slows down the simulation for demo .build(nodes) - .add_force("link", fj::Link::new(edges).distance(50.0).iterations(2)) .add_force("charge", fj::ManyBody::new()) // TODO(grtlr): This is a small stop-gap until we have blueprints to prevent nodes from flying away. .add_force("x", fj::PositionX::new().strength(0.01)) .add_force("y", fj::PositionY::new().strength(0.01)); + let simulation = update_simulation(simulation, params, edges); + Self { simulation, request, } } - pub fn new_with_previous(request: LayoutRequest, layout: &Layout) -> Self { + pub fn new_with_previous( + request: LayoutRequest, + layout: &Layout, + params: &ForceLayoutParams, + ) -> Self { let nodes = request.all_nodes().map(|(id, v)| { if let Some(rect) = layout.get_node(&id) { let pos = rect.center(); @@ -80,12 +102,13 @@ impl ForceLayoutProvider { let simulation = fj::SimulationBuilder::default() .with_alpha_decay(0.01) // TODO(grtlr): slows down the simulation for demo .build(nodes) - .add_force("link", fj::Link::new(edges).distance(50.0).iterations(2)) .add_force("charge", fj::ManyBody::new()) // TODO(grtlr): This is a small stop-gap until we have blueprints to prevent nodes from flying away. .add_force("x", fj::PositionX::new().strength(0.01)) .add_force("y", fj::PositionY::new().strength(0.01)); + let simulation = update_simulation(simulation, params, edges); + Self { simulation, request, diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index bad8caeca671..2464c2482e35 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -67,10 +67,12 @@ pub enum LayoutState { InProgress { layout: Layout, provider: ForceLayoutProvider, + params: ForceLayoutParams, }, Finished { layout: Layout, provider: ForceLayoutProvider, + params: ForceLayoutParams, }, } @@ -105,33 +107,64 @@ impl LayoutState { } // We need to recompute the layout. Self::None => { - let mut provider = ForceLayoutProvider::new(new_request); + let mut provider = ForceLayoutProvider::new(new_request, ¶ms); let layout = provider.tick(); - Self::InProgress { layout, provider } + Self::InProgress { + layout, + provider, + params, + } } Self::Finished { layout, .. } => { - let mut provider = ForceLayoutProvider::new_with_previous(new_request, &layout); + let mut provider = + ForceLayoutProvider::new_with_previous(new_request, &layout, ¶ms); let layout = provider.tick(); - Self::InProgress { layout, provider } + Self::InProgress { + layout, + provider, + params, + } } Self::InProgress { layout, provider, .. } if provider.request != new_request => { - let mut provider = ForceLayoutProvider::new_with_previous(new_request, &layout); + let mut provider = + ForceLayoutProvider::new_with_previous(new_request, &layout, ¶ms); let layout = provider.tick(); - Self::InProgress { layout, provider } + Self::InProgress { + layout, + provider, + params, + } } // We keep iterating on the layout until it is stable. Self::InProgress { mut provider, layout, - } => match provider.is_finished() { - true => Self::Finished { layout, provider }, - false => Self::InProgress { + params: old_params, + } => match (provider.is_finished(), params == old_params) { + (true, true) => Self::Finished { + layout, + provider, + params, + }, + (false, true) => Self::InProgress { layout: provider.tick(), provider, + params, }, + _ => { + let mut provider = + ForceLayoutProvider::new_with_previous(new_request, &layout, ¶ms); + let layout = provider.tick(); + + Self::InProgress { + layout, + provider, + params, + } + } }, } } From 700be1363196e58cda6147f9bc7a0ad060f56050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 13:01:02 +0100 Subject: [PATCH 25/44] Add additional blueprints --- .../rerun/blueprint/archetypes.fbs | 4 + .../blueprint/archetypes/force_center.fbs | 14 ++ .../archetypes/force_collision_radius.fbs | 14 ++ .../rerun/blueprint/archetypes/force_link.fbs | 3 + .../blueprint/archetypes/force_many_body.fbs | 14 ++ .../blueprint/archetypes/force_position.fbs | 17 ++ .../rerun/blueprint/components.fbs | 2 + .../blueprint/components/force_iterations.fbs | 16 ++ .../blueprint/components/force_strength.fbs | 16 ++ .../rerun/blueprint/views/graph.fbs | 12 + .../src/blueprint/archetypes/.gitattributes | 4 + .../src/blueprint/archetypes/force_center.rs | 198 +++++++++++++++ .../archetypes/force_collision_radius.rs | 201 +++++++++++++++ .../blueprint/archetypes/force_many_body.rs | 198 +++++++++++++++ .../blueprint/archetypes/force_position.rs | 230 ++++++++++++++++++ .../re_types/src/blueprint/archetypes/mod.rs | 8 + .../src/blueprint/components/.gitattributes | 2 + .../blueprint/components/force_iterations.rs | 115 +++++++++ .../blueprint/components/force_strength.rs | 116 +++++++++ .../re_types/src/blueprint/components/mod.rs | 4 + .../src/blueprint/views/graph_view.rs | 23 +- crates/viewer/re_component_ui/src/lib.rs | 5 +- .../re_space_view_graph/src/properties.rs | 24 +- .../src/blueprint/validation_gen/mod.rs | 4 + crates/viewer/re_viewer/src/reflection/mod.rs | 84 +++++++ .../reference/types/views/graph_view.md | 21 ++ rerun_cpp/src/rerun/blueprint/archetypes.hpp | 4 + .../rerun/blueprint/archetypes/.gitattributes | 8 + .../blueprint/archetypes/force_center.cpp | 38 +++ .../blueprint/archetypes/force_center.hpp | 69 ++++++ .../archetypes/force_collision_radius.cpp | 39 +++ .../archetypes/force_collision_radius.hpp | 70 ++++++ .../blueprint/archetypes/force_many_body.cpp | 39 +++ .../blueprint/archetypes/force_many_body.hpp | 69 ++++++ .../blueprint/archetypes/force_position.cpp | 44 ++++ .../blueprint/archetypes/force_position.hpp | 80 ++++++ rerun_cpp/src/rerun/blueprint/components.hpp | 2 + .../rerun/blueprint/components/.gitattributes | 2 + .../blueprint/components/force_iterations.hpp | 77 ++++++ .../blueprint/components/force_strength.hpp | 77 ++++++ .../rerun/blueprint/archetypes/.gitattributes | 4 + .../rerun/blueprint/archetypes/__init__.py | 8 + .../blueprint/archetypes/force_center.py | 80 ++++++ .../archetypes/force_collision_radius.py | 80 ++++++ .../blueprint/archetypes/force_many_body.py | 80 ++++++ .../blueprint/archetypes/force_position.py | 96 ++++++++ .../rerun/blueprint/components/.gitattributes | 2 + .../rerun/blueprint/components/__init__.py | 6 + .../blueprint/components/force_iterations.py | 36 +++ .../blueprint/components/force_strength.py | 36 +++ .../rerun/blueprint/views/graph_view.py | 32 +++ 51 files changed, 2422 insertions(+), 5 deletions(-) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_center.rs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_many_body.rs create mode 100644 crates/store/re_types/src/blueprint/archetypes/force_position.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_iterations.rs create mode 100644 crates/store/re_types/src/blueprint/components/force_strength.rs create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position.cpp create mode 100644 rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp create mode 100644 rerun_cpp/src/rerun/blueprint/components/force_strength.hpp create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index b378d9d3e816..df4127d17460 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -3,7 +3,11 @@ include "./archetypes/background.fbs"; include "./archetypes/container_blueprint.fbs"; include "./archetypes/dataframe_query.fbs"; +include "./archetypes/force_center.fbs"; +include "./archetypes/force_collision_radius.fbs"; include "./archetypes/force_link.fbs"; +include "./archetypes/force_many_body.fbs"; +include "./archetypes/force_position.fbs"; include "./archetypes/map_background.fbs"; include "./archetypes/map_zoom.fbs"; include "./archetypes/panel_blueprint.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs new file mode 100644 index 000000000000..6dc43169fc01 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs @@ -0,0 +1,14 @@ +namespace rerun.blueprint.archetypes; + +// TODO + +/// The link force pushes linked nodes together or apart according to a desired distance. +struct ForceCenter ( + "attr.rerun.scope": "blueprint" +) { + /// Whether the force is enabled. + enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100); + + /// The strength of the force. + strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs new file mode 100644 index 000000000000..3709b9679343 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs @@ -0,0 +1,14 @@ +namespace rerun.blueprint.archetypes; + +// TODO + +/// The link force pushes linked nodes together or apart according to a desired distance. +struct ForceCollisionRadius ( + "attr.rerun.scope": "blueprint" +) { + /// Whether the force is enabled. + enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100); + + /// The strength of the force. + strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs index 95cbda704489..ad9eb2550c83 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs @@ -9,4 +9,7 @@ struct ForceLink ( /// The target distance between two nodes. distance: rerun.blueprint.components.ForceDistance ("attr.rerun.component_optional", nullable, order: 200); + + /// The number of iterations to run the force. + //iterations: rerun.blueprint.components.ForceIterations ("attr.rerun.component_optional", nullable, order: 400); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs new file mode 100644 index 000000000000..66755652741d --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs @@ -0,0 +1,14 @@ +namespace rerun.blueprint.archetypes; + +// TODO + +/// The link force pushes linked nodes together or apart according to a desired distance. +struct ForceManyBody ( + "attr.rerun.scope": "blueprint" +) { + /// Whether the force is enabled. + enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100); + + /// The strength of the force. + strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs new file mode 100644 index 000000000000..f0bc021c3a83 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs @@ -0,0 +1,17 @@ +namespace rerun.blueprint.archetypes; + +// TODO + +/// The link force pushes linked nodes together or apart according to a desired distance. +struct ForcePosition ( + "attr.rerun.scope": "blueprint" +) { + /// Whether the force is enabled. + enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100); + + /// The strength of the force. + strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200); + + /// The position where the nodes should bepulled towards. + position: rerun.components.Position2D ("attr.rerun.component_optional", nullable, order: 300); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components.fbs b/crates/store/re_types/definitions/rerun/blueprint/components.fbs index 731466b4d4a5..3c8d5f5deafb 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -13,6 +13,8 @@ include "./components/enabled.fbs"; include "./components/filter_by_range.fbs"; include "./components/filter_is_not_null.fbs"; include "./components/force_distance.fbs"; +include "./components/force_iterations.fbs"; +include "./components/force_strength.fbs"; include "./components/grid_columns.fbs"; include "./components/included_content.fbs"; include "./components/interactive.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs new file mode 100644 index 000000000000..9f016072ca8f --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs @@ -0,0 +1,16 @@ + +namespace rerun.blueprint.components; + +// TODO + +/// The target distance between two nodes. +/// +/// This is helpful to scale the layout, for example if long labels are involved. +struct ForceIterations ( + "attr.arrow.transparent", + "attr.rust.derive": "Default, Copy, PartialEq, Eq", + "attr.rust.repr": "transparent", + "attr.rerun.scope": "blueprint" +) { + distance: rerun.datatypes.UInt64 (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs new file mode 100644 index 000000000000..55c5d0844732 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs @@ -0,0 +1,16 @@ + +namespace rerun.blueprint.components; + +// TODO + +/// The target distance between two nodes. +/// +/// This is helpful to scale the layout, for example if long labels are involved. +struct ForceStrength ( + "attr.arrow.transparent", + "attr.rust.derive": "Default, Copy, PartialEq", + "attr.rust.repr": "transparent", + "attr.rerun.scope": "blueprint" +) { + distance: rerun.datatypes.Float64 (order: 100); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index e4e933c0e567..312690512b0c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -14,4 +14,16 @@ table GraphView ( /// A link force between nodes in the graph. force_link: rerun.blueprint.archetypes.ForceLink (order: 2000); + + /// TODO + force_many_body: rerun.blueprint.archetypes.ForceManyBody (order: 3000); + + /// TODO + force_position: rerun.blueprint.archetypes.ForcePosition (order: 4000); + + /// TODO + force_collision_radius: rerun.blueprint.archetypes.ForceCollisionRadius (order: 5000); + + /// TODO + force_center: rerun.blueprint.archetypes.ForceCenter (order: 6000); } diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index 8bd7fde9abfc..21c7774b8b71 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -3,7 +3,11 @@ .gitattributes linguist-generated=true background.rs linguist-generated=true dataframe_query.rs linguist-generated=true +force_center.rs linguist-generated=true +force_collision_radius.rs linguist-generated=true force_link.rs linguist-generated=true +force_many_body.rs linguist-generated=true +force_position.rs linguist-generated=true map_background.rs linguist-generated=true map_zoom.rs linguist-generated=true mod.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/archetypes/force_center.rs b/crates/store/re_types/src/blueprint/archetypes/force_center.rs new file mode 100644 index 000000000000..041440b24dfe --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_center.rs @@ -0,0 +1,198 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +#[derive(Clone, Debug)] +pub struct ForceCenter { + /// Whether the force is enabled. + pub enabled: Option, + + /// The strength of the force. + pub strength: Option, +} + +impl ::re_types_core::SizeBytes for ForceCenter { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceCenterIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceStrength".into(), + ] + }); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.ForceCenterIndicator".into(), + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceStrength".into(), + ] + }); + +impl ForceCenter { + /// The total number of components in the archetype: 0 required, 1 recommended, 2 optional + pub const NUM_COMPONENTS: usize = 3usize; +} + +/// Indicator component for the [`ForceCenter`] [`::re_types_core::Archetype`] +pub type ForceCenterIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceCenter { + type Indicator = ForceCenterIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceCenter".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force center" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceCenterIndicator = ForceCenterIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let enabled = if let Some(array) = arrays_by_name.get("rerun.blueprint.components.Enabled") + { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceCenter#enabled")? + .into_iter() + .next() + .flatten() + } else { + None + }; + let strength = + if let Some(array) = arrays_by_name.get("rerun.blueprint.components.ForceStrength") { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceCenter#strength")? + .into_iter() + .next() + .flatten() + } else { + None + }; + Ok(Self { enabled, strength }) + } +} + +impl ::re_types_core::AsComponents for ForceCenter { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + self.enabled + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + self.strength + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceCenter {} + +impl ForceCenter { + /// Create a new `ForceCenter`. + #[inline] + pub fn new() -> Self { + Self { + enabled: None, + strength: None, + } + } + + /// Whether the force is enabled. + #[inline] + pub fn with_enabled( + mut self, + enabled: impl Into, + ) -> Self { + self.enabled = Some(enabled.into()); + self + } + + /// The strength of the force. + #[inline] + pub fn with_strength( + mut self, + strength: impl Into, + ) -> Self { + self.strength = Some(strength.into()); + self + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs new file mode 100644 index 000000000000..ee9c0a4b3182 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs @@ -0,0 +1,201 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +#[derive(Clone, Debug)] +pub struct ForceCollisionRadius { + /// Whether the force is enabled. + pub enabled: Option, + + /// The strength of the force. + pub strength: Option, +} + +impl ::re_types_core::SizeBytes for ForceCollisionRadius { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| { + ["rerun.blueprint.components.ForceCollisionRadiusIndicator".into()] + }); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceStrength".into(), + ] + }); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.ForceCollisionRadiusIndicator".into(), + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceStrength".into(), + ] + }); + +impl ForceCollisionRadius { + /// The total number of components in the archetype: 0 required, 1 recommended, 2 optional + pub const NUM_COMPONENTS: usize = 3usize; +} + +/// Indicator component for the [`ForceCollisionRadius`] [`::re_types_core::Archetype`] +pub type ForceCollisionRadiusIndicator = + ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceCollisionRadius { + type Indicator = ForceCollisionRadiusIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceCollisionRadius".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force collision radius" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceCollisionRadiusIndicator = ForceCollisionRadiusIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let enabled = if let Some(array) = arrays_by_name.get("rerun.blueprint.components.Enabled") + { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceCollisionRadius#enabled")? + .into_iter() + .next() + .flatten() + } else { + None + }; + let strength = + if let Some(array) = arrays_by_name.get("rerun.blueprint.components.ForceStrength") { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceCollisionRadius#strength")? + .into_iter() + .next() + .flatten() + } else { + None + }; + Ok(Self { enabled, strength }) + } +} + +impl ::re_types_core::AsComponents for ForceCollisionRadius { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + self.enabled + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + self.strength + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceCollisionRadius {} + +impl ForceCollisionRadius { + /// Create a new `ForceCollisionRadius`. + #[inline] + pub fn new() -> Self { + Self { + enabled: None, + strength: None, + } + } + + /// Whether the force is enabled. + #[inline] + pub fn with_enabled( + mut self, + enabled: impl Into, + ) -> Self { + self.enabled = Some(enabled.into()); + self + } + + /// The strength of the force. + #[inline] + pub fn with_strength( + mut self, + strength: impl Into, + ) -> Self { + self.strength = Some(strength.into()); + self + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs new file mode 100644 index 000000000000..8c8182a92d38 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs @@ -0,0 +1,198 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +#[derive(Clone, Debug)] +pub struct ForceManyBody { + /// Whether the force is enabled. + pub enabled: Option, + + /// The strength of the force. + pub strength: Option, +} + +impl ::re_types_core::SizeBytes for ForceManyBody { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceManyBodyIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceStrength".into(), + ] + }); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.ForceManyBodyIndicator".into(), + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceStrength".into(), + ] + }); + +impl ForceManyBody { + /// The total number of components in the archetype: 0 required, 1 recommended, 2 optional + pub const NUM_COMPONENTS: usize = 3usize; +} + +/// Indicator component for the [`ForceManyBody`] [`::re_types_core::Archetype`] +pub type ForceManyBodyIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForceManyBody { + type Indicator = ForceManyBodyIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForceManyBody".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force many body" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForceManyBodyIndicator = ForceManyBodyIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let enabled = if let Some(array) = arrays_by_name.get("rerun.blueprint.components.Enabled") + { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceManyBody#enabled")? + .into_iter() + .next() + .flatten() + } else { + None + }; + let strength = + if let Some(array) = arrays_by_name.get("rerun.blueprint.components.ForceStrength") { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceManyBody#strength")? + .into_iter() + .next() + .flatten() + } else { + None + }; + Ok(Self { enabled, strength }) + } +} + +impl ::re_types_core::AsComponents for ForceManyBody { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + self.enabled + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + self.strength + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForceManyBody {} + +impl ForceManyBody { + /// Create a new `ForceManyBody`. + #[inline] + pub fn new() -> Self { + Self { + enabled: None, + strength: None, + } + } + + /// Whether the force is enabled. + #[inline] + pub fn with_enabled( + mut self, + enabled: impl Into, + ) -> Self { + self.enabled = Some(enabled.into()); + self + } + + /// The strength of the force. + #[inline] + pub fn with_strength( + mut self, + strength: impl Into, + ) -> Self { + self.strength = Some(strength.into()); + self + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position.rs b/crates/store/re_types/src/blueprint/archetypes/force_position.rs new file mode 100644 index 000000000000..27a222841774 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/force_position.rs @@ -0,0 +1,230 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +#[derive(Clone, Debug)] +pub struct ForcePosition { + /// Whether the force is enabled. + pub enabled: Option, + + /// The strength of the force. + pub strength: Option, + + /// The position where the nodes should bepulled towards. + pub position: Option, +} + +impl ::re_types_core::SizeBytes for ForcePosition { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + + self.strength.heap_size_bytes() + + self.position.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + && >::is_pod() + } +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionIndicator".into()]); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceStrength".into(), + "rerun.components.Position2D".into(), + ] + }); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 4usize]> = + once_cell::sync::Lazy::new(|| { + [ + "rerun.blueprint.components.ForcePositionIndicator".into(), + "rerun.blueprint.components.Enabled".into(), + "rerun.blueprint.components.ForceStrength".into(), + "rerun.components.Position2D".into(), + ] + }); + +impl ForcePosition { + /// The total number of components in the archetype: 0 required, 1 recommended, 3 optional + pub const NUM_COMPONENTS: usize = 4usize; +} + +/// Indicator component for the [`ForcePosition`] [`::re_types_core::Archetype`] +pub type ForcePositionIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for ForcePosition { + type Indicator = ForcePositionIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.ForcePosition".into() + } + + #[inline] + fn display_name() -> &'static str { + "Force position" + } + + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + static INDICATOR: ForcePositionIndicator = ForcePositionIndicator::DEFAULT; + MaybeOwnedComponentBatch::Ref(&INDICATOR) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + ALL_COMPONENTS.as_slice().into() + } + + #[inline] + fn from_arrow2_components( + arrow_data: impl IntoIterator)>, + ) -> DeserializationResult { + re_tracing::profile_function!(); + use ::re_types_core::{Loggable as _, ResultExt as _}; + let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data + .into_iter() + .map(|(name, array)| (name.full_name(), array)) + .collect(); + let enabled = if let Some(array) = arrays_by_name.get("rerun.blueprint.components.Enabled") + { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForcePosition#enabled")? + .into_iter() + .next() + .flatten() + } else { + None + }; + let strength = + if let Some(array) = arrays_by_name.get("rerun.blueprint.components.ForceStrength") { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForcePosition#strength")? + .into_iter() + .next() + .flatten() + } else { + None + }; + let position = if let Some(array) = arrays_by_name.get("rerun.components.Position2D") { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForcePosition#position")? + .into_iter() + .next() + .flatten() + } else { + None + }; + Ok(Self { + enabled, + strength, + position, + }) + } +} + +impl ::re_types_core::AsComponents for ForcePosition { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + self.enabled + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + self.strength + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + self.position + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for ForcePosition {} + +impl ForcePosition { + /// Create a new `ForcePosition`. + #[inline] + pub fn new() -> Self { + Self { + enabled: None, + strength: None, + position: None, + } + } + + /// Whether the force is enabled. + #[inline] + pub fn with_enabled( + mut self, + enabled: impl Into, + ) -> Self { + self.enabled = Some(enabled.into()); + self + } + + /// The strength of the force. + #[inline] + pub fn with_strength( + mut self, + strength: impl Into, + ) -> Self { + self.strength = Some(strength.into()); + self + } + + /// The position where the nodes should bepulled towards. + #[inline] + pub fn with_position(mut self, position: impl Into) -> Self { + self.position = Some(position.into()); + self + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index b66da0bccc2a..654800d05639 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -2,7 +2,11 @@ mod background; mod dataframe_query; +mod force_center; +mod force_collision_radius; mod force_link; +mod force_many_body; +mod force_position; mod map_background; mod map_zoom; mod plot_legend; @@ -18,7 +22,11 @@ mod visual_bounds2d; pub use self::background::Background; pub use self::dataframe_query::DataframeQuery; +pub use self::force_center::ForceCenter; +pub use self::force_collision_radius::ForceCollisionRadius; pub use self::force_link::ForceLink; +pub use self::force_many_body::ForceManyBody; +pub use self::force_position::ForcePosition; pub use self::map_background::MapBackground; pub use self::map_zoom::MapZoom; pub use self::plot_legend::PlotLegend; diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index e3193321b5e4..5d5e1d21a966 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -11,6 +11,8 @@ enabled.rs linguist-generated=true filter_by_range.rs linguist-generated=true filter_is_not_null.rs linguist-generated=true force_distance.rs linguist-generated=true +force_iterations.rs linguist-generated=true +force_strength.rs linguist-generated=true included_content.rs linguist-generated=true interactive.rs linguist-generated=true lock_range_during_zoom.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/force_iterations.rs b/crates/store/re_types/src/blueprint/components/force_iterations.rs new file mode 100644 index 000000000000..97b8bdc40653 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_iterations.rs @@ -0,0 +1,115 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Component**: The target distance between two nodes. +/// +/// This is helpful to scale the layout, for example if long labels are involved. +#[derive(Clone, Debug, Default, Copy, PartialEq, Eq)] +#[repr(transparent)] +pub struct ForceIterations(pub crate::datatypes::UInt64); + +impl ::re_types_core::SizeBytes for ForceIterations { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForceIterations { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceIterations { + #[inline] + fn borrow(&self) -> &crate::datatypes::UInt64 { + &self.0 + } +} + +impl std::ops::Deref for ForceIterations { + type Target = crate::datatypes::UInt64; + + #[inline] + fn deref(&self) -> &crate::datatypes::UInt64 { + &self.0 + } +} + +impl std::ops::DerefMut for ForceIterations { + #[inline] + fn deref_mut(&mut self) -> &mut crate::datatypes::UInt64 { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForceIterations); + +impl ::re_types_core::Loggable for ForceIterations { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::datatypes::UInt64::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::datatypes::UInt64::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::datatypes::UInt64::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } + + #[inline] + fn from_arrow2(arrow_data: &dyn arrow2::array::Array) -> DeserializationResult> + where + Self: Sized, + { + crate::datatypes::UInt64::from_arrow2(arrow_data).map(|v| v.into_iter().map(Self).collect()) + } +} + +impl ::re_types_core::Component for ForceIterations { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForceIterations".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/force_strength.rs b/crates/store/re_types/src/blueprint/components/force_strength.rs new file mode 100644 index 000000000000..0449ce3862dd --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/force_strength.rs @@ -0,0 +1,116 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Component**: The target distance between two nodes. +/// +/// This is helpful to scale the layout, for example if long labels are involved. +#[derive(Clone, Debug, Default, Copy, PartialEq)] +#[repr(transparent)] +pub struct ForceStrength(pub crate::datatypes::Float64); + +impl ::re_types_core::SizeBytes for ForceStrength { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ForceStrength { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceStrength { + #[inline] + fn borrow(&self) -> &crate::datatypes::Float64 { + &self.0 + } +} + +impl std::ops::Deref for ForceStrength { + type Target = crate::datatypes::Float64; + + #[inline] + fn deref(&self) -> &crate::datatypes::Float64 { + &self.0 + } +} + +impl std::ops::DerefMut for ForceStrength { + #[inline] + fn deref_mut(&mut self) -> &mut crate::datatypes::Float64 { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ForceStrength); + +impl ::re_types_core::Loggable for ForceStrength { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::datatypes::Float64::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::datatypes::Float64::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::datatypes::Float64::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } + + #[inline] + fn from_arrow2(arrow_data: &dyn arrow2::array::Array) -> DeserializationResult> + where + Self: Sized, + { + crate::datatypes::Float64::from_arrow2(arrow_data) + .map(|v| v.into_iter().map(Self).collect()) + } +} + +impl ::re_types_core::Component for ForceStrength { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ForceStrength".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index 9686fef21aa0..fbcdf82fc5ad 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -15,6 +15,8 @@ mod filter_by_range_ext; mod filter_is_not_null; mod filter_is_not_null_ext; mod force_distance; +mod force_iterations; +mod force_strength; mod included_content; mod interactive; mod interactive_ext; @@ -53,6 +55,8 @@ pub use self::enabled::Enabled; pub use self::filter_by_range::FilterByRange; pub use self::filter_is_not_null::FilterIsNotNull; pub use self::force_distance::ForceDistance; +pub use self::force_iterations::ForceIterations; +pub use self::force_strength::ForceStrength; pub use self::included_content::IncludedContent; pub use self::interactive::Interactive; pub use self::lock_range_during_zoom::LockRangeDuringZoom; diff --git a/crates/store/re_types/src/blueprint/views/graph_view.rs b/crates/store/re_types/src/blueprint/views/graph_view.rs index b251dd8606eb..91b0f2bcbb57 100644 --- a/crates/store/re_types/src/blueprint/views/graph_view.rs +++ b/crates/store/re_types/src/blueprint/views/graph_view.rs @@ -28,18 +28,39 @@ pub struct GraphView { /// A link force between nodes in the graph. pub force_link: crate::blueprint::archetypes::ForceLink, + + /// TODO + pub force_many_body: crate::blueprint::archetypes::ForceManyBody, + + /// TODO + pub force_position: crate::blueprint::archetypes::ForcePosition, + + /// TODO + pub force_collision_radius: crate::blueprint::archetypes::ForceCollisionRadius, + + /// TODO + pub force_center: crate::blueprint::archetypes::ForceCenter, } impl ::re_types_core::SizeBytes for GraphView { #[inline] fn heap_size_bytes(&self) -> u64 { - self.visual_bounds.heap_size_bytes() + self.force_link.heap_size_bytes() + self.visual_bounds.heap_size_bytes() + + self.force_link.heap_size_bytes() + + self.force_many_body.heap_size_bytes() + + self.force_position.heap_size_bytes() + + self.force_collision_radius.heap_size_bytes() + + self.force_center.heap_size_bytes() } #[inline] fn is_pod() -> bool { ::is_pod() && ::is_pod() + && ::is_pod() + && ::is_pod() + && ::is_pod() + && ::is_pod() } } diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 8830dcf96afa..5b939d67fccc 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -34,8 +34,8 @@ use datatype_uis::{ use re_types::{ blueprint::components::{ - BackgroundKind, Corner2D, Enabled, ForceDistance, LockRangeDuringZoom, MapProvider, - ViewFit, Visible, ZoomLevel, + BackgroundKind, Corner2D, Enabled, ForceDistance, ForceStrength, LockRangeDuringZoom, + MapProvider, ViewFit, Visible, ZoomLevel, }, components::{ AggregationPolicy, AlbedoFactor, AxisLength, Color, DepthMeter, DrawOrder, FillMode, @@ -72,6 +72,7 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f64_zero_to_max); + registry.add_singleline_edit_or_view::(edit_f64_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); diff --git a/crates/viewer/re_space_view_graph/src/properties.rs b/crates/viewer/re_space_view_graph/src/properties.rs index 8096660bbf64..4897e7451af9 100644 --- a/crates/viewer/re_space_view_graph/src/properties.rs +++ b/crates/viewer/re_space_view_graph/src/properties.rs @@ -1,8 +1,9 @@ use re_types::{ blueprint::{ archetypes, - components::{Enabled, ForceDistance, VisualBounds2D}, + components::{Enabled, ForceDistance, ForceStrength, VisualBounds2D}, }, + components::Position2D, Archetype as _, }; use re_viewer_context::{SpaceViewStateExt as _, TypedComponentFallbackProvider}; @@ -30,6 +31,8 @@ impl TypedComponentFallbackProvider for GraphSpaceView { fn fallback_for(&self, ctx: &re_viewer_context::QueryContext<'_>) -> Enabled { match ctx.archetype_name { Some(name) if name == archetypes::ForceLink::name() => true.into(), + Some(name) if name == archetypes::ForceManyBody::name() => true.into(), + Some(name) if name == archetypes::ForcePosition::name() => true.into(), _ => false.into(), } } @@ -41,4 +44,21 @@ impl TypedComponentFallbackProvider for GraphSpaceView { } } -re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D, Enabled, ForceDistance]); +impl TypedComponentFallbackProvider for GraphSpaceView { + fn fallback_for(&self, ctx: &re_viewer_context::QueryContext<'_>) -> ForceStrength { + match ctx.archetype_name { + Some(name) if name == archetypes::ForceManyBody::name() => (-30.).into(), + Some(name) if name == archetypes::ForcePosition::name() => (0.01).into(), + Some(name) if name == archetypes::ForceCenter::name() => (1.0).into(), + _ => Default::default(), + } + } +} + +impl TypedComponentFallbackProvider for GraphSpaceView { + fn fallback_for(&self, _ctx: &re_viewer_context::QueryContext<'_>) -> Position2D { + Default::default() + } +} + +re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D, Enabled, ForceDistance, ForceStrength, Position2D]); diff --git a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs index d0b058316a64..42b486d98b3b 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -11,6 +11,8 @@ pub use re_types::blueprint::components::Enabled; pub use re_types::blueprint::components::FilterByRange; pub use re_types::blueprint::components::FilterIsNotNull; pub use re_types::blueprint::components::ForceDistance; +pub use re_types::blueprint::components::ForceIterations; +pub use re_types::blueprint::components::ForceStrength; pub use re_types::blueprint::components::IncludedContent; pub use re_types::blueprint::components::Interactive; pub use re_types::blueprint::components::LockRangeDuringZoom; @@ -54,6 +56,8 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) + && validate_component::(blueprint) + && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 31cf57d6bdc8..4d3ccccc4d3b 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -140,6 +140,22 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "The target distance between two nodes.\n\nThis is helpful to scale the layout, for example if long labels are involved.", + custom_placeholder: Some(ForceIterations::default().to_arrow2()?), + datatype: ForceIterations::arrow2_datatype(), + }, + ), + ( + ::name(), + ComponentReflection { + docstring_md: "The target distance between two nodes.\n\nThis is helpful to scale the layout, for example if long labels are involved.", + custom_placeholder: Some(ForceStrength::default().to_arrow2()?), + datatype: ForceStrength::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { @@ -1946,6 +1962,38 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceCenter"), + ArchetypeReflection { + display_name: "Force center", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.Enabled".into(), display_name : + "Enabled", docstring_md : "Whether the force is enabled.", + is_required : false, }, ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceStrength".into(), display_name : + "Strength", docstring_md : "The strength of the force.", is_required + : false, }, + ], + }, + ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceCollisionRadius"), + ArchetypeReflection { + display_name: "Force collision radius", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.Enabled".into(), display_name : + "Enabled", docstring_md : "Whether the force is enabled.", + is_required : false, }, ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceStrength".into(), display_name : + "Strength", docstring_md : "The strength of the force.", is_required + : false, }, + ], + }, + ), ( ArchetypeName::new("rerun.blueprint.archetypes.ForceLink"), ArchetypeReflection { @@ -1962,6 +2010,42 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForceManyBody"), + ArchetypeReflection { + display_name: "Force many body", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.Enabled".into(), display_name : + "Enabled", docstring_md : "Whether the force is enabled.", + is_required : false, }, ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceStrength".into(), display_name : + "Strength", docstring_md : "The strength of the force.", is_required + : false, }, + ], + }, + ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.ForcePosition"), + ArchetypeReflection { + display_name: "Force position", + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.Enabled".into(), display_name : + "Enabled", docstring_md : "Whether the force is enabled.", + is_required : false, }, ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceStrength".into(), display_name : + "Strength", docstring_md : "The strength of the force.", is_required + : false, }, ArchetypeFieldReflection { component_name : + "rerun.components.Position2D".into(), display_name : "Position", + docstring_md : + "The position where the nodes should bepulled towards.", is_required + : false, }, + ], + }, + ), ( ArchetypeName::new("rerun.blueprint.archetypes.MapBackground"), ArchetypeReflection { diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index cd01187c0d83..add2fd989baa 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -16,6 +16,27 @@ A link force between nodes in the graph. * `enabled`: Whether the force is enabled. * `distance`: The target distance between two nodes. +### `force_many_body` +TODO + +* `enabled`: Whether the force is enabled. +* `strength`: The strength of the force. +### `force_position` +TODO + +* `enabled`: Whether the force is enabled. +* `strength`: The strength of the force. +* `position`: The position where the nodes should bepulled towards. +### `force_collision_radius` +TODO + +* `enabled`: Whether the force is enabled. +* `strength`: The strength of the force. +### `force_center` +TODO + +* `enabled`: Whether the force is enabled. +* `strength`: The strength of the force. ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index f3544ad39e7e..43b544d12447 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -5,7 +5,11 @@ #include "blueprint/archetypes/background.hpp" #include "blueprint/archetypes/container_blueprint.hpp" #include "blueprint/archetypes/dataframe_query.hpp" +#include "blueprint/archetypes/force_center.hpp" +#include "blueprint/archetypes/force_collision_radius.hpp" #include "blueprint/archetypes/force_link.hpp" +#include "blueprint/archetypes/force_many_body.hpp" +#include "blueprint/archetypes/force_position.hpp" #include "blueprint/archetypes/map_background.hpp" #include "blueprint/archetypes/map_zoom.hpp" #include "blueprint/archetypes/panel_blueprint.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes index 2cb221a27d4c..790cc4338357 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -7,8 +7,16 @@ container_blueprint.cpp linguist-generated=true container_blueprint.hpp linguist-generated=true dataframe_query.cpp linguist-generated=true dataframe_query.hpp linguist-generated=true +force_center.cpp linguist-generated=true +force_center.hpp linguist-generated=true +force_collision_radius.cpp linguist-generated=true +force_collision_radius.hpp linguist-generated=true force_link.cpp linguist-generated=true force_link.hpp linguist-generated=true +force_many_body.cpp linguist-generated=true +force_many_body.hpp linguist-generated=true +force_position.cpp linguist-generated=true +force_position.hpp linguist-generated=true map_background.cpp linguist-generated=true map_background.hpp linguist-generated=true map_zoom.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp new file mode 100644 index 000000000000..1d73bb8365f4 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp @@ -0,0 +1,38 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". + +#include "force_center.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> AsComponents::serialize( + const blueprint::archetypes::ForceCenter& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(3); + + if (archetype.enabled.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + if (archetype.strength.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.strength.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceCenter::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp new file mode 100644 index 000000000000..7e843a7f8709 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp @@ -0,0 +1,69 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". + +#pragma once + +#include "../../blueprint/components/enabled.hpp" +#include "../../blueprint/components/force_strength.hpp" +#include "../../collection.hpp" +#include "../../compiler_utils.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include +#include + +namespace rerun::blueprint::archetypes { + /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + struct ForceCenter { + /// Whether the force is enabled. + std::optional enabled; + + /// The strength of the force. + std::optional strength; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceCenterIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceCenter() = default; + ForceCenter(ForceCenter&& other) = default; + + /// Whether the force is enabled. + ForceCenter with_enabled(rerun::blueprint::components::Enabled _enabled) && { + enabled = std::move(_enabled); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + + /// The strength of the force. + ForceCenter with_strength(rerun::blueprint::components::ForceStrength _strength) && { + strength = std::move(_strength); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceCenter& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp new file mode 100644 index 000000000000..3ff21cabaafc --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp @@ -0,0 +1,39 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs". + +#include "force_collision_radius.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::ForceCollisionRadius& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(3); + + if (archetype.enabled.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + if (archetype.strength.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.strength.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceCollisionRadius::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp new file mode 100644 index 000000000000..0302d0076fa3 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp @@ -0,0 +1,70 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs". + +#pragma once + +#include "../../blueprint/components/enabled.hpp" +#include "../../blueprint/components/force_strength.hpp" +#include "../../collection.hpp" +#include "../../compiler_utils.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include +#include + +namespace rerun::blueprint::archetypes { + /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + struct ForceCollisionRadius { + /// Whether the force is enabled. + std::optional enabled; + + /// The strength of the force. + std::optional strength; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceCollisionRadiusIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceCollisionRadius() = default; + ForceCollisionRadius(ForceCollisionRadius&& other) = default; + + /// Whether the force is enabled. + ForceCollisionRadius with_enabled(rerun::blueprint::components::Enabled _enabled) && { + enabled = std::move(_enabled); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + + /// The strength of the force. + ForceCollisionRadius with_strength(rerun::blueprint::components::ForceStrength _strength + ) && { + strength = std::move(_strength); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceCollisionRadius& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp new file mode 100644 index 000000000000..5cd074c55574 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp @@ -0,0 +1,39 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". + +#include "force_many_body.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::ForceManyBody& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(3); + + if (archetype.enabled.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + if (archetype.strength.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.strength.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForceManyBody::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp new file mode 100644 index 000000000000..4c164a8f734a --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp @@ -0,0 +1,69 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". + +#pragma once + +#include "../../blueprint/components/enabled.hpp" +#include "../../blueprint/components/force_strength.hpp" +#include "../../collection.hpp" +#include "../../compiler_utils.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include +#include + +namespace rerun::blueprint::archetypes { + /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + struct ForceManyBody { + /// Whether the force is enabled. + std::optional enabled; + + /// The strength of the force. + std::optional strength; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForceManyBodyIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForceManyBody() = default; + ForceManyBody(ForceManyBody&& other) = default; + + /// Whether the force is enabled. + ForceManyBody with_enabled(rerun::blueprint::components::Enabled _enabled) && { + enabled = std::move(_enabled); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + + /// The strength of the force. + ForceManyBody with_strength(rerun::blueprint::components::ForceStrength _strength) && { + strength = std::move(_strength); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForceManyBody& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.cpp new file mode 100644 index 000000000000..b3adcbd0b1b2 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.cpp @@ -0,0 +1,44 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs". + +#include "force_position.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::ForcePosition& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(4); + + if (archetype.enabled.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + if (archetype.strength.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.strength.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + if (archetype.position.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.position.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = ForcePosition::IndicatorComponent(); + auto result = ComponentBatch::from_loggable(indicator); + RR_RETURN_NOT_OK(result.error); + cells.emplace_back(std::move(result.value)); + } + + return cells; + } +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp new file mode 100644 index 000000000000..08e345475daa --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp @@ -0,0 +1,80 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs". + +#pragma once + +#include "../../blueprint/components/enabled.hpp" +#include "../../blueprint/components/force_strength.hpp" +#include "../../collection.hpp" +#include "../../compiler_utils.hpp" +#include "../../component_batch.hpp" +#include "../../components/position2d.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include +#include + +namespace rerun::blueprint::archetypes { + /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + struct ForcePosition { + /// Whether the force is enabled. + std::optional enabled; + + /// The strength of the force. + std::optional strength; + + /// The position where the nodes should bepulled towards. + std::optional position; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.ForcePositionIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + ForcePosition() = default; + ForcePosition(ForcePosition&& other) = default; + + /// Whether the force is enabled. + ForcePosition with_enabled(rerun::blueprint::components::Enabled _enabled) && { + enabled = std::move(_enabled); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + + /// The strength of the force. + ForcePosition with_strength(rerun::blueprint::components::ForceStrength _strength) && { + strength = std::move(_strength); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + + /// The position where the nodes should bepulled towards. + ForcePosition with_position(rerun::components::Position2D _position) && { + position = std::move(_position); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } + }; + +} // namespace rerun::blueprint::archetypes + +namespace rerun { + /// \private + template + struct AsComponents; + + /// \private + template <> + struct AsComponents { + /// Serialize all set component batches. + static Result> serialize( + const blueprint::archetypes::ForcePosition& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index 5e2de65ed1bd..0079e0d5c123 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -15,6 +15,8 @@ #include "blueprint/components/filter_by_range.hpp" #include "blueprint/components/filter_is_not_null.hpp" #include "blueprint/components/force_distance.hpp" +#include "blueprint/components/force_iterations.hpp" +#include "blueprint/components/force_strength.hpp" #include "blueprint/components/grid_columns.hpp" #include "blueprint/components/included_content.hpp" #include "blueprint/components/interactive.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index b7d9cc635dce..d5cdc77486e7 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -17,6 +17,8 @@ enabled.hpp linguist-generated=true filter_by_range.hpp linguist-generated=true filter_is_not_null.hpp linguist-generated=true force_distance.hpp linguist-generated=true +force_iterations.hpp linguist-generated=true +force_strength.hpp linguist-generated=true grid_columns.hpp linguist-generated=true included_content.hpp linguist-generated=true interactive.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp b/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp new file mode 100644 index 000000000000..ac16c4a15be8 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp @@ -0,0 +1,77 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs". + +#pragma once + +#include "../../datatypes/uint64.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + /// **Component**: The target distance between two nodes. + /// + /// This is helpful to scale the layout, for example if long labels are involved. + struct ForceIterations { + rerun::datatypes::UInt64 distance; + + public: + ForceIterations() = default; + + ForceIterations(rerun::datatypes::UInt64 distance_) : distance(distance_) {} + + ForceIterations& operator=(rerun::datatypes::UInt64 distance_) { + distance = distance_; + return *this; + } + + ForceIterations(uint64_t value_) : distance(value_) {} + + ForceIterations& operator=(uint64_t value_) { + distance = value_; + return *this; + } + + /// Cast to the underlying UInt64 datatype + operator rerun::datatypes::UInt64() const { + return distance; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::datatypes::UInt64) == sizeof(blueprint::components::ForceIterations) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForceIterations"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForceIterations` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForceIterations* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->distance, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp b/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp new file mode 100644 index 000000000000..87502bd24f48 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp @@ -0,0 +1,77 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs". + +#pragma once + +#include "../../datatypes/float64.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + /// **Component**: The target distance between two nodes. + /// + /// This is helpful to scale the layout, for example if long labels are involved. + struct ForceStrength { + rerun::datatypes::Float64 distance; + + public: + ForceStrength() = default; + + ForceStrength(rerun::datatypes::Float64 distance_) : distance(distance_) {} + + ForceStrength& operator=(rerun::datatypes::Float64 distance_) { + distance = distance_; + return *this; + } + + ForceStrength(double value_) : distance(value_) {} + + ForceStrength& operator=(double value_) { + distance = value_; + return *this; + } + + /// Cast to the underlying Float64 datatype + operator rerun::datatypes::Float64() const { + return distance; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::datatypes::Float64) == sizeof(blueprint::components::ForceStrength) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ForceStrength"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ForceStrength` into an arrow array. + static Result> to_arrow( + const blueprint::components::ForceStrength* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->distance, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index 2e5d54577d98..89c3866a4e19 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -5,7 +5,11 @@ __init__.py linguist-generated=true background.py linguist-generated=true container_blueprint.py linguist-generated=true dataframe_query.py linguist-generated=true +force_center.py linguist-generated=true +force_collision_radius.py linguist-generated=true force_link.py linguist-generated=true +force_many_body.py linguist-generated=true +force_position.py linguist-generated=true map_background.py linguist-generated=true map_zoom.py linguist-generated=true panel_blueprint.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py index a7d1938aba3a..6abdbc8bdfb8 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -5,7 +5,11 @@ from .background import Background from .container_blueprint import ContainerBlueprint from .dataframe_query import DataframeQuery +from .force_center import ForceCenter +from .force_collision_radius import ForceCollisionRadius from .force_link import ForceLink +from .force_many_body import ForceManyBody +from .force_position import ForcePosition from .map_background import MapBackground from .map_zoom import MapZoom from .panel_blueprint import PanelBlueprint @@ -24,7 +28,11 @@ "Background", "ContainerBlueprint", "DataframeQuery", + "ForceCenter", + "ForceCollisionRadius", "ForceLink", + "ForceManyBody", + "ForcePosition", "MapBackground", "MapZoom", "PanelBlueprint", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py new file mode 100644 index 000000000000..059e14d57577 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py @@ -0,0 +1,80 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs". + +# You can extend this class by creating a "ForceCenterExt" class in "force_center_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ... import datatypes +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceCenter"] + + +@define(str=False, repr=False, init=False) +class ForceCenter(Archetype): + """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + + def __init__( + self: Any, *, enabled: datatypes.BoolLike | None = None, strength: datatypes.Float64Like | None = None + ): + """ + Create a new instance of the ForceCenter archetype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + strength: + The strength of the force. + + """ + + # You can define your own __init__ function as a member of ForceCenterExt in force_center_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(enabled=enabled, strength=strength) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + enabled=None, # type: ignore[arg-type] + strength=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceCenter: + """Produce an empty ForceCenter, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + enabled: blueprint_components.EnabledBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.EnabledBatch._optional, # type: ignore[misc] + ) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: blueprint_components.ForceStrengthBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.ForceStrengthBatch._optional, # type: ignore[misc] + ) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py new file mode 100644 index 000000000000..ae4b77bb1151 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py @@ -0,0 +1,80 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs". + +# You can extend this class by creating a "ForceCollisionRadiusExt" class in "force_collision_radius_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ... import datatypes +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceCollisionRadius"] + + +@define(str=False, repr=False, init=False) +class ForceCollisionRadius(Archetype): + """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + + def __init__( + self: Any, *, enabled: datatypes.BoolLike | None = None, strength: datatypes.Float64Like | None = None + ): + """ + Create a new instance of the ForceCollisionRadius archetype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + strength: + The strength of the force. + + """ + + # You can define your own __init__ function as a member of ForceCollisionRadiusExt in force_collision_radius_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(enabled=enabled, strength=strength) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + enabled=None, # type: ignore[arg-type] + strength=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceCollisionRadius: + """Produce an empty ForceCollisionRadius, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + enabled: blueprint_components.EnabledBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.EnabledBatch._optional, # type: ignore[misc] + ) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: blueprint_components.ForceStrengthBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.ForceStrengthBatch._optional, # type: ignore[misc] + ) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py new file mode 100644 index 000000000000..9f414e00e48a --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py @@ -0,0 +1,80 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs". + +# You can extend this class by creating a "ForceManyBodyExt" class in "force_many_body_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ... import datatypes +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForceManyBody"] + + +@define(str=False, repr=False, init=False) +class ForceManyBody(Archetype): + """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + + def __init__( + self: Any, *, enabled: datatypes.BoolLike | None = None, strength: datatypes.Float64Like | None = None + ): + """ + Create a new instance of the ForceManyBody archetype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + strength: + The strength of the force. + + """ + + # You can define your own __init__ function as a member of ForceManyBodyExt in force_many_body_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(enabled=enabled, strength=strength) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + enabled=None, # type: ignore[arg-type] + strength=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForceManyBody: + """Produce an empty ForceManyBody, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + enabled: blueprint_components.EnabledBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.EnabledBatch._optional, # type: ignore[misc] + ) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: blueprint_components.ForceStrengthBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.ForceStrengthBatch._optional, # type: ignore[misc] + ) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py new file mode 100644 index 000000000000..72499b3a9e83 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py @@ -0,0 +1,96 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs". + +# You can extend this class by creating a "ForcePositionExt" class in "force_position_ext.py". + +from __future__ import annotations + +from typing import Any + +from attrs import define, field + +from ... import components, datatypes +from ..._baseclasses import ( + Archetype, +) +from ...blueprint import components as blueprint_components +from ...error_utils import catch_and_log_exceptions + +__all__ = ["ForcePosition"] + + +@define(str=False, repr=False, init=False) +class ForcePosition(Archetype): + """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + + def __init__( + self: Any, + *, + enabled: datatypes.BoolLike | None = None, + strength: datatypes.Float64Like | None = None, + position: datatypes.Vec2DLike | None = None, + ): + """ + Create a new instance of the ForcePosition archetype. + + Parameters + ---------- + enabled: + Whether the force is enabled. + strength: + The strength of the force. + position: + The position where the nodes should bepulled towards. + + """ + + # You can define your own __init__ function as a member of ForcePositionExt in force_position_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(enabled=enabled, strength=strength, position=position) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + enabled=None, # type: ignore[arg-type] + strength=None, # type: ignore[arg-type] + position=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> ForcePosition: + """Produce an empty ForcePosition, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + enabled: blueprint_components.EnabledBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.EnabledBatch._optional, # type: ignore[misc] + ) + # Whether the force is enabled. + # + # (Docstring intentionally commented out to hide this field from the docs) + + strength: blueprint_components.ForceStrengthBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.ForceStrengthBatch._optional, # type: ignore[misc] + ) + # The strength of the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + + position: components.Position2DBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=components.Position2DBatch._optional, # type: ignore[misc] + ) + # The position where the nodes should bepulled towards. + # + # (Docstring intentionally commented out to hide this field from the docs) + + __str__ = Archetype.__str__ + __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes index 27fceb4efb37..db11515a5040 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -15,6 +15,8 @@ enabled.py linguist-generated=true filter_by_range.py linguist-generated=true filter_is_not_null.py linguist-generated=true force_distance.py linguist-generated=true +force_iterations.py linguist-generated=true +force_strength.py linguist-generated=true grid_columns.py linguist-generated=true included_content.py linguist-generated=true interactive.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py index 15d3de279c54..7a68966f5b38 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py @@ -15,6 +15,8 @@ from .filter_by_range import FilterByRange, FilterByRangeBatch from .filter_is_not_null import FilterIsNotNull, FilterIsNotNullBatch from .force_distance import ForceDistance, ForceDistanceBatch +from .force_iterations import ForceIterations, ForceIterationsBatch +from .force_strength import ForceStrength, ForceStrengthBatch from .grid_columns import GridColumns, GridColumnsBatch from .included_content import IncludedContent, IncludedContentBatch from .interactive import Interactive, InteractiveBatch @@ -71,6 +73,10 @@ "FilterIsNotNullBatch", "ForceDistance", "ForceDistanceBatch", + "ForceIterations", + "ForceIterationsBatch", + "ForceStrength", + "ForceStrengthBatch", "GridColumns", "GridColumnsBatch", "IncludedContent", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py new file mode 100644 index 000000000000..ed913db34d83 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py @@ -0,0 +1,36 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs". + +# You can extend this class by creating a "ForceIterationsExt" class in "force_iterations_ext.py". + +from __future__ import annotations + +from ... import datatypes +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) + +__all__ = ["ForceIterations", "ForceIterationsBatch"] + + +class ForceIterations(datatypes.UInt64, ComponentMixin): + """ + **Component**: The target distance between two nodes. + + This is helpful to scale the layout, for example if long labels are involved. + """ + + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForceIterationsExt in force_iterations_ext.py + + # Note: there are no fields here because ForceIterations delegates to datatypes.UInt64 + pass + + +class ForceIterationsBatch(datatypes.UInt64Batch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForceIterations" + + +# This is patched in late to avoid circular dependencies. +ForceIterations._BATCH_TYPE = ForceIterationsBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py new file mode 100644 index 000000000000..37c00331cd0d --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py @@ -0,0 +1,36 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs". + +# You can extend this class by creating a "ForceStrengthExt" class in "force_strength_ext.py". + +from __future__ import annotations + +from ... import datatypes +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) + +__all__ = ["ForceStrength", "ForceStrengthBatch"] + + +class ForceStrength(datatypes.Float64, ComponentMixin): + """ + **Component**: The target distance between two nodes. + + This is helpful to scale the layout, for example if long labels are involved. + """ + + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ForceStrengthExt in force_strength_ext.py + + # Note: there are no fields here because ForceStrength delegates to datatypes.Float64 + pass + + +class ForceStrengthBatch(datatypes.Float64Batch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ForceStrength" + + +# This is patched in late to avoid circular dependencies. +ForceStrength._BATCH_TYPE = ForceStrengthBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py index 17d7552fbb18..3091ce8209b6 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py @@ -71,6 +71,10 @@ def __init__( overrides: dict[EntityPathLike, list[ComponentBatchLike]] = {}, visual_bounds: blueprint_archetypes.VisualBounds2D | None = None, force_link: blueprint_archetypes.ForceLink | None = None, + force_many_body: blueprint_archetypes.ForceManyBody | None = None, + force_position: blueprint_archetypes.ForcePosition | None = None, + force_collision_radius: blueprint_archetypes.ForceCollisionRadius | None = None, + force_center: blueprint_archetypes.ForceCenter | None = None, ) -> None: """ Construct a blueprint for a new GraphView view. @@ -107,6 +111,14 @@ def __init__( Somethings outside of these bounds may also be visible due to letterboxing. force_link: A link force between nodes in the graph. + force_many_body: + TODO + force_position: + TODO + force_collision_radius: + TODO + force_center: + TODO """ @@ -121,6 +133,26 @@ def __init__( force_link = blueprint_archetypes.ForceLink(force_link) properties["ForceLink"] = force_link + if force_many_body is not None: + if not isinstance(force_many_body, blueprint_archetypes.ForceManyBody): + force_many_body = blueprint_archetypes.ForceManyBody(force_many_body) + properties["ForceManyBody"] = force_many_body + + if force_position is not None: + if not isinstance(force_position, blueprint_archetypes.ForcePosition): + force_position = blueprint_archetypes.ForcePosition(force_position) + properties["ForcePosition"] = force_position + + if force_collision_radius is not None: + if not isinstance(force_collision_radius, blueprint_archetypes.ForceCollisionRadius): + force_collision_radius = blueprint_archetypes.ForceCollisionRadius(force_collision_radius) + properties["ForceCollisionRadius"] = force_collision_radius + + if force_center is not None: + if not isinstance(force_center, blueprint_archetypes.ForceCenter): + force_center = blueprint_archetypes.ForceCenter(force_center) + properties["ForceCenter"] = force_center + super().__init__( class_identifier="Graph", origin=origin, From 8398b53417efeb614d57bffa49324c0f1e8b5416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 16:41:30 +0100 Subject: [PATCH 26/44] Bubble charts working --- .../src/datatype_uis/float_drag.rs | 13 +++ .../re_component_ui/src/datatype_uis/mod.rs | 2 +- crates/viewer/re_component_ui/src/lib.rs | 8 +- .../re_space_view_graph/src/layout/params.rs | 103 ++++++++++++++---- .../src/layout/provider.rs | 53 ++++++--- .../re_space_view_graph/src/ui/state.rs | 30 ++--- crates/viewer/re_space_view_graph/src/view.rs | 18 ++- .../check_graph_time_layout.py | 53 ++++++++- 8 files changed, 217 insertions(+), 63 deletions(-) diff --git a/crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs b/crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs index a37f8cfbc3d3..be13868866eb 100644 --- a/crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs +++ b/crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs @@ -102,6 +102,19 @@ pub fn edit_f64_zero_to_max( edit_f64_float_raw_impl(ui, &mut value, 0.0..=f64::MAX) } +/// Generic editor for a [`re_types::datatypes::Float64`] value from min to max float. +pub fn edit_f64_min_to_max_float( + _ctx: &re_viewer_context::ViewerContext<'_>, + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, impl std::ops::DerefMut>, +) -> egui::Response { + let mut value: MaybeMutRef<'_, f64> = match value { + MaybeMutRef::Ref(value) => MaybeMutRef::Ref(value), + MaybeMutRef::MutRef(value) => MaybeMutRef::MutRef(&mut value.deref_mut().0), + }; + edit_f64_float_raw_impl(ui, &mut value, f64::MIN..=f64::MAX) +} + /// Non monomorphized implementation for f64 float editing. pub fn edit_f64_float_raw_impl( ui: &mut egui::Ui, diff --git a/crates/viewer/re_component_ui/src/datatype_uis/mod.rs b/crates/viewer/re_component_ui/src/datatype_uis/mod.rs index d5eb8036bff4..061f2bd2b038 100644 --- a/crates/viewer/re_component_ui/src/datatype_uis/mod.rs +++ b/crates/viewer/re_component_ui/src/datatype_uis/mod.rs @@ -14,7 +14,7 @@ pub use enum_combobox::{ }; pub use float_drag::{ edit_f32_min_to_max_float, edit_f32_zero_to_max, edit_f32_zero_to_one, - edit_f64_float_raw_with_speed_impl, edit_f64_zero_to_max, + edit_f64_float_raw_with_speed_impl, edit_f64_min_to_max_float, edit_f64_zero_to_max, }; pub use range1d::edit_view_range1d; pub use singleline_string::{ diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 5b939d67fccc..ad933e381e0b 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -27,9 +27,9 @@ mod zoom_level; use datatype_uis::{ display_name_ui, display_text_ui, edit_bool, edit_f32_min_to_max_float, edit_f32_zero_to_max, - edit_f32_zero_to_one, edit_f64_zero_to_max, edit_multiline_string, edit_or_view_vec3d, - edit_singleline_string, edit_view_enum, edit_view_enum_with_variant_available, - edit_view_range1d, view_uuid, view_view_id, + edit_f32_zero_to_one, edit_f64_min_to_max_float, edit_f64_zero_to_max, edit_multiline_string, + edit_or_view_vec3d, edit_singleline_string, edit_view_enum, + edit_view_enum_with_variant_available, edit_view_range1d, view_uuid, view_view_id, }; use re_types::{ @@ -72,7 +72,6 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f64_zero_to_max); - registry.add_singleline_edit_or_view::(edit_f64_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); @@ -81,6 +80,7 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry // float min-max components: registry.add_singleline_edit_or_view::(edit_f32_min_to_max_float); + registry.add_singleline_edit_or_view::(edit_f64_min_to_max_float); // float 0-1 components: registry.add_singleline_edit_or_view::(edit_f32_zero_to_one); diff --git a/crates/viewer/re_space_view_graph/src/layout/params.rs b/crates/viewer/re_space_view_graph/src/layout/params.rs index befe053d7712..d8bfa4788b8b 100644 --- a/crates/viewer/re_space_view_graph/src/layout/params.rs +++ b/crates/viewer/re_space_view_graph/src/layout/params.rs @@ -1,40 +1,105 @@ -use re_types::blueprint::{ - archetypes::ForceLink, - components::{Enabled, ForceDistance}, +use re_types::{ + blueprint::{ + archetypes::{ForceCenter, ForceCollisionRadius, ForceLink, ForceManyBody, ForcePosition}, + components::{Enabled, ForceDistance, ForceStrength}, + }, + components::Position2D, + Archetype, Component, }; use re_viewer_context::{ComponentFallbackProvider, SpaceViewState, ViewQuery, ViewerContext}; use re_viewport_blueprint::{ViewProperty, ViewPropertyQueryError}; #[derive(Debug, PartialEq)] pub struct ForceLayoutParams { + // Link pub(super) force_link_enabled: Enabled, pub(super) force_link_distance: ForceDistance, + // Many body + pub(super) force_many_body_enabled: Enabled, + pub(super) force_many_body_strength: ForceStrength, + // Position + pub(super) force_position_enabled: Enabled, + pub(super) force_position_strength: ForceStrength, + pub(super) force_position_pos: Position2D, + // Center + pub(super) force_center_enabled: Enabled, + pub(super) force_center_strength: ForceStrength, + // Collision + pub(super) force_collision_enabled: Enabled, + pub(super) force_collision_strength: ForceStrength, +} + +/// Convenience struct for querying the components of a blueprint archetype or its fallbacks. +struct QueryArchetype<'a, T> { + ctx: &'a ViewerContext<'a>, + provider: &'a dyn ComponentFallbackProvider, + view_state: &'a dyn SpaceViewState, + property: ViewProperty, + _marker: std::marker::PhantomData, +} + +impl<'a, T: Archetype> QueryArchetype<'a, T> { + fn new( + ctx: &'a ViewerContext<'a>, + query: &'a ViewQuery<'a>, + provider: &'a dyn ComponentFallbackProvider, + view_state: &'a dyn SpaceViewState, + ) -> Self { + let property = ViewProperty::from_archetype::( + ctx.blueprint_db(), + ctx.blueprint_query, + query.space_view_id, + ); + Self { + ctx, + provider, + view_state, + property, + _marker: Default::default(), + } + } + + fn get(&self) -> Result + where + R: Component + Default, + { + self.property + .component_or_fallback(self.ctx, self.provider, self.view_state) + } } impl ForceLayoutParams { pub fn get( ctx: &ViewerContext<'_>, query: &ViewQuery<'_>, - fallback_provider: &dyn ComponentFallbackProvider, + provider: &dyn ComponentFallbackProvider, view_state: &dyn SpaceViewState, ) -> Result { - let force_link_property = ViewProperty::from_archetype::( - ctx.blueprint_db(), - ctx.blueprint_query, - query.space_view_id, - ); + // Query the components for the archetype + let force_link = QueryArchetype::::new(ctx, query, provider, view_state); + let force_many = QueryArchetype::::new(ctx, query, provider, view_state); + let force_position = QueryArchetype::::new(ctx, query, provider, view_state); + let force_center = QueryArchetype::::new(ctx, query, provider, view_state); + let force_collision = + QueryArchetype::::new(ctx, query, provider, view_state); Ok(Self { - force_link_enabled: force_link_property.component_or_fallback( - ctx, - fallback_provider, - view_state, - )?, - force_link_distance: force_link_property.component_or_fallback( - ctx, - fallback_provider, - view_state, - )?, + // Link + force_link_enabled: force_link.get()?, + force_link_distance: force_link.get()?, + // Many body + force_many_body_enabled: force_many.get()?, + force_many_body_strength: force_many.get()?, + // Position + force_position_enabled: force_position.get()?, + force_position_strength: force_position.get()?, + force_position_pos: force_position.get()?, + // Center + force_center_enabled: force_center.get()?, + force_center_strength: force_center.get()?, + // Collision + force_collision_enabled: force_collision.get()?, + force_collision_strength: force_collision.get()?, }) } } diff --git a/crates/viewer/re_space_view_graph/src/layout/provider.rs b/crates/viewer/re_space_view_graph/src/layout/provider.rs index 3daa4b80f3dc..678190a0bf9d 100644 --- a/crates/viewer/re_space_view_graph/src/layout/provider.rs +++ b/crates/viewer/re_space_view_graph/src/layout/provider.rs @@ -31,6 +31,7 @@ pub fn update_simulation( mut simulation: fj::Simulation, params: &ForceLayoutParams, edges: Vec<(usize, usize)>, + radii: Vec, ) -> Simulation { if **params.force_link_enabled { simulation = simulation.add_force( @@ -40,6 +41,27 @@ pub fn update_simulation( .iterations(2), ); } + if **params.force_many_body_enabled { + simulation = simulation.add_force( + "charge", + fj::ManyBody::new().strength(params.force_many_body_strength.0 .0), + ); + } + if **params.force_position_enabled { + simulation = simulation + .add_force( + "x", + fj::PositionX::new().strength(params.force_position_strength.0 .0), + ) + .add_force( + "y", + fj::PositionY::new().strength(params.force_position_strength.0 .0), + ); + } + if **params.force_collision_enabled { + simulation = + simulation.add_force("collision", fj::Collide::new().radius(move |i| radii[i])); + } simulation } @@ -64,18 +86,15 @@ fn considered_edges(request: &LayoutRequest) -> Vec<(usize, usize)> { impl ForceLayoutProvider { pub fn new(request: LayoutRequest, params: &ForceLayoutParams) -> Self { let nodes = request.all_nodes().map(|(_, v)| fj::Node::from(v)); + let radii = request + .all_nodes() + .map(|(_, v)| v.size.max_elem() as f64 / 2.0) + .collect::>(); let edges = considered_edges(&request); - // TODO(grtlr): Currently we guesstimate good forces. Eventually these should be exposed as blueprints. - let simulation = fj::SimulationBuilder::default() - .with_alpha_decay(0.01) // TODO(grtlr): slows down the simulation for demo - .build(nodes) - .add_force("charge", fj::ManyBody::new()) - // TODO(grtlr): This is a small stop-gap until we have blueprints to prevent nodes from flying away. - .add_force("x", fj::PositionX::new().strength(0.01)) - .add_force("y", fj::PositionY::new().strength(0.01)); + let simulation = fj::SimulationBuilder::default().build(nodes); - let simulation = update_simulation(simulation, params, edges); + let simulation = update_simulation(simulation, params, edges, radii); Self { simulation, @@ -96,18 +115,16 @@ impl ForceLayoutProvider { fj::Node::from(v) } }); + let radii = request + .all_nodes() + .map(|(_, v)| v.size.max_elem() as f64 / 2.0) + .collect::>(); let edges = considered_edges(&request); // TODO(grtlr): Currently we guesstimate good forces. Eventually these should be exposed as blueprints. - let simulation = fj::SimulationBuilder::default() - .with_alpha_decay(0.01) // TODO(grtlr): slows down the simulation for demo - .build(nodes) - .add_force("charge", fj::ManyBody::new()) - // TODO(grtlr): This is a small stop-gap until we have blueprints to prevent nodes from flying away. - .add_force("x", fj::PositionX::new().strength(0.01)) - .add_force("y", fj::PositionY::new().strength(0.01)); - - let simulation = update_simulation(simulation, params, edges); + let simulation = fj::SimulationBuilder::default().build(nodes); + + let simulation = update_simulation(simulation, params, edges, radii); Self { simulation, diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index 2464c2482e35..59cd9e9d141b 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -99,43 +99,47 @@ impl LayoutState { } /// A simple state machine that keeps track of the different stages and if the layout needs to be recomputed. - fn update(self, new_request: LayoutRequest, params: ForceLayoutParams) -> Self { + fn update(self, new_request: LayoutRequest, new_params: ForceLayoutParams) -> Self { match self { // Layout is up to date, nothing to do here. - Self::Finished { ref provider, .. } if provider.request == new_request => { + Self::Finished { + ref provider, + ref params, + .. + } if (provider.request == new_request) && (params == &new_params) => { self // no op } // We need to recompute the layout. Self::None => { - let mut provider = ForceLayoutProvider::new(new_request, ¶ms); + let mut provider = ForceLayoutProvider::new(new_request, &new_params); let layout = provider.tick(); Self::InProgress { layout, provider, - params, + params: new_params, } } Self::Finished { layout, .. } => { let mut provider = - ForceLayoutProvider::new_with_previous(new_request, &layout, ¶ms); + ForceLayoutProvider::new_with_previous(new_request, &layout, &new_params); let layout = provider.tick(); Self::InProgress { layout, provider, - params, + params: new_params, } } Self::InProgress { layout, provider, .. } if provider.request != new_request => { let mut provider = - ForceLayoutProvider::new_with_previous(new_request, &layout, ¶ms); + ForceLayoutProvider::new_with_previous(new_request, &layout, &new_params); let layout = provider.tick(); Self::InProgress { layout, provider, - params, + params: new_params, } } // We keep iterating on the layout until it is stable. @@ -143,26 +147,26 @@ impl LayoutState { mut provider, layout, params: old_params, - } => match (provider.is_finished(), params == old_params) { + } => match (provider.is_finished(), new_params == old_params) { (true, true) => Self::Finished { layout, provider, - params, + params: new_params, }, (false, true) => Self::InProgress { layout: provider.tick(), provider, - params, + params: new_params, }, _ => { let mut provider = - ForceLayoutProvider::new_with_previous(new_request, &layout, ¶ms); + ForceLayoutProvider::new_with_previous(new_request, &layout, &new_params); let layout = provider.tick(); Self::InProgress { layout, provider, - params, + params: new_params, } } }, diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index 31a2e57732f7..4fff4396a695 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -6,7 +6,10 @@ use re_space_view::{ use re_types::{ blueprint::{ self, - archetypes::{ForceLink, VisualBounds2D}, + archetypes::{ + ForceCenter, ForceCollisionRadius, ForceLink, ForceManyBody, ForcePosition, + VisualBounds2D, + }, }, SpaceViewClassIdentifier, }; @@ -16,11 +19,10 @@ use re_ui::{ ModifiersMarkdown, MouseButtonMarkdown, UiExt as _, }; use re_viewer_context::{ - ComponentFallbackProvider, IdentifiedViewSystem as _, RecommendedSpaceView, SpaceViewClass, - SpaceViewClassLayoutPriority, SpaceViewClassRegistryError, SpaceViewId, - SpaceViewSpawnHeuristics, SpaceViewState, SpaceViewStateExt as _, - SpaceViewSystemExecutionError, SpaceViewSystemRegistrator, SystemExecutionOutput, ViewQuery, - ViewerContext, + IdentifiedViewSystem as _, RecommendedSpaceView, SpaceViewClass, SpaceViewClassLayoutPriority, + SpaceViewClassRegistryError, SpaceViewId, SpaceViewSpawnHeuristics, SpaceViewState, + SpaceViewStateExt as _, SpaceViewSystemExecutionError, SpaceViewSystemRegistrator, + SystemExecutionOutput, ViewQuery, ViewerContext, }; use re_viewport_blueprint::ViewProperty; @@ -136,6 +138,10 @@ Display a graph of nodes and edges. re_ui::list_item::list_item_scope(ui, "graph_selection_ui", |ui| { view_property_ui::(ctx, ui, space_view_id, self, state); view_property_ui::(ctx, ui, space_view_id, self, state); + view_property_ui::(ctx, ui, space_view_id, self, state); + view_property_ui::(ctx, ui, space_view_id, self, state); + view_property_ui::(ctx, ui, space_view_id, self, state); + view_property_ui::(ctx, ui, space_view_id, self, state); }); Ok(()) diff --git a/tests/python/release_checklist/check_graph_time_layout.py b/tests/python/release_checklist/check_graph_time_layout.py index 3d469e1b72c5..825de3fa5388 100644 --- a/tests/python/release_checklist/check_graph_time_layout.py +++ b/tests/python/release_checklist/check_graph_time_layout.py @@ -1,5 +1,7 @@ from __future__ import annotations +# TODO(grtlr): Promote to example + import os import random from argparse import Namespace @@ -8,6 +10,13 @@ import rerun as rr import rerun.blueprint as rrb +# TODO(grtlr): Clean up the exports +from rerun.blueprint.archetypes.force_collision_radius import ForceCollisionRadius +from rerun.blueprint.archetypes.force_link import ForceLink +from rerun.blueprint.archetypes.force_many_body import ForceManyBody +from rerun.components.show_labels import ShowLabels +from rerun.datatypes.rgba32 import Rgba32 + README = """\ # Time-varying graph view @@ -18,6 +27,18 @@ * Scrub the timeline to see how the graph layout changes over time. """ +color_scheme = [ + Rgba32([228, 26, 28, 255]), # Red + Rgba32([55, 126, 184, 255]), # Blue + Rgba32([77, 175, 74, 255]), # Green + Rgba32([152, 78, 163, 255]), # Purple + Rgba32([255, 127, 0, 255]), # Orange + Rgba32([255, 255, 51, 255]), # Yellow + Rgba32([166, 86, 40, 255]), # Brown + Rgba32([247, 129, 191, 255]), # Pink + Rgba32([153, 153, 153, 255]), # Gray +] + def log_readme() -> None: rr.log("readme", rr.TextDocument(README, media_type=rr.MediaType.MARKDOWN), static=True) @@ -25,22 +46,50 @@ def log_readme() -> None: def log_graphs() -> None: nodes = ["root"] + radii = [42] + colors = [Rgba32([81, 81, 81, 255])] edges = [] + # We want reproducible results + random.seed(42) + # Randomly add nodes and edges to the graph for i in range(50): existing = random.choice(nodes) new_node = str(i) nodes.append(new_node) + radii.append(random.randint(10, 50)) + colors.append(random.choice(color_scheme)) edges.append((existing, new_node)) rr.set_time_sequence("frame", i) - rr.log("graph", rr.GraphNodes(nodes, labels=nodes), rr.GraphEdges(edges, graph_type=rr.GraphType.Directed)) + rr.log( + "node_link", + rr.GraphNodes(nodes, labels=nodes, radii=radii, colors=colors), + rr.GraphEdges(edges, graph_type=rr.GraphType.Directed), + ) + rr.log( + "bubble_chart", + rr.GraphNodes(nodes, labels=nodes, radii=radii, colors=colors), + ) rr.send_blueprint( rrb.Blueprint( rrb.Grid( - rrb.GraphView(origin="graph", name="Graph"), + rrb.GraphView( + origin="node_link", + name="Node-link diagram", + force_link=ForceLink(distance=60), + force_many_body=ForceManyBody(strength=-60), + ), + rrb.GraphView( + origin="bubble_chart", + name="Bubble chart", + force_link=ForceLink(enabled=False), + force_many_body=ForceManyBody(enabled=False), + force_collision_radius=ForceCollisionRadius(enabled=True), + defaults=[ShowLabels(False)], + ), rrb.TextDocumentView(origin="readme", name="Instructions"), ) ) From c1d070024f1d6eb33a009ed1846caf7ccf3301c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 6 Dec 2024 16:58:26 +0100 Subject: [PATCH 27/44] Highlight selection on circles --- crates/viewer/re_space_view_graph/src/ui/draw.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/viewer/re_space_view_graph/src/ui/draw.rs b/crates/viewer/re_space_view_graph/src/ui/draw.rs index 21ab773bafa0..0379e9de5518 100644 --- a/crates/viewer/re_space_view_graph/src/ui/draw.rs +++ b/crates/viewer/re_space_view_graph/src/ui/draw.rs @@ -89,9 +89,11 @@ impl DrawableLabel { fn draw_circle_label( ui: &mut Ui, label: &CircleLabel, - _highlight: InteractionHighlight, + highlight: InteractionHighlight, ) -> Response { let &CircleLabel { radius, color } = label; + let visuals = &ui.style().visuals.clone(); + let (resp, painter) = ui.allocate_painter(Vec2::splat(radius * 2.0), Sense::click()); painter.circle( resp.rect.center(), @@ -99,6 +101,16 @@ fn draw_circle_label( color.unwrap_or_else(|| ui.style().visuals.text_color()), Stroke::NONE, ); + + if highlight.selection == SelectionHighlight::Selection { + painter.circle( + resp.rect.center(), + radius - 2.0, + Color32::TRANSPARENT, + Stroke::new(2.0, visuals.selection.stroke.color), + ); + } + resp } From 81a158fb91ce85064acbdcdd9272ab29a9aa79e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 08:15:27 +0100 Subject: [PATCH 28/44] Re-enable iterations [skip ci] --- Cargo.lock | 4 +- Cargo.toml | 2 +- .../archetypes/force_collision_radius.fbs | 5 +- .../rerun/blueprint/archetypes/force_link.fbs | 2 +- .../archetypes/force_collision_radius.rs | 48 +++++++++++++-- .../src/blueprint/archetypes/force_link.rs | 48 +++++++++++++-- .../re_space_view_graph/src/layout/params.rs | 6 +- .../src/layout/provider.rs | 60 ++++++++++++++----- .../re_space_view_graph/src/properties.rs | 15 ++++- .../re_space_view_graph/src/ui/state.rs | 2 +- crates/viewer/re_viewer/src/reflection/mod.rs | 10 +++- .../reference/types/views/graph_view.md | 2 + .../archetypes/force_collision_radius.cpp | 7 ++- .../archetypes/force_collision_radius.hpp | 13 ++++ .../rerun/blueprint/archetypes/force_link.cpp | 7 ++- .../rerun/blueprint/archetypes/force_link.hpp | 11 ++++ .../archetypes/force_collision_radius.py | 20 ++++++- .../rerun/blueprint/archetypes/force_link.py | 20 ++++++- .../check_graph_time_layout.py | 22 +++---- 19 files changed, 248 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e04517c3353..a0da0e5f7466 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2444,9 +2444,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "fjadra" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccc0416b27f53bba6c9bd564260f27d4784c5f430926eb16a519356be7d66bbc" +checksum = "d8d17b174735bd1464bc491c49570fc824466e9140617c371de9a6d86ebd33ec" [[package]] name = "flatbuffers" diff --git a/Cargo.toml b/Cargo.toml index d027a3a764ab..34c4a45e8622 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -189,7 +189,7 @@ enumset = "1.0.12" env_logger = { version = "0.10", default-features = false } ffmpeg-sidecar = { version = "2.0.2", default-features = false } fixed = { version = "1.28", default-features = false } -fjadra = "0.1" +fjadra = "0.2" flatbuffers = "23.0" futures-channel = "0.3" futures-util = { version = "0.3", default-features = false } diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs index 3709b9679343..4f5492ec8ebd 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs @@ -1,7 +1,5 @@ namespace rerun.blueprint.archetypes; -// TODO - /// The link force pushes linked nodes together or apart according to a desired distance. struct ForceCollisionRadius ( "attr.rerun.scope": "blueprint" @@ -11,4 +9,7 @@ struct ForceCollisionRadius ( /// The strength of the force. strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200); + + /// The number of iterations to run the force. + iterations: rerun.blueprint.components.ForceIterations ("attr.rerun.component_optional", nullable, order: 300); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs index ad9eb2550c83..5864593e1791 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs @@ -11,5 +11,5 @@ struct ForceLink ( distance: rerun.blueprint.components.ForceDistance ("attr.rerun.component_optional", nullable, order: 200); /// The number of iterations to run the force. - //iterations: rerun.blueprint.components.ForceIterations ("attr.rerun.component_optional", nullable, order: 400); + iterations: rerun.blueprint.components.ForceIterations ("attr.rerun.component_optional", nullable, order: 300); } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs index ee9c0a4b3182..f835ee5fca63 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs @@ -26,18 +26,24 @@ pub struct ForceCollisionRadius { /// The strength of the force. pub strength: Option, + + /// The number of iterations to run the force. + pub iterations: Option, } impl ::re_types_core::SizeBytes for ForceCollisionRadius { #[inline] fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() + self.enabled.heap_size_bytes() + + self.strength.heap_size_bytes() + + self.iterations.heap_size_bytes() } #[inline] fn is_pod() -> bool { >::is_pod() && >::is_pod() + && >::is_pod() } } @@ -49,26 +55,28 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = ["rerun.blueprint.components.ForceCollisionRadiusIndicator".into()] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.blueprint.components.Enabled".into(), "rerun.blueprint.components.ForceStrength".into(), + "rerun.blueprint.components.ForceIterations".into(), ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.blueprint.components.ForceCollisionRadiusIndicator".into(), "rerun.blueprint.components.Enabled".into(), "rerun.blueprint.components.ForceStrength".into(), + "rerun.blueprint.components.ForceIterations".into(), ] }); impl ForceCollisionRadius { - /// The total number of components in the archetype: 0 required, 1 recommended, 2 optional - pub const NUM_COMPONENTS: usize = 3usize; + /// The total number of components in the archetype: 0 required, 1 recommended, 3 optional + pub const NUM_COMPONENTS: usize = 4usize; } /// Indicator component for the [`ForceCollisionRadius`] [`::re_types_core::Archetype`] @@ -144,7 +152,21 @@ impl ::re_types_core::Archetype for ForceCollisionRadius { } else { None }; - Ok(Self { enabled, strength }) + let iterations = + if let Some(array) = arrays_by_name.get("rerun.blueprint.components.ForceIterations") { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceCollisionRadius#iterations")? + .into_iter() + .next() + .flatten() + } else { + None + }; + Ok(Self { + enabled, + strength, + iterations, + }) } } @@ -160,6 +182,9 @@ impl ::re_types_core::AsComponents for ForceCollisionRadius { self.strength .as_ref() .map(|comp| (comp as &dyn ComponentBatch).into()), + self.iterations + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), ] .into_iter() .flatten() @@ -176,6 +201,7 @@ impl ForceCollisionRadius { Self { enabled: None, strength: None, + iterations: None, } } @@ -198,4 +224,14 @@ impl ForceCollisionRadius { self.strength = Some(strength.into()); self } + + /// The number of iterations to run the force. + #[inline] + pub fn with_iterations( + mut self, + iterations: impl Into, + ) -> Self { + self.iterations = Some(iterations.into()); + self + } } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs index c3ed0667d5d1..5668c2812ffb 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_link.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -26,18 +26,24 @@ pub struct ForceLink { /// The target distance between two nodes. pub distance: Option, + + /// The number of iterations to run the force. + pub iterations: Option, } impl ::re_types_core::SizeBytes for ForceLink { #[inline] fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() + self.distance.heap_size_bytes() + self.enabled.heap_size_bytes() + + self.distance.heap_size_bytes() + + self.iterations.heap_size_bytes() } #[inline] fn is_pod() -> bool { >::is_pod() && >::is_pod() + && >::is_pod() } } @@ -47,26 +53,28 @@ static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.blueprint.components.Enabled".into(), "rerun.blueprint.components.ForceDistance".into(), + "rerun.blueprint.components.ForceIterations".into(), ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.blueprint.components.ForceLinkIndicator".into(), "rerun.blueprint.components.Enabled".into(), "rerun.blueprint.components.ForceDistance".into(), + "rerun.blueprint.components.ForceIterations".into(), ] }); impl ForceLink { - /// The total number of components in the archetype: 0 required, 1 recommended, 2 optional - pub const NUM_COMPONENTS: usize = 3usize; + /// The total number of components in the archetype: 0 required, 1 recommended, 3 optional + pub const NUM_COMPONENTS: usize = 4usize; } /// Indicator component for the [`ForceLink`] [`::re_types_core::Archetype`] @@ -141,7 +149,21 @@ impl ::re_types_core::Archetype for ForceLink { } else { None }; - Ok(Self { enabled, distance }) + let iterations = + if let Some(array) = arrays_by_name.get("rerun.blueprint.components.ForceIterations") { + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.ForceLink#iterations")? + .into_iter() + .next() + .flatten() + } else { + None + }; + Ok(Self { + enabled, + distance, + iterations, + }) } } @@ -157,6 +179,9 @@ impl ::re_types_core::AsComponents for ForceLink { self.distance .as_ref() .map(|comp| (comp as &dyn ComponentBatch).into()), + self.iterations + .as_ref() + .map(|comp| (comp as &dyn ComponentBatch).into()), ] .into_iter() .flatten() @@ -173,6 +198,7 @@ impl ForceLink { Self { enabled: None, distance: None, + iterations: None, } } @@ -195,4 +221,14 @@ impl ForceLink { self.distance = Some(distance.into()); self } + + /// The number of iterations to run the force. + #[inline] + pub fn with_iterations( + mut self, + iterations: impl Into, + ) -> Self { + self.iterations = Some(iterations.into()); + self + } } diff --git a/crates/viewer/re_space_view_graph/src/layout/params.rs b/crates/viewer/re_space_view_graph/src/layout/params.rs index d8bfa4788b8b..14192d905c26 100644 --- a/crates/viewer/re_space_view_graph/src/layout/params.rs +++ b/crates/viewer/re_space_view_graph/src/layout/params.rs @@ -1,7 +1,7 @@ use re_types::{ blueprint::{ archetypes::{ForceCenter, ForceCollisionRadius, ForceLink, ForceManyBody, ForcePosition}, - components::{Enabled, ForceDistance, ForceStrength}, + components::{Enabled, ForceDistance, ForceIterations, ForceStrength}, }, components::Position2D, Archetype, Component, @@ -14,6 +14,7 @@ pub struct ForceLayoutParams { // Link pub(super) force_link_enabled: Enabled, pub(super) force_link_distance: ForceDistance, + pub(super) force_link_iterations: ForceIterations, // Many body pub(super) force_many_body_enabled: Enabled, pub(super) force_many_body_strength: ForceStrength, @@ -27,6 +28,7 @@ pub struct ForceLayoutParams { // Collision pub(super) force_collision_enabled: Enabled, pub(super) force_collision_strength: ForceStrength, + pub(super) force_collision_iterations: ForceIterations, } /// Convenience struct for querying the components of a blueprint archetype or its fallbacks. @@ -87,6 +89,7 @@ impl ForceLayoutParams { // Link force_link_enabled: force_link.get()?, force_link_distance: force_link.get()?, + force_link_iterations: force_link.get()?, // Many body force_many_body_enabled: force_many.get()?, force_many_body_strength: force_many.get()?, @@ -100,6 +103,7 @@ impl ForceLayoutParams { // Collision force_collision_enabled: force_collision.get()?, force_collision_strength: force_collision.get()?, + force_collision_iterations: force_collision.get()?, }) } } diff --git a/crates/viewer/re_space_view_graph/src/layout/provider.rs b/crates/viewer/re_space_view_graph/src/layout/provider.rs index 678190a0bf9d..2fb7f9ed1557 100644 --- a/crates/viewer/re_space_view_graph/src/layout/provider.rs +++ b/crates/viewer/re_space_view_graph/src/layout/provider.rs @@ -11,8 +11,8 @@ use fjadra::{self as fj, Simulation}; use crate::graph::{EdgeId, NodeId}; use super::{ - params::{self, ForceLayoutParams}, - request::{self, NodeTemplate}, + params::ForceLayoutParams, + request::NodeTemplate, slots::{slotted_edges, Slot, SlotKind}, EdgeGeometry, EdgeTemplate, Layout, LayoutRequest, PathGeometry, }; @@ -33,34 +33,66 @@ pub fn update_simulation( edges: Vec<(usize, usize)>, radii: Vec, ) -> Simulation { - if **params.force_link_enabled { + // We destructure here to get compiler warnings if we add new parameters. + let &ForceLayoutParams { + force_link_enabled, + force_link_distance, + force_link_iterations, + force_many_body_enabled, + force_many_body_strength, + force_position_enabled, + force_position_strength, + force_position_pos, + force_center_enabled, + force_center_strength, + force_collision_enabled, + force_collision_strength, + force_collision_iterations, + } = params; + + if **force_link_enabled { simulation = simulation.add_force( "link", fj::Link::new(edges) - .distance(params.force_link_distance.0 .0) - .iterations(2), + .distance(**force_link_distance) + .iterations(**force_link_iterations as usize), ); } - if **params.force_many_body_enabled { + if **force_many_body_enabled { simulation = simulation.add_force( "charge", - fj::ManyBody::new().strength(params.force_many_body_strength.0 .0), + fj::ManyBody::new().strength(**force_many_body_strength), ); } - if **params.force_position_enabled { + if **force_position_enabled { simulation = simulation .add_force( "x", - fj::PositionX::new().strength(params.force_position_strength.0 .0), + fj::PositionX::new() + .strength(**force_position_strength) + .x(force_position_pos[0].into()), ) .add_force( "y", - fj::PositionY::new().strength(params.force_position_strength.0 .0), + fj::PositionY::new() + .strength(**force_position_strength) + .y(force_position_pos[1].into()), ); } - if **params.force_collision_enabled { - simulation = - simulation.add_force("collision", fj::Collide::new().radius(move |i| radii[i])); + if **force_collision_enabled { + simulation = simulation.add_force( + "collision", + fj::Collide::new() + .radius(move |i| radii[i]) + .iterations(**force_collision_iterations as usize) + .strength(**force_collision_strength), + ); + } + if **force_center_enabled { + simulation = simulation.add_force( + "center", + fj::Center::new().strength(**force_center_strength), + ); } simulation } @@ -270,7 +302,7 @@ impl ForceLayoutProvider { } pub fn is_finished(&self) -> bool { - self.simulation.finished() + self.simulation.is_finished() } } diff --git a/crates/viewer/re_space_view_graph/src/properties.rs b/crates/viewer/re_space_view_graph/src/properties.rs index 4897e7451af9..3f018b92c384 100644 --- a/crates/viewer/re_space_view_graph/src/properties.rs +++ b/crates/viewer/re_space_view_graph/src/properties.rs @@ -1,7 +1,7 @@ use re_types::{ blueprint::{ archetypes, - components::{Enabled, ForceDistance, ForceStrength, VisualBounds2D}, + components::{Enabled, ForceDistance, ForceIterations, ForceStrength, VisualBounds2D}, }, components::Position2D, Archetype as _, @@ -49,7 +49,16 @@ impl TypedComponentFallbackProvider for GraphSpaceView { match ctx.archetype_name { Some(name) if name == archetypes::ForceManyBody::name() => (-30.).into(), Some(name) if name == archetypes::ForcePosition::name() => (0.01).into(), - Some(name) if name == archetypes::ForceCenter::name() => (1.0).into(), + _ => (1.0).into(), + } + } +} + +impl TypedComponentFallbackProvider for GraphSpaceView { + fn fallback_for(&self, ctx: &re_viewer_context::QueryContext<'_>) -> ForceIterations { + match ctx.archetype_name { + Some(name) if name == archetypes::ForceLink::name() => 3.into(), + Some(name) if name == archetypes::ForceCollisionRadius::name() => 1.into(), _ => Default::default(), } } @@ -61,4 +70,4 @@ impl TypedComponentFallbackProvider for GraphSpaceView { } } -re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D, Enabled, ForceDistance, ForceStrength, Position2D]); +re_viewer_context::impl_component_fallback_provider!(GraphSpaceView => [VisualBounds2D, Enabled, ForceDistance, ForceStrength, ForceIterations, Position2D]); diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index 59cd9e9d141b..60f901a3c160 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -1,6 +1,6 @@ use egui::Rect; use re_format::format_f32; -use re_types::blueprint::{self, components::VisualBounds2D}; +use re_types::blueprint::components::VisualBounds2D; use re_ui::UiExt; use re_viewer_context::SpaceViewState; diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 4d3ccccc4d3b..916aae294b63 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -1990,7 +1990,10 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { is_required : false, }, ArchetypeFieldReflection { component_name : "rerun.blueprint.components.ForceStrength".into(), display_name : "Strength", docstring_md : "The strength of the force.", is_required - : false, }, + : false, }, ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceIterations".into(), display_name : + "Iterations", docstring_md : + "The number of iterations to run the force.", is_required : false, }, ], }, ), @@ -2006,7 +2009,10 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { is_required : false, }, ArchetypeFieldReflection { component_name : "rerun.blueprint.components.ForceDistance".into(), display_name : "Distance", docstring_md : "The target distance between two nodes.", - is_required : false, }, + is_required : false, }, ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ForceIterations".into(), display_name : + "Iterations", docstring_md : + "The number of iterations to run the force.", is_required : false, }, ], }, ), diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index add2fd989baa..0d78273058c9 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -16,6 +16,7 @@ A link force between nodes in the graph. * `enabled`: Whether the force is enabled. * `distance`: The target distance between two nodes. +* `iterations`: The number of iterations to run the force. ### `force_many_body` TODO @@ -32,6 +33,7 @@ TODO * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. +* `iterations`: The number of iterations to run the force. ### `force_center` TODO diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp index 3ff21cabaafc..e1d064e50f80 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp @@ -15,7 +15,7 @@ namespace rerun { ) { using namespace blueprint::archetypes; std::vector cells; - cells.reserve(3); + cells.reserve(4); if (archetype.enabled.has_value()) { auto result = ComponentBatch::from_loggable(archetype.enabled.value()); @@ -27,6 +27,11 @@ namespace rerun { RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } + if (archetype.iterations.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.iterations.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } { auto indicator = ForceCollisionRadius::IndicatorComponent(); auto result = ComponentBatch::from_loggable(indicator); diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp index 0302d0076fa3..d6789e2e84b0 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp @@ -4,6 +4,7 @@ #pragma once #include "../../blueprint/components/enabled.hpp" +#include "../../blueprint/components/force_iterations.hpp" #include "../../blueprint/components/force_strength.hpp" #include "../../collection.hpp" #include "../../compiler_utils.hpp" @@ -25,6 +26,9 @@ namespace rerun::blueprint::archetypes { /// The strength of the force. std::optional strength; + /// The number of iterations to run the force. + std::optional iterations; + public: static constexpr const char IndicatorComponentName[] = "rerun.blueprint.components.ForceCollisionRadiusIndicator"; @@ -50,6 +54,15 @@ namespace rerun::blueprint::archetypes { // See: https://github.com/rerun-io/rerun/issues/4027 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) } + + /// The number of iterations to run the force. + ForceCollisionRadius with_iterations( + rerun::blueprint::components::ForceIterations _iterations + ) && { + iterations = std::move(_iterations); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } }; } // namespace rerun::blueprint::archetypes diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp index 229d9d558bf2..dc39192e8cec 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp @@ -14,7 +14,7 @@ namespace rerun { ) { using namespace blueprint::archetypes; std::vector cells; - cells.reserve(3); + cells.reserve(4); if (archetype.enabled.has_value()) { auto result = ComponentBatch::from_loggable(archetype.enabled.value()); @@ -26,6 +26,11 @@ namespace rerun { RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } + if (archetype.iterations.has_value()) { + auto result = ComponentBatch::from_loggable(archetype.iterations.value()); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } { auto indicator = ForceLink::IndicatorComponent(); auto result = ComponentBatch::from_loggable(indicator); diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp index 391928a569b9..ffb1aa663310 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp @@ -5,6 +5,7 @@ #include "../../blueprint/components/enabled.hpp" #include "../../blueprint/components/force_distance.hpp" +#include "../../blueprint/components/force_iterations.hpp" #include "../../collection.hpp" #include "../../compiler_utils.hpp" #include "../../component_batch.hpp" @@ -25,6 +26,9 @@ namespace rerun::blueprint::archetypes { /// The target distance between two nodes. std::optional distance; + /// The number of iterations to run the force. + std::optional iterations; + public: static constexpr const char IndicatorComponentName[] = "rerun.blueprint.components.ForceLinkIndicator"; @@ -49,6 +53,13 @@ namespace rerun::blueprint::archetypes { // See: https://github.com/rerun-io/rerun/issues/4027 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) } + + /// The number of iterations to run the force. + ForceLink with_iterations(rerun::blueprint::components::ForceIterations _iterations) && { + iterations = std::move(_iterations); + // See: https://github.com/rerun-io/rerun/issues/4027 + RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) + } }; } // namespace rerun::blueprint::archetypes diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py index ae4b77bb1151..daf3404c2487 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py @@ -24,7 +24,11 @@ class ForceCollisionRadius(Archetype): """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" def __init__( - self: Any, *, enabled: datatypes.BoolLike | None = None, strength: datatypes.Float64Like | None = None + self: Any, + *, + enabled: datatypes.BoolLike | None = None, + strength: datatypes.Float64Like | None = None, + iterations: datatypes.UInt64Like | None = None, ): """ Create a new instance of the ForceCollisionRadius archetype. @@ -35,12 +39,14 @@ def __init__( Whether the force is enabled. strength: The strength of the force. + iterations: + The number of iterations to run the force. """ # You can define your own __init__ function as a member of ForceCollisionRadiusExt in force_collision_radius_ext.py with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(enabled=enabled, strength=strength) + self.__attrs_init__(enabled=enabled, strength=strength, iterations=iterations) return self.__attrs_clear__() @@ -49,6 +55,7 @@ def __attrs_clear__(self) -> None: self.__attrs_init__( enabled=None, # type: ignore[arg-type] strength=None, # type: ignore[arg-type] + iterations=None, # type: ignore[arg-type] ) @classmethod @@ -76,5 +83,14 @@ def _clear(cls) -> ForceCollisionRadius: # # (Docstring intentionally commented out to hide this field from the docs) + iterations: blueprint_components.ForceIterationsBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.ForceIterationsBatch._optional, # type: ignore[misc] + ) + # The number of iterations to run the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + __str__ = Archetype.__str__ __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py index 9dee65a56941..3023fb6f4fb9 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py @@ -24,7 +24,11 @@ class ForceLink(Archetype): """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" def __init__( - self: Any, *, enabled: datatypes.BoolLike | None = None, distance: datatypes.Float64Like | None = None + self: Any, + *, + enabled: datatypes.BoolLike | None = None, + distance: datatypes.Float64Like | None = None, + iterations: datatypes.UInt64Like | None = None, ): """ Create a new instance of the ForceLink archetype. @@ -35,12 +39,14 @@ def __init__( Whether the force is enabled. distance: The target distance between two nodes. + iterations: + The number of iterations to run the force. """ # You can define your own __init__ function as a member of ForceLinkExt in force_link_ext.py with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(enabled=enabled, distance=distance) + self.__attrs_init__(enabled=enabled, distance=distance, iterations=iterations) return self.__attrs_clear__() @@ -49,6 +55,7 @@ def __attrs_clear__(self) -> None: self.__attrs_init__( enabled=None, # type: ignore[arg-type] distance=None, # type: ignore[arg-type] + iterations=None, # type: ignore[arg-type] ) @classmethod @@ -76,5 +83,14 @@ def _clear(cls) -> ForceLink: # # (Docstring intentionally commented out to hide this field from the docs) + iterations: blueprint_components.ForceIterationsBatch | None = field( + metadata={"component": "optional"}, + default=None, + converter=blueprint_components.ForceIterationsBatch._optional, # type: ignore[misc] + ) + # The number of iterations to run the force. + # + # (Docstring intentionally commented out to hide this field from the docs) + __str__ = Archetype.__str__ __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/tests/python/release_checklist/check_graph_time_layout.py b/tests/python/release_checklist/check_graph_time_layout.py index 825de3fa5388..591a5412f28d 100644 --- a/tests/python/release_checklist/check_graph_time_layout.py +++ b/tests/python/release_checklist/check_graph_time_layout.py @@ -14,8 +14,8 @@ from rerun.blueprint.archetypes.force_collision_radius import ForceCollisionRadius from rerun.blueprint.archetypes.force_link import ForceLink from rerun.blueprint.archetypes.force_many_body import ForceManyBody +from rerun.components.color import Color from rerun.components.show_labels import ShowLabels -from rerun.datatypes.rgba32 import Rgba32 README = """\ # Time-varying graph view @@ -28,15 +28,15 @@ """ color_scheme = [ - Rgba32([228, 26, 28, 255]), # Red - Rgba32([55, 126, 184, 255]), # Blue - Rgba32([77, 175, 74, 255]), # Green - Rgba32([152, 78, 163, 255]), # Purple - Rgba32([255, 127, 0, 255]), # Orange - Rgba32([255, 255, 51, 255]), # Yellow - Rgba32([166, 86, 40, 255]), # Brown - Rgba32([247, 129, 191, 255]), # Pink - Rgba32([153, 153, 153, 255]), # Gray + Color([228, 26, 28]), # Red + Color([55, 126, 184]), # Blue + Color([77, 175, 74]), # Green + Color([152, 78, 163]), # Purple + Color([255, 127, 0]), # Orange + Color([255, 255, 51]), # Yellow + Color([166, 86, 40]), # Brown + Color([247, 129, 191]), # Pink + Color([153, 153, 153]), # Gray ] @@ -47,7 +47,7 @@ def log_readme() -> None: def log_graphs() -> None: nodes = ["root"] radii = [42] - colors = [Rgba32([81, 81, 81, 255])] + colors = [Color([81, 81, 81])] edges = [] # We want reproducible results From 1f445e4adb370183872505038d66ff7a365ed57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 09:37:02 +0100 Subject: [PATCH 29/44] Improve selection ui [skip ci] --- Cargo.lock | 1 + crates/viewer/re_space_view_graph/Cargo.toml | 1 + .../re_space_view_graph/src/properties.rs | 4 +- .../viewer/re_space_view_graph/src/ui/mod.rs | 2 + .../re_space_view_graph/src/ui/selection.rs | 86 +++++++++++++++++++ crates/viewer/re_space_view_graph/src/view.rs | 12 +-- 6 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 crates/viewer/re_space_view_graph/src/ui/selection.rs diff --git a/Cargo.lock b/Cargo.lock index a0da0e5f7466..cc9f04e9e2b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6245,6 +6245,7 @@ dependencies = [ "re_data_ui", "re_entity_db", "re_format", + "re_log", "re_log_types", "re_query", "re_renderer", diff --git a/crates/viewer/re_space_view_graph/Cargo.toml b/crates/viewer/re_space_view_graph/Cargo.toml index 136dbbbb2ad3..6ba3f933edb0 100644 --- a/crates/viewer/re_space_view_graph/Cargo.toml +++ b/crates/viewer/re_space_view_graph/Cargo.toml @@ -23,6 +23,7 @@ re_data_ui.workspace = true re_chunk.workspace = true re_entity_db.workspace = true re_format.workspace = true +re_log.workspace = true re_log_types.workspace = true re_query.workspace = true re_renderer.workspace = true diff --git a/crates/viewer/re_space_view_graph/src/properties.rs b/crates/viewer/re_space_view_graph/src/properties.rs index 3f018b92c384..402831a223a8 100644 --- a/crates/viewer/re_space_view_graph/src/properties.rs +++ b/crates/viewer/re_space_view_graph/src/properties.rs @@ -40,14 +40,14 @@ impl TypedComponentFallbackProvider for GraphSpaceView { impl TypedComponentFallbackProvider for GraphSpaceView { fn fallback_for(&self, _ctx: &re_viewer_context::QueryContext<'_>) -> ForceDistance { - (42.).into() + (60.).into() } } impl TypedComponentFallbackProvider for GraphSpaceView { fn fallback_for(&self, ctx: &re_viewer_context::QueryContext<'_>) -> ForceStrength { match ctx.archetype_name { - Some(name) if name == archetypes::ForceManyBody::name() => (-30.).into(), + Some(name) if name == archetypes::ForceManyBody::name() => (-60.).into(), Some(name) if name == archetypes::ForcePosition::name() => (0.01).into(), _ => (1.0).into(), } diff --git a/crates/viewer/re_space_view_graph/src/ui/mod.rs b/crates/viewer/re_space_view_graph/src/ui/mod.rs index 57c7974e5b72..876b32ffb8ac 100644 --- a/crates/viewer/re_space_view_graph/src/ui/mod.rs +++ b/crates/viewer/re_space_view_graph/src/ui/mod.rs @@ -1,5 +1,7 @@ mod draw; +mod selection; mod state; pub use draw::{draw_debug, draw_graph, DrawableLabel}; +pub use selection::view_property_force_ui; pub use state::GraphSpaceViewState; diff --git a/crates/viewer/re_space_view_graph/src/ui/selection.rs b/crates/viewer/re_space_view_graph/src/ui/selection.rs new file mode 100644 index 000000000000..a010e8f971f3 --- /dev/null +++ b/crates/viewer/re_space_view_graph/src/ui/selection.rs @@ -0,0 +1,86 @@ +use re_space_view::{view_property_component_ui, view_property_component_ui_custom}; +use re_types::{ + blueprint::components::Enabled, Archetype, ArchetypeReflectionMarker, Component as _, +}; +use re_viewer_context::{ComponentFallbackProvider, SpaceViewId, SpaceViewState, ViewerContext}; +use re_viewport_blueprint::ViewProperty; + +pub fn view_property_force_ui( + ctx: &ViewerContext<'_>, + ui: &mut egui::Ui, + view_id: SpaceViewId, + fallback_provider: &dyn ComponentFallbackProvider, + view_state: &dyn SpaceViewState, +) { + let property = + ViewProperty::from_archetype::(ctx.blueprint_db(), ctx.blueprint_query, view_id); + + let Some(reflection) = ctx.reflection.archetypes.get(&property.archetype_name) else { + // The `ArchetypeReflectionMarker` bound should make this impossible. + re_log::warn_once!( + "Missing reflection data for archetype {:?}.", + property.archetype_name + ); + return; + }; + + let query_ctx = property.query_context(ctx, view_state); + + if reflection.fields.len() == 1 { + let field = &reflection.fields[0]; + + view_property_component_ui( + &query_ctx, + ui, + &property, + reflection.display_name, + field, + fallback_provider, + ); + } else { + let sub_prop_ui = |ui: &mut egui::Ui| { + for field in &reflection.fields { + view_property_component_ui( + &query_ctx, + ui, + &property, + field.display_name, + field, + fallback_provider, + ); + } + }; + + let field = reflection + .fields + .iter() + .find(|field| field.component_name == Enabled::name()) + .expect("forces are required to have an `Enabled` component"); + + let component_array = property.component_raw(field.component_name); + let row_id = property.component_row_id(field.component_name); + + let singleline_ui: &dyn Fn(&mut egui::Ui) = &|ui| { + ctx.component_ui_registry.singleline_edit_ui( + &query_ctx, + ui, + ctx.blueprint_db(), + query_ctx.target_entity_path, + field.component_name, + row_id, + component_array.as_deref(), + fallback_provider, + ); + }; + + view_property_component_ui_custom( + &query_ctx, + ui, + &property, + reflection.display_name, + field, + singleline_ui, + Some(&sub_prop_ui), + ); + } +} diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index 4fff4396a695..dc84ead92cc3 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -29,7 +29,7 @@ use re_viewport_blueprint::ViewProperty; use crate::{ graph::Graph, layout::{ForceLayoutParams, LayoutRequest}, - ui::{draw_debug, draw_graph, GraphSpaceViewState}, + ui::{draw_debug, draw_graph, view_property_force_ui, GraphSpaceViewState}, visualizers::{merge, EdgesVisualizer, NodeVisualizer}, }; @@ -137,11 +137,11 @@ Display a graph of nodes and edges. re_ui::list_item::list_item_scope(ui, "graph_selection_ui", |ui| { view_property_ui::(ctx, ui, space_view_id, self, state); - view_property_ui::(ctx, ui, space_view_id, self, state); - view_property_ui::(ctx, ui, space_view_id, self, state); - view_property_ui::(ctx, ui, space_view_id, self, state); - view_property_ui::(ctx, ui, space_view_id, self, state); - view_property_ui::(ctx, ui, space_view_id, self, state); + view_property_force_ui::(ctx, ui, space_view_id, self, state); + view_property_force_ui::(ctx, ui, space_view_id, self, state); + view_property_force_ui::(ctx, ui, space_view_id, self, state); + view_property_force_ui::(ctx, ui, space_view_id, self, state); + view_property_force_ui::(ctx, ui, space_view_id, self, state); }); Ok(()) From 67a04e1c5fbe8be3f367aa686a3cfeae7290c3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 10:02:31 +0100 Subject: [PATCH 30/44] Add `singleline_edit_position2d` --- crates/viewer/re_component_ui/src/lib.rs | 3 ++ .../viewer/re_component_ui/src/position2d.rs | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 crates/viewer/re_component_ui/src/position2d.rs diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index ad933e381e0b..146eca127c9d 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -14,6 +14,7 @@ mod line_strip; mod map_provider; mod marker_shape; mod pinhole; +mod position2d; mod radius; mod recording_uri; mod resolution; @@ -141,6 +142,8 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_multiline_edit_or_view(visual_bounds2d::multiline_edit_visual_bounds2d); registry.add_singleline_edit_or_view(visual_bounds2d::singleline_edit_visual_bounds2d); + registry.add_singleline_edit_or_view(position2d::singleline_edit_position2d); + registry.add_multiline_edit_or_view(transforms::multiline_view_transform_mat3x3); registry.add_singleline_edit_or_view(transforms::singleline_view_transform_mat3x3); diff --git a/crates/viewer/re_component_ui/src/position2d.rs b/crates/viewer/re_component_ui/src/position2d.rs new file mode 100644 index 000000000000..57c00ff4ac22 --- /dev/null +++ b/crates/viewer/re_component_ui/src/position2d.rs @@ -0,0 +1,37 @@ +use re_types::components::Position2D; +use re_viewer_context::{MaybeMutRef, ViewerContext}; + +pub fn singleline_edit_position2d( + _ctx: &ViewerContext<'_>, + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, Position2D>, +) -> egui::Response { + if let Some(value) = value.as_mut() { + let x = value.0[0]; + let y = value.0[1]; + + let mut x_edit = x; + let mut y_edit = y; + + ui.label("["); + let response_x = ui.add(egui::DragValue::new(&mut x_edit)); + ui.label(","); + let response_y = ui.add(egui::DragValue::new(&mut y_edit)); + ui.label("]"); + let response = response_y | response_x; + + if response.changed() { + *value = Position2D([x_edit, y_edit].into()); + } + + response + } else { + let x = value.0[0]; + let y = value.0[1]; + ui.label(format!( + "[ {} , {} ]", + re_format::format_f32(x), + re_format::format_f32(y) + )) + } +} From ae9fd7da4ca1d8baf3cf1af666cc31cedcff01da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 10:02:31 +0100 Subject: [PATCH 31/44] Add `singleline_edit_position2d` --- crates/viewer/re_component_ui/src/lib.rs | 3 ++ .../viewer/re_component_ui/src/position2d.rs | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 crates/viewer/re_component_ui/src/position2d.rs diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 55b7da2d4730..a074679ccf5e 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -15,6 +15,7 @@ mod map_provider; mod marker_shape; mod pinhole; mod plane3d; +mod position2d; mod radius; mod recording_uri; mod resolution; @@ -139,6 +140,8 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_multiline_edit_or_view(visual_bounds2d::multiline_edit_visual_bounds2d); registry.add_singleline_edit_or_view(visual_bounds2d::singleline_edit_visual_bounds2d); + registry.add_singleline_edit_or_view(position2d::singleline_edit_position2d); + registry.add_multiline_edit_or_view(transforms::multiline_view_transform_mat3x3); registry.add_singleline_edit_or_view(transforms::singleline_view_transform_mat3x3); diff --git a/crates/viewer/re_component_ui/src/position2d.rs b/crates/viewer/re_component_ui/src/position2d.rs new file mode 100644 index 000000000000..57c00ff4ac22 --- /dev/null +++ b/crates/viewer/re_component_ui/src/position2d.rs @@ -0,0 +1,37 @@ +use re_types::components::Position2D; +use re_viewer_context::{MaybeMutRef, ViewerContext}; + +pub fn singleline_edit_position2d( + _ctx: &ViewerContext<'_>, + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, Position2D>, +) -> egui::Response { + if let Some(value) = value.as_mut() { + let x = value.0[0]; + let y = value.0[1]; + + let mut x_edit = x; + let mut y_edit = y; + + ui.label("["); + let response_x = ui.add(egui::DragValue::new(&mut x_edit)); + ui.label(","); + let response_y = ui.add(egui::DragValue::new(&mut y_edit)); + ui.label("]"); + let response = response_y | response_x; + + if response.changed() { + *value = Position2D([x_edit, y_edit].into()); + } + + response + } else { + let x = value.0[0]; + let y = value.0[1]; + ui.label(format!( + "[ {} , {} ]", + re_format::format_f32(x), + re_format::format_f32(y) + )) + } +} From 78488da014061b1eed96b15e7c175e8621b6b73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 11:01:49 +0100 Subject: [PATCH 32/44] Small cleanup --- crates/viewer/re_component_ui/src/position2d.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/viewer/re_component_ui/src/position2d.rs b/crates/viewer/re_component_ui/src/position2d.rs index 57c00ff4ac22..0c002edda2c0 100644 --- a/crates/viewer/re_component_ui/src/position2d.rs +++ b/crates/viewer/re_component_ui/src/position2d.rs @@ -6,10 +6,10 @@ pub fn singleline_edit_position2d( ui: &mut egui::Ui, value: &mut MaybeMutRef<'_, Position2D>, ) -> egui::Response { - if let Some(value) = value.as_mut() { - let x = value.0[0]; - let y = value.0[1]; + let x = value.0[0]; + let y = value.0[1]; + if let Some(value) = value.as_mut() { let mut x_edit = x; let mut y_edit = y; @@ -26,8 +26,6 @@ pub fn singleline_edit_position2d( response } else { - let x = value.0[0]; - let y = value.0[1]; ui.label(format!( "[ {} , {} ]", re_format::format_f32(x), From 2b2fb45a8f073056db2ace1b1fa5866c2579de98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 11:02:48 +0100 Subject: [PATCH 33/44] Trigger CI --- crates/viewer/re_component_ui/src/position2d.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/viewer/re_component_ui/src/position2d.rs b/crates/viewer/re_component_ui/src/position2d.rs index 57c00ff4ac22..0c002edda2c0 100644 --- a/crates/viewer/re_component_ui/src/position2d.rs +++ b/crates/viewer/re_component_ui/src/position2d.rs @@ -6,10 +6,10 @@ pub fn singleline_edit_position2d( ui: &mut egui::Ui, value: &mut MaybeMutRef<'_, Position2D>, ) -> egui::Response { - if let Some(value) = value.as_mut() { - let x = value.0[0]; - let y = value.0[1]; + let x = value.0[0]; + let y = value.0[1]; + if let Some(value) = value.as_mut() { let mut x_edit = x; let mut y_edit = y; @@ -26,8 +26,6 @@ pub fn singleline_edit_position2d( response } else { - let x = value.0[0]; - let y = value.0[1]; ui.label(format!( "[ {} , {} ]", re_format::format_f32(x), From f36ef0b45f17e1c791c74e62f138cf7824f180a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 11:07:22 +0100 Subject: [PATCH 34/44] Missing files --- .../src/blueprint/archetypes/force_center.rs | 116 +++++++++----- .../archetypes/force_collision_radius.rs | 145 ++++++++++++----- .../src/blueprint/archetypes/force_link.rs | 147 +++++++++++++----- .../blueprint/archetypes/force_many_body.rs | 116 +++++++++----- .../blueprint/archetypes/force_position.rs | 147 +++++++++++++----- .../src/blueprint/components/enabled.rs | 80 +++++----- .../blueprint/components/force_distance.rs | 84 +++++----- .../blueprint/components/force_iterations.rs | 84 +++++----- .../blueprint/components/force_strength.rs | 84 +++++----- .../blueprint/archetypes/force_center.cpp | 18 ++- .../archetypes/force_collision_radius.cpp | 27 +++- .../rerun/blueprint/archetypes/force_link.cpp | 27 +++- .../blueprint/archetypes/force_many_body.cpp | 18 ++- .../blueprint/archetypes/force_position.cpp | 27 +++- .../rerun/blueprint/components/enabled.hpp | 3 +- .../blueprint/components/force_distance.hpp | 4 +- .../blueprint/components/force_iterations.hpp | 4 +- .../blueprint/components/force_strength.hpp | 4 +- .../rerun/blueprint/components/enabled.py | 3 +- .../blueprint/components/force_distance.py | 3 +- .../blueprint/components/force_iterations.py | 3 +- .../blueprint/components/force_strength.py | 3 +- 22 files changed, 759 insertions(+), 388 deletions(-) diff --git a/crates/store/re_types/src/blueprint/archetypes/force_center.rs b/crates/store/re_types/src/blueprint/archetypes/force_center.rs index 041440b24dfe..2b359bd35878 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_center.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_center.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. @@ -28,39 +28,52 @@ pub struct ForceCenter { pub strength: Option, } -impl ::re_types_core::SizeBytes for ForceCenter { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = once_cell::sync::Lazy::new(|| []); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceCenterIndicator".into()]); +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = + once_cell::sync::Lazy::new(|| { + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), + component_name: "ForceCenterIndicator".into(), + archetype_field_name: None, + }] + }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceStrength".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), + component_name: "rerun.blueprint.components.ForceStrength".into(), + archetype_field_name: Some("strength".into()), + }, ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.ForceCenterIndicator".into(), - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceStrength".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), + component_name: "ForceCenterIndicator".into(), + archetype_field_name: None, + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), + component_name: "rerun.blueprint.components.ForceStrength".into(), + archetype_field_name: Some("strength".into()), + }, ] }); @@ -86,28 +99,28 @@ impl ::re_types_core::Archetype for ForceCenter { } #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { + fn indicator() -> ComponentBatchCowWithDescriptor<'static> { static INDICATOR: ForceCenterIndicator = ForceCenterIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) + ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { ALL_COMPONENTS.as_slice().into() } @@ -146,17 +159,35 @@ impl ::re_types_core::Archetype for ForceCenter { } impl ::re_types_core::AsComponents for ForceCenter { - fn as_component_batches(&self) -> Vec> { + fn as_component_batches(&self) -> Vec> { re_tracing::profile_function!(); use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - self.enabled + (self + .enabled .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.strength + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), + archetype_field_name: Some(("enabled").into()), + component_name: ("rerun.blueprint.components.Enabled").into(), + }), + }), + (self + .strength .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), + archetype_field_name: Some(("strength").into()), + component_name: ("rerun.blueprint.components.ForceStrength").into(), + }), + }), ] .into_iter() .flatten() @@ -196,3 +227,16 @@ impl ForceCenter { self } } + +impl ::re_types_core::SizeBytes for ForceCenter { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs index f835ee5fca63..dd8733fdb5f9 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. @@ -31,46 +31,62 @@ pub struct ForceCollisionRadius { pub iterations: Option, } -impl ::re_types_core::SizeBytes for ForceCollisionRadius { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() - + self.strength.heap_size_bytes() - + self.iterations.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = once_cell::sync::Lazy::new(|| []); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = once_cell::sync::Lazy::new(|| { - ["rerun.blueprint.components.ForceCollisionRadiusIndicator".into()] + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + component_name: "ForceCollisionRadiusIndicator".into(), + archetype_field_name: None, + }] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceStrength".into(), - "rerun.blueprint.components.ForceIterations".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + component_name: "rerun.blueprint.components.ForceStrength".into(), + archetype_field_name: Some("strength".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + component_name: "rerun.blueprint.components.ForceIterations".into(), + archetype_field_name: Some("iterations".into()), + }, ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 4usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.ForceCollisionRadiusIndicator".into(), - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceStrength".into(), - "rerun.blueprint.components.ForceIterations".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + component_name: "ForceCollisionRadiusIndicator".into(), + archetype_field_name: None, + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + component_name: "rerun.blueprint.components.ForceStrength".into(), + archetype_field_name: Some("strength".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + component_name: "rerun.blueprint.components.ForceIterations".into(), + archetype_field_name: Some("iterations".into()), + }, ] }); @@ -97,28 +113,28 @@ impl ::re_types_core::Archetype for ForceCollisionRadius { } #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { + fn indicator() -> ComponentBatchCowWithDescriptor<'static> { static INDICATOR: ForceCollisionRadiusIndicator = ForceCollisionRadiusIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) + ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { ALL_COMPONENTS.as_slice().into() } @@ -171,20 +187,47 @@ impl ::re_types_core::Archetype for ForceCollisionRadius { } impl ::re_types_core::AsComponents for ForceCollisionRadius { - fn as_component_batches(&self) -> Vec> { + fn as_component_batches(&self) -> Vec> { re_tracing::profile_function!(); use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - self.enabled + (self + .enabled .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.strength + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + archetype_field_name: Some(("enabled").into()), + component_name: ("rerun.blueprint.components.Enabled").into(), + }), + }), + (self + .strength .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.iterations + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + archetype_field_name: Some(("strength").into()), + component_name: ("rerun.blueprint.components.ForceStrength").into(), + }), + }), + (self + .iterations .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), + archetype_field_name: Some(("iterations").into()), + component_name: ("rerun.blueprint.components.ForceIterations").into(), + }), + }), ] .into_iter() .flatten() @@ -235,3 +278,19 @@ impl ForceCollisionRadius { self } } + +impl ::re_types_core::SizeBytes for ForceCollisionRadius { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + + self.strength.heap_size_bytes() + + self.iterations.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + && >::is_pod() + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs index 5668c2812ffb..5d098d0dacae 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_link.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. @@ -31,44 +31,62 @@ pub struct ForceLink { pub iterations: Option, } -impl ::re_types_core::SizeBytes for ForceLink { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() - + self.distance.heap_size_bytes() - + self.iterations.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = once_cell::sync::Lazy::new(|| []); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceLinkIndicator".into()]); +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = + once_cell::sync::Lazy::new(|| { + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + component_name: "ForceLinkIndicator".into(), + archetype_field_name: None, + }] + }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceDistance".into(), - "rerun.blueprint.components.ForceIterations".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + component_name: "rerun.blueprint.components.ForceDistance".into(), + archetype_field_name: Some("distance".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + component_name: "rerun.blueprint.components.ForceIterations".into(), + archetype_field_name: Some("iterations".into()), + }, ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 4usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.ForceLinkIndicator".into(), - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceDistance".into(), - "rerun.blueprint.components.ForceIterations".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + component_name: "ForceLinkIndicator".into(), + archetype_field_name: None, + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + component_name: "rerun.blueprint.components.ForceDistance".into(), + archetype_field_name: Some("distance".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + component_name: "rerun.blueprint.components.ForceIterations".into(), + archetype_field_name: Some("iterations".into()), + }, ] }); @@ -94,28 +112,28 @@ impl ::re_types_core::Archetype for ForceLink { } #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { + fn indicator() -> ComponentBatchCowWithDescriptor<'static> { static INDICATOR: ForceLinkIndicator = ForceLinkIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) + ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { ALL_COMPONENTS.as_slice().into() } @@ -168,20 +186,47 @@ impl ::re_types_core::Archetype for ForceLink { } impl ::re_types_core::AsComponents for ForceLink { - fn as_component_batches(&self) -> Vec> { + fn as_component_batches(&self) -> Vec> { re_tracing::profile_function!(); use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - self.enabled + (self + .enabled .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.distance + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + archetype_field_name: Some(("enabled").into()), + component_name: ("rerun.blueprint.components.Enabled").into(), + }), + }), + (self + .distance .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.iterations + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + archetype_field_name: Some(("distance").into()), + component_name: ("rerun.blueprint.components.ForceDistance").into(), + }), + }), + (self + .iterations .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), + archetype_field_name: Some(("iterations").into()), + component_name: ("rerun.blueprint.components.ForceIterations").into(), + }), + }), ] .into_iter() .flatten() @@ -232,3 +277,19 @@ impl ForceLink { self } } + +impl ::re_types_core::SizeBytes for ForceLink { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + + self.distance.heap_size_bytes() + + self.iterations.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + && >::is_pod() + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs index 8c8182a92d38..0001b9d39046 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. @@ -28,39 +28,52 @@ pub struct ForceManyBody { pub strength: Option, } -impl ::re_types_core::SizeBytes for ForceManyBody { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = once_cell::sync::Lazy::new(|| []); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForceManyBodyIndicator".into()]); +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = + once_cell::sync::Lazy::new(|| { + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), + component_name: "ForceManyBodyIndicator".into(), + archetype_field_name: None, + }] + }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceStrength".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), + component_name: "rerun.blueprint.components.ForceStrength".into(), + archetype_field_name: Some("strength".into()), + }, ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.ForceManyBodyIndicator".into(), - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceStrength".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), + component_name: "ForceManyBodyIndicator".into(), + archetype_field_name: None, + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), + component_name: "rerun.blueprint.components.ForceStrength".into(), + archetype_field_name: Some("strength".into()), + }, ] }); @@ -86,28 +99,28 @@ impl ::re_types_core::Archetype for ForceManyBody { } #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { + fn indicator() -> ComponentBatchCowWithDescriptor<'static> { static INDICATOR: ForceManyBodyIndicator = ForceManyBodyIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) + ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { ALL_COMPONENTS.as_slice().into() } @@ -146,17 +159,35 @@ impl ::re_types_core::Archetype for ForceManyBody { } impl ::re_types_core::AsComponents for ForceManyBody { - fn as_component_batches(&self) -> Vec> { + fn as_component_batches(&self) -> Vec> { re_tracing::profile_function!(); use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - self.enabled + (self + .enabled .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.strength + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), + archetype_field_name: Some(("enabled").into()), + component_name: ("rerun.blueprint.components.Enabled").into(), + }), + }), + (self + .strength .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), + archetype_field_name: Some(("strength").into()), + component_name: ("rerun.blueprint.components.ForceStrength").into(), + }), + }), ] .into_iter() .flatten() @@ -196,3 +227,16 @@ impl ForceManyBody { self } } + +impl ::re_types_core::SizeBytes for ForceManyBody { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + self.strength.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position.rs b/crates/store/re_types/src/blueprint/archetypes/force_position.rs index 27a222841774..fc26dbe573ee 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_position.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_position.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. @@ -31,44 +31,62 @@ pub struct ForcePosition { pub position: Option, } -impl ::re_types_core::SizeBytes for ForcePosition { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.enabled.heap_size_bytes() - + self.strength.heap_size_bytes() - + self.position.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - } -} - -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = once_cell::sync::Lazy::new(|| []); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ForcePositionIndicator".into()]); +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = + once_cell::sync::Lazy::new(|| { + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + component_name: "ForcePositionIndicator".into(), + archetype_field_name: None, + }] + }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceStrength".into(), - "rerun.components.Position2D".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + component_name: "rerun.blueprint.components.ForceStrength".into(), + archetype_field_name: Some("strength".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + component_name: "rerun.components.Position2D".into(), + archetype_field_name: Some("position".into()), + }, ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 4usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> = once_cell::sync::Lazy::new(|| { [ - "rerun.blueprint.components.ForcePositionIndicator".into(), - "rerun.blueprint.components.Enabled".into(), - "rerun.blueprint.components.ForceStrength".into(), - "rerun.components.Position2D".into(), + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + component_name: "ForcePositionIndicator".into(), + archetype_field_name: None, + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + component_name: "rerun.blueprint.components.Enabled".into(), + archetype_field_name: Some("enabled".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + component_name: "rerun.blueprint.components.ForceStrength".into(), + archetype_field_name: Some("strength".into()), + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + component_name: "rerun.components.Position2D".into(), + archetype_field_name: Some("position".into()), + }, ] }); @@ -94,28 +112,28 @@ impl ::re_types_core::Archetype for ForcePosition { } #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { + fn indicator() -> ComponentBatchCowWithDescriptor<'static> { static INDICATOR: ForcePositionIndicator = ForcePositionIndicator::DEFAULT; - MaybeOwnedComponentBatch::Ref(&INDICATOR) + ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { ALL_COMPONENTS.as_slice().into() } @@ -167,20 +185,47 @@ impl ::re_types_core::Archetype for ForcePosition { } impl ::re_types_core::AsComponents for ForcePosition { - fn as_component_batches(&self) -> Vec> { + fn as_component_batches(&self) -> Vec> { re_tracing::profile_function!(); use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - self.enabled + (self + .enabled .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.strength + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + archetype_field_name: Some(("enabled").into()), + component_name: ("rerun.blueprint.components.Enabled").into(), + }), + }), + (self + .strength .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.position + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + archetype_field_name: Some(("strength").into()), + component_name: ("rerun.blueprint.components.ForceStrength").into(), + }), + }), + (self + .position .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), + .map(|comp| (comp as &dyn ComponentBatch))) + .map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), + archetype_field_name: Some(("position").into()), + component_name: ("rerun.components.Position2D").into(), + }), + }), ] .into_iter() .flatten() @@ -228,3 +273,19 @@ impl ForcePosition { self } } + +impl ::re_types_core::SizeBytes for ForcePosition { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.enabled.heap_size_bytes() + + self.strength.heap_size_bytes() + + self.position.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + >::is_pod() + && >::is_pod() + && >::is_pod() + } +} diff --git a/crates/store/re_types/src/blueprint/components/enabled.rs b/crates/store/re_types/src/blueprint/components/enabled.rs index e762ed65d1e3..542ac4dfc1ae 100644 --- a/crates/store/re_types/src/blueprint/components/enabled.rs +++ b/crates/store/re_types/src/blueprint/components/enabled.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Component**: Whether a procedure is enabled. @@ -23,15 +23,43 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; #[repr(transparent)] pub struct Enabled(pub crate::datatypes::Bool); -impl ::re_types_core::SizeBytes for Enabled { +impl ::re_types_core::Component for Enabled { #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() + fn descriptor() -> ComponentDescriptor { + ComponentDescriptor::new("rerun.blueprint.components.Enabled") } +} +::re_types_core::macros::impl_into_cow!(Enabled); + +impl ::re_types_core::Loggable for Enabled { #[inline] - fn is_pod() -> bool { - ::is_pod() + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::datatypes::Bool::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::datatypes::Bool::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::datatypes::Bool::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) } } @@ -64,42 +92,14 @@ impl std::ops::DerefMut for Enabled { } } -::re_types_core::macros::impl_into_cow!(Enabled); - -impl ::re_types_core::Loggable for Enabled { +impl ::re_types_core::SizeBytes for Enabled { #[inline] - fn arrow_datatype() -> arrow::datatypes::DataType { - crate::datatypes::Bool::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult - where - Self: Clone + 'a, - { - crate::datatypes::Bool::to_arrow_opt(data.into_iter().map(|datum| { - datum.map(|datum| match datum.into() { - ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), - ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), - }) - })) - } - - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::datatypes::Bool::from_arrow2_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() } -} -impl ::re_types_core::Component for Enabled { #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.Enabled".into() + fn is_pod() -> bool { + ::is_pod() } } diff --git a/crates/store/re_types/src/blueprint/components/force_distance.rs b/crates/store/re_types/src/blueprint/components/force_distance.rs index da755bae96f6..8a70ffc068f7 100644 --- a/crates/store/re_types/src/blueprint/components/force_distance.rs +++ b/crates/store/re_types/src/blueprint/components/force_distance.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Component**: The target distance between two nodes. @@ -25,44 +25,10 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; #[repr(transparent)] pub struct ForceDistance(pub crate::datatypes::Float64); -impl ::re_types_core::SizeBytes for ForceDistance { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForceDistance { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForceDistance { - #[inline] - fn borrow(&self) -> &crate::datatypes::Float64 { - &self.0 - } -} - -impl std::ops::Deref for ForceDistance { - type Target = crate::datatypes::Float64; - - #[inline] - fn deref(&self) -> &crate::datatypes::Float64 { - &self.0 - } -} - -impl std::ops::DerefMut for ForceDistance { +impl ::re_types_core::Component for ForceDistance { #[inline] - fn deref_mut(&mut self) -> &mut crate::datatypes::Float64 { - &mut self.0 + fn descriptor() -> ComponentDescriptor { + ComponentDescriptor::new("rerun.blueprint.components.ForceDistance") } } @@ -108,9 +74,43 @@ impl ::re_types_core::Loggable for ForceDistance { } } -impl ::re_types_core::Component for ForceDistance { +impl> From for ForceDistance { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceDistance { + #[inline] + fn borrow(&self) -> &crate::datatypes::Float64 { + &self.0 + } +} + +impl std::ops::Deref for ForceDistance { + type Target = crate::datatypes::Float64; + + #[inline] + fn deref(&self) -> &crate::datatypes::Float64 { + &self.0 + } +} + +impl std::ops::DerefMut for ForceDistance { #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForceDistance".into() + fn deref_mut(&mut self) -> &mut crate::datatypes::Float64 { + &mut self.0 + } +} + +impl ::re_types_core::SizeBytes for ForceDistance { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() } } diff --git a/crates/store/re_types/src/blueprint/components/force_iterations.rs b/crates/store/re_types/src/blueprint/components/force_iterations.rs index 97b8bdc40653..61e4215364d5 100644 --- a/crates/store/re_types/src/blueprint/components/force_iterations.rs +++ b/crates/store/re_types/src/blueprint/components/force_iterations.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Component**: The target distance between two nodes. @@ -25,44 +25,10 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; #[repr(transparent)] pub struct ForceIterations(pub crate::datatypes::UInt64); -impl ::re_types_core::SizeBytes for ForceIterations { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForceIterations { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForceIterations { - #[inline] - fn borrow(&self) -> &crate::datatypes::UInt64 { - &self.0 - } -} - -impl std::ops::Deref for ForceIterations { - type Target = crate::datatypes::UInt64; - - #[inline] - fn deref(&self) -> &crate::datatypes::UInt64 { - &self.0 - } -} - -impl std::ops::DerefMut for ForceIterations { +impl ::re_types_core::Component for ForceIterations { #[inline] - fn deref_mut(&mut self) -> &mut crate::datatypes::UInt64 { - &mut self.0 + fn descriptor() -> ComponentDescriptor { + ComponentDescriptor::new("rerun.blueprint.components.ForceIterations") } } @@ -107,9 +73,43 @@ impl ::re_types_core::Loggable for ForceIterations { } } -impl ::re_types_core::Component for ForceIterations { +impl> From for ForceIterations { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceIterations { + #[inline] + fn borrow(&self) -> &crate::datatypes::UInt64 { + &self.0 + } +} + +impl std::ops::Deref for ForceIterations { + type Target = crate::datatypes::UInt64; + + #[inline] + fn deref(&self) -> &crate::datatypes::UInt64 { + &self.0 + } +} + +impl std::ops::DerefMut for ForceIterations { #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForceIterations".into() + fn deref_mut(&mut self) -> &mut crate::datatypes::UInt64 { + &mut self.0 + } +} + +impl ::re_types_core::SizeBytes for ForceIterations { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() } } diff --git a/crates/store/re_types/src/blueprint/components/force_strength.rs b/crates/store/re_types/src/blueprint/components/force_strength.rs index 0449ce3862dd..40240db74cda 100644 --- a/crates/store/re_types/src/blueprint/components/force_strength.rs +++ b/crates/store/re_types/src/blueprint/components/force_strength.rs @@ -13,9 +13,9 @@ #![allow(clippy::too_many_lines)] use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Component**: The target distance between two nodes. @@ -25,44 +25,10 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; #[repr(transparent)] pub struct ForceStrength(pub crate::datatypes::Float64); -impl ::re_types_core::SizeBytes for ForceStrength { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for ForceStrength { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for ForceStrength { - #[inline] - fn borrow(&self) -> &crate::datatypes::Float64 { - &self.0 - } -} - -impl std::ops::Deref for ForceStrength { - type Target = crate::datatypes::Float64; - - #[inline] - fn deref(&self) -> &crate::datatypes::Float64 { - &self.0 - } -} - -impl std::ops::DerefMut for ForceStrength { +impl ::re_types_core::Component for ForceStrength { #[inline] - fn deref_mut(&mut self) -> &mut crate::datatypes::Float64 { - &mut self.0 + fn descriptor() -> ComponentDescriptor { + ComponentDescriptor::new("rerun.blueprint.components.ForceStrength") } } @@ -108,9 +74,43 @@ impl ::re_types_core::Loggable for ForceStrength { } } -impl ::re_types_core::Component for ForceStrength { +impl> From for ForceStrength { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ForceStrength { + #[inline] + fn borrow(&self) -> &crate::datatypes::Float64 { + &self.0 + } +} + +impl std::ops::Deref for ForceStrength { + type Target = crate::datatypes::Float64; + + #[inline] + fn deref(&self) -> &crate::datatypes::Float64 { + &self.0 + } +} + +impl std::ops::DerefMut for ForceStrength { #[inline] - fn name() -> ComponentName { - "rerun.blueprint.components.ForceStrength".into() + fn deref_mut(&mut self) -> &mut crate::datatypes::Float64 { + &mut self.0 + } +} + +impl ::re_types_core::SizeBytes for ForceStrength { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() } } diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp index 1d73bb8365f4..a05527d07e18 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.cpp @@ -17,12 +17,26 @@ namespace rerun { cells.reserve(3); if (archetype.enabled.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + auto result = ComponentBatch::from_loggable( + archetype.enabled.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceCenter", + "enabled", + "rerun.blueprint.components.Enabled" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } if (archetype.strength.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.strength.value()); + auto result = ComponentBatch::from_loggable( + archetype.strength.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceCenter", + "strength", + "rerun.blueprint.components.ForceStrength" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp index e1d064e50f80..1fd8539d8a54 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.cpp @@ -18,17 +18,38 @@ namespace rerun { cells.reserve(4); if (archetype.enabled.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + auto result = ComponentBatch::from_loggable( + archetype.enabled.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceCollisionRadius", + "enabled", + "rerun.blueprint.components.Enabled" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } if (archetype.strength.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.strength.value()); + auto result = ComponentBatch::from_loggable( + archetype.strength.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceCollisionRadius", + "strength", + "rerun.blueprint.components.ForceStrength" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } if (archetype.iterations.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.iterations.value()); + auto result = ComponentBatch::from_loggable( + archetype.iterations.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceCollisionRadius", + "iterations", + "rerun.blueprint.components.ForceIterations" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp index dc39192e8cec..7cda317fa91b 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.cpp @@ -17,17 +17,38 @@ namespace rerun { cells.reserve(4); if (archetype.enabled.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + auto result = ComponentBatch::from_loggable( + archetype.enabled.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceLink", + "enabled", + "rerun.blueprint.components.Enabled" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } if (archetype.distance.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.distance.value()); + auto result = ComponentBatch::from_loggable( + archetype.distance.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceLink", + "distance", + "rerun.blueprint.components.ForceDistance" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } if (archetype.iterations.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.iterations.value()); + auto result = ComponentBatch::from_loggable( + archetype.iterations.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceLink", + "iterations", + "rerun.blueprint.components.ForceIterations" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp index 5cd074c55574..58a115516b29 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.cpp @@ -18,12 +18,26 @@ namespace rerun { cells.reserve(3); if (archetype.enabled.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + auto result = ComponentBatch::from_loggable( + archetype.enabled.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceManyBody", + "enabled", + "rerun.blueprint.components.Enabled" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } if (archetype.strength.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.strength.value()); + auto result = ComponentBatch::from_loggable( + archetype.strength.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForceManyBody", + "strength", + "rerun.blueprint.components.ForceStrength" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.cpp index b3adcbd0b1b2..d30542673513 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_position.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.cpp @@ -18,17 +18,38 @@ namespace rerun { cells.reserve(4); if (archetype.enabled.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.enabled.value()); + auto result = ComponentBatch::from_loggable( + archetype.enabled.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForcePosition", + "enabled", + "rerun.blueprint.components.Enabled" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } if (archetype.strength.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.strength.value()); + auto result = ComponentBatch::from_loggable( + archetype.strength.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForcePosition", + "strength", + "rerun.blueprint.components.ForceStrength" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } if (archetype.position.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.position.value()); + auto result = ComponentBatch::from_loggable( + archetype.position.value(), + ComponentDescriptor( + "rerun.blueprint.archetypes.ForcePosition", + "position", + "rerun.components.Position2D" + ) + ); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } diff --git a/rerun_cpp/src/rerun/blueprint/components/enabled.hpp b/rerun_cpp/src/rerun/blueprint/components/enabled.hpp index 54d26c9f3c6a..c80c4f640189 100644 --- a/rerun_cpp/src/rerun/blueprint/components/enabled.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/enabled.hpp @@ -3,6 +3,7 @@ #pragma once +#include "../../component_descriptor.hpp" #include "../../datatypes/bool.hpp" #include "../../result.hpp" @@ -44,7 +45,7 @@ namespace rerun { /// \private template <> struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.Enabled"; + static constexpr ComponentDescriptor Descriptor = "rerun.blueprint.components.Enabled"; /// Returns the arrow data type this type corresponds to. static const std::shared_ptr& arrow_datatype() { diff --git a/rerun_cpp/src/rerun/blueprint/components/force_distance.hpp b/rerun_cpp/src/rerun/blueprint/components/force_distance.hpp index 95a388b11ed8..05b0b79dbeb1 100644 --- a/rerun_cpp/src/rerun/blueprint/components/force_distance.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/force_distance.hpp @@ -3,6 +3,7 @@ #pragma once +#include "../../component_descriptor.hpp" #include "../../datatypes/float64.hpp" #include "../../result.hpp" @@ -48,7 +49,8 @@ namespace rerun { /// \private template <> struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForceDistance"; + static constexpr ComponentDescriptor Descriptor = + "rerun.blueprint.components.ForceDistance"; /// Returns the arrow data type this type corresponds to. static const std::shared_ptr& arrow_datatype() { diff --git a/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp b/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp index ac16c4a15be8..0468df342b49 100644 --- a/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp @@ -3,6 +3,7 @@ #pragma once +#include "../../component_descriptor.hpp" #include "../../datatypes/uint64.hpp" #include "../../result.hpp" @@ -48,7 +49,8 @@ namespace rerun { /// \private template <> struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForceIterations"; + static constexpr ComponentDescriptor Descriptor = + "rerun.blueprint.components.ForceIterations"; /// Returns the arrow data type this type corresponds to. static const std::shared_ptr& arrow_datatype() { diff --git a/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp b/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp index 87502bd24f48..ae01dbf6deb5 100644 --- a/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp @@ -3,6 +3,7 @@ #pragma once +#include "../../component_descriptor.hpp" #include "../../datatypes/float64.hpp" #include "../../result.hpp" @@ -48,7 +49,8 @@ namespace rerun { /// \private template <> struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ForceStrength"; + static constexpr ComponentDescriptor Descriptor = + "rerun.blueprint.components.ForceStrength"; /// Returns the arrow data type this type corresponds to. static const std::shared_ptr& arrow_datatype() { diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/enabled.py b/rerun_py/rerun_sdk/rerun/blueprint/components/enabled.py index 8c53284c0b57..6487469df9bb 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/enabled.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/enabled.py @@ -8,6 +8,7 @@ from ... import datatypes from ..._baseclasses import ( ComponentBatchMixin, + ComponentDescriptor, ComponentMixin, ) @@ -25,7 +26,7 @@ class Enabled(datatypes.Bool, ComponentMixin): class EnabledBatch(datatypes.BoolBatch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.Enabled" + _COMPONENT_DESCRIPTOR: ComponentDescriptor = ComponentDescriptor("rerun.blueprint.components.Enabled") # This is patched in late to avoid circular dependencies. diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_distance.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_distance.py index b8bdbe282bd5..b0bb1069b160 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_distance.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_distance.py @@ -8,6 +8,7 @@ from ... import datatypes from ..._baseclasses import ( ComponentBatchMixin, + ComponentDescriptor, ComponentMixin, ) @@ -29,7 +30,7 @@ class ForceDistance(datatypes.Float64, ComponentMixin): class ForceDistanceBatch(datatypes.Float64Batch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForceDistance" + _COMPONENT_DESCRIPTOR: ComponentDescriptor = ComponentDescriptor("rerun.blueprint.components.ForceDistance") # This is patched in late to avoid circular dependencies. diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py index ed913db34d83..145ada8cb3e7 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py @@ -8,6 +8,7 @@ from ... import datatypes from ..._baseclasses import ( ComponentBatchMixin, + ComponentDescriptor, ComponentMixin, ) @@ -29,7 +30,7 @@ class ForceIterations(datatypes.UInt64, ComponentMixin): class ForceIterationsBatch(datatypes.UInt64Batch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForceIterations" + _COMPONENT_DESCRIPTOR: ComponentDescriptor = ComponentDescriptor("rerun.blueprint.components.ForceIterations") # This is patched in late to avoid circular dependencies. diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py index 37c00331cd0d..f26121829e06 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py @@ -8,6 +8,7 @@ from ... import datatypes from ..._baseclasses import ( ComponentBatchMixin, + ComponentDescriptor, ComponentMixin, ) @@ -29,7 +30,7 @@ class ForceStrength(datatypes.Float64, ComponentMixin): class ForceStrengthBatch(datatypes.Float64Batch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ForceStrength" + _COMPONENT_DESCRIPTOR: ComponentDescriptor = ComponentDescriptor("rerun.blueprint.components.ForceStrength") # This is patched in late to avoid circular dependencies. From 098cb3cc4e18214592a81b656f736ca2af7fa6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 12:28:54 +0100 Subject: [PATCH 35/44] Cleanup --- .../re_component_ui/src/datatype_uis/mod.rs | 2 +- .../re_component_ui/src/datatype_uis/vec.rs | 109 ++++++++++++------ crates/viewer/re_component_ui/src/lib.rs | 16 +-- .../viewer/re_component_ui/src/position2d.rs | 35 ------ 4 files changed, 85 insertions(+), 77 deletions(-) delete mode 100644 crates/viewer/re_component_ui/src/position2d.rs diff --git a/crates/viewer/re_component_ui/src/datatype_uis/mod.rs b/crates/viewer/re_component_ui/src/datatype_uis/mod.rs index 9a8db3c714f9..5147a63dac32 100644 --- a/crates/viewer/re_component_ui/src/datatype_uis/mod.rs +++ b/crates/viewer/re_component_ui/src/datatype_uis/mod.rs @@ -20,6 +20,6 @@ pub use range1d::edit_view_range1d; pub use singleline_string::{ display_name_ui, display_text_ui, edit_multiline_string, edit_singleline_string, }; -pub use vec::{edit_or_view_vec3d, edit_or_view_vec3d_raw}; +pub use vec::{edit_or_view_vec2d, edit_or_view_vec3d, edit_or_view_vec3d_raw}; pub use view_id::view_view_id; pub use view_uuid::view_uuid; diff --git a/crates/viewer/re_component_ui/src/datatype_uis/vec.rs b/crates/viewer/re_component_ui/src/datatype_uis/vec.rs index 2c06dd16c505..ba9ef9b4a6f5 100644 --- a/crates/viewer/re_component_ui/src/datatype_uis/vec.rs +++ b/crates/viewer/re_component_ui/src/datatype_uis/vec.rs @@ -1,7 +1,20 @@ +use std::ops::RangeInclusive; + +use egui::NumExt as _; use re_types::datatypes; use re_viewer_context::MaybeMutRef; -use super::float_drag::edit_f32_float_raw; +pub fn edit_or_view_vec2d( + _ctx: &re_viewer_context::ViewerContext<'_>, + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, impl std::ops::DerefMut>, +) -> egui::Response { + let mut value: MaybeMutRef<'_, datatypes::Vec2D> = match value { + MaybeMutRef::Ref(value) => MaybeMutRef::Ref(value), + MaybeMutRef::MutRef(value) => MaybeMutRef::MutRef(value), + }; + edit_or_view_vec2d_raw(ui, &mut value) +} pub fn edit_or_view_vec3d( _ctx: &re_viewer_context::ViewerContext<'_>, @@ -12,50 +25,80 @@ pub fn edit_or_view_vec3d( MaybeMutRef::Ref(value) => MaybeMutRef::Ref(value), MaybeMutRef::MutRef(value) => MaybeMutRef::MutRef(value), }; - edit_or_view_vec3d_raw_immutable(ui, &mut value) + edit_or_view_vec3d_raw(ui, &mut value) } -// TODO(#6743): Since overrides are not yet taken into account, editing this value has no effect. -//MaybeMutRef::MutRef(value) => MaybeMutRef::MutRef(&mut value[i]), -fn edit_or_view_vec3d_raw_immutable( - ui: &mut egui::Ui, - value: &mut MaybeMutRef<'_, datatypes::Vec3D>, -) -> egui::Response { - edit_or_view_vector_component_immutable(ui, value, 0) - | edit_or_view_vector_component_immutable(ui, value, 1) - | edit_or_view_vector_component_immutable(ui, value, 2) +fn drag<'a>(value: &'a mut f32, range: RangeInclusive, suffix: &str) -> egui::DragValue<'a> { + let speed = (value.abs() * 0.01).at_least(0.001); + egui::DragValue::new(value) + .clamp_existing_to_range(false) + .range(range) + .speed(speed) + .suffix(suffix) } -fn edit_or_view_vector_component_immutable( +// TODO(#6743): Since overrides are not yet taken into account, editing this value has no effect. +pub fn edit_or_view_vec2d_raw( ui: &mut egui::Ui, - value: &mut MaybeMutRef<'_, datatypes::Vec3D>, - i: usize, + value: &mut MaybeMutRef<'_, datatypes::Vec2D>, ) -> egui::Response { - let mut value: MaybeMutRef<'_, f32> = match value { - MaybeMutRef::Ref(value) => MaybeMutRef::Ref(&value[i]), + let x = value.0[0]; + let y = value.0[1]; - MaybeMutRef::MutRef(value) => MaybeMutRef::Ref(&value[i]), - }; - edit_f32_float_raw(ui, &mut value, f32::MIN..=f32::MAX, "") + if let Some(value) = value.as_mut() { + let mut x_edit = x; + let mut y_edit = y; + + let response_x = ui.add(drag(&mut x_edit, f32::MIN..=f32::MAX, "")); + let response_y = ui.add(drag(&mut y_edit, f32::MIN..=f32::MAX, "")); + + let response = response_y | response_x; + + if response.changed() { + *value = datatypes::Vec2D([x_edit, y_edit]); + } + + response + } else { + ui.label(format!( + "[ {} , {} ]", + re_format::format_f32(x), + re_format::format_f32(y), + )) + } } +// TODO(#6743): Since overrides are not yet taken into account, editing this value has no effect. pub fn edit_or_view_vec3d_raw( ui: &mut egui::Ui, value: &mut MaybeMutRef<'_, datatypes::Vec3D>, ) -> egui::Response { - edit_or_view_vector_component(ui, value, 0) - | edit_or_view_vector_component(ui, value, 1) - | edit_or_view_vector_component(ui, value, 2) -} + let x = value.0[0]; + let y = value.0[1]; + let z = value.0[2]; -fn edit_or_view_vector_component( - ui: &mut egui::Ui, - value: &mut MaybeMutRef<'_, datatypes::Vec3D>, - i: usize, -) -> egui::Response { - let mut value: MaybeMutRef<'_, f32> = match value { - MaybeMutRef::Ref(value) => MaybeMutRef::Ref(&value[i]), - MaybeMutRef::MutRef(value) => MaybeMutRef::MutRef(&mut value[i]), - }; - edit_f32_float_raw(ui, &mut value, f32::MIN..=f32::MAX, "") + if let Some(value) = value.as_mut() { + let mut x_edit = x; + let mut y_edit = y; + let mut z_edit = z; + + let response_x = ui.add(drag(&mut x_edit, f32::MIN..=f32::MAX, "")); + let response_y = ui.add(drag(&mut y_edit, f32::MIN..=f32::MAX, "")); + let response_z = ui.add(drag(&mut z_edit, f32::MIN..=f32::MAX, "")); + + let response = response_y | response_x | response_z; + + if response.changed() { + *value = datatypes::Vec3D([x_edit, y_edit, z_edit]); + } + + response + } else { + ui.label(format!( + "[ {} , {}, {} ]", + re_format::format_f32(x), + re_format::format_f32(y), + re_format::format_f32(z), + )) + } } diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index a074679ccf5e..7460795c9fc5 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -15,7 +15,6 @@ mod map_provider; mod marker_shape; mod pinhole; mod plane3d; -mod position2d; mod radius; mod recording_uri; mod resolution; @@ -29,9 +28,9 @@ mod zoom_level; use datatype_uis::{ display_name_ui, display_text_ui, edit_bool, edit_f32_min_to_max_float, edit_f32_zero_to_max, - edit_f32_zero_to_one, edit_multiline_string, edit_or_view_vec3d, edit_singleline_string, - edit_ui_points, edit_view_enum, edit_view_enum_with_variant_available, edit_view_range1d, - view_uuid, view_view_id, + edit_f32_zero_to_one, edit_multiline_string, edit_or_view_vec2d, edit_or_view_vec3d, + edit_singleline_string, edit_ui_points, edit_view_enum, edit_view_enum_with_variant_available, + edit_view_range1d, view_uuid, view_view_id, }; use re_types::{ @@ -41,8 +40,8 @@ use re_types::{ components::{ AggregationPolicy, AlbedoFactor, AxisLength, Color, DepthMeter, DrawOrder, FillMode, FillRatio, GammaCorrection, GraphType, ImagePlaneDistance, MagnificationFilter, MarkerSize, - Name, Opacity, Range1D, Scale3D, ShowLabels, StrokeWidth, Text, TransformRelation, - Translation3D, ValueRange, + Name, Opacity, Position2D, Range1D, Scale3D, ShowLabels, StrokeWidth, Text, + TransformRelation, Translation3D, ValueRange, }, Component as _, }; @@ -115,6 +114,9 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view::(edit_view_enum); registry.add_singleline_edit_or_view::(edit_view_enum); + // Vec2 components: + registry.add_singleline_edit_or_view::(edit_or_view_vec2d); + // Vec3 components: registry.add_singleline_edit_or_view::(edit_or_view_vec3d); registry.add_singleline_edit_or_view::(edit_or_view_vec3d); @@ -140,8 +142,6 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_multiline_edit_or_view(visual_bounds2d::multiline_edit_visual_bounds2d); registry.add_singleline_edit_or_view(visual_bounds2d::singleline_edit_visual_bounds2d); - registry.add_singleline_edit_or_view(position2d::singleline_edit_position2d); - registry.add_multiline_edit_or_view(transforms::multiline_view_transform_mat3x3); registry.add_singleline_edit_or_view(transforms::singleline_view_transform_mat3x3); diff --git a/crates/viewer/re_component_ui/src/position2d.rs b/crates/viewer/re_component_ui/src/position2d.rs deleted file mode 100644 index 0c002edda2c0..000000000000 --- a/crates/viewer/re_component_ui/src/position2d.rs +++ /dev/null @@ -1,35 +0,0 @@ -use re_types::components::Position2D; -use re_viewer_context::{MaybeMutRef, ViewerContext}; - -pub fn singleline_edit_position2d( - _ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - value: &mut MaybeMutRef<'_, Position2D>, -) -> egui::Response { - let x = value.0[0]; - let y = value.0[1]; - - if let Some(value) = value.as_mut() { - let mut x_edit = x; - let mut y_edit = y; - - ui.label("["); - let response_x = ui.add(egui::DragValue::new(&mut x_edit)); - ui.label(","); - let response_y = ui.add(egui::DragValue::new(&mut y_edit)); - ui.label("]"); - let response = response_y | response_x; - - if response.changed() { - *value = Position2D([x_edit, y_edit].into()); - } - - response - } else { - ui.label(format!( - "[ {} , {} ]", - re_format::format_f32(x), - re_format::format_f32(y) - )) - } -} From 5651f59a67fe015ff87b465f074103e7e5428a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 13:11:27 +0100 Subject: [PATCH 36/44] Add `ForceIterations` [skip ci] --- .../src/datatype_uis/int_drag.rs | 51 +++++++++++++++++++ .../re_component_ui/src/datatype_uis/mod.rs | 2 + crates/viewer/re_component_ui/src/lib.rs | 14 ++--- .../viewer/re_component_ui/src/position2d.rs | 35 ------------- 4 files changed, 61 insertions(+), 41 deletions(-) create mode 100644 crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs delete mode 100644 crates/viewer/re_component_ui/src/position2d.rs diff --git a/crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs b/crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs new file mode 100644 index 000000000000..620cd3091cd3 --- /dev/null +++ b/crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs @@ -0,0 +1,51 @@ +use std::ops::RangeInclusive; + +use egui::NumExt as _; +use re_types_core::datatypes; +use re_viewer_context::MaybeMutRef; + +/// Generic editor for a [`re_types::datatypes::UInt64`] values wihtin a given range. +pub fn edit_u64_range( + _ctx: &re_viewer_context::ViewerContext<'_>, + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, impl std::ops::DerefMut>, + range: RangeInclusive, +) -> egui::Response { + let mut value: MaybeMutRef<'_, u64> = match value { + MaybeMutRef::Ref(value) => MaybeMutRef::Ref(value), + MaybeMutRef::MutRef(value) => MaybeMutRef::MutRef(&mut value.deref_mut().0), + }; + edit_u64_raw(ui, &mut value, range, "") +} + +/// Non monomorphized implementation for u64 editing. +pub fn edit_u64_raw( + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, u64>, + range: RangeInclusive, + suffix: &str, +) -> egui::Response { + let speed = (**value as f64 * 0.01).at_least(0.001); + edit_u64_raw_with_speed_impl(ui, value, range, speed, suffix) +} + +/// Non monomorphized implementation for u64 editing with a given speed. +pub fn edit_u64_raw_with_speed_impl( + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, u64>, + range: RangeInclusive, + speed: f64, + suffix: &str, +) -> egui::Response { + if let Some(value) = value.as_mut() { + ui.add( + egui::DragValue::new(value) + .clamp_existing_to_range(false) + .range(range) + .speed(speed) + .suffix(suffix), + ) + } else { + ui.label(format!("{}{}", re_format::format_uint(**value), suffix)) + } +} diff --git a/crates/viewer/re_component_ui/src/datatype_uis/mod.rs b/crates/viewer/re_component_ui/src/datatype_uis/mod.rs index 87dbd05d3744..9dc22e8ac240 100644 --- a/crates/viewer/re_component_ui/src/datatype_uis/mod.rs +++ b/crates/viewer/re_component_ui/src/datatype_uis/mod.rs @@ -1,6 +1,7 @@ mod bool_toggle; mod enum_combobox; mod float_drag; +mod int_drag; mod range1d; mod singleline_string; mod vec; @@ -17,6 +18,7 @@ pub use float_drag::{ edit_f64_float_raw_with_speed_impl, edit_f64_min_to_max_float, edit_f64_zero_to_max, edit_ui_points, }; +pub use int_drag::edit_u64_range; pub use range1d::edit_view_range1d; pub use singleline_string::{ display_name_ui, display_text_ui, edit_multiline_string, edit_singleline_string, diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 126a1f4c738d..acb856c78a31 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -15,7 +15,6 @@ mod map_provider; mod marker_shape; mod pinhole; mod plane3d; -mod position2d; mod radius; mod recording_uri; mod resolution; @@ -30,14 +29,14 @@ mod zoom_level; use datatype_uis::{ display_name_ui, display_text_ui, edit_bool, edit_f32_min_to_max_float, edit_f32_zero_to_max, edit_f32_zero_to_one, edit_f64_min_to_max_float, edit_f64_zero_to_max, edit_multiline_string, - edit_or_view_vec3d, edit_singleline_string, edit_ui_points, edit_view_enum, + edit_or_view_vec3d, edit_singleline_string, edit_u64_range, edit_ui_points, edit_view_enum, edit_view_enum_with_variant_available, edit_view_range1d, view_uuid, view_view_id, }; use re_types::{ blueprint::components::{ - BackgroundKind, Corner2D, Enabled, ForceDistance, ForceStrength, GridSpacing, - LockRangeDuringZoom, MapProvider, ViewFit, Visible, + BackgroundKind, Corner2D, Enabled, ForceDistance, ForceIterations, ForceStrength, + GridSpacing, LockRangeDuringZoom, MapProvider, ViewFit, Visible, }, components::{ AggregationPolicy, AlbedoFactor, AxisLength, Color, DepthMeter, DrawOrder, FillMode, @@ -87,6 +86,11 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry // float 0-1 components: registry.add_singleline_edit_or_view::(edit_f32_zero_to_one); + // integer range components: + registry.add_singleline_edit_or_view::(|ctx, ui, value| { + edit_u64_range(ctx, ui, value, 1..=5) + }); + // Bool components: registry.add_singleline_edit_or_view::(edit_bool); registry.add_singleline_edit_or_view::(edit_bool); @@ -143,8 +147,6 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_multiline_edit_or_view(visual_bounds2d::multiline_edit_visual_bounds2d); registry.add_singleline_edit_or_view(visual_bounds2d::singleline_edit_visual_bounds2d); - registry.add_singleline_edit_or_view(position2d::singleline_edit_position2d); - registry.add_multiline_edit_or_view(transforms::multiline_view_transform_mat3x3); registry.add_singleline_edit_or_view(transforms::singleline_view_transform_mat3x3); diff --git a/crates/viewer/re_component_ui/src/position2d.rs b/crates/viewer/re_component_ui/src/position2d.rs deleted file mode 100644 index 0c002edda2c0..000000000000 --- a/crates/viewer/re_component_ui/src/position2d.rs +++ /dev/null @@ -1,35 +0,0 @@ -use re_types::components::Position2D; -use re_viewer_context::{MaybeMutRef, ViewerContext}; - -pub fn singleline_edit_position2d( - _ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - value: &mut MaybeMutRef<'_, Position2D>, -) -> egui::Response { - let x = value.0[0]; - let y = value.0[1]; - - if let Some(value) = value.as_mut() { - let mut x_edit = x; - let mut y_edit = y; - - ui.label("["); - let response_x = ui.add(egui::DragValue::new(&mut x_edit)); - ui.label(","); - let response_y = ui.add(egui::DragValue::new(&mut y_edit)); - ui.label("]"); - let response = response_y | response_x; - - if response.changed() { - *value = Position2D([x_edit, y_edit].into()); - } - - response - } else { - ui.label(format!( - "[ {} , {} ]", - re_format::format_f32(x), - re_format::format_f32(y) - )) - } -} From 88249c1379a64913575628e339c28f95e875b2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 16:50:18 +0100 Subject: [PATCH 37/44] Better documentation of forces [skip ci] --- .../rerun/blueprint/archetypes/force_center.fbs | 4 +--- .../blueprint/archetypes/force_collision_radius.fbs | 2 +- .../rerun/blueprint/archetypes/force_link.fbs | 2 +- .../rerun/blueprint/archetypes/force_many_body.fbs | 6 +++--- .../rerun/blueprint/archetypes/force_position.fbs | 4 +--- .../rerun/blueprint/components/force_iterations.fbs | 6 ++---- .../rerun/blueprint/components/force_strength.fbs | 6 ++---- .../definitions/rerun/blueprint/views/graph.fbs | 10 +++++----- .../re_types/src/blueprint/archetypes/force_center.rs | 2 +- .../src/blueprint/archetypes/force_collision_radius.rs | 2 +- .../re_types/src/blueprint/archetypes/force_link.rs | 2 +- .../src/blueprint/archetypes/force_many_body.rs | 4 +++- .../src/blueprint/archetypes/force_position.rs | 2 +- .../src/blueprint/components/force_iterations.rs | 4 ++-- .../src/blueprint/components/force_strength.rs | 4 ++-- .../store/re_types/src/blueprint/views/graph_view.rs | 10 +++++----- crates/viewer/re_viewer/src/reflection/mod.rs | 4 ++-- docs/content/reference/types/views/graph_view.md | 10 +++++----- .../src/rerun/blueprint/archetypes/force_center.hpp | 2 +- .../blueprint/archetypes/force_collision_radius.hpp | 2 +- .../src/rerun/blueprint/archetypes/force_link.hpp | 2 +- .../src/rerun/blueprint/archetypes/force_many_body.hpp | 4 +++- .../src/rerun/blueprint/archetypes/force_position.hpp | 2 +- .../rerun/blueprint/components/force_iterations.hpp | 4 ++-- .../src/rerun/blueprint/components/force_strength.hpp | 4 ++-- .../rerun/blueprint/archetypes/force_center.py | 2 +- .../blueprint/archetypes/force_collision_radius.py | 2 +- .../rerun_sdk/rerun/blueprint/archetypes/force_link.py | 2 +- .../rerun/blueprint/archetypes/force_many_body.py | 6 +++++- .../rerun/blueprint/archetypes/force_position.py | 2 +- .../rerun/blueprint/components/force_iterations.py | 4 ++-- .../rerun/blueprint/components/force_strength.py | 4 ++-- rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py | 10 +++++----- 33 files changed, 68 insertions(+), 68 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs index 6dc43169fc01..c3b477bf49d0 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_center.fbs @@ -1,8 +1,6 @@ namespace rerun.blueprint.archetypes; -// TODO - -/// The link force pushes linked nodes together or apart according to a desired distance. +/// Tries to move the center of mass of the graph to the origin. struct ForceCenter ( "attr.rerun.scope": "blueprint" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs index 4f5492ec8ebd..4c2f9bd37b07 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs @@ -1,6 +1,6 @@ namespace rerun.blueprint.archetypes; -/// The link force pushes linked nodes together or apart according to a desired distance. +/// Resolves collisons between the bounding spheres, according to the radius of the nodes. struct ForceCollisionRadius ( "attr.rerun.scope": "blueprint" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs index 5864593e1791..182aa83783b9 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs @@ -1,6 +1,6 @@ namespace rerun.blueprint.archetypes; -/// The link force pushes linked nodes together or apart according to a desired distance. +/// Aims to achieve a target distance between two nodes that are connected by an edge. struct ForceLink ( "attr.rerun.scope": "blueprint" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs index 66755652741d..fc8e78e46bcd 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs @@ -1,8 +1,8 @@ namespace rerun.blueprint.archetypes; -// TODO - -/// The link force pushes linked nodes together or apart according to a desired distance. +/// A force between each pair of nodes that ressembles an electrical charge. +/// +/// If `ForceStrength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. struct ForceManyBody ( "attr.rerun.scope": "blueprint" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs index f0bc021c3a83..3288cf77e182 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs @@ -1,8 +1,6 @@ namespace rerun.blueprint.archetypes; -// TODO - -/// The link force pushes linked nodes together or apart according to a desired distance. +/// Similar to gravity, this force pulls nodes towards a specific position. struct ForcePosition ( "attr.rerun.scope": "blueprint" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs index 9f016072ca8f..f4d9384d995a 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs @@ -1,11 +1,9 @@ namespace rerun.blueprint.components; -// TODO - -/// The target distance between two nodes. +/// The number of internal iterations of a given force. /// -/// This is helpful to scale the layout, for example if long labels are involved. +/// Increasing this parameter can lead to better results at the cost of longer computation time. struct ForceIterations ( "attr.arrow.transparent", "attr.rust.derive": "Default, Copy, PartialEq, Eq", diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs index 55c5d0844732..505deda12ac7 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_strength.fbs @@ -1,11 +1,9 @@ namespace rerun.blueprint.components; -// TODO - -/// The target distance between two nodes. +/// The strength of a given force. /// -/// This is helpful to scale the layout, for example if long labels are involved. +/// Allows to assign different weights to the individual forces, prioritizing one over the other. struct ForceStrength ( "attr.arrow.transparent", "attr.rust.derive": "Default, Copy, PartialEq", diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index 312690512b0c..115fce675e8c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -12,18 +12,18 @@ table GraphView ( /// Somethings outside of these bounds may also be visible due to letterboxing. visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 1000); - /// A link force between nodes in the graph. + /// Allows to control the interaction between two nodes connecting throught an edge. force_link: rerun.blueprint.archetypes.ForceLink (order: 2000); - /// TODO + /// A force between each pair of nodes that ressembles an electrical charge. force_many_body: rerun.blueprint.archetypes.ForceManyBody (order: 3000); - /// TODO + /// Similar to gravity, this force pulls nodes towards a specific position. force_position: rerun.blueprint.archetypes.ForcePosition (order: 4000); - /// TODO + /// Resolves collisons between the bounding spheres, according to the radius of the nodes. force_collision_radius: rerun.blueprint.archetypes.ForceCollisionRadius (order: 5000); - /// TODO + /// Tries to move the center of mass of the graph to the origin. force_center: rerun.blueprint.archetypes.ForceCenter (order: 6000); } diff --git a/crates/store/re_types/src/blueprint/archetypes/force_center.rs b/crates/store/re_types/src/blueprint/archetypes/force_center.rs index 2b359bd35878..2f6be81786be 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_center.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_center.rs @@ -18,7 +18,7 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +/// **Archetype**: Tries to move the center of mass of the graph to the origin. #[derive(Clone, Debug)] pub struct ForceCenter { /// Whether the force is enabled. diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs index dd8733fdb5f9..debc09090152 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs @@ -18,7 +18,7 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +/// **Archetype**: Resolves collisons between the bounding spheres, according to the radius of the nodes. #[derive(Clone, Debug)] pub struct ForceCollisionRadius { /// Whether the force is enabled. diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs index 5d098d0dacae..79b3bab0d192 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_link.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -18,7 +18,7 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +/// **Archetype**: Aims to achieve a target distance between two nodes that are connected by an edge. #[derive(Clone, Debug)] pub struct ForceLink { /// Whether the force is enabled. diff --git a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs index 0001b9d39046..e651e2bc4f12 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs @@ -18,7 +18,9 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +/// **Archetype**: A force between each pair of nodes that ressembles an electrical charge. +/// +/// If `ForceStrength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. #[derive(Clone, Debug)] pub struct ForceManyBody { /// Whether the force is enabled. diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position.rs b/crates/store/re_types/src/blueprint/archetypes/force_position.rs index fc26dbe573ee..4f89c4052457 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_position.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_position.rs @@ -18,7 +18,7 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. +/// **Archetype**: Similar to gravity, this force pulls nodes towards a specific position. #[derive(Clone, Debug)] pub struct ForcePosition { /// Whether the force is enabled. diff --git a/crates/store/re_types/src/blueprint/components/force_iterations.rs b/crates/store/re_types/src/blueprint/components/force_iterations.rs index 61e4215364d5..c4b356b2f7f8 100644 --- a/crates/store/re_types/src/blueprint/components/force_iterations.rs +++ b/crates/store/re_types/src/blueprint/components/force_iterations.rs @@ -18,9 +18,9 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Component**: The target distance between two nodes. +/// **Component**: The number of internal iterations of a given force. /// -/// This is helpful to scale the layout, for example if long labels are involved. +/// Increasing this parameter can lead to better results at the cost of longer computation time. #[derive(Clone, Debug, Default, Copy, PartialEq, Eq)] #[repr(transparent)] pub struct ForceIterations(pub crate::datatypes::UInt64); diff --git a/crates/store/re_types/src/blueprint/components/force_strength.rs b/crates/store/re_types/src/blueprint/components/force_strength.rs index 40240db74cda..d1efe60bbb4f 100644 --- a/crates/store/re_types/src/blueprint/components/force_strength.rs +++ b/crates/store/re_types/src/blueprint/components/force_strength.rs @@ -18,9 +18,9 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Component**: The target distance between two nodes. +/// **Component**: The strength of a given force. /// -/// This is helpful to scale the layout, for example if long labels are involved. +/// Allows to assign different weights to the individual forces, prioritizing one over the other. #[derive(Clone, Debug, Default, Copy, PartialEq)] #[repr(transparent)] pub struct ForceStrength(pub crate::datatypes::Float64); diff --git a/crates/store/re_types/src/blueprint/views/graph_view.rs b/crates/store/re_types/src/blueprint/views/graph_view.rs index caf30d1d0627..df6135e684ce 100644 --- a/crates/store/re_types/src/blueprint/views/graph_view.rs +++ b/crates/store/re_types/src/blueprint/views/graph_view.rs @@ -26,19 +26,19 @@ pub struct GraphView { /// Somethings outside of these bounds may also be visible due to letterboxing. pub visual_bounds: crate::blueprint::archetypes::VisualBounds2D, - /// A link force between nodes in the graph. + /// Allows to control the interaction between two nodes connecting throught an edge. pub force_link: crate::blueprint::archetypes::ForceLink, - /// TODO + /// A force between each pair of nodes that ressembles an electrical charge. pub force_many_body: crate::blueprint::archetypes::ForceManyBody, - /// TODO + /// Similar to gravity, this force pulls nodes towards a specific position. pub force_position: crate::blueprint::archetypes::ForcePosition, - /// TODO + /// Resolves collisons between the bounding spheres, according to the radius of the nodes. pub force_collision_radius: crate::blueprint::archetypes::ForceCollisionRadius, - /// TODO + /// Tries to move the center of mass of the graph to the origin. pub force_center: crate::blueprint::archetypes::ForceCenter, } diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 754bcbe6206c..0c5dbe5ba5fa 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -143,7 +143,7 @@ fn generate_component_reflection() -> Result::name(), ComponentReflection { - docstring_md: "The target distance between two nodes.\n\nThis is helpful to scale the layout, for example if long labels are involved.", + docstring_md: "The number of internal iterations of a given force.\n\nIncreasing this parameter can lead to better results at the cost of longer computation time.", custom_placeholder: Some(ForceIterations::default().to_arrow2()?), datatype: ForceIterations::arrow2_datatype(), }, @@ -151,7 +151,7 @@ fn generate_component_reflection() -> Result::name(), ComponentReflection { - docstring_md: "The target distance between two nodes.\n\nThis is helpful to scale the layout, for example if long labels are involved.", + docstring_md: "The strength of a given force.\n\nAllows to assign different weights to the individual forces, prioritizing one over the other.", custom_placeholder: Some(ForceStrength::default().to_arrow2()?), datatype: ForceStrength::arrow2_datatype(), }, diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 0d78273058c9..121e84ad496a 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -12,30 +12,30 @@ Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. ### `force_link` -A link force between nodes in the graph. +Allows to control the interaction between two nodes connecting throught an edge. * `enabled`: Whether the force is enabled. * `distance`: The target distance between two nodes. * `iterations`: The number of iterations to run the force. ### `force_many_body` -TODO +A force between each pair of nodes that ressembles an electrical charge. * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. ### `force_position` -TODO +Similar to gravity, this force pulls nodes towards a specific position. * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. * `position`: The position where the nodes should bepulled towards. ### `force_collision_radius` -TODO +Resolves collisons between the bounding spheres, according to the radius of the nodes. * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. * `iterations`: The number of iterations to run the force. ### `force_center` -TODO +Tries to move the center of mass of the graph to the origin. * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp index 7e843a7f8709..8c3854765b91 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_center.hpp @@ -17,7 +17,7 @@ #include namespace rerun::blueprint::archetypes { - /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + /// **Archetype**: Tries to move the center of mass of the graph to the origin. struct ForceCenter { /// Whether the force is enabled. std::optional enabled; diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp index d6789e2e84b0..adedb7dcdeb7 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp @@ -18,7 +18,7 @@ #include namespace rerun::blueprint::archetypes { - /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + /// **Archetype**: Resolves collisons between the bounding spheres, according to the radius of the nodes. struct ForceCollisionRadius { /// Whether the force is enabled. std::optional enabled; diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp index ffb1aa663310..0f4271ee9161 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp @@ -18,7 +18,7 @@ #include namespace rerun::blueprint::archetypes { - /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + /// **Archetype**: Aims to achieve a target distance between two nodes that are connected by an edge. struct ForceLink { /// Whether the force is enabled. std::optional enabled; diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp index 4c164a8f734a..edd0650918d5 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp @@ -17,7 +17,9 @@ #include namespace rerun::blueprint::archetypes { - /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + /// **Archetype**: A force between each pair of nodes that ressembles an electrical charge. + /// + /// If `ForceStrength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. struct ForceManyBody { /// Whether the force is enabled. std::optional enabled; diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp index 08e345475daa..92a6a178ba6c 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp @@ -18,7 +18,7 @@ #include namespace rerun::blueprint::archetypes { - /// **Archetype**: The link force pushes linked nodes together or apart according to a desired distance. + /// **Archetype**: Similar to gravity, this force pulls nodes towards a specific position. struct ForcePosition { /// Whether the force is enabled. std::optional enabled; diff --git a/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp b/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp index 0468df342b49..90f5374db9c8 100644 --- a/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp @@ -11,9 +11,9 @@ #include namespace rerun::blueprint::components { - /// **Component**: The target distance between two nodes. + /// **Component**: The number of internal iterations of a given force. /// - /// This is helpful to scale the layout, for example if long labels are involved. + /// Increasing this parameter can lead to better results at the cost of longer computation time. struct ForceIterations { rerun::datatypes::UInt64 distance; diff --git a/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp b/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp index ae01dbf6deb5..ebb49b44191b 100644 --- a/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/force_strength.hpp @@ -11,9 +11,9 @@ #include namespace rerun::blueprint::components { - /// **Component**: The target distance between two nodes. + /// **Component**: The strength of a given force. /// - /// This is helpful to scale the layout, for example if long labels are involved. + /// Allows to assign different weights to the individual forces, prioritizing one over the other. struct ForceStrength { rerun::datatypes::Float64 distance; diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py index 059e14d57577..7d026c887d70 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_center.py @@ -21,7 +21,7 @@ @define(str=False, repr=False, init=False) class ForceCenter(Archetype): - """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + """**Archetype**: Tries to move the center of mass of the graph to the origin.""" def __init__( self: Any, *, enabled: datatypes.BoolLike | None = None, strength: datatypes.Float64Like | None = None diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py index daf3404c2487..afb961f63ea3 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py @@ -21,7 +21,7 @@ @define(str=False, repr=False, init=False) class ForceCollisionRadius(Archetype): - """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + """**Archetype**: Resolves collisons between the bounding spheres, according to the radius of the nodes.""" def __init__( self: Any, diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py index 3023fb6f4fb9..b1b760720f84 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py @@ -21,7 +21,7 @@ @define(str=False, repr=False, init=False) class ForceLink(Archetype): - """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + """**Archetype**: Aims to achieve a target distance between two nodes that are connected by an edge.""" def __init__( self: Any, diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py index 9f414e00e48a..6e19a7a28a06 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py @@ -21,7 +21,11 @@ @define(str=False, repr=False, init=False) class ForceManyBody(Archetype): - """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + """ + **Archetype**: A force between each pair of nodes that ressembles an electrical charge. + + If `ForceStrength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. + """ def __init__( self: Any, *, enabled: datatypes.BoolLike | None = None, strength: datatypes.Float64Like | None = None diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py index 72499b3a9e83..df5bb39362c3 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py @@ -21,7 +21,7 @@ @define(str=False, repr=False, init=False) class ForcePosition(Archetype): - """**Archetype**: The link force pushes linked nodes together or apart according to a desired distance.""" + """**Archetype**: Similar to gravity, this force pulls nodes towards a specific position.""" def __init__( self: Any, diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py index 145ada8cb3e7..cf772d1333db 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py @@ -17,9 +17,9 @@ class ForceIterations(datatypes.UInt64, ComponentMixin): """ - **Component**: The target distance between two nodes. + **Component**: The number of internal iterations of a given force. - This is helpful to scale the layout, for example if long labels are involved. + Increasing this parameter can lead to better results at the cost of longer computation time. """ _BATCH_TYPE = None diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py index f26121829e06..8a475f2d7bb4 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_strength.py @@ -17,9 +17,9 @@ class ForceStrength(datatypes.Float64, ComponentMixin): """ - **Component**: The target distance between two nodes. + **Component**: The strength of a given force. - This is helpful to scale the layout, for example if long labels are involved. + Allows to assign different weights to the individual forces, prioritizing one over the other. """ _BATCH_TYPE = None diff --git a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py index 3091ce8209b6..bdf01ce29f63 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py @@ -110,15 +110,15 @@ def __init__( Somethings outside of these bounds may also be visible due to letterboxing. force_link: - A link force between nodes in the graph. + Allows to control the interaction between two nodes connecting throught an edge. force_many_body: - TODO + A force between each pair of nodes that ressembles an electrical charge. force_position: - TODO + Similar to gravity, this force pulls nodes towards a specific position. force_collision_radius: - TODO + Resolves collisons between the bounding spheres, according to the radius of the nodes. force_center: - TODO + Tries to move the center of mass of the graph to the origin. """ From 319e6972d8efd8618dd9c8e5a0c52ad74392370e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 9 Dec 2024 17:05:23 +0100 Subject: [PATCH 38/44] Not needed anymore [skip ci] --- .../re_types_builder/src/codegen/rust/api.rs | 17 ----------------- .../archetypes/force_collision_radius.fbs | 2 +- .../re_space_view_graph/src/layout/provider.rs | 2 -- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/crates/build/re_types_builder/src/codegen/rust/api.rs b/crates/build/re_types_builder/src/codegen/rust/api.rs index 8e37fdc43865..3125197d0889 100644 --- a/crates/build/re_types_builder/src/codegen/rust/api.rs +++ b/crates/build/re_types_builder/src/codegen/rust/api.rs @@ -1042,23 +1042,6 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream { assert_eq!(kind, &ObjectKind::Archetype); - // sanity check that each field has one of the rerun component type attributes - for field in &obj.fields { - assert!( - [ - ATTR_RERUN_COMPONENT_OPTIONAL, - ATTR_RERUN_COMPONENT_RECOMMENDED, - ATTR_RERUN_COMPONENT_REQUIRED - ] - .iter() - .any(|attr| field.try_get_attr::(attr).is_some()), - "archetype `{}` must add one of the \"attr.rerun.component_{{required|recommended|\ - optional}}\" attributes to field `{}`", - obj.name, - field.name - ); - } - let display_name = re_case::to_human_case(name); let archetype_name = &obj.fqname; let name = format_ident!("{name}"); diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs index 4c2f9bd37b07..a1915795e4bc 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs @@ -1,6 +1,6 @@ namespace rerun.blueprint.archetypes; -/// Resolves collisons between the bounding spheres, according to the radius of the nodes. +/// Resolves collisions between the bounding spheres, according to the radius of the nodes. struct ForceCollisionRadius ( "attr.rerun.scope": "blueprint" ) { diff --git a/crates/viewer/re_space_view_graph/src/layout/provider.rs b/crates/viewer/re_space_view_graph/src/layout/provider.rs index 2fb7f9ed1557..72c6b7a31f17 100644 --- a/crates/viewer/re_space_view_graph/src/layout/provider.rs +++ b/crates/viewer/re_space_view_graph/src/layout/provider.rs @@ -153,9 +153,7 @@ impl ForceLayoutProvider { .collect::>(); let edges = considered_edges(&request); - // TODO(grtlr): Currently we guesstimate good forces. Eventually these should be exposed as blueprints. let simulation = fj::SimulationBuilder::default().build(nodes); - let simulation = update_simulation(simulation, params, edges, radii); Self { From 93ed4e685204a061819aed7faadb152882d5e3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 10 Dec 2024 11:14:46 +0100 Subject: [PATCH 39/44] Address feedback --- .../archetypes/force_collision_radius.fbs | 4 +++- .../rerun/blueprint/archetypes/force_link.fbs | 4 +++- .../blueprint/archetypes/force_many_body.fbs | 2 ++ .../rerun/blueprint/archetypes/force_position.fbs | 2 +- .../rerun/blueprint/components/enabled.fbs | 2 +- .../blueprint/components/force_iterations.fbs | 2 +- .../archetypes/force_collision_radius.rs | 10 +++++++--- .../src/blueprint/archetypes/force_link.rs | 8 ++++++-- .../src/blueprint/archetypes/force_many_body.rs | 4 ++++ .../src/blueprint/archetypes/force_position.rs | 4 ++-- .../re_types/src/blueprint/components/enabled.rs | 2 +- .../src/blueprint/components/enabled_ext.rs | 9 --------- .../src/blueprint/components/force_iterations.rs | 2 +- .../re_space_view_graph/src/ui/selection.rs | 4 ++++ crates/viewer/re_viewer/src/reflection/mod.rs | 15 +++++++++------ docs/content/reference/types/views/graph_view.md | 6 +++--- .../archetypes/force_collision_radius.hpp | 10 +++++++--- .../src/rerun/blueprint/archetypes/force_link.hpp | 8 ++++++-- .../blueprint/archetypes/force_many_body.hpp | 4 ++++ .../rerun/blueprint/archetypes/force_position.hpp | 4 ++-- .../blueprint/components/force_iterations.hpp | 2 +- .../archetypes/force_collision_radius.py | 10 +++++++--- .../rerun/blueprint/archetypes/force_link.py | 8 ++++++-- .../rerun/blueprint/archetypes/force_many_body.py | 4 ++++ .../rerun/blueprint/archetypes/force_position.py | 4 ++-- .../blueprint/components/force_iterations.py | 2 +- 26 files changed, 88 insertions(+), 48 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs index a1915795e4bc..9ffcf43376ff 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_collision_radius.fbs @@ -10,6 +10,8 @@ struct ForceCollisionRadius ( /// The strength of the force. strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200); - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. iterations: rerun.blueprint.components.ForceIterations ("attr.rerun.component_optional", nullable, order: 300); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs index 182aa83783b9..fc963b757cf3 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_link.fbs @@ -10,6 +10,8 @@ struct ForceLink ( /// The target distance between two nodes. distance: rerun.blueprint.components.ForceDistance ("attr.rerun.component_optional", nullable, order: 200); - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. iterations: rerun.blueprint.components.ForceIterations ("attr.rerun.component_optional", nullable, order: 300); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs index fc8e78e46bcd..45aa32c40f46 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs @@ -10,5 +10,7 @@ struct ForceManyBody ( enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100); /// The strength of the force. + /// + /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs index 3288cf77e182..7ff9fd24d340 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_position.fbs @@ -10,6 +10,6 @@ struct ForcePosition ( /// The strength of the force. strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200); - /// The position where the nodes should bepulled towards. + /// The position where the nodes should be pulled towards. position: rerun.components.Position2D ("attr.rerun.component_optional", nullable, order: 300); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs index 5b2babd7e033..d4b9219adb9f 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/enabled.fbs @@ -7,7 +7,7 @@ struct Enabled ( "attr.arrow.transparent", "attr.rerun.scope": "blueprint", "attr.python.aliases": "bool", - "attr.rust.derive": "Copy, PartialEq, Eq, PartialOrd, Ord", + "attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord", "attr.rust.repr": "transparent", "attr.rust.tuple_struct" ) { diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs index f4d9384d995a..6cdcca9af94c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/force_iterations.fbs @@ -1,7 +1,7 @@ namespace rerun.blueprint.components; -/// The number of internal iterations of a given force. +/// Specifies how often this force should be applied per iteration. /// /// Increasing this parameter can lead to better results at the cost of longer computation time. struct ForceIterations ( diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs index debc09090152..3b7d483fc9dd 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs @@ -18,7 +18,7 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Archetype**: Resolves collisons between the bounding spheres, according to the radius of the nodes. +/// **Archetype**: Resolves collisions between the bounding spheres, according to the radius of the nodes. #[derive(Clone, Debug)] pub struct ForceCollisionRadius { /// Whether the force is enabled. @@ -27,7 +27,9 @@ pub struct ForceCollisionRadius { /// The strength of the force. pub strength: Option, - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. pub iterations: Option, } @@ -268,7 +270,9 @@ impl ForceCollisionRadius { self } - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. #[inline] pub fn with_iterations( mut self, diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs index 79b3bab0d192..d418f7aa2a82 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_link.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -27,7 +27,9 @@ pub struct ForceLink { /// The target distance between two nodes. pub distance: Option, - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. pub iterations: Option, } @@ -267,7 +269,9 @@ impl ForceLink { self } - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. #[inline] pub fn with_iterations( mut self, diff --git a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs index e651e2bc4f12..684a7314365e 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs @@ -27,6 +27,8 @@ pub struct ForceManyBody { pub enabled: Option, /// The strength of the force. + /// + /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. pub strength: Option, } @@ -220,6 +222,8 @@ impl ForceManyBody { } /// The strength of the force. + /// + /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. #[inline] pub fn with_strength( mut self, diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position.rs b/crates/store/re_types/src/blueprint/archetypes/force_position.rs index 4f89c4052457..f0f904ee457a 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_position.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_position.rs @@ -27,7 +27,7 @@ pub struct ForcePosition { /// The strength of the force. pub strength: Option, - /// The position where the nodes should bepulled towards. + /// The position where the nodes should be pulled towards. pub position: Option, } @@ -266,7 +266,7 @@ impl ForcePosition { self } - /// The position where the nodes should bepulled towards. + /// The position where the nodes should be pulled towards. #[inline] pub fn with_position(mut self, position: impl Into) -> Self { self.position = Some(position.into()); diff --git a/crates/store/re_types/src/blueprint/components/enabled.rs b/crates/store/re_types/src/blueprint/components/enabled.rs index 542ac4dfc1ae..dc258abb03d2 100644 --- a/crates/store/re_types/src/blueprint/components/enabled.rs +++ b/crates/store/re_types/src/blueprint/components/enabled.rs @@ -19,7 +19,7 @@ use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Component**: Whether a procedure is enabled. -#[derive(Clone, Debug, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Copy, Default, PartialEq, Eq, PartialOrd, Ord)] #[repr(transparent)] pub struct Enabled(pub crate::datatypes::Bool); diff --git a/crates/store/re_types/src/blueprint/components/enabled_ext.rs b/crates/store/re_types/src/blueprint/components/enabled_ext.rs index 62e72b4e082b..2865f1ca4b5b 100644 --- a/crates/store/re_types/src/blueprint/components/enabled_ext.rs +++ b/crates/store/re_types/src/blueprint/components/enabled_ext.rs @@ -1,14 +1,5 @@ -use re_types_core::datatypes::Bool; - use super::Enabled; -impl Default for Enabled { - #[inline] - fn default() -> Self { - Self(Bool(false)) - } -} - impl From for bool { #[inline] fn from(v: Enabled) -> Self { diff --git a/crates/store/re_types/src/blueprint/components/force_iterations.rs b/crates/store/re_types/src/blueprint/components/force_iterations.rs index c4b356b2f7f8..d91a043a615f 100644 --- a/crates/store/re_types/src/blueprint/components/force_iterations.rs +++ b/crates/store/re_types/src/blueprint/components/force_iterations.rs @@ -18,7 +18,7 @@ use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Component**: The number of internal iterations of a given force. +/// **Component**: Specifies how often this force should be applied per iteration. /// /// Increasing this parameter can lead to better results at the cost of longer computation time. #[derive(Clone, Debug, Default, Copy, PartialEq, Eq)] diff --git a/crates/viewer/re_space_view_graph/src/ui/selection.rs b/crates/viewer/re_space_view_graph/src/ui/selection.rs index a010e8f971f3..3b67eeef116f 100644 --- a/crates/viewer/re_space_view_graph/src/ui/selection.rs +++ b/crates/viewer/re_space_view_graph/src/ui/selection.rs @@ -5,6 +5,10 @@ use re_types::{ use re_viewer_context::{ComponentFallbackProvider, SpaceViewId, SpaceViewState, ViewerContext}; use re_viewport_blueprint::ViewProperty; +/// This function is similar to [`view_property_component_ui`], but it always +/// picks the [`Enabled`] component for the single-line edit UI. +/// Also, it will always show the single-line edit UI (and not only if there is +/// a single property per archetype). pub fn view_property_force_ui( ctx: &ViewerContext<'_>, ui: &mut egui::Ui, diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index c88f258fe5c7..9b4080ac6a40 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -143,7 +143,7 @@ fn generate_component_reflection() -> Result::name(), ComponentReflection { - docstring_md: "The number of internal iterations of a given force.\n\nIncreasing this parameter can lead to better results at the cost of longer computation time.", + docstring_md: "Specifies how often this force should be applied per iteration.\n\nIncreasing this parameter can lead to better results at the cost of longer computation time.", custom_placeholder: Some(ForceIterations::default().to_arrow2()?), datatype: ForceIterations::arrow2_datatype(), }, @@ -2009,7 +2009,8 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { : false, }, ArchetypeFieldReflection { component_name : "rerun.blueprint.components.ForceIterations".into(), display_name : "Iterations", docstring_md : - "The number of iterations to run the force.", is_required : false, }, + "Specifies how often this force should be applied per iteration.\n\nIncreasing this parameter can lead to better results at the cost of longer computation time.", + is_required : false, }, ], }, ), @@ -2028,7 +2029,8 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { is_required : false, }, ArchetypeFieldReflection { component_name : "rerun.blueprint.components.ForceIterations".into(), display_name : "Iterations", docstring_md : - "The number of iterations to run the force.", is_required : false, }, + "Specifies how often this force should be applied per iteration.\n\nIncreasing this parameter can lead to better results at the cost of longer computation time.", + is_required : false, }, ], }, ), @@ -2043,8 +2045,9 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { "Enabled", docstring_md : "Whether the force is enabled.", is_required : false, }, ArchetypeFieldReflection { component_name : "rerun.blueprint.components.ForceStrength".into(), display_name : - "Strength", docstring_md : "The strength of the force.", is_required - : false, }, + "Strength", docstring_md : + "The strength of the force.\n\nIf `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together.", + is_required : false, }, ], }, ), @@ -2063,7 +2066,7 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { : false, }, ArchetypeFieldReflection { component_name : "rerun.components.Position2D".into(), display_name : "Position", docstring_md : - "The position where the nodes should bepulled towards.", is_required + "The position where the nodes should be pulled towards.", is_required : false, }, ], }, diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 121e84ad496a..034bef023bd9 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -16,7 +16,7 @@ Allows to control the interaction between two nodes connecting throught an edge. * `enabled`: Whether the force is enabled. * `distance`: The target distance between two nodes. -* `iterations`: The number of iterations to run the force. +* `iterations`: Specifies how often this force should be applied per iteration. ### `force_many_body` A force between each pair of nodes that ressembles an electrical charge. @@ -27,13 +27,13 @@ Similar to gravity, this force pulls nodes towards a specific position. * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. -* `position`: The position where the nodes should bepulled towards. +* `position`: The position where the nodes should be pulled towards. ### `force_collision_radius` Resolves collisons between the bounding spheres, according to the radius of the nodes. * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. -* `iterations`: The number of iterations to run the force. +* `iterations`: Specifies how often this force should be applied per iteration. ### `force_center` Tries to move the center of mass of the graph to the origin. diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp index adedb7dcdeb7..5b8ff3d1d511 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_collision_radius.hpp @@ -18,7 +18,7 @@ #include namespace rerun::blueprint::archetypes { - /// **Archetype**: Resolves collisons between the bounding spheres, according to the radius of the nodes. + /// **Archetype**: Resolves collisions between the bounding spheres, according to the radius of the nodes. struct ForceCollisionRadius { /// Whether the force is enabled. std::optional enabled; @@ -26,7 +26,9 @@ namespace rerun::blueprint::archetypes { /// The strength of the force. std::optional strength; - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. std::optional iterations; public: @@ -55,7 +57,9 @@ namespace rerun::blueprint::archetypes { RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) } - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. ForceCollisionRadius with_iterations( rerun::blueprint::components::ForceIterations _iterations ) && { diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp index 0f4271ee9161..0d88538bc59b 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_link.hpp @@ -26,7 +26,9 @@ namespace rerun::blueprint::archetypes { /// The target distance between two nodes. std::optional distance; - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. std::optional iterations; public: @@ -54,7 +56,9 @@ namespace rerun::blueprint::archetypes { RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) } - /// The number of iterations to run the force. + /// Specifies how often this force should be applied per iteration. + /// + /// Increasing this parameter can lead to better results at the cost of longer computation time. ForceLink with_iterations(rerun::blueprint::components::ForceIterations _iterations) && { iterations = std::move(_iterations); // See: https://github.com/rerun-io/rerun/issues/4027 diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp index edd0650918d5..e97c96239c9a 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp @@ -25,6 +25,8 @@ namespace rerun::blueprint::archetypes { std::optional enabled; /// The strength of the force. + /// + /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. std::optional strength; public: @@ -46,6 +48,8 @@ namespace rerun::blueprint::archetypes { } /// The strength of the force. + /// + /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. ForceManyBody with_strength(rerun::blueprint::components::ForceStrength _strength) && { strength = std::move(_strength); // See: https://github.com/rerun-io/rerun/issues/4027 diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp index 92a6a178ba6c..36d740ce7393 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_position.hpp @@ -26,7 +26,7 @@ namespace rerun::blueprint::archetypes { /// The strength of the force. std::optional strength; - /// The position where the nodes should bepulled towards. + /// The position where the nodes should be pulled towards. std::optional position; public: @@ -54,7 +54,7 @@ namespace rerun::blueprint::archetypes { RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) } - /// The position where the nodes should bepulled towards. + /// The position where the nodes should be pulled towards. ForcePosition with_position(rerun::components::Position2D _position) && { position = std::move(_position); // See: https://github.com/rerun-io/rerun/issues/4027 diff --git a/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp b/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp index 90f5374db9c8..49f1ceef04ea 100644 --- a/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/force_iterations.hpp @@ -11,7 +11,7 @@ #include namespace rerun::blueprint::components { - /// **Component**: The number of internal iterations of a given force. + /// **Component**: Specifies how often this force should be applied per iteration. /// /// Increasing this parameter can lead to better results at the cost of longer computation time. struct ForceIterations { diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py index afb961f63ea3..80464759b93f 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_collision_radius.py @@ -21,7 +21,7 @@ @define(str=False, repr=False, init=False) class ForceCollisionRadius(Archetype): - """**Archetype**: Resolves collisons between the bounding spheres, according to the radius of the nodes.""" + """**Archetype**: Resolves collisions between the bounding spheres, according to the radius of the nodes.""" def __init__( self: Any, @@ -40,7 +40,9 @@ def __init__( strength: The strength of the force. iterations: - The number of iterations to run the force. + Specifies how often this force should be applied per iteration. + + Increasing this parameter can lead to better results at the cost of longer computation time. """ @@ -88,7 +90,9 @@ def _clear(cls) -> ForceCollisionRadius: default=None, converter=blueprint_components.ForceIterationsBatch._optional, # type: ignore[misc] ) - # The number of iterations to run the force. + # Specifies how often this force should be applied per iteration. + # + # Increasing this parameter can lead to better results at the cost of longer computation time. # # (Docstring intentionally commented out to hide this field from the docs) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py index b1b760720f84..bf24c7265d63 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_link.py @@ -40,7 +40,9 @@ def __init__( distance: The target distance between two nodes. iterations: - The number of iterations to run the force. + Specifies how often this force should be applied per iteration. + + Increasing this parameter can lead to better results at the cost of longer computation time. """ @@ -88,7 +90,9 @@ def _clear(cls) -> ForceLink: default=None, converter=blueprint_components.ForceIterationsBatch._optional, # type: ignore[misc] ) - # The number of iterations to run the force. + # Specifies how often this force should be applied per iteration. + # + # Increasing this parameter can lead to better results at the cost of longer computation time. # # (Docstring intentionally commented out to hide this field from the docs) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py index 6e19a7a28a06..615bee835fb5 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py @@ -40,6 +40,8 @@ def __init__( strength: The strength of the force. + If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. + """ # You can define your own __init__ function as a member of ForceManyBodyExt in force_many_body_ext.py @@ -78,6 +80,8 @@ def _clear(cls) -> ForceManyBody: ) # The strength of the force. # + # If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. + # # (Docstring intentionally commented out to hide this field from the docs) __str__ = Archetype.__str__ diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py index df5bb39362c3..61e63623c9c2 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_position.py @@ -40,7 +40,7 @@ def __init__( strength: The strength of the force. position: - The position where the nodes should bepulled towards. + The position where the nodes should be pulled towards. """ @@ -88,7 +88,7 @@ def _clear(cls) -> ForcePosition: default=None, converter=components.Position2DBatch._optional, # type: ignore[misc] ) - # The position where the nodes should bepulled towards. + # The position where the nodes should be pulled towards. # # (Docstring intentionally commented out to hide this field from the docs) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py b/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py index cf772d1333db..f9bf7f7a0e24 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/force_iterations.py @@ -17,7 +17,7 @@ class ForceIterations(datatypes.UInt64, ComponentMixin): """ - **Component**: The number of internal iterations of a given force. + **Component**: Specifies how often this force should be applied per iteration. Increasing this parameter can lead to better results at the cost of longer computation time. """ From a0f1a0bc44930bb0c735258d61cde38c9b00c4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 10 Dec 2024 11:24:29 +0100 Subject: [PATCH 40/44] Merge remains --- Cargo.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 094da1d30996..f41c6edc923b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5999,7 +5999,6 @@ dependencies = [ "bytemuck", "clean-path", "criterion", - "crossbeam", "document-features", "fixed", "half", From 927a0e45bd409c7df653e41cabb9e2d90df081f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 10 Dec 2024 11:28:54 +0100 Subject: [PATCH 41/44] Rerun codegen --- .../rerun/blueprint/archetypes/force_many_body.fbs | 2 +- .../store/re_types/src/blueprint/archetypes/force_center.rs | 4 ++-- .../src/blueprint/archetypes/force_collision_radius.rs | 4 ++-- .../store/re_types/src/blueprint/archetypes/force_link.rs | 4 ++-- .../re_types/src/blueprint/archetypes/force_many_body.rs | 6 +++--- .../re_types/src/blueprint/archetypes/force_position.rs | 4 ++-- docs/content/reference/types/views/graph_view.md | 6 +++--- .../src/rerun/blueprint/archetypes/force_many_body.hpp | 2 +- .../rerun_sdk/rerun/blueprint/archetypes/force_many_body.py | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs index 45aa32c40f46..edafce01c777 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/force_many_body.fbs @@ -2,7 +2,7 @@ namespace rerun.blueprint.archetypes; /// A force between each pair of nodes that ressembles an electrical charge. /// -/// If `ForceStrength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. +/// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. struct ForceManyBody ( "attr.rerun.scope": "blueprint" ) { diff --git a/crates/store/re_types/src/blueprint/archetypes/force_center.rs b/crates/store/re_types/src/blueprint/archetypes/force_center.rs index 2f6be81786be..9cb1870a5af5 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_center.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_center.rs @@ -35,7 +35,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usiz once_cell::sync::Lazy::new(|| { [ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), - component_name: "ForceCenterIndicator".into(), + component_name: "rerun.blueprint.components.ForceCenterIndicator".into(), archetype_field_name: None, }] }); @@ -61,7 +61,7 @@ static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = [ ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForceCenter".into()), - component_name: "ForceCenterIndicator".into(), + component_name: "rerun.blueprint.components.ForceCenterIndicator".into(), archetype_field_name: None, }, ComponentDescriptor { diff --git a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs index 3b7d483fc9dd..71055ab49f0f 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_collision_radius.rs @@ -40,7 +40,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usiz once_cell::sync::Lazy::new(|| { [ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), - component_name: "ForceCollisionRadiusIndicator".into(), + component_name: "rerun.blueprint.components.ForceCollisionRadiusIndicator".into(), archetype_field_name: None, }] }); @@ -71,7 +71,7 @@ static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> = [ ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForceCollisionRadius".into()), - component_name: "ForceCollisionRadiusIndicator".into(), + component_name: "rerun.blueprint.components.ForceCollisionRadiusIndicator".into(), archetype_field_name: None, }, ComponentDescriptor { diff --git a/crates/store/re_types/src/blueprint/archetypes/force_link.rs b/crates/store/re_types/src/blueprint/archetypes/force_link.rs index d418f7aa2a82..9c6fe8aa11d2 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_link.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_link.rs @@ -40,7 +40,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usiz once_cell::sync::Lazy::new(|| { [ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), - component_name: "ForceLinkIndicator".into(), + component_name: "rerun.blueprint.components.ForceLinkIndicator".into(), archetype_field_name: None, }] }); @@ -71,7 +71,7 @@ static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> = [ ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForceLink".into()), - component_name: "ForceLinkIndicator".into(), + component_name: "rerun.blueprint.components.ForceLinkIndicator".into(), archetype_field_name: None, }, ComponentDescriptor { diff --git a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs index 684a7314365e..9720ff5a4f17 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_many_body.rs @@ -20,7 +20,7 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Archetype**: A force between each pair of nodes that ressembles an electrical charge. /// -/// If `ForceStrength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. +/// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. #[derive(Clone, Debug)] pub struct ForceManyBody { /// Whether the force is enabled. @@ -39,7 +39,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usiz once_cell::sync::Lazy::new(|| { [ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), - component_name: "ForceManyBodyIndicator".into(), + component_name: "rerun.blueprint.components.ForceManyBodyIndicator".into(), archetype_field_name: None, }] }); @@ -65,7 +65,7 @@ static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = [ ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForceManyBody".into()), - component_name: "ForceManyBodyIndicator".into(), + component_name: "rerun.blueprint.components.ForceManyBodyIndicator".into(), archetype_field_name: None, }, ComponentDescriptor { diff --git a/crates/store/re_types/src/blueprint/archetypes/force_position.rs b/crates/store/re_types/src/blueprint/archetypes/force_position.rs index f0f904ee457a..e106a452c2a2 100644 --- a/crates/store/re_types/src/blueprint/archetypes/force_position.rs +++ b/crates/store/re_types/src/blueprint/archetypes/force_position.rs @@ -38,7 +38,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usiz once_cell::sync::Lazy::new(|| { [ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), - component_name: "ForcePositionIndicator".into(), + component_name: "rerun.blueprint.components.ForcePositionIndicator".into(), archetype_field_name: None, }] }); @@ -69,7 +69,7 @@ static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> = [ ComponentDescriptor { archetype_name: Some("rerun.blueprint.archetypes.ForcePosition".into()), - component_name: "ForcePositionIndicator".into(), + component_name: "rerun.blueprint.components.ForcePositionIndicator".into(), archetype_field_name: None, }, ComponentDescriptor { diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 6059c3992640..127a18c21377 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -11,6 +11,9 @@ A graph view to display time-variying, directed or undirected graph visualizatio Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. + +* `range`: Controls the visible range of a 2D view. +* `near_clip_plane`: Controls the distance to the near clip plane in 3D scene units. ### `force_link` Allows to control the interaction between two nodes connecting throught an edge. @@ -40,9 +43,6 @@ Tries to move the center of mass of the graph to the origin. * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. -* `range`: Controls the visible range of a 2D view. -* `near_clip_plane`: Controls the distance to the near clip plane in 3D scene units. - ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp index e97c96239c9a..c5267b3cf692 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/force_many_body.hpp @@ -19,7 +19,7 @@ namespace rerun::blueprint::archetypes { /// **Archetype**: A force between each pair of nodes that ressembles an electrical charge. /// - /// If `ForceStrength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. + /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. struct ForceManyBody { /// Whether the force is enabled. std::optional enabled; diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py index 615bee835fb5..4750ac834505 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/force_many_body.py @@ -24,7 +24,7 @@ class ForceManyBody(Archetype): """ **Archetype**: A force between each pair of nodes that ressembles an electrical charge. - If `ForceStrength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. + If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together. """ def __init__( From 8dfa3da288b74a742cdc493f681abd35b3f047e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 10 Dec 2024 11:38:08 +0100 Subject: [PATCH 42/44] Format --- tests/python/release_checklist/check_graph_time_layout.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/python/release_checklist/check_graph_time_layout.py b/tests/python/release_checklist/check_graph_time_layout.py index 591a5412f28d..e10bde1053a5 100644 --- a/tests/python/release_checklist/check_graph_time_layout.py +++ b/tests/python/release_checklist/check_graph_time_layout.py @@ -1,7 +1,6 @@ from __future__ import annotations # TODO(grtlr): Promote to example - import os import random from argparse import Namespace From e231cb26a870520f787d7f1cb3644ff53343f386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 10 Dec 2024 11:41:26 +0100 Subject: [PATCH 43/44] Typo --- .../re_types/definitions/rerun/blueprint/views/graph.fbs | 4 ++-- crates/store/re_types/src/blueprint/views/graph_view.rs | 4 ++-- docs/content/reference/types/views/graph_view.md | 4 ++-- rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs index 115fce675e8c..848ad4f3255a 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs @@ -12,7 +12,7 @@ table GraphView ( /// Somethings outside of these bounds may also be visible due to letterboxing. visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 1000); - /// Allows to control the interaction between two nodes connecting throught an edge. + /// Allows to control the interaction between two nodes connected by an edge. force_link: rerun.blueprint.archetypes.ForceLink (order: 2000); /// A force between each pair of nodes that ressembles an electrical charge. @@ -21,7 +21,7 @@ table GraphView ( /// Similar to gravity, this force pulls nodes towards a specific position. force_position: rerun.blueprint.archetypes.ForcePosition (order: 4000); - /// Resolves collisons between the bounding spheres, according to the radius of the nodes. + /// Resolves collisions between the bounding spheres, according to the radius of the nodes. force_collision_radius: rerun.blueprint.archetypes.ForceCollisionRadius (order: 5000); /// Tries to move the center of mass of the graph to the origin. diff --git a/crates/store/re_types/src/blueprint/views/graph_view.rs b/crates/store/re_types/src/blueprint/views/graph_view.rs index df6135e684ce..74e6771dc9b2 100644 --- a/crates/store/re_types/src/blueprint/views/graph_view.rs +++ b/crates/store/re_types/src/blueprint/views/graph_view.rs @@ -26,7 +26,7 @@ pub struct GraphView { /// Somethings outside of these bounds may also be visible due to letterboxing. pub visual_bounds: crate::blueprint::archetypes::VisualBounds2D, - /// Allows to control the interaction between two nodes connecting throught an edge. + /// Allows to control the interaction between two nodes connected by an edge. pub force_link: crate::blueprint::archetypes::ForceLink, /// A force between each pair of nodes that ressembles an electrical charge. @@ -35,7 +35,7 @@ pub struct GraphView { /// Similar to gravity, this force pulls nodes towards a specific position. pub force_position: crate::blueprint::archetypes::ForcePosition, - /// Resolves collisons between the bounding spheres, according to the radius of the nodes. + /// Resolves collisions between the bounding spheres, according to the radius of the nodes. pub force_collision_radius: crate::blueprint::archetypes::ForceCollisionRadius, /// Tries to move the center of mass of the graph to the origin. diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 127a18c21377..4b483c3fda87 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -15,7 +15,7 @@ Somethings outside of these bounds may also be visible due to letterboxing. * `range`: Controls the visible range of a 2D view. * `near_clip_plane`: Controls the distance to the near clip plane in 3D scene units. ### `force_link` -Allows to control the interaction between two nodes connecting throught an edge. +Allows to control the interaction between two nodes connected by an edge. * `enabled`: Whether the force is enabled. * `distance`: The target distance between two nodes. @@ -32,7 +32,7 @@ Similar to gravity, this force pulls nodes towards a specific position. * `strength`: The strength of the force. * `position`: The position where the nodes should be pulled towards. ### `force_collision_radius` -Resolves collisons between the bounding spheres, according to the radius of the nodes. +Resolves collisions between the bounding spheres, according to the radius of the nodes. * `enabled`: Whether the force is enabled. * `strength`: The strength of the force. diff --git a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py index bdf01ce29f63..753f74e416d1 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/views/graph_view.py @@ -110,13 +110,13 @@ def __init__( Somethings outside of these bounds may also be visible due to letterboxing. force_link: - Allows to control the interaction between two nodes connecting throught an edge. + Allows to control the interaction between two nodes connected by an edge. force_many_body: A force between each pair of nodes that ressembles an electrical charge. force_position: Similar to gravity, this force pulls nodes towards a specific position. force_collision_radius: - Resolves collisons between the bounding spheres, according to the radius of the nodes. + Resolves collisions between the bounding spheres, according to the radius of the nodes. force_center: Tries to move the center of mass of the graph to the origin. From b79e16f90db1d3f1911a42284c729c0068f3c490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 10 Dec 2024 12:21:41 +0100 Subject: [PATCH 44/44] Typo again --- crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs b/crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs index 620cd3091cd3..e92b3c91a39b 100644 --- a/crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs +++ b/crates/viewer/re_component_ui/src/datatype_uis/int_drag.rs @@ -4,7 +4,7 @@ use egui::NumExt as _; use re_types_core::datatypes; use re_viewer_context::MaybeMutRef; -/// Generic editor for a [`re_types::datatypes::UInt64`] values wihtin a given range. +/// Generic editor for a [`re_types::datatypes::UInt64`] values within a given range. pub fn edit_u64_range( _ctx: &re_viewer_context::ViewerContext<'_>, ui: &mut egui::Ui,