Skip to content

Commit

Permalink
Rename "applicable" to "maybe visualizable" and adjust various docs a…
Browse files Browse the repository at this point in the history
…ccordingly (#8767)
  • Loading branch information
Wumpf authored Jan 22, 2025
1 parent 85fc27d commit 5dcb63f
Show file tree
Hide file tree
Showing 47 changed files with 249 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ fn recommended_views_for_selection(ctx: &ContextMenuContext<'_>) -> IntSet<ViewC

let view_class_registry = ctx.viewer_context.view_class_registry;
let recording = ctx.viewer_context.recording();
let applicable_entities_per_visualizer =
view_class_registry.applicable_entities_for_visualizer_systems(&recording.store_id());
let maybe_visualizable_entities = view_class_registry
.maybe_visualizable_entities_for_visualizer_systems(&recording.store_id());

for entry in view_class_registry.iter_registry() {
let Some(suggested_root) = entry
Expand All @@ -98,7 +98,7 @@ fn recommended_views_for_selection(ctx: &ContextMenuContext<'_>) -> IntSet<ViewC
};

let visualizable_entities = entry.class.determine_visualizable_entities(
&applicable_entities_per_visualizer,
&maybe_visualizable_entities,
recording,
&view_class_registry.new_visualizer_collection(entry.identifier),
&suggested_root,
Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_selection_panel/src/visualizer_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,15 @@ fn available_inactive_visualizers(
) -> Vec<ViewSystemIdentifier> {
// TODO(jleibs): This has already been computed for the View this frame. Maybe We
// should do this earlier and store it with the View?
let applicable_entities_per_visualizer = ctx
let maybe_visualizable_entities = ctx
.viewer_ctx
.view_class_registry
.applicable_entities_for_visualizer_systems(&entity_db.store_id());
.maybe_visualizable_entities_for_visualizer_systems(&entity_db.store_id());

let visualizable_entities = view
.class(ctx.viewer_ctx.view_class_registry)
.determine_visualizable_entities(
&applicable_entities_per_visualizer,
&maybe_visualizable_entities,
entity_db,
&ctx.visualizer_collection,
&view.space_origin,
Expand Down
12 changes: 6 additions & 6 deletions crates/viewer/re_view/src/heuristics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use re_viewer_context::{
ApplicableEntities, IdentifiedViewSystem, RecommendedView, ViewClass, ViewSpawnHeuristics,
ViewerContext, VisualizerSystem,
IdentifiedViewSystem, MaybeVisualizableEntities, RecommendedView, ViewClass,
ViewSpawnHeuristics, ViewerContext, VisualizerSystem,
};

/// Spawns a view for each single entity which is visualizable & indicator-matching for a given visualizer.
Expand All @@ -22,21 +22,21 @@ where
else {
return Default::default();
};
let Some(applicable_entities) = ctx
.applicable_entities_per_visualizer
let Some(maybe_visualizable_entities) = ctx
.maybe_visualizable_entities_per_visualizer
.get(&TVisualizer::identifier())
else {
return Default::default();
};

let visualizer = TVisualizer::default();
let recommended_views = applicable_entities
let recommended_views = maybe_visualizable_entities
.intersection(indicator_matching_entities)
.filter_map(|entity| {
let context = view.visualizable_filter_context(entity, ctx.recording());
if visualizer
.filter_visualizable_entities(
ApplicableEntities(std::iter::once(entity.clone()).collect()),
MaybeVisualizableEntities(std::iter::once(entity.clone()).collect()),
context.as_ref(),
)
.is_empty()
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub mod external {

// -----------

/// Utility for implementing [`re_viewer_context::VisualizerAdditionalApplicabilityFilter`] using on the properties of a concrete component.
/// Utility for implementing [`re_viewer_context::DataBasedVisualizabilityFilter`] using on the properties of a concrete component.
#[inline]
pub fn diff_component_filter<T: re_types_core::Component>(
event: &re_chunk_store::ChunkStoreEvent,
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_view_bar_chart/src/view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use re_view::controls::{
};
use re_view::{controls, suggest_view_for_each_entity, view_property_ui};
use re_viewer_context::{
ApplicableEntities, IdentifiedViewSystem as _, IndicatedEntities, PerVisualizer,
IdentifiedViewSystem as _, IndicatedEntities, MaybeVisualizableEntities, PerVisualizer,
TypedComponentFallbackProvider, ViewClass, ViewClassRegistryError, ViewId, ViewQuery,
ViewState, ViewStateExt, ViewSystemExecutionError, ViewerContext, VisualizableEntities,
};
Expand Down Expand Up @@ -75,7 +75,7 @@ Display a 1D tensor as a bar chart.
fn choose_default_visualizers(
&self,
entity_path: &EntityPath,
_applicable_entities_per_visualizer: &PerVisualizer<ApplicableEntities>,
_maybe_visualizable_entities_per_visualizer: &PerVisualizer<MaybeVisualizableEntities>,
visualizable_entities_per_visualizer: &PerVisualizer<VisualizableEntities>,
_indicated_entities_per_visualizer: &PerVisualizer<IndicatedEntities>,
) -> re_viewer_context::SmallVisualizerSet {
Expand Down
16 changes: 8 additions & 8 deletions crates/viewer/re_view_bar_chart/src/visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use re_types::{
};
use re_view::{diff_component_filter, DataResultQuery as _};
use re_viewer_context::{
auto_color_for_entity_path, IdentifiedViewSystem, QueryContext, TypedComponentFallbackProvider,
ViewContext, ViewContextCollection, ViewQuery, ViewSystemExecutionError,
VisualizerAdditionalApplicabilityFilter, VisualizerQueryInfo, VisualizerSystem,
auto_color_for_entity_path, DataBasedVisualizabilityFilter, IdentifiedViewSystem, QueryContext,
TypedComponentFallbackProvider, ViewContext, ViewContextCollection, ViewQuery,
ViewSystemExecutionError, VisualizerQueryInfo, VisualizerSystem,
};

/// A bar chart system, with everything needed to render it.
Expand All @@ -27,11 +27,11 @@ impl IdentifiedViewSystem for BarChartVisualizerSystem {
}
}

struct BarChartVisualizerEntityFilter;
struct BarChartVisualizabilityFilter;

impl VisualizerAdditionalApplicabilityFilter for BarChartVisualizerEntityFilter {
impl DataBasedVisualizabilityFilter for BarChartVisualizabilityFilter {
#[inline]
fn update_applicability(&mut self, event: &ChunkStoreEvent) -> bool {
fn update_visualizability(&mut self, event: &ChunkStoreEvent) -> bool {
diff_component_filter(event, |tensor: &re_types::components::TensorData| {
tensor.is_vector()
})
Expand All @@ -43,8 +43,8 @@ impl VisualizerSystem for BarChartVisualizerSystem {
VisualizerQueryInfo::from_archetype::<BarChart>()
}

fn applicability_filter(&self) -> Option<Box<dyn VisualizerAdditionalApplicabilityFilter>> {
Some(Box::new(BarChartVisualizerEntityFilter))
fn data_based_visualizability_filter(&self) -> Option<Box<dyn DataBasedVisualizabilityFilter>> {
Some(Box::new(BarChartVisualizabilityFilter))
}

fn execute(
Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_view_graph/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ Display a graph of nodes and edges.
}

fn spawn_heuristics(&self, ctx: &ViewerContext<'_>) -> ViewSpawnHeuristics {
if let Some(applicable) = ctx
.applicable_entities_per_visualizer
if let Some(maybe_visualizable) = ctx
.maybe_visualizable_entities_per_visualizer
.get(&NodeVisualizer::identifier())
{
ViewSpawnHeuristics::new(
applicable
maybe_visualizable
.iter()
.cloned()
.map(RecommendedView::new_single_entity),
Expand Down
7 changes: 4 additions & 3 deletions crates/viewer/re_view_spatial/src/heuristics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use crate::{view_kind::SpatialViewKind, visualizers::SpatialViewVisualizerData};

/// Returns all entities for which a visualizer of the given kind would be picked.
///
/// I.e. all entities for which at least one visualizer of the specified kind is applicable
/// I.e. all entities for which at least one visualizer of the specified kind is "maybe visualizable"
/// *and* has a matching indicator component.
/// (we can't reason with "visualizable" because that can be influenced by view properties like its origin)
pub fn default_visualized_entities_for_visualizer_kind(
ctx: &ViewerContext<'_>,
view_class_identifier: ViewClassIdentifier,
Expand All @@ -27,8 +28,8 @@ pub fn default_visualized_entities_for_visualizer_kind(

if data.preferred_view_kind == Some(visualizer_kind) {
let indicator_matching = ctx.indicated_entities_per_visualizer.get(&id)?;
let applicable = ctx.applicable_entities_per_visualizer.get(&id)?;
Some(indicator_matching.intersection(applicable))
let maybe_visualizable = ctx.maybe_visualizable_entities_per_visualizer.get(&id)?;
Some(indicator_matching.intersection(maybe_visualizable))
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_view_spatial/src/spatial_topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl ChunkStoreSubscriber for SpatialTopologyStoreSubscriber {
///
/// Describes how 2D & 3D spaces are connected/disconnected.
///
/// Used to determine whether 2D/3D visualizers are applicable and to inform
/// Used to determine whether 2D/3D visualizers are visualizable and to inform
/// view generation heuristics.
///
/// Spatial topology is time independent but may change as new data comes in.
Expand Down
35 changes: 19 additions & 16 deletions crates/viewer/re_view_spatial/src/view_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use re_types::{
use re_ui::{list_item, UiExt as _};
use re_view::view_property_ui;
use re_viewer_context::{
ApplicableEntities, IdentifiedViewSystem, IndicatedEntities, PerVisualizer, RecommendedView,
SmallVisualizerSet, ViewClass, ViewClassRegistryError, ViewId, ViewQuery, ViewSpawnHeuristics,
ViewState, ViewStateExt as _, ViewSystemExecutionError, ViewSystemIdentifier, ViewerContext,
VisualizableEntities, VisualizableFilterContext,
IdentifiedViewSystem, IndicatedEntities, MaybeVisualizableEntities, PerVisualizer,
RecommendedView, SmallVisualizerSet, ViewClass, ViewClassRegistryError, ViewId, ViewQuery,
ViewSpawnHeuristics, ViewState, ViewStateExt as _, ViewSystemExecutionError,
ViewSystemIdentifier, ViewerContext, VisualizableEntities, VisualizableFilterContext,
};
use re_viewport_blueprint::ViewProperty;

Expand Down Expand Up @@ -195,24 +195,25 @@ impl ViewClass for SpatialView3D {
fn choose_default_visualizers(
&self,
entity_path: &EntityPath,
applicable_entities_per_visualizer: &PerVisualizer<ApplicableEntities>,
maybe_visualizable_entities_per_visualizer: &PerVisualizer<MaybeVisualizableEntities>,
visualizable_entities_per_visualizer: &PerVisualizer<VisualizableEntities>,
indicated_entities_per_visualizer: &PerVisualizer<IndicatedEntities>,
) -> SmallVisualizerSet {
let arrows_viz = Transform3DArrowsVisualizer::identifier();
let axis_detector = AxisLengthDetector::identifier();
let camera_viz = CamerasVisualizer::identifier();

let applicable: HashSet<&ViewSystemIdentifier> = applicable_entities_per_visualizer
.iter()
.filter_map(|(visualizer, ents)| {
if ents.contains(entity_path) {
Some(visualizer)
} else {
None
}
})
.collect();
let maybe_visualizable: HashSet<&ViewSystemIdentifier> =
maybe_visualizable_entities_per_visualizer
.iter()
.filter_map(|(visualizer, ents)| {
if ents.contains(entity_path) {
Some(visualizer)
} else {
None
}
})
.collect();

let visualizable: HashSet<&ViewSystemIdentifier> = visualizable_entities_per_visualizer
.iter()
Expand Down Expand Up @@ -251,7 +252,9 @@ impl ViewClass for SpatialView3D {
// … then we enable it if either:
// - If someone set an axis_length explicitly, so [`AxisLengthDetector`] is applicable.
// - If we already have the [`CamerasVisualizer`] active.
if applicable.contains(&axis_detector) || enabled_visualizers.contains(&camera_viz) {
if maybe_visualizable.contains(&axis_detector)
|| enabled_visualizers.contains(&camera_viz)
{
enabled_visualizers.push(arrows_viz);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_view_spatial/src/visualizers/arrows2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use re_types::{
};
use re_view::{process_annotation_and_keypoint_slices, process_color_slice};
use re_viewer_context::{
auto_color_for_entity_path, ApplicableEntities, IdentifiedViewSystem, QueryContext,
auto_color_for_entity_path, IdentifiedViewSystem, MaybeVisualizableEntities, QueryContext,
TypedComponentFallbackProvider, ViewContext, ViewContextCollection, ViewQuery,
ViewSystemExecutionError, VisualizableEntities, VisualizableFilterContext, VisualizerQueryInfo,
VisualizerSystem,
Expand Down Expand Up @@ -178,7 +178,7 @@ impl VisualizerSystem for Arrows2DVisualizer {

fn filter_visualizable_entities(
&self,
entities: ApplicableEntities,
entities: MaybeVisualizableEntities,
context: &dyn VisualizableFilterContext,
) -> VisualizableEntities {
re_tracing::profile_function!();
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_view_spatial/src/visualizers/arrows3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use re_types::{
};
use re_view::{process_annotation_slices, process_color_slice};
use re_viewer_context::{
auto_color_for_entity_path, ApplicableEntities, IdentifiedViewSystem, QueryContext,
auto_color_for_entity_path, IdentifiedViewSystem, MaybeVisualizableEntities, QueryContext,
TypedComponentFallbackProvider, ViewContext, ViewContextCollection, ViewQuery,
ViewSystemExecutionError, VisualizableEntities, VisualizableFilterContext, VisualizerQueryInfo,
VisualizerSystem,
Expand Down Expand Up @@ -177,7 +177,7 @@ impl VisualizerSystem for Arrows3DVisualizer {

fn filter_visualizable_entities(
&self,
entities: ApplicableEntities,
entities: MaybeVisualizableEntities,
context: &dyn VisualizableFilterContext,
) -> VisualizableEntities {
re_tracing::profile_function!();
Expand Down
8 changes: 4 additions & 4 deletions crates/viewer/re_view_spatial/src/visualizers/assets3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use re_types::{
ArrowBuffer, ArrowString, Component as _,
};
use re_viewer_context::{
ApplicableEntities, IdentifiedViewSystem, QueryContext, ViewContext, ViewContextCollection,
ViewQuery, ViewSystemExecutionError, VisualizableEntities, VisualizableFilterContext,
VisualizerQueryInfo, VisualizerSystem,
IdentifiedViewSystem, MaybeVisualizableEntities, QueryContext, ViewContext,
ViewContextCollection, ViewQuery, ViewSystemExecutionError, VisualizableEntities,
VisualizableFilterContext, VisualizerQueryInfo, VisualizerSystem,
};

use super::{filter_visualizable_3d_entities, SpatialViewVisualizerData};
Expand Down Expand Up @@ -121,7 +121,7 @@ impl VisualizerSystem for Asset3DVisualizer {

fn filter_visualizable_entities(
&self,
entities: ApplicableEntities,
entities: MaybeVisualizableEntities,
context: &dyn VisualizableFilterContext,
) -> VisualizableEntities {
re_tracing::profile_function!();
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_view_spatial/src/visualizers/boxes2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use re_types::{
};
use re_view::{process_annotation_slices, process_color_slice};
use re_viewer_context::{
auto_color_for_entity_path, ApplicableEntities, IdentifiedViewSystem, QueryContext,
auto_color_for_entity_path, IdentifiedViewSystem, MaybeVisualizableEntities, QueryContext,
TypedComponentFallbackProvider, ViewContext, ViewContextCollection, ViewQuery,
ViewSystemExecutionError, VisualizableEntities, VisualizableFilterContext, VisualizerQueryInfo,
VisualizerSystem,
Expand Down Expand Up @@ -177,7 +177,7 @@ impl VisualizerSystem for Boxes2DVisualizer {

fn filter_visualizable_entities(
&self,
entities: ApplicableEntities,
entities: MaybeVisualizableEntities,
context: &dyn VisualizableFilterContext,
) -> VisualizableEntities {
re_tracing::profile_function!();
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_view_spatial/src/visualizers/boxes3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use re_types::{
ArrowString, Component as _,
};
use re_viewer_context::{
auto_color_for_entity_path, ApplicableEntities, IdentifiedViewSystem, QueryContext,
auto_color_for_entity_path, IdentifiedViewSystem, MaybeVisualizableEntities, QueryContext,
TypedComponentFallbackProvider, ViewContext, ViewContextCollection, ViewQuery,
ViewSystemExecutionError, VisualizableEntities, VisualizableFilterContext, VisualizerQueryInfo,
VisualizerSystem,
Expand Down Expand Up @@ -101,7 +101,7 @@ impl VisualizerSystem for Boxes3DVisualizer {

fn filter_visualizable_entities(
&self,
entities: ApplicableEntities,
entities: MaybeVisualizableEntities,
context: &dyn VisualizableFilterContext,
) -> VisualizableEntities {
re_tracing::profile_function!();
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_view_spatial/src/visualizers/cameras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use re_types::{
components::{ImagePlaneDistance, ViewCoordinates},
};
use re_viewer_context::{
ApplicableEntities, DataResult, IdentifiedViewSystem, QueryContext,
DataResult, IdentifiedViewSystem, MaybeVisualizableEntities, QueryContext,
TypedComponentFallbackProvider, ViewContext, ViewContextCollection, ViewOutlineMasks,
ViewQuery, ViewStateExt as _, ViewSystemExecutionError, VisualizableEntities,
VisualizableFilterContext, VisualizerQueryInfo, VisualizerSystem,
Expand Down Expand Up @@ -202,7 +202,7 @@ impl VisualizerSystem for CamerasVisualizer {

fn filter_visualizable_entities(
&self,
entities: ApplicableEntities,
entities: MaybeVisualizableEntities,
context: &dyn VisualizableFilterContext,
) -> VisualizableEntities {
re_tracing::profile_function!();
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_view_spatial/src/visualizers/capsules3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use re_types::{
};
use re_view::clamped_or_nothing;
use re_viewer_context::{
auto_color_for_entity_path, ApplicableEntities, IdentifiedViewSystem, QueryContext,
auto_color_for_entity_path, IdentifiedViewSystem, MaybeVisualizableEntities, QueryContext,
TypedComponentFallbackProvider, ViewContext, ViewContextCollection, ViewQuery,
ViewSystemExecutionError, VisualizableEntities, VisualizableFilterContext, VisualizerQueryInfo,
VisualizerSystem,
Expand Down Expand Up @@ -123,7 +123,7 @@ impl VisualizerSystem for Capsules3DVisualizer {

fn filter_visualizable_entities(
&self,
entities: ApplicableEntities,
entities: MaybeVisualizableEntities,
context: &dyn VisualizableFilterContext,
) -> VisualizableEntities {
re_tracing::profile_function!();
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_view_spatial/src/visualizers/depth_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use re_types::{
Component as _,
};
use re_viewer_context::{
ApplicableEntities, ColormapWithRange, IdentifiedViewSystem, ImageInfo, ImageStatsCache,
ColormapWithRange, IdentifiedViewSystem, ImageInfo, ImageStatsCache, MaybeVisualizableEntities,
QueryContext, TypedComponentFallbackProvider, ViewClass, ViewContext, ViewContextCollection,
ViewQuery, ViewSystemExecutionError, VisualizableEntities, VisualizableFilterContext,
VisualizerQueryInfo, VisualizerSystem,
Expand Down Expand Up @@ -239,7 +239,7 @@ impl VisualizerSystem for DepthImageVisualizer {

fn filter_visualizable_entities(
&self,
entities: ApplicableEntities,
entities: MaybeVisualizableEntities,
context: &dyn VisualizableFilterContext,
) -> VisualizableEntities {
re_tracing::profile_function!();
Expand Down
Loading

0 comments on commit 5dcb63f

Please sign in to comment.