Skip to content

Commit

Permalink
Show all entities/components in the Stream Tree, even if empty in the…
Browse files Browse the repository at this point in the history
… selected timeline
  • Loading branch information
abey79 committed Oct 10, 2023
1 parent 4d8fcad commit f8edf1b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
12 changes: 7 additions & 5 deletions crates/re_data_ui/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ impl DataUi for InstancePath {

let Some(components) = store.all_components(&query.timeline, entity_path) else {
if ctx.store_db.entity_db.is_known_entity(entity_path) {
ui.label(format!(
"No components in entity {:?} on timeline {:?}",
entity_path,
query.timeline.name()
));
ui.label(
egui::RichText::new(format!(
"No components logged on timeline {:?}",
query.timeline.name()
))
.color(egui::Color32::KHAKI),
);
} else {
ui.label(
ctx.re_ui
Expand Down
63 changes: 33 additions & 30 deletions crates/re_time_panel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,10 @@ impl TimePanel {
tree: &EntityTree,
ui: &mut egui::Ui,
) {
if !tree
let tree_has_data_in_current_timeline = tree
.prefix_times
.has_timeline(ctx.rec_cfg.time_ctrl.timeline())
&& tree.num_timeless_messages() == 0
{
return; // ignore entities that have no data for the current timeline, nor any timeless data.
}
|| tree.num_timeless_messages() > 0;

// The last part of the path component
let text = if let Some(last_path_part) = last_path_part {
Expand Down Expand Up @@ -478,7 +475,7 @@ impl TimePanel {
let response_rect = response.rect;
self.next_col_right = self.next_col_right.max(response_rect.right());

// From the left of the label, all the way to the rightmost of the time panel
// From the left of the label, all the way to the right-most of the time panel
let full_width_rect = Rect::from_x_y_ranges(
response_rect.left()..=ui.max_rect().right(),
response_rect.y_range(),
Expand All @@ -489,7 +486,7 @@ impl TimePanel {
// ----------------------------------------------

// show the data in the time area:
if is_visible {
if is_visible && tree_has_data_in_current_timeline {
let row_rect =
Rect::from_x_y_ranges(time_area_response.rect.x_range(), response_rect.y_range());

Expand Down Expand Up @@ -547,12 +544,9 @@ impl TimePanel {
for component_name in re_data_ui::ui_visible_components(tree.components.keys()) {
let data = &tree.components[component_name];

if !data.times.has_timeline(ctx.rec_cfg.time_ctrl.timeline())
&& data.num_timeless_messages() == 0
{
continue; // ignore fields that have no data for the current timeline
}

let component_has_data_in_current_timeline =
data.times.has_timeline(ctx.rec_cfg.time_ctrl.timeline())
|| data.num_timeless_messages() > 0;
let component_path = ComponentPath::new(tree.path.clone(), *component_name);
let short_component_name = component_path.component_name.short_name();
let item = Item::ComponentPath(component_path);
Expand Down Expand Up @@ -587,29 +581,38 @@ impl TimePanel {

let response_rect = response.rect;

let empty_messages_over_time = TimeHistogram::default();
let messages_over_time = data
.times
.get(ctx.rec_cfg.time_ctrl.timeline())
.unwrap_or(&empty_messages_over_time);

// `data.times` does not contain timeless. Need to add those manually:
let total_num_messages =
messages_over_time.total_count() + data.num_timeless_messages() as u64;
response.on_hover_ui(|ui| {
if total_num_messages == 0 {
ui.label(
egui::RichText::new(format!(
"No event logged on timeline {:?}",
ctx.rec_cfg.time_ctrl.timeline().name()
))
.color(Color32::KHAKI),
);
} else {
ui.label(format!("Number of events: {total_num_messages}"));
}
});

self.next_col_right = self.next_col_right.max(response_rect.right());

// From the left of the label, all the way to the rightmost of the time panel
// From the left of the label, all the way to the right-most of the time panel
let full_width_rect = Rect::from_x_y_ranges(
response_rect.left()..=ui.max_rect().right(),
response_rect.y_range(),
);
let is_visible = ui.is_rect_visible(full_width_rect);

if is_visible {
let empty_messages_over_time = TimeHistogram::default();
let messages_over_time = data
.times
.get(ctx.rec_cfg.time_ctrl.timeline())
.unwrap_or(&empty_messages_over_time);

// `data.times` does not contain timeless. Need to add those manually:
let total_num_messages =
messages_over_time.total_count() + data.num_timeless_messages() as u64;
response.on_hover_ui(|ui| {
ui.label(format!("Number of events: {total_num_messages}"));
});

if is_visible && component_has_data_in_current_timeline {
// show the data in the time area:
let row_rect = Rect::from_x_y_ranges(
time_area_response.rect.x_range(),
Expand Down Expand Up @@ -859,7 +862,7 @@ fn view_everything(x_range: &Rangef, timeline_axis: &TimelineAxis) -> TimeView {
let factor = if width_sans_gaps > 0.0 {
width / width_sans_gaps
} else {
1.0 // too narrow to fit everything anyways
1.0 // too narrow to fit everything anyway
};

let min = timeline_axis.min();
Expand Down

0 comments on commit f8edf1b

Please sign in to comment.