Skip to content

Commit

Permalink
Name space views after the space and indicate duplicate names (#1653)
Browse files Browse the repository at this point in the history
* Always name the view after the base of the space path
* Make space view name unique when adding to blueprint
  • Loading branch information
jleibs authored Mar 21, 2023
1 parent 8f5faa9 commit f40752a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
11 changes: 5 additions & 6 deletions crates/re_viewer/src/ui/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ impl SpaceView {
space_path: &EntityPath,
queries_entities: &[EntityPath],
) -> Self {
let display_name = if queries_entities.len() == 1 {
// A single entity in this space-view - name the space after it.
queries_entities[0]
.last()
.map_or_else(|| "/".to_owned(), |part| part.to_string())
} else if let Some(name) = space_path.iter().last() {
// We previously named the [`SpaceView`] after the [`EntityPath`] if there was only a single entity. However,
// this led to somewhat confusing and inconsistent behavior. See https://github.com/rerun-io/rerun/issues/1220
// Spaces are now always named after the final element of the space-path (or the root), independent of the
// query entities.
let display_name = if let Some(name) = space_path.iter().last() {
name.to_string()
} else {
// Include category name in the display for root paths because they look a tad bit too short otherwise.
Expand Down
20 changes: 19 additions & 1 deletion crates/re_viewer/src/ui/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,26 @@ impl Viewport {
self.has_been_user_edited = true;
}

pub(crate) fn add_space_view(&mut self, space_view: SpaceView) -> SpaceViewId {
pub(crate) fn add_space_view(&mut self, mut space_view: SpaceView) -> SpaceViewId {
let id = space_view.id;

// Find a unique name for the space view
let mut candidate_name = space_view.display_name.clone();
let mut append_count = 1;
let unique_name = 'outer: loop {
for view in &self.space_views {
if candidate_name == view.1.display_name {
append_count += 1;
candidate_name = format!("{} ({})", space_view.display_name, append_count);

continue 'outer;
}
}
break candidate_name;
};

space_view.display_name = unique_name;

self.space_views.insert(id, space_view);
self.visible.insert(id);
self.trees.clear(); // Reset them
Expand Down

1 comment on commit f40752a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: f40752a Previous: 8f5faa9 Ratio
datastore/insert/batch/rects/insert 568806 ns/iter (± 16721) 611571 ns/iter (± 9415) 0.93
datastore/latest_at/batch/rects/query 1851 ns/iter (± 19) 1881 ns/iter (± 6) 0.98
datastore/latest_at/missing_components/primary 286 ns/iter (± 2) 292 ns/iter (± 0) 0.98
datastore/latest_at/missing_components/secondaries 436 ns/iter (± 6) 444 ns/iter (± 2) 0.98
datastore/range/batch/rects/query 152105 ns/iter (± 1156) 156402 ns/iter (± 653) 0.97
mono_points_arrow/generate_message_bundles 45979019 ns/iter (± 2444878) 52018822 ns/iter (± 843344) 0.88
mono_points_arrow/generate_messages 125882789 ns/iter (± 1130132) 141149486 ns/iter (± 1422668) 0.89
mono_points_arrow/encode_log_msg 155092853 ns/iter (± 989537) 170055896 ns/iter (± 1126383) 0.91
mono_points_arrow/encode_total 331380404 ns/iter (± 3853483) 363977625 ns/iter (± 2799016) 0.91
mono_points_arrow/decode_log_msg 181397874 ns/iter (± 903393) 190968672 ns/iter (± 992698) 0.95
mono_points_arrow/decode_message_bundles 63434644 ns/iter (± 835235) 78083482 ns/iter (± 1164348) 0.81
mono_points_arrow/decode_total 239948585 ns/iter (± 1724437) 262339281 ns/iter (± 1681345) 0.91
batch_points_arrow/generate_message_bundles 327224 ns/iter (± 5298) 329826 ns/iter (± 1508) 0.99
batch_points_arrow/generate_messages 6474 ns/iter (± 59) 6505 ns/iter (± 35) 1.00
batch_points_arrow/encode_log_msg 359165 ns/iter (± 1562) 414182 ns/iter (± 1715) 0.87
batch_points_arrow/encode_total 702124 ns/iter (± 32600) 751231 ns/iter (± 2861) 0.93
batch_points_arrow/decode_log_msg 351430 ns/iter (± 1385) 355473 ns/iter (± 1844) 0.99
batch_points_arrow/decode_message_bundles 2081 ns/iter (± 23) 2078 ns/iter (± 12) 1.00
batch_points_arrow/decode_total 354815 ns/iter (± 1718) 387702 ns/iter (± 1851) 0.92
arrow_mono_points/insert 6068951500 ns/iter (± 71845807) 7180897831 ns/iter (± 30015588) 0.85
arrow_mono_points/query 1791332 ns/iter (± 69594) 1862983 ns/iter (± 12336) 0.96
arrow_batch_points/insert 2699432 ns/iter (± 18446) 2895608 ns/iter (± 16668) 0.93
arrow_batch_points/query 16110 ns/iter (± 186) 16157 ns/iter (± 56) 1.00
arrow_batch_vecs/insert 42963 ns/iter (± 516) 46839 ns/iter (± 241) 0.92
arrow_batch_vecs/query 387654 ns/iter (± 3546) 406390 ns/iter (± 4723) 0.95
tuid/Tuid::random 34 ns/iter (± 0) 34 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.