Skip to content

Commit

Permalink
Add UI for latest-at on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Sep 26, 2024
1 parent 56a06fd commit 347c3e4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions crates/viewer/re_space_view_dataframe/src/view_query_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ impl QueryV2 {
self.query_property
.save_blueprint_component(ctx, &component);
}

pub(crate) fn latest_at(&self) -> Result<bool, SpaceViewSystemExecutionError> {
Ok(self
.query_property
.component_or_empty::<components::ApplyLatestAt>()?
.map_or(false, |comp| *comp.0))
}

pub(crate) fn set_latest_at(&self, ctx: &ViewerContext<'_>, latest_at: bool) {
self.query_property
.save_blueprint_component(ctx, &components::ApplyLatestAt(latest_at.into()));
}
}

// UI
Expand All @@ -150,8 +162,12 @@ impl QueryV2 {
let timeline = self.timeline(ctx)?;

self.timeline_ui(ctx, ui, &timeline)?;
ui.separator();
self.filter_range_ui(ctx, ui, &timeline)?;
ui.separator();
self.filter_event_ui(ctx, ui, &timeline, space_view_id)?;
ui.separator();
self.latest_at_ui(ctx, ui)?;

Ok(())
}
Expand Down Expand Up @@ -392,6 +408,29 @@ impl QueryV2 {

Ok(())
}

fn latest_at_ui(
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
) -> Result<(), SpaceViewSystemExecutionError> {
ui.label("Empty cells:");

let mut latest_at = self.latest_at()?;
let changed = {
ui.re_radio_value(&mut latest_at, false, "Leave empty")
.changed()
} | {
ui.re_radio_value(&mut latest_at, true, "Fill with latest-at values")
.changed()
};

if changed {
self.set_latest_at(ctx, latest_at);
}

Ok(())
}
}

/// Gather all entities that can meaningfully be used as point-of-view for this view.
Expand Down

0 comments on commit 347c3e4

Please sign in to comment.