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

Fix visiblity toggles for time series not working #2444

Merged
merged 3 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions crates/re_data_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ pub fn annotations(
let mut annotation_map = re_viewer_context::AnnotationMap::default();
let entity_paths: nohash_hasher::IntSet<_> = std::iter::once(entity_path.clone()).collect();
let entity_props_map = re_data_store::EntityPropertyMap::default();
let scene_query = re_viewer_context::SceneQuery {
space_origin: entity_path,
entity_paths: &entity_paths,
timeline: query.timeline,
latest_at: query.at,
entity_props_map: &entity_props_map,
};
let scene_query = re_viewer_context::SceneQuery::new(
entity_path,
&entity_paths,
query.timeline,
query.at,
&entity_props_map,
);
annotation_map.load(ctx, &scene_query);
annotation_map.find(entity_path)
}
12 changes: 2 additions & 10 deletions crates/re_space_view_text/src/scene_part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,7 @@ impl ScenePart<TextSpaceView> for SceneText {
) -> Vec<re_renderer::QueueableDrawData> {
let store = &ctx.store_db.entity_db.data_store;

for entity_path in query.entity_paths {
let ent_path = entity_path;

// Early filtering: if we're not showing it the view, there isn't much point
// in querying it to begin with... at least for now.
if !state.filters.is_entity_path_visible(ent_path) {
continue;
}

for (ent_path, _) in query.iter_entities() {
let query = re_arrow_store::RangeQuery::new(
query.timeline,
TimeRange::new(i64::MIN.into(), i64::MAX.into()),
Expand Down Expand Up @@ -84,7 +76,7 @@ impl ScenePart<TextSpaceView> for SceneText {
if is_visible {
self.text_entries.push(TextEntry {
row_id: ent_view.row_id(),
entity_path: entity_path.clone(),
entity_path: ent_path.clone(),
time: time.map(|time| time.as_i64()),
color: color.map(|c| c.to_array()),
level,
Expand Down
6 changes: 2 additions & 4 deletions crates/re_space_view_time_series/src/scene_part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ impl SceneTimeSeries {

let store = &ctx.store_db.entity_db.data_store;

for entity_path in query.entity_paths {
let ent_path = entity_path;

for (ent_path, _ent_props) in query.iter_entities() {
let mut points = Vec::new();
let annotations = self.annotation_map.find(ent_path);
let annotation_info = annotations.class_description(None).annotation_info();
Expand Down Expand Up @@ -167,7 +165,7 @@ impl SceneTimeSeries {
(points.iter().all(|p| p.attrs.label.as_ref() == Some(label)))
.then(|| label.clone())
};
let line_label = same_label(&points).unwrap_or_else(|| entity_path.to_string());
let line_label = same_label(&points).unwrap_or_else(|| ent_path.to_string());

self.add_line_segments(&line_label, points);
}
Expand Down
8 changes: 2 additions & 6 deletions crates/re_viewer_context/src/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,8 @@ impl AnnotationMap {

// This logic is borrowed from `iter_ancestor_meta_field`, but using the arrow-store instead
// not made generic as `AnnotationContext` was the only user of that function
for entity_path in scene_query
.entity_paths
.iter()
.filter(|entity_path| scene_query.entity_props_map.get(entity_path).visible)
{
let mut next_parent = Some(entity_path.clone());
for (ent_path, _) in scene_query.iter_entities() {
let mut next_parent = Some(ent_path.clone());
while let Some(parent) = next_parent {
// If we've visited this parent before it's safe to break early.
// All of it's parents have have also been visited.
Expand Down
20 changes: 19 additions & 1 deletion crates/re_viewer_context/src/space_view/scene_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ pub struct SceneQuery<'s> {
pub space_origin: &'s EntityPath,

/// All queried entities.
pub entity_paths: &'s IntSet<EntityPath>,
///
/// Contains also invisible objects, use `iter_entities` to iterate over visible ones.
entity_paths: &'s IntSet<EntityPath>,

/// The timeline we're on.
pub timeline: Timeline,
Expand All @@ -21,6 +23,22 @@ pub struct SceneQuery<'s> {
}

impl<'s> SceneQuery<'s> {
pub fn new(
space_origin: &'s EntityPath,
entity_paths: &'s IntSet<EntityPath>,
timeline: Timeline,
latest_at: TimeInt,
entity_props_map: &'s EntityPropertyMap,
) -> Self {
Self {
space_origin,
entity_paths,
timeline,
latest_at,
entity_props_map,
}
}

/// Iter over all of the currently visible [`EntityPath`]s in the [`SceneQuery`].
///
/// Also includes the corresponding [`EntityProperties`].
Expand Down
12 changes: 6 additions & 6 deletions crates/re_viewport/src/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ impl SpaceViewBlueprint {
self.data_blueprint.data_blueprints_individual(),
);

let query = re_viewer_context::SceneQuery {
space_origin: &self.space_origin,
entity_paths: self.data_blueprint.entity_paths(),
timeline: *ctx.rec_cfg.time_ctrl.timeline(),
let query = re_viewer_context::SceneQuery::new(
&self.space_origin,
self.data_blueprint.entity_paths(),
*ctx.rec_cfg.time_ctrl.timeline(),
latest_at,
entity_props_map: self.data_blueprint.data_blueprints_projected(),
};
self.data_blueprint.data_blueprints_projected(),
);

let mut scene = class.new_scene();
scene.populate(ctx, &query, view_state, highlights);
Expand Down