Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow hiding/showing entity subtrees under shown/hidden parent tree #5508

Merged
merged 12 commits into from
Mar 15, 2024
8 changes: 1 addition & 7 deletions crates/re_entity_db/src/entity_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ impl FromIterator<(EntityPath, EntityProperties)> for EntityPropertyMap {
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct EntityProperties {
pub visible: bool,
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
pub visible_history: re_query::ExtraQueryHistory,
pub interactive: bool,

Expand Down Expand Up @@ -144,7 +143,6 @@ pub struct EntityProperties {
impl Default for EntityProperties {
fn default() -> Self {
Self {
visible: true,
visible_history: re_query::ExtraQueryHistory::default(),
interactive: true,
color_mapper: EditableAutoValue::default(),
Expand All @@ -166,7 +164,6 @@ impl EntityProperties {
/// Multiply/and these together.
pub fn with_child(&self, child: &Self) -> Self {
Self {
visible: self.visible && child.visible,
visible_history: self.visible_history.with_child(&child.visible_history),
interactive: self.interactive && child.interactive,

Expand Down Expand Up @@ -211,7 +208,6 @@ impl EntityProperties {
/// loaded from the Blueprint store where the Auto values are not up-to-date.
pub fn merge_with(&self, other: &Self) -> Self {
Self {
visible: other.visible,
visible_history: self.visible_history.with_child(&other.visible_history),
interactive: other.interactive,

Expand Down Expand Up @@ -250,7 +246,6 @@ impl EntityProperties {
/// Determine whether this `EntityProperty` has user-edits relative to another `EntityProperty`
pub fn has_edits(&self, other: &Self) -> bool {
let Self {
visible,
visible_history,
interactive,
color_mapper,
Expand All @@ -265,8 +260,7 @@ impl EntityProperties {
time_series_aggregator,
} = self;

visible != &other.visible
|| visible_history != &other.visible_history
visible_history != &other.visible_history
|| interactive != &other.interactive
|| color_mapper.has_edits(&other.color_mapper)
|| pinhole_image_plane_distance.has_edits(&other.pinhole_image_plane_distance)
Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view/src/data_query.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ahash::HashMap;
use nohash_hasher::IntMap;

use re_entity_db::{external::re_data_store::LatestAtQuery, EntityProperties, EntityPropertyMap};
use re_log_types::{EntityPath, StoreKind};
Expand All @@ -11,7 +11,7 @@ pub struct EntityOverrideContext {
pub recursive: EntityPropertyMap,

/// Base component overrides that are inherited by all entities.
pub root_component_overrides: HashMap<ComponentName, (StoreKind, EntityPath)>,
pub root_component_overrides: IntMap<ComponentName, (StoreKind, EntityPath)>,
}

/// Trait for resolving properties needed by most implementations of [`DataQuery`]
Expand Down
30 changes: 15 additions & 15 deletions crates/re_space_view/src/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl SpaceViewBlueprint {
accumulated_properties,
individual_properties,
recursive_properties: Default::default(),
component_overrides: Default::default(),
resolved_component_overrides: Default::default(),
recursive_override_path: entity_path.clone(),
individual_override_path: entity_path,
}),
Expand Down Expand Up @@ -581,9 +581,9 @@ mod tests {
);
}

// Now, override visibility on parent individually.
// Now, override interactive on parent individually.
let mut overrides = parent.individual_properties().cloned().unwrap_or_default();
overrides.visible = false;
overrides.interactive = false;

save_override(
overrides,
Expand All @@ -592,7 +592,7 @@ mod tests {
);
}

// Parent is not visible, but children are
// Parent is not interactive, but children are
{
let ctx = StoreContext {
blueprint: &blueprint,
Expand Down Expand Up @@ -620,18 +620,18 @@ mod tests {
.lookup_result_by_path(&EntityPath::from("parent/skip/child2"))
.unwrap();

assert!(!parent.accumulated_properties().visible);
assert!(!parent.accumulated_properties().interactive);

for result in [child1, child2] {
assert!(result.accumulated_properties().visible);
assert!(result.accumulated_properties().interactive);
}

// Override visibility on parent recursively.
// Override interactivity on parent recursively.
let mut overrides = parent_group
.individual_properties()
.cloned()
.unwrap_or_default();
overrides.visible = false;
overrides.interactive = false;

save_override(
overrides,
Expand All @@ -640,7 +640,7 @@ mod tests {
);
}

// Nobody is visible
// Nobody is interactive
{
let ctx = StoreContext {
blueprint: &blueprint,
Expand All @@ -665,11 +665,11 @@ mod tests {
.unwrap();

for result in [parent, child1, child2] {
assert!(!result.accumulated_properties().visible);
assert!(!result.accumulated_properties().interactive);
}
}

// Override visible range on root
// Override interactive range on root
{
let root = space_view.root_data_result(
&StoreContext {
Expand All @@ -690,7 +690,7 @@ mod tests {
);
}

// Everyone has visible history
// Everyone has interactive history
{
let ctx = StoreContext {
blueprint: &blueprint,
Expand Down Expand Up @@ -731,7 +731,7 @@ mod tests {
);
}

// Child2 has its own visible history
// Child2 has its own interactive history
{
let ctx = StoreContext {
blueprint: &blueprint,
Expand Down Expand Up @@ -1035,11 +1035,11 @@ mod tests {
query_result.tree.visit(&mut |node| {
let result = &node.data_result;
if let Some(property_overrides) = &result.property_overrides {
if !property_overrides.component_overrides.is_empty() {
if !property_overrides.resolved_component_overrides.is_empty() {
visited.insert(
result.entity_path.clone(),
property_overrides
.component_overrides
.resolved_component_overrides
.iter()
.map(|(component_name, (store_kind, path))| {
assert_eq!(store_kind, &StoreKind::Blueprint);
Expand Down
8 changes: 4 additions & 4 deletions crates/re_space_view/src/space_view_contents.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ahash::HashMap;
use nohash_hasher::IntMap;
use slotmap::SlotMap;
use smallvec::SmallVec;

Expand Down Expand Up @@ -340,7 +340,7 @@ impl DataQueryPropertyResolver<'_> {
.space_view
.root_data_result(ctx, query)
.property_overrides
.map(|p| (p.accumulated_properties, p.component_overrides))
.map(|p| (p.accumulated_properties, p.resolved_component_overrides))
.unwrap_or_default();

for prefix in &self.default_stack {
Expand Down Expand Up @@ -416,7 +416,7 @@ impl DataQueryPropertyResolver<'_> {
query_result: &mut DataQueryResult,
override_context: &EntityOverrideContext,
accumulated: &EntityProperties,
recursive_property_overrides: &HashMap<ComponentName, (StoreKind, EntityPath)>,
recursive_property_overrides: &IntMap<ComponentName, (StoreKind, EntityPath)>,
handle: DataResultHandle,
) {
if let Some((child_handles, accumulated, recursive_property_overrides)) =
Expand Down Expand Up @@ -527,7 +527,7 @@ impl DataQueryPropertyResolver<'_> {
accumulated_properties,
individual_properties: individual_properties.cloned(),
recursive_properties: recursive_properties.cloned(),
component_overrides,
resolved_component_overrides: component_overrides,
recursive_override_path,
individual_override_path,
});
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_bar_chart/src/visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl VisualizerSystem for BarChartVisualizerSystem {

let store = ctx.entity_db.store();

for data_result in query.iter_visible_data_results(Self::identifier()) {
for data_result in query.iter_visible_data_results(ctx, Self::identifier()) {
let query = LatestAtQuery::new(query.timeline, query.latest_at);
let tensor = store.query_latest_component::<re_types::components::TensorData>(
&data_result.entity_path,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_dataframe/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl SpaceViewClass for DataframeSpaceView {
// These are the entity paths whose content we must display.
let sorted_entity_paths: BTreeSet<_> = query
.iter_all_data_results()
.filter(|data_result| data_result.accumulated_properties().visible)
.filter(|data_result| data_result.is_visible(ctx))
.map(|data_result| &data_result.entity_path)
.cloned()
.collect();
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/contexts/depth_offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl ViewContextSystem for EntityDepthOffsets {

// Use a BTreeSet for entity hashes to get a stable order.
let mut entities_per_draw_order = BTreeMap::<DrawOrder, BTreeSet<DrawOrderTarget>>::new();
for data_result in query.iter_visible_data_results(Self::identifier()) {
for data_result in query.iter_visible_data_results(ctx, Self::identifier()) {
if let Some(draw_order) = store
.query_latest_component::<DrawOrder>(&data_result.entity_path, &ctx.current_query())
{
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/visualizers/cameras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl VisualizerSystem for CamerasVisualizer {
let mut line_builder = re_renderer::LineDrawableBuilder::new(ctx.render_ctx);
line_builder.radius_boost_in_ui_points_for_outlines(SIZE_BOOST_IN_POINTS_FOR_LINE_OUTLINES);

for data_result in query.iter_visible_data_results(Self::identifier()) {
for data_result in query.iter_visible_data_results(ctx, Self::identifier()) {
let time_query = re_data_store::LatestAtQuery::new(query.timeline, query.latest_at);

if let Some(pinhole) = query_pinhole(store, &time_query, &data_result.entity_path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ where
let annotations = view_ctx.get::<AnnotationSceneContext>()?;
let counter = view_ctx.get::<PrimitiveCounter>()?;

for data_result in query.iter_visible_data_results(System::identifier()) {
for data_result in query.iter_visible_data_results(ctx, System::identifier()) {
// The transform that considers pinholes only makes sense if this is a 3D space-view
let world_from_entity =
if view_ctx.space_view_class_identifier() == SpatialSpaceView3D::identifier() {
Expand Down Expand Up @@ -151,7 +151,7 @@ macro_rules! impl_process_archetype {
let annotations = view_ctx.get::<AnnotationSceneContext>()?;
let counter = view_ctx.get::<PrimitiveCounter>()?;

for data_result in query.iter_visible_data_results(S::identifier()) {
for data_result in query.iter_visible_data_results(ctx, S::identifier()) {
// The transform that considers pinholes only makes sense if this is a 3D space-view
let world_from_entity = if view_ctx.space_view_class_identifier() == SpatialSpaceView3D::identifier() {
transforms.reference_from_entity(&data_result.entity_path)
Expand Down Expand Up @@ -256,7 +256,7 @@ pub fn count_instances_in_archetype_views<

let mut num_instances = 0;

for data_result in query.iter_visible_data_results(System::identifier()) {
for data_result in query.iter_visible_data_results(ctx, System::identifier()) {
match query_archetype_with_history::<A, N>(
ctx.entity_db.store(),
&query.timeline,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl VisualizerSystem for Transform3DArrowsVisualizer {
let mut line_builder = re_renderer::LineDrawableBuilder::new(ctx.render_ctx);
line_builder.radius_boost_in_ui_points_for_outlines(SIZE_BOOST_IN_POINTS_FOR_LINE_OUTLINES);

for data_result in query.iter_visible_data_results(Self::identifier()) {
for data_result in query.iter_visible_data_results(ctx, Self::identifier()) {
if !*data_result.accumulated_properties().transform_3d_visible {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_tensor/src/visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl VisualizerSystem for TensorSystem {
re_tracing::profile_function!();

let store = ctx.entity_db.store();
for data_result in query.iter_visible_data_results(Self::identifier()) {
for data_result in query.iter_visible_data_results(ctx, Self::identifier()) {
let timeline_query = LatestAtQuery::new(query.timeline, query.latest_at);

if let Some(tensor) = store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl VisualizerSystem for TextDocumentSystem {

let timeline_query = LatestAtQuery::new(query.timeline, query.latest_at);

for data_result in query.iter_visible_data_results(Self::identifier()) {
for data_result in query.iter_visible_data_results(ctx, Self::identifier()) {
// TODO(#3320): this match can go away once the issue is resolved
match query_archetype::<archetypes::TextDocument>(
store,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_text_log/src/visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl VisualizerSystem for TextLogSystem {
let query_caches = ctx.entity_db.query_caches();
let store = ctx.entity_db.store();

for data_result in query.iter_visible_data_results(Self::identifier()) {
for data_result in query.iter_visible_data_results(ctx, Self::identifier()) {
re_tracing::profile_scope!("primary", &data_result.entity_path.to_string());

// We want everything, for all times:
Expand Down
19 changes: 11 additions & 8 deletions crates/re_space_view_time_series/src/legacy_visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use re_viewer_context::{
};

use crate::{
overrides::{initial_override_color, lookup_override},
overrides::initial_override_color,
util::{determine_plot_bounds_and_time_per_pixel, determine_time_range, points_to_series},
PlotPoint, PlotPointAttrs, PlotSeries, PlotSeriesKind, ScatterAttrs,
};
Expand Down Expand Up @@ -57,7 +57,7 @@ impl VisualizerSystem for LegacyTimeSeriesSystem {
ctx,
&query.latest_at_query(),
query
.iter_visible_data_results(Self::identifier())
.iter_visible_data_results(ctx, Self::identifier())
.map(|data| &data.entity_path),
);

Expand Down Expand Up @@ -102,7 +102,7 @@ impl LegacyTimeSeriesSystem {
let (plot_bounds, time_per_pixel) = determine_plot_bounds_and_time_per_pixel(ctx, query);

// TODO(cmc): this should be thread-pooled in case there are a gazillon series in the same plot…
for data_result in query.iter_visible_data_results(Self::identifier()) {
for data_result in query.iter_visible_data_results(ctx, Self::identifier()) {
let annotations = self.annotation_map.find(&data_result.entity_path);
let annotation_info = annotations
.resolved_class_description(None)
Expand All @@ -111,11 +111,14 @@ impl LegacyTimeSeriesSystem {

const DEFAULT_RADIUS: f32 = 0.75;

let override_color = lookup_override::<Color>(data_result, ctx).map(|c| c.to_array());
let override_label = lookup_override::<Text>(data_result, ctx).map(|t| t.0);
let override_scattered =
lookup_override::<ScalarScattering>(data_result, ctx).map(|s| s.0);
let override_radius = lookup_override::<Radius>(data_result, ctx).map(|r| r.0);
let override_color = data_result
.lookup_override::<Color>(ctx)
.map(|c| c.to_array());
let override_label = data_result.lookup_override::<Text>(ctx).map(|t| t.0);
let override_scattered = data_result
.lookup_override::<ScalarScattering>(ctx)
.map(|s| s.0);
let override_radius = data_result.lookup_override::<Radius>(ctx).map(|r| r.0);

// All the default values for a `PlotPoint`, accounting for both overrides and default
// values.
Expand Down
14 changes: 8 additions & 6 deletions crates/re_space_view_time_series/src/line_visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::overrides::initial_override_color;
use crate::util::{
determine_plot_bounds_and_time_per_pixel, determine_time_range, points_to_series,
};
use crate::{overrides::lookup_override, PlotPoint, PlotPointAttrs, PlotSeries, PlotSeriesKind};
use crate::{PlotPoint, PlotPointAttrs, PlotSeries, PlotSeriesKind};

/// The system for rendering [`SeriesLine`] archetypes.
#[derive(Default, Debug)]
Expand Down Expand Up @@ -56,7 +56,7 @@ impl VisualizerSystem for SeriesLineSystem {
ctx,
&query.latest_at_query(),
query
.iter_visible_data_results(Self::identifier())
.iter_visible_data_results(ctx, Self::identifier())
.map(|data| &data.entity_path),
);

Expand Down Expand Up @@ -98,7 +98,7 @@ impl SeriesLineSystem {

let (plot_bounds, time_per_pixel) = determine_plot_bounds_and_time_per_pixel(ctx, query);

let data_results = query.iter_visible_data_results(Self::identifier());
let data_results = query.iter_visible_data_results(ctx, Self::identifier());

let parallel_loading = false; // TODO(emilk): enable parallel loading when it is faster, because right now it is often slower.
if parallel_loading {
Expand Down Expand Up @@ -162,9 +162,11 @@ fn load_series(
.resolved_class_description(None)
.annotation_info();
let default_color = DefaultColor::EntityPath(&data_result.entity_path);
let override_color = lookup_override::<Color>(data_result, ctx).map(|c| c.to_array());
let override_series_name = lookup_override::<Name>(data_result, ctx).map(|t| t.0);
let override_stroke_width = lookup_override::<StrokeWidth>(data_result, ctx).map(|r| r.0);
let override_color = data_result
.lookup_override::<Color>(ctx)
.map(|c| c.to_array());
let override_series_name = data_result.lookup_override::<Name>(ctx).map(|t| t.0);
let override_stroke_width = data_result.lookup_override::<StrokeWidth>(ctx).map(|r| r.0);

// All the default values for a `PlotPoint`, accounting for both overrides and default
// values.
Expand Down
Loading
Loading