Skip to content

Commit

Permalink
Port over visible_time_range to use eager serialization
Browse files Browse the repository at this point in the history
Removed _ext file in the process - blueprint api isn't really exposed yet on Rust and this makes it easier to not do silly things.
  • Loading branch information
Wumpf committed Jan 15, 2025
1 parent 10e0b21 commit 0ed287f
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ namespace rerun.blueprint.archetypes;
/// - For time series views, the default is to show the entire timeline.
/// - For any other view, the default is to apply latest-at semantics.
table VisibleTimeRanges (
// TODO:?
//"attr.rust.archetype_eager",
"attr.rust.archetype_eager",
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Default",
"attr.python.aliases": "datatypes.VisibleTimeRangeLike, Sequence[datatypes.VisibleTimeRangeLike]"
Expand Down
1 change: 0 additions & 1 deletion crates/store/re_types/src/blueprint/archetypes/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

29 changes: 21 additions & 8 deletions crates/viewer/re_selection_panel/src/visible_time_range_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn visible_time_range_ui(
) {
use re_types::Component as _;

let ranges = ctx
let visible_time_ranges = ctx
.blueprint_db()
.latest_at(
ctx.blueprint_query,
Expand All @@ -70,12 +70,11 @@ fn visible_time_range_ui(
)
.component_batch::<VisibleTimeRange>()
.unwrap_or_default();
let visible_time_ranges = re_types::blueprint::archetypes::VisibleTimeRanges { ranges };

let timeline_name = *ctx.rec_cfg.time_ctrl.read().timeline().name();
let mut has_individual_range = visible_time_ranges
.range_for_timeline(timeline_name.as_str())
.is_some();
.iter()
.any(|range| range.timeline.as_str() == timeline_name.as_str());

let has_individual_range_before = has_individual_range;
let query_range_before = resolved_query_range.clone();
Expand Down Expand Up @@ -112,7 +111,7 @@ fn save_visible_time_ranges(
has_individual_range: bool,
query_range: QueryRange,
property_path: &EntityPath,
mut visible_time_ranges: re_types::blueprint::archetypes::VisibleTimeRanges,
mut visible_time_range_list: Vec<VisibleTimeRange>,
) {
if has_individual_range {
let time_range = match query_range {
Expand All @@ -125,12 +124,26 @@ fn save_visible_time_ranges(
return;
}
};
visible_time_ranges.set_range_for_timeline(timeline_name, Some(time_range));

if let Some(existing) = visible_time_range_list
.iter_mut()
.find(|r| r.timeline.as_str() == timeline_name.as_str())
{
existing.range = time_range;
} else {
visible_time_range_list.push(
re_types::datatypes::VisibleTimeRange {
timeline: timeline_name.as_str().into(),
range: time_range,
}
.into(),
);
}
} else {
visible_time_ranges.set_range_for_timeline(timeline_name, None);
visible_time_range_list.retain(|r| r.timeline.as_str() != timeline_name.as_str());
}

ctx.save_blueprint_archetype(property_path, &visible_time_ranges);
ctx.save_blueprint_component(property_path, &visible_time_range_list);
}

/// Draws ui for showing and configuring a query range.
Expand Down
9 changes: 5 additions & 4 deletions crates/viewer/re_viewport_blueprint/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,13 @@ impl ViewBlueprint {
blueprint_query,
self.id,
);
let ranges = property.component_array();
let ranges = property.component_array::<blueprint_components::VisibleTimeRange>();

let time_range = ranges.ok().flatten().and_then(|ranges| {
blueprint_archetypes::VisibleTimeRanges { ranges }
.range_for_timeline(active_timeline.name().as_str())
.cloned()
ranges
.iter()
.find(|range| range.timeline.as_str() == active_timeline.name().as_str())
.map(|range| range.range.clone())
});
time_range.map_or_else(
|| {
Expand Down

0 comments on commit 0ed287f

Please sign in to comment.