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.
-->

Fixes #2415
* #2415

* [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 committed Jun 15, 2023
1 parent 29046de commit 1c95e21
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 39 deletions.
12 changes: 6 additions & 6 deletions crates/re_data_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ 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 {
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_paths,
query.timeline,
query.at,
&entity_props_map,
);
annotation_map.load(ctx, &scene_query);
annotation_map.find(entity_path)
}
Expand Down
10 changes: 5 additions & 5 deletions crates/re_viewer/src/ui/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ impl SpaceView {
return;
}

let query = re_viewer_context::SceneQuery {
entity_paths: self.data_blueprint.entity_paths(),
timeline: *ctx.rec_cfg.time_ctrl.timeline(),
let query = re_viewer_context::SceneQuery::new(
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(),
);

match self.category {
ViewCategory::Text => {
Expand Down
12 changes: 2 additions & 10 deletions crates/re_viewer/src/ui/view_text/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,7 @@ impl SceneText {

let store = &ctx.log_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 !filters.is_entity_path_visible(ent_path) {
return;
}

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 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
7 changes: 0 additions & 7 deletions crates/re_viewer/src/ui/view_text/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@ impl Default for ViewTextFilters {
}

impl ViewTextFilters {
pub fn is_entity_path_visible(&self, entity_path: &EntityPath) -> bool {
self.row_entity_paths
.get(entity_path)
.copied()
.unwrap_or(true)
}

pub fn is_log_level_visible(&self, level: &str) -> bool {
self.row_log_levels.get(level).copied().unwrap_or(true)
}
Expand Down
6 changes: 2 additions & 4 deletions crates/re_viewer/src/ui/view_time_series/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ impl SceneTimeSeries {

let store = &ctx.log_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 @@ -153,7 +151,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
21 changes: 20 additions & 1 deletion crates/re_viewer_context/src/scene_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,32 @@ use nohash_hasher::IntSet;
use re_data_store::{EntityPath, EntityProperties, EntityPropertyMap, TimeInt, Timeline};

pub struct SceneQuery<'s> {
pub entity_paths: &'s IntSet<EntityPath>,
/// All queried entities.
///
/// 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,
pub latest_at: TimeInt,
pub entity_props_map: &'s EntityPropertyMap,
}

impl<'s> SceneQuery<'s> {
pub fn new(
entity_paths: &'s IntSet<EntityPath>,
timeline: Timeline,
latest_at: TimeInt,
entity_props_map: &'s EntityPropertyMap,
) -> Self {
Self {
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

0 comments on commit 1c95e21

Please sign in to comment.