diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs index 625ddb9f0271..f1a11d176958 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes.fbs @@ -3,7 +3,6 @@ include "./archetypes/background.fbs"; include "./archetypes/container_blueprint.fbs"; include "./archetypes/dataframe_query.fbs"; -include "./archetypes/dataframe_visible_columns.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/dataframe_visible_columns.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/dataframe_visible_columns.fbs deleted file mode 100644 index f8f527ca2af0..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/dataframe_visible_columns.fbs +++ /dev/null @@ -1,18 +0,0 @@ -namespace rerun.blueprint.archetypes; - - -/// Which columns should be displayed by the dataframe view. -table DataframeVisibleColumns ( - "attr.rerun.scope": "blueprint" -) { - // --- Optional --- - - /// Are all column selected, or only those specified by the user? - selection_mode: rerun.blueprint.components.ColumnSelectionMode ("attr.rerun.component_optional", nullable, order: 100); - - /// The time columns to include (if mode is set to "Selected"). - time_columns: [rerun.blueprint.components.TimelineName] ("attr.rerun.component_optional", nullable, order: 200); - - /// The component columns to include (if mode is set to "Selected"). - component_columns: [rerun.blueprint.components.ComponentColumnSelector] ("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 bba11a44b2f9..e2d03b25554c 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -5,7 +5,6 @@ include "./components/apply_latest_at.fbs"; include "./components/auto_layout.fbs"; include "./components/auto_space_views.fbs"; include "./components/background_kind.fbs"; -include "./components/column_selection_mode.fbs"; include "./components/column_share.fbs"; include "./components/component_column_selector.fbs"; include "./components/container_kind.fbs"; diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/column_selection_mode.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/column_selection_mode.fbs deleted file mode 100644 index 4320b30ae7fd..000000000000 --- a/crates/store/re_types/definitions/rerun/blueprint/components/column_selection_mode.fbs +++ /dev/null @@ -1,16 +0,0 @@ -namespace rerun.blueprint.components; - - -/// How are columns selected in the dataframe view? -enum ColumnSelectionMode: ubyte ( - "attr.rerun.scope": "blueprint" -) { - /// Invalid value. Won't show up in generated types. - Invalid = 0, - - /// Show all columns returned by the query. - All = 1 (default), - - /// Show only the columns specified by the user. - Selected = 2, -} diff --git a/crates/store/re_types/src/blueprint/archetypes/.gitattributes b/crates/store/re_types/src/blueprint/archetypes/.gitattributes index b1f386517f06..ced82b80ceda 100644 --- a/crates/store/re_types/src/blueprint/archetypes/.gitattributes +++ b/crates/store/re_types/src/blueprint/archetypes/.gitattributes @@ -4,7 +4,6 @@ background.rs linguist-generated=true dataframe_query.rs linguist-generated=true dataframe_query_v2.rs linguist-generated=true -dataframe_visible_columns.rs linguist-generated=true mod.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/dataframe_visible_columns.rs b/crates/store/re_types/src/blueprint/archetypes/dataframe_visible_columns.rs deleted file mode 100644 index 413ec7281832..000000000000 --- a/crates/store/re_types/src/blueprint/archetypes/dataframe_visible_columns.rs +++ /dev/null @@ -1,256 +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/dataframe_visible_columns.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**: Which columns should be displayed by the dataframe view. -#[derive(Clone, Debug)] -pub struct DataframeVisibleColumns { - /// Are all column selected, or only those specified by the user? - pub selection_mode: Option, - - /// The time columns to include (if mode is set to "Selected"). - pub time_columns: Option>, - - /// The component columns to include (if mode is set to "Selected"). - pub component_columns: Option>, -} - -impl ::re_types_core::SizeBytes for DataframeVisibleColumns { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.selection_mode.heap_size_bytes() - + self.time_columns.heap_size_bytes() - + self.component_columns.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.DataframeVisibleColumnsIndicator".into()] - }); - -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = - once_cell::sync::Lazy::new(|| { - [ - "rerun.blueprint.components.ColumnSelectionMode".into(), - "rerun.blueprint.components.TimelineName".into(), - "rerun.blueprint.components.ComponentColumnSelector".into(), - ] - }); - -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 4usize]> = - once_cell::sync::Lazy::new(|| { - [ - "rerun.blueprint.components.DataframeVisibleColumnsIndicator".into(), - "rerun.blueprint.components.ColumnSelectionMode".into(), - "rerun.blueprint.components.TimelineName".into(), - "rerun.blueprint.components.ComponentColumnSelector".into(), - ] - }); - -impl DataframeVisibleColumns { - /// The total number of components in the archetype: 0 required, 1 recommended, 3 optional - pub const NUM_COMPONENTS: usize = 4usize; -} - -/// Indicator component for the [`DataframeVisibleColumns`] [`::re_types_core::Archetype`] -pub type DataframeVisibleColumnsIndicator = - ::re_types_core::GenericIndicatorComponent; - -impl ::re_types_core::Archetype for DataframeVisibleColumns { - type Indicator = DataframeVisibleColumnsIndicator; - - #[inline] - fn name() -> ::re_types_core::ArchetypeName { - "rerun.blueprint.archetypes.DataframeVisibleColumns".into() - } - - #[inline] - fn display_name() -> &'static str { - "Dataframe visible columns" - } - - #[inline] - fn indicator() -> MaybeOwnedComponentBatch<'static> { - static INDICATOR: DataframeVisibleColumnsIndicator = - DataframeVisibleColumnsIndicator::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_arrow_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 selection_mode = if let Some(array) = - arrays_by_name.get("rerun.blueprint.components.ColumnSelectionMode") - { - ::from_arrow_opt(&**array) - .with_context("rerun.blueprint.archetypes.DataframeVisibleColumns#selection_mode")? - .into_iter() - .next() - .flatten() - } else { - None - }; - let time_columns = - if let Some(array) = arrays_by_name.get("rerun.blueprint.components.TimelineName") { - Some({ - ::from_arrow_opt(&**array) - .with_context( - "rerun.blueprint.archetypes.DataframeVisibleColumns#time_columns", - )? - .into_iter() - .map(|v| v.ok_or_else(DeserializationError::missing_data)) - .collect::>>() - .with_context( - "rerun.blueprint.archetypes.DataframeVisibleColumns#time_columns", - )? - }) - } else { - None - }; - let component_columns = if let Some(array) = - arrays_by_name.get("rerun.blueprint.components.ComponentColumnSelector") - { - Some({ - ::from_arrow_opt(&**array) - .with_context( - "rerun.blueprint.archetypes.DataframeVisibleColumns#component_columns", - )? - .into_iter() - .map(|v| v.ok_or_else(DeserializationError::missing_data)) - .collect::>>() - .with_context( - "rerun.blueprint.archetypes.DataframeVisibleColumns#component_columns", - )? - }) - } else { - None - }; - Ok(Self { - selection_mode, - time_columns, - component_columns, - }) - } -} - -impl ::re_types_core::AsComponents for DataframeVisibleColumns { - fn as_component_batches(&self) -> Vec> { - re_tracing::profile_function!(); - use ::re_types_core::Archetype as _; - [ - Some(Self::indicator()), - self.selection_mode - .as_ref() - .map(|comp| (comp as &dyn ComponentBatch).into()), - self.time_columns - .as_ref() - .map(|comp_batch| (comp_batch as &dyn ComponentBatch).into()), - self.component_columns - .as_ref() - .map(|comp_batch| (comp_batch as &dyn ComponentBatch).into()), - ] - .into_iter() - .flatten() - .collect() - } -} - -impl ::re_types_core::ArchetypeReflectionMarker for DataframeVisibleColumns {} - -impl DataframeVisibleColumns { - /// Create a new `DataframeVisibleColumns`. - #[inline] - pub fn new() -> Self { - Self { - selection_mode: None, - time_columns: None, - component_columns: None, - } - } - - /// Are all column selected, or only those specified by the user? - #[inline] - pub fn with_selection_mode( - mut self, - selection_mode: impl Into, - ) -> Self { - self.selection_mode = Some(selection_mode.into()); - self - } - - /// The time columns to include (if mode is set to "Selected"). - #[inline] - pub fn with_time_columns( - mut self, - time_columns: impl IntoIterator>, - ) -> Self { - self.time_columns = Some(time_columns.into_iter().map(Into::into).collect()); - self - } - - /// The component columns to include (if mode is set to "Selected"). - #[inline] - pub fn with_component_columns( - mut self, - component_columns: impl IntoIterator< - Item = impl Into, - >, - ) -> Self { - self.component_columns = Some(component_columns.into_iter().map(Into::into).collect()); - self - } -} diff --git a/crates/store/re_types/src/blueprint/archetypes/mod.rs b/crates/store/re_types/src/blueprint/archetypes/mod.rs index cb7c8e466971..8e48933ed614 100644 --- a/crates/store/re_types/src/blueprint/archetypes/mod.rs +++ b/crates/store/re_types/src/blueprint/archetypes/mod.rs @@ -3,7 +3,6 @@ mod background; mod dataframe_query; mod dataframe_query_v2; -mod dataframe_visible_columns; mod plot_legend; mod scalar_axis; mod space_view_blueprint; @@ -18,7 +17,6 @@ mod visual_bounds2d; pub use self::background::Background; pub use self::dataframe_query::DataframeQuery; pub use self::dataframe_query_v2::DataframeQueryV2; -pub use self::dataframe_visible_columns::DataframeVisibleColumns; pub use self::plot_legend::PlotLegend; pub use self::scalar_axis::ScalarAxis; pub use self::space_view_blueprint::SpaceViewBlueprint; diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index 9f55f576a5e4..18fe2582947e 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -4,7 +4,6 @@ active_tab.rs linguist-generated=true apply_latest_at.rs linguist-generated=true background_kind.rs linguist-generated=true -column_selection_mode.rs linguist-generated=true column_share.rs linguist-generated=true component_column_selector.rs linguist-generated=true corner2d.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/column_selection_mode.rs b/crates/store/re_types/src/blueprint/components/column_selection_mode.rs deleted file mode 100644 index a49674897a07..000000000000 --- a/crates/store/re_types/src/blueprint/components/column_selection_mode.rs +++ /dev/null @@ -1,150 +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/column_selection_mode.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**: How are columns selected in the dataframe view? -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)] -#[repr(u8)] -pub enum ColumnSelectionMode { - /// Show all columns returned by the query. - #[default] - All = 1, - - /// Show only the columns specified by the user. - Selected = 2, -} - -impl ::re_types_core::reflection::Enum for ColumnSelectionMode { - #[inline] - fn variants() -> &'static [Self] { - &[Self::All, Self::Selected] - } - - #[inline] - fn docstring_md(self) -> &'static str { - match self { - Self::All => "Show all columns returned by the query.", - Self::Selected => "Show only the columns specified by the user.", - } - } -} - -impl ::re_types_core::SizeBytes for ColumnSelectionMode { - #[inline] - fn heap_size_bytes(&self) -> u64 { - 0 - } - - #[inline] - fn is_pod() -> bool { - true - } -} - -impl std::fmt::Display for ColumnSelectionMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::All => write!(f, "All"), - Self::Selected => write!(f, "Selected"), - } - } -} - -::re_types_core::macros::impl_into_cow!(ColumnSelectionMode); - -impl ::re_types_core::Loggable for ColumnSelectionMode { - type Name = ::re_types_core::ComponentName; - - #[inline] - fn name() -> Self::Name { - "rerun.blueprint.components.ColumnSelectionMode".into() - } - - #[inline] - fn arrow_datatype() -> arrow2::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow2::datatypes::*; - DataType::UInt8 - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult> - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow2::{array::*, datatypes::*}; - Ok({ - let (somes, data0): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - let datum = datum.map(|datum| *datum as u8); - (datum.is_some(), datum) - }) - .unzip(); - let data0_bitmap: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - PrimitiveArray::new( - Self::arrow_datatype(), - data0.into_iter().map(|v| v.unwrap_or_default()).collect(), - data0_bitmap, - ) - .boxed() - }) - } - - fn from_arrow_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow2::{array::*, buffer::*, datatypes::*}; - Ok(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.components.ColumnSelectionMode#enum")? - .into_iter() - .map(|opt| opt.copied()) - .map(|typ| match typ { - Some(1) => Ok(Some(Self::All)), - Some(2) => Ok(Some(Self::Selected)), - None => Ok(None), - Some(invalid) => Err(DeserializationError::missing_union_arm( - Self::arrow_datatype(), - "", - invalid as _, - )), - }) - .collect::>>>() - .with_context("rerun.blueprint.components.ColumnSelectionMode")?) - } -} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index 2cf2a63e2479..8b7cdc140394 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -3,7 +3,6 @@ mod active_tab; mod apply_latest_at; mod background_kind; -mod column_selection_mode; mod column_share; mod component_column_selector; mod component_column_selector_ext; @@ -47,7 +46,6 @@ mod visual_bounds2d_ext; pub use self::active_tab::ActiveTab; pub use self::apply_latest_at::ApplyLatestAt; pub use self::background_kind::BackgroundKind; -pub use self::column_selection_mode::ColumnSelectionMode; pub use self::column_share::ColumnShare; pub use self::component_column_selector::ComponentColumnSelector; pub use self::corner2d::Corner2D; diff --git a/crates/viewer/re_space_view_dataframe/src/space_view_class.rs b/crates/viewer/re_space_view_dataframe/src/space_view_class.rs index a8c6aa42fe5c..347418b18b4a 100644 --- a/crates/viewer/re_space_view_dataframe/src/space_view_class.rs +++ b/crates/viewer/re_space_view_dataframe/src/space_view_class.rs @@ -1,22 +1,17 @@ use std::any::Any; -use std::collections::HashSet; -use re_chunk_store::{ColumnDescriptor, ColumnSelector}; -use re_log_types::{EntityPath, EntityPathFilter, ResolvedTimeRange, TimelineName}; -use re_types::blueprint::{archetypes, components}; +use crate::{ + dataframe_ui::dataframe_ui, expanded_rows::ExpandedRowsCache, query_kind::QueryKind, + view_query_v2, visualizer_system::EmptySystem, +}; +use re_chunk_store::ColumnDescriptor; +use re_log_types::{EntityPath, EntityPathFilter, ResolvedTimeRange}; use re_types_core::SpaceViewClassIdentifier; -use re_ui::UiExt as _; use re_viewer_context::{ SpaceViewClass, SpaceViewClassRegistryError, SpaceViewId, SpaceViewState, SpaceViewStateExt, SpaceViewSystemExecutionError, SystemExecutionOutput, ViewQuery, ViewerContext, }; -use re_viewport_blueprint::{SpaceViewContents, ViewProperty}; - -use crate::dataframe_ui::HideColumnAction; -use crate::{ - dataframe_ui::dataframe_ui, expanded_rows::ExpandedRowsCache, query_kind::QueryKind, - view_query_v2, visualizer_system::EmptySystem, -}; +use re_viewport_blueprint::SpaceViewContents; #[derive(Default)] struct DataframeSpaceViewState { @@ -124,44 +119,6 @@ mode sets the default time range to _everything_. You can override this in the s view_query.selection_panel_ui(ctx, ui, space_view_id, schema) } - fn extra_title_bar_ui( - &self, - ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - state: &mut dyn SpaceViewState, - _space_origin: &EntityPath, - space_view_id: SpaceViewId, - ) -> Result<(), SpaceViewSystemExecutionError> { - let state = state.downcast_mut::()?; - - let result = ui - .add_enabled_ui(state.schema.is_some(), |ui| { - egui::menu::menu_custom_button( - ui, - ui.small_icon_button_widget(&re_ui::icons::COLUMN_VISIBILITY), - |ui| { - let Some(schema) = &state.schema else { - // Shouldn't happen, except maybe on the first frame, which is too early - // for the user to click the menu anyway. - return Ok(()); - }; - - let view_query = - super::view_query::Query::try_from_blueprint(ctx, space_view_id)?; - let query_timeline_name = view_query.timeline_name(ctx); - - column_visibility_ui(ctx, ui, space_view_id, schema, &query_timeline_name) - }, - ) - .inner - }) - .inner; - - // Note: we get the `Result<(), SpaceViewSystemExecutionError>` from the inner closure only - // if it was actually executed. - result.unwrap_or(Ok(())) - } - fn ui( &self, ctx: &ViewerContext<'_>, @@ -193,6 +150,9 @@ mode sets the default time range to _everything_. You can override this in the s let entity_path_filter = Self::entity_path_filter(ctx, query.space_view_id, query.space_origin); + // use the new query for column visibility + let query_v2 = view_query_v2::QueryV2::from_blueprint(ctx, query.space_view_id); + let (schema, hide_column_actions) = match query_mode { QueryKind::LatestAt { time } => { let query = re_chunk_store::LatestAtQueryExpression { @@ -203,7 +163,7 @@ mode sets the default time range to _everything_. You can override this in the s let schema = query_engine.schema_for_query(&query.clone().into()); let selected_columns = - apply_column_visibility_to_schema(ctx, space_view_id, &timeline_name, &schema)?; + query_v2.apply_column_visibility_to_view_columns(ctx, &schema)?; let hide_column_actions = dataframe_ui( ctx, @@ -234,7 +194,7 @@ mode sets the default time range to _everything_. You can override this in the s let schema = query_engine.schema_for_query(&query.clone().into()); let selected_columns = - apply_column_visibility_to_schema(ctx, space_view_id, &timeline_name, &schema)?; + query_v2.apply_column_visibility_to_view_columns(ctx, &schema)?; let hide_column_actions = dataframe_ui( ctx, @@ -247,7 +207,7 @@ mode sets the default time range to _everything_. You can override this in the s } }; - handle_hide_column_actions(ctx, space_view_id, &schema, hide_column_actions)?; + query_v2.handle_hide_column_actions(ctx, &schema, hide_column_actions)?; // make schema accessible to the column visibility UI state.schema = Some(schema); @@ -256,298 +216,6 @@ mode sets the default time range to _everything_. You can override this in the s } } -/// Reads the blueprint configuration for column visibility, applies it to the schema, and returns -/// a [`re_dataframe::QueryEngine`]-compatible column selection. -fn apply_column_visibility_to_schema( - ctx: &ViewerContext<'_>, - space_view_id: SpaceViewId, - query_timeline_name: &TimelineName, - schema: &[ColumnDescriptor], -) -> Result>, SpaceViewSystemExecutionError> { - let property = ViewProperty::from_archetype::( - ctx.blueprint_db(), - ctx.blueprint_query, - space_view_id, - ); - - let column_selection_mode = property - .component_or_empty::()? - .unwrap_or_default(); - - if column_selection_mode == components::ColumnSelectionMode::All { - return Ok(None); - } - - let selected_time_columns = property - .component_array_or_empty::()? - .into_iter() - .collect::>(); - - let selected_component_columns = property - .component_array_or_empty::()? - .into_iter() - .collect::>(); - - let result = schema - .iter() - .filter(|column| match column { - ColumnDescriptor::Control(_) => true, - ColumnDescriptor::Time(desc) => { - // we always include the query timeline column because we need it for the dataframe ui - desc.timeline.name() == query_timeline_name - || selected_time_columns - .contains(&components::TimelineName::from_timeline(&desc.timeline)) - } - ColumnDescriptor::Component(desc) => { - let blueprint_component_descriptor = components::ComponentColumnSelector::new( - &desc.entity_path, - desc.component_name, - ); - - selected_component_columns.contains(&blueprint_component_descriptor) - } - }) - .cloned() - .map(ColumnSelector::from) - .collect(); - - Ok(Some(result)) -} - -/// Act upon any action triggered by the dataframe UI. -fn handle_hide_column_actions( - ctx: &ViewerContext<'_>, - space_view_id: SpaceViewId, - schema: &[ColumnDescriptor], - actions: Vec, -) -> Result<(), SpaceViewSystemExecutionError> { - if actions.is_empty() { - return Ok(()); - } - - let property = ViewProperty::from_archetype::( - ctx.blueprint_db(), - ctx.blueprint_query, - space_view_id, - ); - - let mut column_selection_mode = property - .component_or_empty::()? - .unwrap_or_default(); - - // We are hiding some columns, so we need to handle the switch from "All" to "Selected". When - // that happens, we default to selecting all time columns and all component columns. - let (mut selected_time_columns, mut selected_component_columns) = - if column_selection_mode == components::ColumnSelectionMode::All { - column_selection_mode = components::ColumnSelectionMode::Selected; - property.save_blueprint_component(ctx, &column_selection_mode); - - let selected_time_columns = schema - .iter() - .filter_map(|column| match column { - ColumnDescriptor::Time(desc) => { - Some(components::TimelineName::from_timeline(&desc.timeline)) - } - _ => None, - }) - .collect::>(); - - let selected_component_columns = schema - .iter() - .filter_map(|column| match column { - ColumnDescriptor::Component(desc) => { - Some(components::ComponentColumnSelector::new( - &desc.entity_path, - desc.component_name, - )) - } - _ => None, - }) - .collect::>(); - - (selected_time_columns, selected_component_columns) - } else { - ( - property.component_array_or_empty::()?, - property.component_array_or_empty::()?, - ) - }; - - for action in actions { - match action { - HideColumnAction::HideTimeColumn { timeline_name } => { - selected_time_columns - .retain(|name| name != &components::TimelineName::from(timeline_name.as_str())); - } - - HideColumnAction::HideComponentColumn { - entity_path, - component_name, - } => { - let blueprint_component_descriptor = - components::ComponentColumnSelector::new(&entity_path, component_name); - selected_component_columns.retain(|desc| desc != &blueprint_component_descriptor); - } - } - } - - property.save_blueprint_component(ctx, &selected_time_columns); - property.save_blueprint_component(ctx, &selected_component_columns); - - Ok(()) -} - -fn column_visibility_ui( - ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - space_view_id: SpaceViewId, - schema: &[ColumnDescriptor], - query_timeline_name: &TimelineName, -) -> Result<(), SpaceViewSystemExecutionError> { - let property = ViewProperty::from_archetype::( - ctx.blueprint_db(), - ctx.blueprint_query, - space_view_id, - ); - - let menu_ui = |ui: &mut egui::Ui| -> Result<(), SpaceViewSystemExecutionError> { - ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend); - - // - // All or selected? - // - - let mut column_selection_mode = property - .component_or_empty::()? - .unwrap_or_default(); - - let changed = { - ui.re_radio_value( - &mut column_selection_mode, - components::ColumnSelectionMode::All, - "All", - ) - .changed() - } | { - ui.re_radio_value( - &mut column_selection_mode, - components::ColumnSelectionMode::Selected, - "Selected", - ) - .changed() - }; - - if changed { - property.save_blueprint_component(ctx, &column_selection_mode); - } - - // - // Selected time columns - // - - let mut selected_time_columns = property - .component_array_or_empty::()? - .into_iter() - .collect::>(); - - ui.label("Timelines"); - - let mut changed = false; - for column in schema { - let ColumnDescriptor::Time(time_column_descriptor) = column else { - continue; - }; - - let is_query_timeline = time_column_descriptor.timeline.name() == query_timeline_name; - let is_enabled = !is_query_timeline - && column_selection_mode == components::ColumnSelectionMode::Selected; - let mut is_visible = is_query_timeline - || selected_time_columns.contains(&components::TimelineName::from_timeline( - &time_column_descriptor.timeline, - )); - - ui.add_enabled_ui(is_enabled, |ui| { - if ui - .re_checkbox(&mut is_visible, column.short_name()) - .on_disabled_hover_text("The query timeline must always be visible") - .changed() - { - changed = true; - - let timeline_name = - components::TimelineName::from_timeline(&time_column_descriptor.timeline); - if is_visible { - selected_time_columns.insert(timeline_name); - } else { - selected_time_columns.remove(&timeline_name); - } - } - }); - } - - if changed { - let selected_time_columns = selected_time_columns.into_iter().collect::>(); - property.save_blueprint_component(ctx, &selected_time_columns); - } - - // - // Selected component columns - // - - let mut selected_component_columns = property - .component_array_or_empty::()? - .into_iter() - .collect::>(); - - let mut current_entity = None; - let mut changed = false; - for column in schema { - let ColumnDescriptor::Component(component_column_descriptor) = column else { - continue; - }; - - if Some(&component_column_descriptor.entity_path) != current_entity.as_ref() { - current_entity = Some(component_column_descriptor.entity_path.clone()); - ui.label(component_column_descriptor.entity_path.to_string()); - } - - let blueprint_component_descriptor = components::ComponentColumnSelector::new( - &component_column_descriptor.entity_path, - component_column_descriptor.component_name, - ); - - let is_enabled = column_selection_mode == components::ColumnSelectionMode::Selected; - let mut is_visible = - selected_component_columns.contains(&blueprint_component_descriptor); - - ui.add_enabled_ui(is_enabled, |ui| { - if ui - .re_checkbox(&mut is_visible, column.short_name()) - .changed() - { - changed = true; - - if is_visible { - selected_component_columns.insert(blueprint_component_descriptor); - } else { - selected_component_columns.remove(&blueprint_component_descriptor); - } - } - }); - } - - if changed { - let selected_component_columns = - selected_component_columns.into_iter().collect::>(); - property.save_blueprint_component(ctx, &selected_component_columns); - } - - Ok(()) - }; - - egui::ScrollArea::vertical().show(ui, menu_ui).inner -} - impl DataframeSpaceView { fn entity_path_filter( ctx: &ViewerContext<'_>, diff --git a/crates/viewer/re_space_view_dataframe/src/view_query_v2/blueprint.rs b/crates/viewer/re_space_view_dataframe/src/view_query_v2/blueprint.rs index 55af18c8d08f..b5d981665cb0 100644 --- a/crates/viewer/re_space_view_dataframe/src/view_query_v2/blueprint.rs +++ b/crates/viewer/re_space_view_dataframe/src/view_query_v2/blueprint.rs @@ -196,7 +196,6 @@ impl QueryV2 { Ok(Some(result)) } - #[allow(dead_code)] //TODO(ab): used in next PR pub(crate) fn handle_hide_column_actions( &self, ctx: &ViewerContext<'_>, 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 73f857bb01fb..c8496ca62280 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -4,7 +4,6 @@ use re_entity_db::EntityDb; pub use re_types::blueprint::components::ActiveTab; pub use re_types::blueprint::components::ApplyLatestAt; pub use re_types::blueprint::components::BackgroundKind; -pub use re_types::blueprint::components::ColumnSelectionMode; pub use re_types::blueprint::components::ColumnShare; pub use re_types::blueprint::components::ComponentColumnSelector; pub use re_types::blueprint::components::Corner2D; @@ -47,7 +46,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) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 20554b3835f1..a16bfbfcb590 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -69,13 +69,6 @@ fn generate_component_reflection() -> Result::name(), - ComponentReflection { - docstring_md: "How are columns selected in the dataframe view?", - placeholder: Some(ColumnSelectionMode::default().to_arrow()?), - }, - ), ( ::name(), ComponentReflection { @@ -1638,27 +1631,6 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { ], }, ), - ( - ArchetypeName::new("rerun.blueprint.archetypes.DataframeVisibleColumns"), - ArchetypeReflection { - display_name: "Dataframe visible columns", - fields: vec![ - ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ColumnSelectionMode".into(), display_name - : "Selection mode", docstring_md : - "Are all column selected, or only those specified by the user?", - is_required : false, }, ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.TimelineName".into(), display_name : - "Time columns", docstring_md : - "The time columns to include (if mode is set to \"Selected\").", - is_required : false, }, ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ComponentColumnSelector".into(), - display_name : "Component columns", docstring_md : - "The component columns to include (if mode is set to \"Selected\").", - is_required : false, }, - ], - }, - ), ( ArchetypeName::new("rerun.blueprint.archetypes.PanelBlueprint"), ArchetypeReflection { diff --git a/rerun_cpp/src/rerun/blueprint/archetypes.hpp b/rerun_cpp/src/rerun/blueprint/archetypes.hpp index c7bb76cc5a57..3915908e6432 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes.hpp @@ -6,7 +6,6 @@ #include "blueprint/archetypes/container_blueprint.hpp" #include "blueprint/archetypes/dataframe_query.hpp" #include "blueprint/archetypes/dataframe_query_v2.hpp" -#include "blueprint/archetypes/dataframe_visible_columns.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 c0639074ebf8..c4a06635d4c0 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/archetypes/.gitattributes @@ -9,8 +9,6 @@ dataframe_query.cpp linguist-generated=true dataframe_query.hpp linguist-generated=true dataframe_query_v2.cpp linguist-generated=true dataframe_query_v2.hpp linguist-generated=true -dataframe_visible_columns.cpp linguist-generated=true -dataframe_visible_columns.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/dataframe_visible_columns.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/dataframe_visible_columns.cpp deleted file mode 100644 index a7b95eedf796..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/dataframe_visible_columns.cpp +++ /dev/null @@ -1,44 +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/dataframe_visible_columns.fbs". - -#include "dataframe_visible_columns.hpp" - -#include "../../collection_adapter_builtins.hpp" - -namespace rerun::blueprint::archetypes {} - -namespace rerun { - - Result> - AsComponents::serialize( - const blueprint::archetypes::DataframeVisibleColumns& archetype - ) { - using namespace blueprint::archetypes; - std::vector cells; - cells.reserve(4); - - if (archetype.selection_mode.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.selection_mode.value()); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - if (archetype.time_columns.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.time_columns.value()); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - if (archetype.component_columns.has_value()) { - auto result = ComponentBatch::from_loggable(archetype.component_columns.value()); - RR_RETURN_NOT_OK(result.error); - cells.push_back(std::move(result.value)); - } - { - auto indicator = DataframeVisibleColumns::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/dataframe_visible_columns.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/dataframe_visible_columns.hpp deleted file mode 100644 index 199b1b473075..000000000000 --- a/rerun_cpp/src/rerun/blueprint/archetypes/dataframe_visible_columns.hpp +++ /dev/null @@ -1,87 +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/dataframe_visible_columns.fbs". - -#pragma once - -#include "../../blueprint/components/column_selection_mode.hpp" -#include "../../blueprint/components/component_column_selector.hpp" -#include "../../blueprint/components/timeline_name.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**: Which columns should be displayed by the dataframe view. - struct DataframeVisibleColumns { - /// Are all column selected, or only those specified by the user? - std::optional selection_mode; - - /// The time columns to include (if mode is set to "Selected"). - std::optional> time_columns; - - /// The component columns to include (if mode is set to "Selected"). - std::optional> - component_columns; - - public: - static constexpr const char IndicatorComponentName[] = - "rerun.blueprint.components.DataframeVisibleColumnsIndicator"; - - /// Indicator component, used to identify the archetype when converting to a list of components. - using IndicatorComponent = rerun::components::IndicatorComponent; - - public: - DataframeVisibleColumns() = default; - DataframeVisibleColumns(DataframeVisibleColumns&& other) = default; - - /// Are all column selected, or only those specified by the user? - DataframeVisibleColumns with_selection_mode( - rerun::blueprint::components::ColumnSelectionMode _selection_mode - ) && { - selection_mode = std::move(_selection_mode); - // See: https://github.com/rerun-io/rerun/issues/4027 - RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) - } - - /// The time columns to include (if mode is set to "Selected"). - DataframeVisibleColumns with_time_columns( - Collection _time_columns - ) && { - time_columns = std::move(_time_columns); - // See: https://github.com/rerun-io/rerun/issues/4027 - RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);) - } - - /// The component columns to include (if mode is set to "Selected"). - DataframeVisibleColumns with_component_columns( - Collection _component_columns - ) && { - component_columns = std::move(_component_columns); - // 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::DataframeVisibleColumns& archetype - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index ea4cfda9b831..fe7c63c22b40 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -7,7 +7,6 @@ #include "blueprint/components/auto_layout.hpp" #include "blueprint/components/auto_space_views.hpp" #include "blueprint/components/background_kind.hpp" -#include "blueprint/components/column_selection_mode.hpp" #include "blueprint/components/column_share.hpp" #include "blueprint/components/component_column_selector.hpp" #include "blueprint/components/container_kind.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index 4ab15e2bb668..ce4345c5411a 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -7,8 +7,6 @@ auto_layout.hpp linguist-generated=true auto_space_views.hpp linguist-generated=true background_kind.cpp linguist-generated=true background_kind.hpp linguist-generated=true -column_selection_mode.cpp linguist-generated=true -column_selection_mode.hpp linguist-generated=true column_share.hpp linguist-generated=true component_column_selector.hpp linguist-generated=true container_kind.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/column_selection_mode.cpp b/rerun_cpp/src/rerun/blueprint/components/column_selection_mode.cpp deleted file mode 100644 index ea8ba49f48db..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/column_selection_mode.cpp +++ /dev/null @@ -1,61 +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/column_selection_mode.fbs". - -#include "column_selection_mode.hpp" - -#include -#include - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::uint8(); - return datatype; - } - - Result> - Loggable::to_arrow( - const blueprint::components::ColumnSelectionMode* 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::UInt8Builder* builder, const blueprint::components::ColumnSelectionMode* 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." - ); - } - - ARROW_RETURN_NOT_OK(builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - const auto variant = elements[elem_idx]; - ARROW_RETURN_NOT_OK(builder->Append(static_cast(variant))); - } - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/blueprint/components/column_selection_mode.hpp b/rerun_cpp/src/rerun/blueprint/components/column_selection_mode.hpp deleted file mode 100644 index dbaae7fdacac..000000000000 --- a/rerun_cpp/src/rerun/blueprint/components/column_selection_mode.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/components/column_selection_mode.fbs". - -#pragma once - -#include "../../result.hpp" - -#include -#include - -namespace arrow { - /// \private - template - class NumericBuilder; - - class Array; - class DataType; - class UInt8Type; - using UInt8Builder = NumericBuilder; -} // namespace arrow - -namespace rerun::blueprint::components { - /// **Component**: How are columns selected in the dataframe view? - enum class ColumnSelectionMode : uint8_t { - - /// Show all columns returned by the query. - All = 1, - - /// Show only the columns specified by the user. - Selected = 2, - }; -} // namespace rerun::blueprint::components - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ColumnSelectionMode"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::blueprint:: components::ColumnSelectionMode` into an arrow array. - static Result> to_arrow( - const blueprint::components::ColumnSelectionMode* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::UInt8Builder* builder, - const blueprint::components::ColumnSelectionMode* elements, size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/blueprint/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/__init__.py index 10450ec4404e..8ec8a0cc53ce 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/__init__.py @@ -30,7 +30,6 @@ from .archetypes import ( Background as Background, DataframeQuery as DataframeQuery, - DataframeVisibleColumns as DataframeVisibleColumns, PlotLegend as PlotLegend, ScalarAxis as ScalarAxis, TensorScalarMapping as TensorScalarMapping, diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes index 1e43163fe811..3916525a8bcd 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/.gitattributes @@ -6,7 +6,6 @@ background.py linguist-generated=true container_blueprint.py linguist-generated=true dataframe_query.py linguist-generated=true dataframe_query_v2.py linguist-generated=true -dataframe_visible_columns.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 7559a42e447d..2eefb2ec1ef0 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/__init__.py @@ -6,7 +6,6 @@ from .container_blueprint import ContainerBlueprint from .dataframe_query import DataframeQuery from .dataframe_query_v2 import DataframeQueryV2 -from .dataframe_visible_columns import DataframeVisibleColumns from .panel_blueprint import PanelBlueprint from .plot_legend import PlotLegend from .scalar_axis import ScalarAxis @@ -24,7 +23,6 @@ "ContainerBlueprint", "DataframeQuery", "DataframeQueryV2", - "DataframeVisibleColumns", "PanelBlueprint", "PlotLegend", "ScalarAxis", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/dataframe_visible_columns.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/dataframe_visible_columns.py deleted file mode 100644 index 7d7afeb7a8e6..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/dataframe_visible_columns.py +++ /dev/null @@ -1,98 +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/dataframe_visible_columns.fbs". - -# You can extend this class by creating a "DataframeVisibleColumnsExt" class in "dataframe_visible_columns_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, datatypes as blueprint_datatypes -from ...error_utils import catch_and_log_exceptions - -__all__ = ["DataframeVisibleColumns"] - - -@define(str=False, repr=False, init=False) -class DataframeVisibleColumns(Archetype): - """**Archetype**: Which columns should be displayed by the dataframe view.""" - - def __init__( - self: Any, - *, - selection_mode: blueprint_components.ColumnSelectionModeLike | None = None, - time_columns: datatypes.Utf8ArrayLike | None = None, - component_columns: blueprint_datatypes.ComponentColumnSelectorArrayLike | None = None, - ): - """ - Create a new instance of the DataframeVisibleColumns archetype. - - Parameters - ---------- - selection_mode: - Are all column selected, or only those specified by the user? - time_columns: - The time columns to include (if mode is set to "Selected"). - component_columns: - The component columns to include (if mode is set to "Selected"). - - """ - - # You can define your own __init__ function as a member of DataframeVisibleColumnsExt in dataframe_visible_columns_ext.py - with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__( - selection_mode=selection_mode, time_columns=time_columns, component_columns=component_columns - ) - return - self.__attrs_clear__() - - def __attrs_clear__(self) -> None: - """Convenience method for calling `__attrs_init__` with all `None`s.""" - self.__attrs_init__( - selection_mode=None, # type: ignore[arg-type] - time_columns=None, # type: ignore[arg-type] - component_columns=None, # type: ignore[arg-type] - ) - - @classmethod - def _clear(cls) -> DataframeVisibleColumns: - """Produce an empty DataframeVisibleColumns, bypassing `__init__`.""" - inst = cls.__new__(cls) - inst.__attrs_clear__() - return inst - - selection_mode: blueprint_components.ColumnSelectionModeBatch | None = field( - metadata={"component": "optional"}, - default=None, - converter=blueprint_components.ColumnSelectionModeBatch._optional, # type: ignore[misc] - ) - # Are all column selected, or only those specified by the user? - # - # (Docstring intentionally commented out to hide this field from the docs) - - time_columns: blueprint_components.TimelineNameBatch | None = field( - metadata={"component": "optional"}, - default=None, - converter=blueprint_components.TimelineNameBatch._optional, # type: ignore[misc] - ) - # The time columns to include (if mode is set to "Selected"). - # - # (Docstring intentionally commented out to hide this field from the docs) - - component_columns: blueprint_components.ComponentColumnSelectorBatch | None = field( - metadata={"component": "optional"}, - default=None, - converter=blueprint_components.ComponentColumnSelectorBatch._optional, # type: ignore[misc] - ) - # The component columns to include (if mode is set to "Selected"). - # - # (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 2709b58765ef..5692a1eb3387 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -7,7 +7,6 @@ apply_latest_at.py linguist-generated=true auto_layout.py linguist-generated=true auto_space_views.py linguist-generated=true background_kind.py linguist-generated=true -column_selection_mode.py linguist-generated=true column_share.py linguist-generated=true component_column_selector.py linguist-generated=true container_kind.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 553de8b34eb6..c6ccb3687857 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 @@ BackgroundKindLike, BackgroundKindType, ) -from .column_selection_mode import ( - ColumnSelectionMode, - ColumnSelectionModeArrayLike, - ColumnSelectionModeBatch, - ColumnSelectionModeLike, - ColumnSelectionModeType, -) from .column_share import ColumnShare, ColumnShareBatch, ColumnShareType from .component_column_selector import ( ComponentColumnSelector, @@ -99,11 +92,6 @@ "BackgroundKindBatch", "BackgroundKindLike", "BackgroundKindType", - "ColumnSelectionMode", - "ColumnSelectionModeArrayLike", - "ColumnSelectionModeBatch", - "ColumnSelectionModeLike", - "ColumnSelectionModeType", "ColumnShare", "ColumnShareBatch", "ColumnShareType", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/column_selection_mode.py b/rerun_py/rerun_sdk/rerun/blueprint/components/column_selection_mode.py deleted file mode 100644 index 24c9aaded089..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/column_selection_mode.py +++ /dev/null @@ -1,81 +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/column_selection_mode.fbs". - -# You can extend this class by creating a "ColumnSelectionModeExt" class in "column_selection_mode_ext.py". - -from __future__ import annotations - -from typing import Literal, Sequence, Union - -import pyarrow as pa - -from ..._baseclasses import ( - BaseBatch, - BaseExtensionType, - ComponentBatchMixin, -) - -__all__ = [ - "ColumnSelectionMode", - "ColumnSelectionModeArrayLike", - "ColumnSelectionModeBatch", - "ColumnSelectionModeLike", - "ColumnSelectionModeType", -] - - -from enum import Enum - - -class ColumnSelectionMode(Enum): - """**Component**: How are columns selected in the dataframe view?.""" - - All = 1 - """Show all columns returned by the query.""" - - Selected = 2 - """Show only the columns specified by the user.""" - - @classmethod - def auto(cls, val: str | int | ColumnSelectionMode) -> ColumnSelectionMode: - """Best-effort converter, including a case-insensitive string matcher.""" - if isinstance(val, ColumnSelectionMode): - return val - if isinstance(val, int): - return cls(val) - try: - return cls[val] - except KeyError: - val_lower = val.lower() - for variant in cls: - if variant.name.lower() == val_lower: - return variant - raise ValueError(f"Cannot convert {val} to {cls.__name__}") - - def __str__(self) -> str: - """Returns the variant name.""" - return self.name - - -ColumnSelectionModeLike = Union[ColumnSelectionMode, Literal["All", "Selected", "all", "selected"], int] -ColumnSelectionModeArrayLike = Union[ColumnSelectionModeLike, Sequence[ColumnSelectionModeLike]] - - -class ColumnSelectionModeType(BaseExtensionType): - _TYPE_NAME: str = "rerun.blueprint.components.ColumnSelectionMode" - - def __init__(self) -> None: - pa.ExtensionType.__init__(self, pa.uint8(), self._TYPE_NAME) - - -class ColumnSelectionModeBatch(BaseBatch[ColumnSelectionModeArrayLike], ComponentBatchMixin): - _ARROW_TYPE = ColumnSelectionModeType() - - @staticmethod - def _native_to_pa_array(data: ColumnSelectionModeArrayLike, data_type: pa.DataType) -> pa.Array: - if isinstance(data, (ColumnSelectionMode, int, str)): - data = [data] - - pa_data = [ColumnSelectionMode.auto(v).value if v is not None else None for v in data] # type: ignore[redundant-expr] - - return pa.array(pa_data, type=data_type)