Skip to content

Commit

Permalink
Fix visiblity toggles for time series not working (#2444)
Browse files Browse the repository at this point in the history
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

Fixes #2415
* #2415 

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)

<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2444

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/76a741b/docs
Examples preview: https://rerun.io/preview/76a741b/examples
<!-- pr-link-docs:end -->
  • Loading branch information
Wumpf authored Jun 15, 2023
1 parent f844d5e commit 1921c04
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 34 deletions.
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

0 comments on commit 1921c04

Please sign in to comment.