diff --git a/Cargo.lock b/Cargo.lock index fef05a09e3c4..86e23cf1341b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1934,7 +1934,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "ecolor" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "bytemuck", "color-hex", @@ -1951,7 +1951,7 @@ checksum = "18aade80d5e09429040243ce1143ddc08a92d7a22820ac512610410a4dd5214f" [[package]] name = "eframe" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "ahash", "bytemuck", @@ -1972,7 +1972,7 @@ dependencies = [ "parking_lot", "percent-encoding", "pollster 0.4.0", - "puffin", + "profiling", "raw-window-handle", "ron", "serde", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "egui" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "accesskit", "ahash", @@ -1999,7 +1999,7 @@ dependencies = [ "epaint", "log", "nohash-hasher", - "puffin", + "profiling", "ron", "serde", ] @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "ahash", "bytemuck", @@ -2015,7 +2015,7 @@ dependencies = [ "egui", "epaint", "log", - "puffin", + "profiling", "thiserror", "type-map", "web-time", @@ -2026,14 +2026,14 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "accesskit_winit", "ahash", "arboard", "egui", "log", - "puffin", + "profiling", "raw-window-handle", "serde", "smithay-clipboard", @@ -2068,7 +2068,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "ahash", "egui", @@ -2077,7 +2077,7 @@ dependencies = [ "image", "log", "mime_guess2", - "puffin", + "profiling", "resvg", "serde", ] @@ -2085,16 +2085,15 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "ahash", "bytemuck", "egui", - "egui-winit", "glow 0.16.0", "log", "memoffset", - "puffin", + "profiling", "wasm-bindgen", "web-sys", "winit", @@ -2103,7 +2102,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "dify", "egui", @@ -2172,7 +2171,7 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "emath" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "bytemuck", "serde", @@ -2288,7 +2287,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" dependencies = [ "ab_glyph", "ahash", @@ -2299,7 +2298,7 @@ dependencies = [ "log", "nohash-hasher", "parking_lot", - "puffin", + "profiling", "rayon", "serde", ] @@ -2307,7 +2306,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.29.1" -source = "git+https://github.com/emilk/egui.git?rev=13352d606496d7b1c5fd6fcfbe3c85baae39c040#13352d606496d7b1c5fd6fcfbe3c85baae39c040" +source = "git+https://github.com/emilk/egui.git?rev=f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b#f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" [[package]] name = "equivalent" diff --git a/Cargo.toml b/Cargo.toml index f9093aa23cf5..f66d51928ef2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,7 +127,6 @@ ecolor = "0.29.1" eframe = { version = "0.29.1", default-features = false, features = [ "accesskit", "default_fonts", - "puffin", "wayland", "x11", ] } @@ -135,16 +134,10 @@ egui = { version = "0.29.1", features = [ "callstack", "color-hex", "log", - "puffin", "rayon", ] } egui_commonmark = { version = "0.18", default-features = false } -egui_extras = { version = "0.29.1", features = [ - "http", - "image", - "puffin", - "serde", -] } +egui_extras = { version = "0.29.1", features = ["http", "image", "serde"] } egui_kittest = { version = "0.29.1", features = ["wgpu", "snapshot"] } egui_plot = "0.29.0" # https://github.com/emilk/egui_plot egui_table = "0.1.0" # https://github.com/rerun-io/egui_table @@ -560,13 +553,13 @@ significant_drop_tightening = "allow" # An update of parking_lot made this trigg # As a last resport, patch with a commit to our own repository. # ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk. -ecolor = { git = "https://github.com/emilk/egui.git", rev = "13352d606496d7b1c5fd6fcfbe3c85baae39c040" } # egui master 2024-12-09 -eframe = { git = "https://github.com/emilk/egui.git", rev = "13352d606496d7b1c5fd6fcfbe3c85baae39c040" } # egui master 2024-12-09 -egui = { git = "https://github.com/emilk/egui.git", rev = "13352d606496d7b1c5fd6fcfbe3c85baae39c040" } # egui master 2024-12-09 -egui_extras = { git = "https://github.com/emilk/egui.git", rev = "13352d606496d7b1c5fd6fcfbe3c85baae39c040" } # egui master 2024-12-09 -egui_kittest = { git = "https://github.com/emilk/egui.git", rev = "13352d606496d7b1c5fd6fcfbe3c85baae39c040" } # egui master 2024-12-09 -egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "13352d606496d7b1c5fd6fcfbe3c85baae39c040" } # egui master 2024-12-09 -emath = { git = "https://github.com/emilk/egui.git", rev = "13352d606496d7b1c5fd6fcfbe3c85baae39c040" } # egui master 2024-12-09 +ecolor = { git = "https://github.com/emilk/egui.git", rev = "f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" } # egui master 2024-12-16 +eframe = { git = "https://github.com/emilk/egui.git", rev = "f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" } # egui master 2024-12-16 +egui = { git = "https://github.com/emilk/egui.git", rev = "f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" } # egui master 2024-12-16 +egui_extras = { git = "https://github.com/emilk/egui.git", rev = "f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" } # egui master 2024-12-16 +egui_kittest = { git = "https://github.com/emilk/egui.git", rev = "f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" } # egui master 2024-12-16 +egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" } # egui master 2024-12-16 +emath = { git = "https://github.com/emilk/egui.git", rev = "f7efb2186d529ddc9e69f7173c6ae3ae5f403d0b" } # egui master 2024-12-16 # Useful while developing: # ecolor = { path = "../../egui/crates/ecolor" } diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index fbbed167ca0c..832d2487a112 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -11,6 +11,7 @@ include "./archetypes/force_position.fbs"; include "./archetypes/line_grid3d.fbs"; include "./archetypes/map_background.fbs"; include "./archetypes/map_zoom.fbs"; +include "./archetypes/near_clip_plane.fbs"; include "./archetypes/panel_blueprint.fbs"; include "./archetypes/plot_legend.fbs"; include "./archetypes/scalar_axis.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs new file mode 100644 index 000000000000..a157d67a2982 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/near_clip_plane.fbs @@ -0,0 +1,13 @@ +namespace rerun.blueprint.archetypes; + +/// Controls the distance to the near clip plane in 3D scene units. +table NearClipPlane ( + "attr.docs.unreleased", + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Copy" +) { + /// Controls the distance to the near clip plane in 3D scene units. + /// + /// Content closer than this distance will not be visible. + near_clip_plane: rerun.blueprint.components.NearClipPlane ("attr.rerun.component_optional", order: 1000); +} diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs index 21b8599e5383..38c38541640c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs @@ -1,6 +1,5 @@ namespace rerun.blueprint.archetypes; - /// Controls the visual bounds of a 2D view. /// /// Everything within these bounds are guaranteed to be visible. @@ -16,9 +15,4 @@ table VisualBounds2D ( /// /// Use this to control pan & zoom of the view. range: rerun.blueprint.components.VisualBounds2D ("attr.rerun.component_required", order: 1000); - - /// Controls the distance to the near clip plane in 3D scene units. - /// - /// Content closer than this distance will not be visible. - near_clip_plane: rerun.blueprint.components.NearClipPlane ("attr.rerun.component_optional", order: 2000); } diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index e8331953aab0..bb60dc4d4d53 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -13,6 +13,7 @@ line_grid3d.rs linguist-generated=true map_background.rs linguist-generated=true map_zoom.rs linguist-generated=true mod.rs linguist-generated=true +near_clip_plane.rs linguist-generated=true panel_blueprint.rs linguist-generated=true plot_legend.rs linguist-generated=true scalar_axis.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index c0b54d19a91d..92d1c164ee4e 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -11,6 +11,7 @@ mod force_position; mod line_grid3d; mod map_background; mod map_zoom; +mod near_clip_plane; mod panel_blueprint; mod plot_legend; mod scalar_axis; @@ -35,6 +36,7 @@ pub use self::force_position::ForcePosition; pub use self::line_grid3d::LineGrid3D; pub use self::map_background::MapBackground; pub use self::map_zoom::MapZoom; +pub use self::near_clip_plane::NearClipPlane; pub use self::panel_blueprint::PanelBlueprint; pub use self::plot_legend::PlotLegend; pub use self::scalar_axis::ScalarAxis; diff --git a/crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs b/crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs new file mode 100644 index 000000000000..9714d55ddff1 --- /dev/null +++ b/crates/store/re_types/src/blueprint/archetypes/near_clip_plane.rs @@ -0,0 +1,186 @@ +// 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/near_clip_plane.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::SerializationResult; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Archetype**: Controls the distance to the near clip plane in 3D scene units. +#[derive(Clone, Debug, Copy)] +pub struct NearClipPlane { + /// Controls the distance to the near clip plane in 3D scene units. + /// + /// Content closer than this distance will not be visible. + pub near_clip_plane: crate::blueprint::components::NearClipPlane, +} + +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = + once_cell::sync::Lazy::new(|| []); + +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = + once_cell::sync::Lazy::new(|| { + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + component_name: "rerun.blueprint.components.NearClipPlaneIndicator".into(), + archetype_field_name: None, + }] + }); + +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = + once_cell::sync::Lazy::new(|| { + [ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + component_name: "rerun.blueprint.components.NearClipPlane".into(), + archetype_field_name: Some("near_clip_plane".into()), + }] + }); + +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> = + once_cell::sync::Lazy::new(|| { + [ + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + component_name: "rerun.blueprint.components.NearClipPlaneIndicator".into(), + archetype_field_name: None, + }, + ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + component_name: "rerun.blueprint.components.NearClipPlane".into(), + archetype_field_name: Some("near_clip_plane".into()), + }, + ] + }); + +impl NearClipPlane { + /// The total number of components in the archetype: 0 required, 1 recommended, 1 optional + pub const NUM_COMPONENTS: usize = 2usize; +} + +/// Indicator component for the [`NearClipPlane`] [`::re_types_core::Archetype`] +pub type NearClipPlaneIndicator = ::re_types_core::GenericIndicatorComponent; + +impl ::re_types_core::Archetype for NearClipPlane { + type Indicator = NearClipPlaneIndicator; + + #[inline] + fn name() -> ::re_types_core::ArchetypeName { + "rerun.blueprint.archetypes.NearClipPlane".into() + } + + #[inline] + fn display_name() -> &'static str { + "Near clip plane" + } + + #[inline] + fn indicator() -> ComponentBatchCowWithDescriptor<'static> { + static INDICATOR: NearClipPlaneIndicator = NearClipPlaneIndicator::DEFAULT; + ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch) + } + + #[inline] + fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { + REQUIRED_COMPONENTS.as_slice().into() + } + + #[inline] + fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { + RECOMMENDED_COMPONENTS.as_slice().into() + } + + #[inline] + fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { + OPTIONAL_COMPONENTS.as_slice().into() + } + + #[inline] + fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> { + 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 near_clip_plane = { + let array = arrays_by_name + .get("rerun.blueprint.components.NearClipPlane") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.NearClipPlane#near_clip_plane")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.NearClipPlane#near_clip_plane")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.NearClipPlane#near_clip_plane")? + }; + Ok(Self { near_clip_plane }) + } +} + +impl ::re_types_core::AsComponents for NearClipPlane { + fn as_component_batches(&self) -> Vec> { + re_tracing::profile_function!(); + use ::re_types_core::Archetype as _; + [ + Some(Self::indicator()), + (Some(&self.near_clip_plane as &dyn ComponentBatch)).map(|batch| { + ::re_types_core::ComponentBatchCowWithDescriptor { + batch: batch.into(), + descriptor_override: Some(ComponentDescriptor { + archetype_name: Some("rerun.blueprint.archetypes.NearClipPlane".into()), + archetype_field_name: Some(("near_clip_plane").into()), + component_name: ("rerun.blueprint.components.NearClipPlane").into(), + }), + } + }), + ] + .into_iter() + .flatten() + .collect() + } +} + +impl ::re_types_core::ArchetypeReflectionMarker for NearClipPlane {} + +impl NearClipPlane { + /// Create a new `NearClipPlane`. + #[inline] + pub fn new(near_clip_plane: impl Into) -> Self { + Self { + near_clip_plane: near_clip_plane.into(), + } + } +} + +impl ::re_types_core::SizeBytes for NearClipPlane { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.near_clip_plane.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} diff --git a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs index 48072b0eedf8..e409e5dbd94a 100644 --- a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs +++ b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs @@ -31,11 +31,6 @@ pub struct VisualBounds2D { /// /// Use this to control pan & zoom of the view. pub range: crate::blueprint::components::VisualBounds2D, - - /// Controls the distance to the near clip plane in 3D scene units. - /// - /// Content closer than this distance will not be visible. - pub near_clip_plane: crate::blueprint::components::NearClipPlane, } static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = @@ -56,16 +51,10 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usiz }] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> = - once_cell::sync::Lazy::new(|| { - [ComponentDescriptor { - archetype_name: Some("rerun.blueprint.archetypes.VisualBounds2D".into()), - component_name: "rerun.blueprint.components.NearClipPlane".into(), - archetype_field_name: Some("near_clip_plane".into()), - }] - }); +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> = + once_cell::sync::Lazy::new(|| []); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> = once_cell::sync::Lazy::new(|| { [ ComponentDescriptor { @@ -78,17 +67,12 @@ static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> = component_name: "rerun.blueprint.components.VisualBounds2DIndicator".into(), archetype_field_name: None, }, - ComponentDescriptor { - archetype_name: Some("rerun.blueprint.archetypes.VisualBounds2D".into()), - component_name: "rerun.blueprint.components.NearClipPlane".into(), - archetype_field_name: Some("near_clip_plane".into()), - }, ] }); impl VisualBounds2D { - /// The total number of components in the archetype: 1 required, 1 recommended, 1 optional - pub const NUM_COMPONENTS: usize = 3usize; + /// The total number of components in the archetype: 1 required, 1 recommended, 0 optional + pub const NUM_COMPONENTS: usize = 2usize; } /// Indicator component for the [`VisualBounds2D`] [`::re_types_core::Archetype`] @@ -156,23 +140,7 @@ impl ::re_types_core::Archetype for VisualBounds2D { .ok_or_else(DeserializationError::missing_data) .with_context("rerun.blueprint.archetypes.VisualBounds2D#range")? }; - let near_clip_plane = { - let array = arrays_by_name - .get("rerun.blueprint.components.NearClipPlane") - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")? - .into_iter() - .next() - .flatten() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")? - }; - Ok(Self { - range, - near_clip_plane, - }) + Ok(Self { range }) } } @@ -192,16 +160,6 @@ impl ::re_types_core::AsComponents for VisualBounds2D { }), } }), - (Some(&self.near_clip_plane as &dyn ComponentBatch)).map(|batch| { - ::re_types_core::ComponentBatchCowWithDescriptor { - batch: batch.into(), - descriptor_override: Some(ComponentDescriptor { - archetype_name: Some("rerun.blueprint.archetypes.VisualBounds2D".into()), - archetype_field_name: Some(("near_clip_plane").into()), - component_name: ("rerun.blueprint.components.NearClipPlane").into(), - }), - } - }), ] .into_iter() .flatten() @@ -214,13 +172,9 @@ impl ::re_types_core::ArchetypeReflectionMarker for VisualBounds2D {} impl VisualBounds2D { /// Create a new `VisualBounds2D`. #[inline] - pub fn new( - range: impl Into, - near_clip_plane: impl Into, - ) -> Self { + pub fn new(range: impl Into) -> Self { Self { range: range.into(), - near_clip_plane: near_clip_plane.into(), } } } @@ -228,12 +182,11 @@ impl VisualBounds2D { impl ::re_types_core::SizeBytes for VisualBounds2D { #[inline] fn heap_size_bytes(&self) -> u64 { - self.range.heap_size_bytes() + self.near_clip_plane.heap_size_bytes() + self.range.heap_size_bytes() } #[inline] fn is_pod() -> bool { ::is_pod() - && ::is_pod() } } diff --git a/crates/store/re_types/src/reflection/mod.rs b/crates/store/re_types/src/reflection/mod.rs index 13a12e4af4fb..c9c15388e158 100644 --- a/crates/store/re_types/src/reflection/mod.rs +++ b/crates/store/re_types/src/reflection/mod.rs @@ -2193,6 +2193,21 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), + ( + ArchetypeName::new("rerun.blueprint.archetypes.NearClipPlane"), + ArchetypeReflection { + display_name: "Near clip plane", + scope: Some("blueprint"), + view_types: &[], + fields: vec![ + ArchetypeFieldReflection { name : "near_clip_plane", display_name : + "Near clip plane", component_name : + "rerun.blueprint.components.NearClipPlane".into(), docstring_md : + "Controls the distance to the near clip plane in 3D scene units.\n\nContent closer than this distance will not be visible.", + is_required : false, }, + ], + }, + ), ( ArchetypeName::new("rerun.blueprint.archetypes.PanelBlueprint"), ArchetypeReflection { @@ -2411,11 +2426,7 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { component_name : "rerun.blueprint.components.VisualBounds2D".into(), docstring_md : "Controls the visible range of a 2D view.\n\nUse this to control pan & zoom of the view.", - is_required : true, }, ArchetypeFieldReflection { name : - "near_clip_plane", display_name : "Near clip plane", component_name : - "rerun.blueprint.components.NearClipPlane".into(), docstring_md : - "Controls the distance to the near clip plane in 3D scene units.\n\nContent closer than this distance will not be visible.", - is_required : false, }, + is_required : true, }, ], }, ), diff --git a/crates/viewer/re_ui/src/zoom_pan_area.rs b/crates/viewer/re_ui/src/zoom_pan_area.rs index 46020aa15c34..f3f2530ba571 100644 --- a/crates/viewer/re_ui/src/zoom_pan_area.rs +++ b/crates/viewer/re_ui/src/zoom_pan_area.rs @@ -5,7 +5,7 @@ //! * `view`-space: The space where the pan-and-zoom area is drawn. //! * `scene`-space: The space where the actual content is drawn. -use egui::{emath::TSTransform, Area, Rect, Response, Ui, UiKind}; +use egui::{emath::TSTransform, Rect, Response, Ui, UiBuilder, Vec2}; /// Helper function to handle pan and zoom interactions on a response. fn register_pan_and_zoom(ui: &Ui, resp: &Response, ui_from_scene: &mut TSTransform) { @@ -19,16 +19,22 @@ fn register_pan_and_zoom(ui: &Ui, resp: &Response, ui_from_scene: &mut TSTransfo let zoom_delta = ui.ctx().input(|i| i.zoom_delta()); let pan_delta = ui.ctx().input(|i| i.smooth_scroll_delta); + // Most of the time we can return early. This is also important to + // avoid `ui_from_scene` to change slightly due to floating point errors. + if zoom_delta == 1.0 && pan_delta == Vec2::ZERO { + return; + } + // Zoom in on pointer, but only if we are not zoomed out too far. if zoom_delta < 1.0 || ui_from_scene.scaling < 1.0 { *ui_from_scene = *ui_from_scene * TSTransform::from_translation(pointer_in_scene.to_vec2()) * TSTransform::from_scaling(zoom_delta) * TSTransform::from_translation(-pointer_in_scene.to_vec2()); - } - // We clamp the resulting scaling to avoid zooming out too far. - ui_from_scene.scaling = ui_from_scene.scaling.min(1.0); + // We clamp the resulting scaling to avoid zooming out too far. + ui_from_scene.scaling = ui_from_scene.scaling.min(1.0); + } // Pan: *ui_from_scene = TSTransform::from_translation(pan_delta) * *ui_from_scene; @@ -57,46 +63,52 @@ pub fn fit_to_rect_in_scene(rect_in_ui: Rect, rect_in_scene: Rect) -> TSTransfor } /// Provides a zoom-pan area for a given view. +/// +/// Will fill the entire `max_rect` of the `parent_ui`. pub fn zoom_pan_area( - ui: &Ui, - view_bounds_in_ui: Rect, - ui_from_scene: &mut TSTransform, + parent_ui: &mut Ui, + to_global: &mut TSTransform, draw_contents: impl FnOnce(&mut Ui), ) -> Response { - let area_resp = Area::new(ui.id().with("zoom_pan_area")) - .constrain_to(view_bounds_in_ui) - .order(ui.layer_id().order) - .kind(UiKind::GenericArea) - .show(ui.ctx(), |ui| { - // Transform to the scene space: - let visible_rect_in_scene = ui_from_scene.inverse() * view_bounds_in_ui; - - // set proper clip-rect so we can interact with the background. - ui.set_clip_rect(visible_rect_in_scene); - - // A Ui for sensing drag-to-pan, scroll-to-zoom, etc - let mut drag_sense_ui = ui.new_child( - egui::UiBuilder::new() - .sense(egui::Sense::click_and_drag()) - .max_rect(visible_rect_in_scene), - ); - - drag_sense_ui.set_min_size(visible_rect_in_scene.size()); - let pan_response = drag_sense_ui.response(); - - // Update the transform based on the interactions: - register_pan_and_zoom(ui, &pan_response, ui_from_scene); - - // Update the clip-rect with the new transform, to avoid frame-delays - ui.set_clip_rect(ui_from_scene.inverse() * view_bounds_in_ui); - - // Add the actual contents to the area: - draw_contents(ui); - pan_response - }); - - ui.ctx() - .set_transform_layer(area_resp.response.layer_id, *ui_from_scene); - - area_resp.inner + // Create a new egui paint layer, where we can draw our contents: + let zoom_pan_layer_id = egui::LayerId::new( + parent_ui.layer_id().order, + parent_ui.id().with("zoom_pan_area"), + ); + + // Put the layer directly on-top of the main layer of the ui: + parent_ui + .ctx() + .set_sublayer(parent_ui.layer_id(), zoom_pan_layer_id); + + let global_view_bounds = parent_ui.max_rect(); + + let mut local_ui = parent_ui.new_child( + UiBuilder::new() + .layer_id(zoom_pan_layer_id) + .max_rect(to_global.inverse() * global_view_bounds) + .sense(egui::Sense::click_and_drag()), + ); + local_ui.set_min_size(local_ui.max_rect().size()); // Allocate all available space + + // Set proper clip-rect so we can interact with the background: + local_ui.set_clip_rect(local_ui.max_rect()); + + let pan_response = local_ui.response(); + + // Update the `to_global` transform based on use interaction: + register_pan_and_zoom(&local_ui, &pan_response, to_global); + + // Update the clip-rect with the new transform, to avoid frame-delays + local_ui.set_clip_rect(to_global.inverse() * global_view_bounds); + + // Add the actual contents to the area: + draw_contents(&mut local_ui); + + // Tell egui to apply the transform on the layer: + local_ui + .ctx() + .set_transform_layer(zoom_pan_layer_id, *to_global); + + pan_response } diff --git a/crates/viewer/re_view_graph/src/properties.rs b/crates/viewer/re_view_graph/src/properties.rs index 3a99d6c777f0..35ad81696095 100644 --- a/crates/viewer/re_view_graph/src/properties.rs +++ b/crates/viewer/re_view_graph/src/properties.rs @@ -55,7 +55,7 @@ impl TypedComponentFallbackProvider for GraphView { impl TypedComponentFallbackProvider for GraphView { fn fallback_for(&self, ctx: &re_viewer_context::QueryContext<'_>) -> ForceStrength { match ctx.archetype_name { - Some(name) if name == archetypes::ForceManyBody::name() => (-60.).into(), + Some(name) if name == archetypes::ForceManyBody::name() => (-60.0).into(), Some(name) if name == archetypes::ForcePosition::name() => (0.01).into(), _ => (1.0).into(), } diff --git a/crates/viewer/re_view_graph/src/ui/state.rs b/crates/viewer/re_view_graph/src/ui/state.rs index 05eff3718fbc..d8dce815d1df 100644 --- a/crates/viewer/re_view_graph/src/ui/state.rs +++ b/crates/viewer/re_view_graph/src/ui/state.rs @@ -1,4 +1,4 @@ -use egui::{emath::TSTransform, Rect}; +use egui::Rect; use re_format::format_f32; use re_types::blueprint::components::VisualBounds2D; use re_ui::UiExt; @@ -16,7 +16,6 @@ pub struct GraphViewState { pub show_debug: bool, pub visual_bounds: Option, - pub ui_from_world: Option, pub rect_in_ui: Option, } @@ -25,7 +24,7 @@ impl GraphViewState { let Some(rect) = self.layout_state.bounding_rect() else { return; }; - ui.grid_left_hand_label("Layout") + ui.grid_left_hand_label("Bounding box") .on_hover_text("The bounding box encompassing all entities in the view right now"); ui.vertical(|ui| { ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend); diff --git a/crates/viewer/re_view_graph/src/view.rs b/crates/viewer/re_view_graph/src/view.rs index 8948a343c423..edb59eceb27d 100644 --- a/crates/viewer/re_view_graph/src/view.rs +++ b/crates/viewer/re_view_graph/src/view.rs @@ -183,22 +183,14 @@ Display a graph of nodes and edges. let layout = state.layout_state.get(request, params); // Prepare the view and the transformations. - let prev_rect_in_ui = state.rect_in_ui; let rect_in_ui = *state.rect_in_ui.insert(ui.max_rect()); - let ui_from_world = state - .ui_from_world - .get_or_insert_with(|| fit_to_rect_in_scene(rect_in_ui, rect_in_scene.into())); + let mut ui_from_world = fit_to_rect_in_scene(rect_in_ui, rect_in_scene.into()); - // We ensure that the view's center is kept during resizing. - if let Some(prev) = prev_rect_in_ui { - if prev != rect_in_ui { - let delta = rect_in_ui.center() - prev.center(); - ui_from_world.translation += delta; - } - } + // We store a copy of the transformation to see if it has changed. + let ui_from_world_ref = ui_from_world; - let resp = zoom_pan_area(ui, rect_in_ui, ui_from_world, |ui| { + let resp = zoom_pan_area(ui, &mut ui_from_world, |ui| { let mut world_bounding_rect = egui::Rect::NOTHING; for graph in &graphs { @@ -217,8 +209,7 @@ Display a graph of nodes and edges. blueprint::components::VisualBounds2D::from(ui_from_world.inverse() * rect_in_ui); if resp.double_clicked() { bounds_property.reset_blueprint_component::(ctx); - state.ui_from_world = None; - } else if rect_in_scene != updated_rect_in_scene { + } else if ui_from_world != ui_from_world_ref { bounds_property.save_blueprint_component(ctx, &updated_rect_in_scene); } // Update stored bounds on the state, so visualizers see an up-to-date value. diff --git a/crates/viewer/re_view_spatial/src/ui_2d.rs b/crates/viewer/re_view_spatial/src/ui_2d.rs index bf557b8a6a07..d58897e90ac5 100644 --- a/crates/viewer/re_view_spatial/src/ui_2d.rs +++ b/crates/viewer/re_view_spatial/src/ui_2d.rs @@ -7,7 +7,7 @@ use re_renderer::view_builder::{TargetConfiguration, ViewBuilder}; use re_types::{ archetypes::Pinhole, blueprint::{ - archetypes::{Background, VisualBounds2D}, + archetypes::{Background, NearClipPlane, VisualBounds2D}, components as blueprint_components, }, components::ViewCoordinates, @@ -168,12 +168,17 @@ impl SpatialView2D { ctx.blueprint_query, query.view_id, ); + let clip_property = ViewProperty::from_archetype::( + ctx.blueprint_db(), + ctx.blueprint_query, + query.view_id, + ); // Convert ui coordinates to/from scene coordinates. let ui_from_scene = ui_from_scene(ctx, &response, self, state, &bounds_property); let scene_from_ui = ui_from_scene.inverse(); - let near_clip_plane: blueprint_components::NearClipPlane = bounds_property + let near_clip_plane: blueprint_components::NearClipPlane = clip_property .component_or_fallback(ctx, self, state) .ok_or_log_error() .unwrap_or_default(); diff --git a/crates/viewer/re_view_spatial/src/view_2d.rs b/crates/viewer/re_view_spatial/src/view_2d.rs index 89fb14ea39a3..724118f27275 100644 --- a/crates/viewer/re_view_spatial/src/view_2d.rs +++ b/crates/viewer/re_view_spatial/src/view_2d.rs @@ -6,7 +6,7 @@ use re_log_types::EntityPath; use re_types::View; use re_types::{ archetypes::{DepthImage, Image}, - blueprint::archetypes::{Background, VisualBounds2D}, + blueprint::archetypes::{Background, NearClipPlane, VisualBounds2D}, Archetype, ComponentName, ViewClassIdentifier, }; use re_ui::UiExt as _; @@ -246,6 +246,7 @@ impl ViewClass for SpatialView2D { re_ui::list_item::list_item_scope(ui, "spatial_view2d_selection_ui", |ui| { view_property_ui::(ctx, ui, view_id, self, state); + view_property_ui::(ctx, ui, view_id, self, state); view_property_ui::(ctx, ui, view_id, self, state); }); diff --git a/crates/viewer/re_viewer/Cargo.toml b/crates/viewer/re_viewer/Cargo.toml index ae496fc924a6..3b076ba1df97 100644 --- a/crates/viewer/re_viewer/Cargo.toml +++ b/crates/viewer/re_viewer/Cargo.toml @@ -104,7 +104,6 @@ cfg-if.workspace = true eframe = { workspace = true, default-features = false, features = [ "default_fonts", "persistence", - "puffin", "wgpu", ] } egui_plot.workspace = true diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 90a12b048c15..7e39cfc769e4 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -11,9 +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. - -* `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 connected by an edge. diff --git a/docs/content/reference/types/views/spatial2d_view.md b/docs/content/reference/types/views/spatial2d_view.md index afcc55b75980..5bb3a50596e9 100644 --- a/docs/content/reference/types/views/spatial2d_view.md +++ b/docs/content/reference/types/views/spatial2d_view.md @@ -17,9 +17,6 @@ The visible parts of the scene, in the coordinate space of the scene. Everything within these bounds are 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. ### `time_ranges` Configures which range on each timeline is shown by this view (unless specified differently per entity). diff --git a/examples/manifest.toml b/examples/manifest.toml index b229b765acd5..a5ef1ebb1152 100644 --- a/examples/manifest.toml +++ b/examples/manifest.toml @@ -168,7 +168,6 @@ examples = [ "drone_lidar", "extend_viewer_ui", "external_data_loader", - "graph_binary_tree", "graph_lattice", "incremental_logging", "minimal_serve", diff --git a/examples/python/air_traffic_data/air_traffic_data.py b/examples/python/air_traffic_data/air_traffic_data.py index 911c4423e69d..2e2352e0ef0c 100644 --- a/examples/python/air_traffic_data/air_traffic_data.py +++ b/examples/python/air_traffic_data/air_traffic_data.py @@ -239,6 +239,7 @@ def process_measurement(self, measurement: Measurement) -> None: ) entity_path = f"aircraft/{measurement.icao_id}" + color = rr.components.Color.from_string(entity_path) if ( measurement.latitude is not None @@ -247,13 +248,16 @@ def process_measurement(self, measurement: Measurement) -> None: ): rr.log( entity_path, - rr.Points3D([ - self._proj.transform( - measurement.longitude, - measurement.latitude, - measurement.barometric_altitude, - ) - ]), + rr.Points3D( + [ + self._proj.transform( + measurement.longitude, + measurement.latitude, + measurement.barometric_altitude, + ), + ], + colors=color, + ), rr.GeoPoints(lat_lon=[measurement.latitude, measurement.longitude]), ) @@ -264,6 +268,7 @@ def process_measurement(self, measurement: Measurement) -> None: rr.log( entity_path + "/barometric_altitude", rr.Scalar(measurement.barometric_altitude), + rr.SeriesLine(color=color), ) def flush(self) -> None: @@ -310,7 +315,13 @@ def log_position_and_altitude(self, df: polars.DataFrame, icao_id: str) -> None: return if icao_id not in self._position_indicators: - rr.log(entity_path, [rr.archetypes.Points3D.indicator(), rr.archetypes.GeoPoints.indicator()], static=True) + color = rr.components.Color.from_string(entity_path) + rr.log( + entity_path, + [rr.archetypes.Points3D.indicator(), rr.archetypes.GeoPoints.indicator(), color], + static=True, + ) + rr.log(entity_path + "/barometric_altitude", [rr.archetypes.SeriesLine.indicator(), color], static=True) self._position_indicators.add(icao_id) timestamps = rr.TimeSecondsColumn("unix_time", df["timestamp"].to_numpy()) diff --git a/examples/python/arkit_scenes/arkit_scenes/download_dataset.py b/examples/python/arkit_scenes/arkit_scenes/download_dataset.py index 2ed6ca7797d5..156cf6a1c848 100644 --- a/examples/python/arkit_scenes/arkit_scenes/download_dataset.py +++ b/examples/python/arkit_scenes/arkit_scenes/download_dataset.py @@ -7,7 +7,7 @@ import subprocess import zipfile from pathlib import Path -from typing import Final +from typing import Final, Optional import pandas as pd @@ -196,14 +196,14 @@ def download_laser_scanner_point_clouds(laser_scanner_point_cloud_id: str, visit download_file(file_url, filename, laser_scanner_point_clouds_folder_path) -def get_metadata(dataset: str, download_dir: Path) -> pd.DataFrame: +def get_metadata(dataset: str, download_dir: Path) -> Optional[pd.DataFrame]: filename = "metadata.csv" url = f"{ARkitscense_url}/threedod/{filename}" if "3dod" == dataset else f"{ARkitscense_url}/{dataset}/{filename}" dst_folder = download_dir / dataset dst_file = dst_folder / filename if not download_file(url, filename, dst_folder): - return + return None metadata = pd.read_csv(dst_file) return metadata @@ -235,7 +235,7 @@ def download_data( """ metadata = get_metadata(dataset, download_dir) - if None is metadata: + if metadata is None: print(f"Error retrieving metadata for dataset {dataset}") return diff --git a/examples/python/graph_lattice/README.md b/examples/python/graph_lattice/README.md index 8ffe2530634f..a44ec2eeab8d 100644 --- a/examples/python/graph_lattice/README.md +++ b/examples/python/graph_lattice/README.md @@ -3,7 +3,6 @@ title = "Graph lattice" tags = ["Graph", "Layout"] thumbnail = "https://static.rerun.io/graph_lattice/f9169da9c3f35b7260c9d74cd5be5fe710aec6a8/480w.png" thumbnail_dimensions = [480, 269] -channel = "main" --> This example shows different attributes that you can associate with nodes in a graph. diff --git a/examples/python/graphs/README.md b/examples/python/graphs/README.md index 245143a18cc0..b06d813bd166 100644 --- a/examples/python/graphs/README.md +++ b/examples/python/graphs/README.md @@ -1,29 +1,51 @@ -This example shows different attributes that you can associate with nodes in a graph. -Since no explicit positions are passed for the nodes, Rerun will layout the graph automatically. +This example shows different types of graphs (and layouts) that you can visualize using Rerun. - - - - - + + + + + +Rerun ships with an integrated engine to produce [force-based layouts](https://en.wikipedia.org/wiki/Force-directed_graph_drawing) to visualize graphs. +Force-directed layout approaches have to advantage that they are flexible and can therefore be used to create different kinds of visualizations. +This example shows different types of layouts: + +* Regular force-directed layouts of node-link diagrams +* Bubble charts, which are based on packing circles + ## Used Rerun types + [`GraphNodes`](https://www.rerun.io/docs/reference/types/archetypes/graph_nodes?speculative-link), [`GraphEdges`](https://www.rerun.io/docs/reference/types/archetypes/graph_edges?speculative-link) +## Force-based layouts + +To compute the graph layouts, Rerun implements a physics simulation that is very similar to [`d3-force`](https://d3js.org/d3-force). In particular, we implement the following forces: + +* Centering force, which shifts the center of mass of the entire graph. +* Collision radius force, which resolves collisions between nodes in the graph, taking their radius into account. +* Many-Body force, which can be used to create attraction or repulsion between nodes. +* Link force, which acts like a spring between two connected nodes. +* Position force, which pull all nodes towards a given position, similar to gravity. + +If you want to learn more about these forces, we recommend looking at the [D3 documentation](https://d3js.org/d3-force) as well. + +Our implementation of the physics simulation is called _Fjädra_. You can find it on [GitHub](https://github.com/grtlr/fjadra) and on [`crates.io`](https://crates.io/crates/fjadra). + ## Run the code ```bash pip install -e examples/python/graphs python -m graphs ``` + diff --git a/examples/rust/graph_lattice/README.md b/examples/rust/graph_lattice/README.md index a4ebaa3a477f..0f3e4ea460f9 100644 --- a/examples/rust/graph_lattice/README.md +++ b/examples/rust/graph_lattice/README.md @@ -3,7 +3,6 @@ title = "Graph lattice" tags = ["Graph", "Layout"] thumbnail = "https://static.rerun.io/graph_lattice/f9169da9c3f35b7260c9d74cd5be5fe710aec6a8/480w.png" thumbnail_dimensions = [480, 269] -channel = "main" --> This example shows different attributes that you can associate with nodes in a graph. diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index f29777108ae4..83bfdf51b7bd 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -13,6 +13,7 @@ #include "blueprint/archetypes/line_grid3d.hpp" #include "blueprint/archetypes/map_background.hpp" #include "blueprint/archetypes/map_zoom.hpp" +#include "blueprint/archetypes/near_clip_plane.hpp" #include "blueprint/archetypes/panel_blueprint.hpp" #include "blueprint/archetypes/plot_legend.hpp" #include "blueprint/archetypes/scalar_axis.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes index 4f4c826ff1bd..eb9e19447493 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -23,6 +23,8 @@ map_background.cpp linguist-generated=true map_background.hpp linguist-generated=true map_zoom.cpp linguist-generated=true map_zoom.hpp linguist-generated=true +near_clip_plane.cpp linguist-generated=true +near_clip_plane.hpp linguist-generated=true panel_blueprint.cpp linguist-generated=true panel_blueprint.hpp linguist-generated=true plot_legend.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.cpp new file mode 100644 index 000000000000..2e16afb302ab --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.cpp @@ -0,0 +1,41 @@ +// 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/near_clip_plane.fbs". + +#include "near_clip_plane.hpp" + +#include "../../collection_adapter_builtins.hpp" + +namespace rerun::blueprint::archetypes {} + +namespace rerun { + + Result> + AsComponents::serialize( + const blueprint::archetypes::NearClipPlane& archetype + ) { + using namespace blueprint::archetypes; + std::vector cells; + cells.reserve(2); + + { + auto result = ComponentBatch::from_loggable( + archetype.near_clip_plane, + ComponentDescriptor( + "rerun.blueprint.archetypes.NearClipPlane", + "near_clip_plane", + "rerun.blueprint.components.NearClipPlane" + ) + ); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } + { + auto indicator = NearClipPlane::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/near_clip_plane.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.hpp new file mode 100644 index 000000000000..b01dee338d3c --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/archetypes/near_clip_plane.hpp @@ -0,0 +1,54 @@ +// 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/near_clip_plane.fbs". + +#pragma once + +#include "../../blueprint/components/near_clip_plane.hpp" +#include "../../collection.hpp" +#include "../../component_batch.hpp" +#include "../../indicator_component.hpp" +#include "../../result.hpp" + +#include +#include +#include + +namespace rerun::blueprint::archetypes { + /// **Archetype**: Controls the distance to the near clip plane in 3D scene units. + struct NearClipPlane { + /// Controls the distance to the near clip plane in 3D scene units. + /// + /// Content closer than this distance will not be visible. + rerun::blueprint::components::NearClipPlane near_clip_plane; + + public: + static constexpr const char IndicatorComponentName[] = + "rerun.blueprint.components.NearClipPlaneIndicator"; + + /// Indicator component, used to identify the archetype when converting to a list of components. + using IndicatorComponent = rerun::components::IndicatorComponent; + + public: + NearClipPlane() = default; + NearClipPlane(NearClipPlane&& other) = default; + + explicit NearClipPlane(rerun::blueprint::components::NearClipPlane _near_clip_plane) + : near_clip_plane(std::move(_near_clip_plane)) {} + }; + +} // 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::NearClipPlane& archetype + ); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp index d5756b46e0ef..9326c22b3548 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp @@ -15,7 +15,7 @@ namespace rerun { ) { using namespace blueprint::archetypes; std::vector cells; - cells.reserve(3); + cells.reserve(2); { auto result = ComponentBatch::from_loggable( @@ -29,18 +29,6 @@ namespace rerun { RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } - { - auto result = ComponentBatch::from_loggable( - archetype.near_clip_plane, - ComponentDescriptor( - "rerun.blueprint.archetypes.VisualBounds2D", - "near_clip_plane", - "rerun.blueprint.components.NearClipPlane" - ) - ); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } { auto indicator = VisualBounds2D::IndicatorComponent(); auto result = ComponentBatch::from_loggable(indicator); diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp index 0cf72032e464..fc0f11e560f1 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp @@ -3,7 +3,6 @@ #pragma once -#include "../../blueprint/components/near_clip_plane.hpp" #include "../../blueprint/components/visual_bounds2d.hpp" #include "../../collection.hpp" #include "../../component_batch.hpp" @@ -28,11 +27,6 @@ namespace rerun::blueprint::archetypes { /// Use this to control pan & zoom of the view. rerun::blueprint::components::VisualBounds2D range; - /// Controls the distance to the near clip plane in 3D scene units. - /// - /// Content closer than this distance will not be visible. - rerun::blueprint::components::NearClipPlane near_clip_plane; - public: static constexpr const char IndicatorComponentName[] = "rerun.blueprint.components.VisualBounds2DIndicator"; @@ -44,11 +38,8 @@ namespace rerun::blueprint::archetypes { VisualBounds2D() = default; VisualBounds2D(VisualBounds2D&& other) = default; - explicit VisualBounds2D( - rerun::blueprint::components::VisualBounds2D _range, - rerun::blueprint::components::NearClipPlane _near_clip_plane - ) - : range(std::move(_range)), near_clip_plane(std::move(_near_clip_plane)) {} + explicit VisualBounds2D(rerun::blueprint::components::VisualBounds2D _range) + : range(std::move(_range)) {} }; } // namespace rerun::blueprint::archetypes diff --git a/rerun_py/rerun_sdk/rerun/_send_columns.py b/rerun_py/rerun_sdk/rerun/_send_columns.py index 888ff21d6648..683d442f6053 100644 --- a/rerun_py/rerun_sdk/rerun/_send_columns.py +++ b/rerun_py/rerun_sdk/rerun/_send_columns.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Iterable, Protocol, TypeVar, Union +from typing import Iterable, Protocol, TypeVar import pyarrow as pa import rerun_bindings as bindings @@ -121,7 +121,7 @@ def as_arrow_array(self) -> pa.Array: def send_columns( entity_path: str, times: Iterable[TimeColumnLike], - components: Iterable[Union[ComponentBatchLike]], + components: Iterable[ComponentBatchLike], recording: RecordingStream | None = None, strict: bool | None = None, ) -> None: diff --git a/rerun_py/rerun_sdk/rerun/archetypes/image_ext.py b/rerun_py/rerun_sdk/rerun/archetypes/image_ext.py index 8e77711a44c7..8c31e41bfe4f 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/image_ext.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/image_ext.py @@ -18,6 +18,8 @@ from ..error_utils import _send_warning_or_raise, catch_and_log_exceptions if TYPE_CHECKING: + from PIL import Image as PILImage + ImageLike = Union[ npt.NDArray[np.float16], npt.NDArray[np.float32], @@ -30,18 +32,23 @@ npt.NDArray[np.uint32], npt.NDArray[np.uint64], npt.NDArray[np.uint8], + PILImage.Image, ] from . import EncodedImage, Image def _to_numpy(tensor: ImageLike) -> npt.NDArray[Any]: + from PIL import Image as PILImage + # isinstance is 4x faster than catching AttributeError if isinstance(tensor, np.ndarray): return tensor + if isinstance(tensor, PILImage.Image): + return np.array(tensor, copy=False) try: # Make available to the cpu - return tensor.numpy(force=True) # type: ignore[union-attr] + return tensor.numpy(force=True) # type: ignore[union-attr, no-any-return] except AttributeError: return np.array(tensor, copy=False) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index 7c61132e3f62..1d0779e1ac40 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -13,6 +13,7 @@ force_position.py linguist-generated=true line_grid3d.py linguist-generated=true map_background.py linguist-generated=true map_zoom.py linguist-generated=true +near_clip_plane.py linguist-generated=true panel_blueprint.py linguist-generated=true plot_legend.py linguist-generated=true scalar_axis.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 897b98f6da68..45d0221ebd08 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -13,6 +13,7 @@ from .line_grid3d import LineGrid3D from .map_background import MapBackground from .map_zoom import MapZoom +from .near_clip_plane import NearClipPlane from .panel_blueprint import PanelBlueprint from .plot_legend import PlotLegend from .scalar_axis import ScalarAxis @@ -37,6 +38,7 @@ "LineGrid3D", "MapBackground", "MapZoom", + "NearClipPlane", "PanelBlueprint", "PlotLegend", "ScalarAxis", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/near_clip_plane.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/near_clip_plane.py new file mode 100644 index 000000000000..dee3bdaccadb --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/near_clip_plane.py @@ -0,0 +1,69 @@ +# 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/near_clip_plane.fbs". + +# You can extend this class by creating a "NearClipPlaneExt" class in "near_clip_plane_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__ = ["NearClipPlane"] + + +@define(str=False, repr=False, init=False) +class NearClipPlane(Archetype): + """**Archetype**: Controls the distance to the near clip plane in 3D scene units.""" + + def __init__(self: Any, near_clip_plane: datatypes.Float32Like): + """ + Create a new instance of the NearClipPlane archetype. + + Parameters + ---------- + near_clip_plane: + Controls the distance to the near clip plane in 3D scene units. + + Content closer than this distance will not be visible. + + """ + + # You can define your own __init__ function as a member of NearClipPlaneExt in near_clip_plane_ext.py + with catch_and_log_exceptions(context=self.__class__.__name__): + self.__attrs_init__(near_clip_plane=near_clip_plane) + return + self.__attrs_clear__() + + def __attrs_clear__(self) -> None: + """Convenience method for calling `__attrs_init__` with all `None`s.""" + self.__attrs_init__( + near_clip_plane=None, # type: ignore[arg-type] + ) + + @classmethod + def _clear(cls) -> NearClipPlane: + """Produce an empty NearClipPlane, bypassing `__init__`.""" + inst = cls.__new__(cls) + inst.__attrs_clear__() + return inst + + near_clip_plane: blueprint_components.NearClipPlaneBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.NearClipPlaneBatch._required, # type: ignore[misc] + ) + # Controls the distance to the near clip plane in 3D scene units. + # + # Content closer than this distance will not be visible. + # + # (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/visual_bounds2d.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py index 110ebd5c2d69..7a6a5159dc0b 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py @@ -34,7 +34,6 @@ def __attrs_clear__(self) -> None: """Convenience method for calling `__attrs_init__` with all `None`s.""" self.__attrs_init__( range=None, # type: ignore[arg-type] - near_clip_plane=None, # type: ignore[arg-type] ) @classmethod @@ -54,15 +53,5 @@ def _clear(cls) -> VisualBounds2D: # # (Docstring intentionally commented out to hide this field from the docs) - near_clip_plane: blueprint_components.NearClipPlaneBatch = field( - metadata={"component": "required"}, - converter=blueprint_components.NearClipPlaneBatch._required, # type: ignore[misc] - ) - # Controls the distance to the near clip plane in 3D scene units. - # - # Content closer than this distance will not be visible. - # - # (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/visual_bounds2d_ext.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py index f28c2ae1f359..05a427e30cfe 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py @@ -15,7 +15,6 @@ def __init__( *, x_range: datatypes.Range1DLike | None = None, y_range: datatypes.Range1DLike | None = None, - near_clip_plane: datatypes.Float32Like | None = None, ): """ Create a new instance of the VisualBounds2D archetype. @@ -26,8 +25,6 @@ def __init__( The minimum visible range of the X-axis (usually left and right bounds). y_range: The minimum visible range of the Y-axis (usually left and right bounds). - near_clip_plane: - The distance to the near clipping plane. """ @@ -41,7 +38,6 @@ def __init__( with catch_and_log_exceptions(context=self.__class__.__name__): self.__attrs_init__( range=range, - near_clip_plane=near_clip_plane, ) return self.__attrs_clear__() diff --git a/rerun_py/rerun_sdk/rerun/components/color.py b/rerun_py/rerun_sdk/rerun/components/color.py index 5d72204fde68..122a0a9cfd7f 100644 --- a/rerun_py/rerun_sdk/rerun/components/color.py +++ b/rerun_py/rerun_sdk/rerun/components/color.py @@ -11,11 +11,12 @@ ComponentDescriptor, ComponentMixin, ) +from .color_ext import ColorExt __all__ = ["Color", "ColorBatch"] -class Color(datatypes.Rgba32, ComponentMixin): +class Color(ColorExt, datatypes.Rgba32, ComponentMixin): """ **Component**: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha. diff --git a/rerun_py/rerun_sdk/rerun/components/color_ext.py b/rerun_py/rerun_sdk/rerun/components/color_ext.py new file mode 100644 index 000000000000..b06d2f7c9624 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/components/color_ext.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +import colorsys +import math +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from . import Color + +_GOLDEN_RATIO = (math.sqrt(5.0) - 1.0) / 2.0 + + +class ColorExt: + """Extension for [Color][rerun.components.Color].""" + + @staticmethod + def from_string(s: str) -> Color: + """ + Generate a random yet deterministic color based on a string. + + The color is guaranteed to be identical for the same input string. + """ + + from . import Color + + # adapted from egui::PlotUi + hue = (hash(s) & 0xFFFF) / 2**16 * _GOLDEN_RATIO + return Color([round(comp * 255) for comp in colorsys.hsv_to_rgb(hue, 0.85, 0.5)]) diff --git a/rerun_py/src/remote.rs b/rerun_py/src/remote.rs index b8af391dd922..a74f3a1a0666 100644 --- a/rerun_py/src/remote.rs +++ b/rerun_py/src/remote.rs @@ -81,7 +81,7 @@ pub struct PyStorageNodeClient { #[pymethods] impl PyStorageNodeClient { - /// Query the recordings metadata catalog. + /// Get the metadata for all recordings in the storage node. fn query_catalog(&mut self) -> PyResult>> { let reader = self.runtime.block_on(async { // TODO(jleibs): Support column projection and filtering