Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New debug option to show an actual timeline for the Blueprint #4609

Merged
merged 23 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0e71c3d
Swap out the whole timeline panel for the blueprint store
jleibs Dec 21, 2023
33d1ce5
Switch blueprint to log with real timepoints
jleibs Dec 21, 2023
2d5e400
Use correct time_ctrl for determining visibillity
jleibs Dec 21, 2023
b7e054f
Use correct query for blueprint entities
jleibs Dec 21, 2023
6d075b1
Use the blueprint time_ctrl to drive the blueprint queries
jleibs Dec 22, 2023
810de30
Make the blueprint timeline useful with an option to disable GC
jleibs Dec 22, 2023
3c91af7
Fix rebase for blueprint timepoint
jleibs Jan 16, 2024
7a5e641
Cleanup menu / config options
jleibs Jan 16, 2024
46af2f8
Fix time state updates
jleibs Jan 16, 2024
f6902ce
Fix build error in release
jleibs Jan 16, 2024
03416d0
Merge branch 'main' into jleibs/blueprint_timeline
jleibs Jan 18, 2024
9d88924
Make the blueprint inspection panel a secondary timeline panel
jleibs Jan 18, 2024
3b8e773
GC the blueprints more frequently
jleibs Jan 18, 2024
5215ad9
Switch blueprint gc to a radio button
jleibs Jan 18, 2024
d773da7
Comment explaining why we can't update the blueprint while we're insp…
jleibs Jan 18, 2024
b2a6047
Use re_ui.radio_value
jleibs Jan 18, 2024
af8cc5d
Plumb store through data_ui
jleibs Jan 18, 2024
072118b
On the timeline view derive store from the TimePanel source
jleibs Jan 18, 2024
c532ed7
More plumbing of queries and stores
jleibs Jan 18, 2024
ea96bb2
Limit entity-path store+query guessing to the selection_panel impleme…
jleibs Jan 18, 2024
b7a5014
Renames and docstrings
jleibs Jan 18, 2024
23ee728
Merge branch 'main' into jleibs/blueprint_timeline
jleibs Jan 18, 2024
79e395a
Title the blueprint streams accordingly
jleibs Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions crates/re_data_ui/src/component_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ impl DataUi for ComponentPath {
component_name,
} = self;

let store = if ctx.app_options.show_blueprint_in_timeline
&& ctx.store_context.blueprint.is_logged_entity(entity_path)
{
ctx.store_context.blueprint.store()
} else {
ctx.entity_db.store()
};
let store = ctx.choose_store_for_query(query);

if let Some(archetype_name) = component_name.indicator_component_archetype() {
ui.label(format!(
Expand Down
5 changes: 4 additions & 1 deletion crates/re_data_ui/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ fn tensor_ui(
let meter = if meaning == TensorDataMeaning::Depth {
ctx.entity_db
.store()
.query_latest_component::<DepthMeter>(entity_path, &ctx.current_query())
.query_latest_component::<DepthMeter>(
entity_path,
&ctx.current_query_for_entity_path(entity_path),
Copy link
Member

Choose a reason for hiding this comment

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

Will a tensor entity ever be on the blueprint timeline? I thought that was only applicable to stuff like containers and space view entities?

Copy link
Member

Choose a reason for hiding this comment

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

I guess I'm a bit confused why some current_query() has become current_query_for_entity_path, but not all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will a tensor entity ever be on the blueprint timeline?

Yes -- data overrides will be stored in the blueprint. So if you set an override, and then select the blueprint entity representing that override you'll hit this code path.

I guess I'm a bit confused why some current_query() has become current_query_for_entity_path, but not all.

I scoped my search & replace to the data_ui elements which is the only context in which it should theoretically matter .

)
.map(|meter| meter.value.0)
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/image_meaning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn image_meaning_for_entity(
ctx: &ViewerContext<'_>,
) -> TensorDataMeaning {
let store = ctx.entity_db.store();
let timeline = &ctx.current_query().timeline;
let timeline = &ctx.current_query_for_entity_path(entity_path).timeline;
if store.entity_has_component(timeline, entity_path, &DepthImage::indicator().name()) {
TensorDataMeaning::Depth
} else if store.entity_has_component(
Expand Down
8 changes: 1 addition & 7 deletions crates/re_data_ui/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ impl DataUi for InstancePath {
instance_key,
} = self;

let store = if ctx.app_options.show_blueprint_in_timeline
&& ctx.store_context.blueprint.is_logged_entity(entity_path)
{
ctx.store_context.blueprint.store()
} else {
ctx.entity_db.store()
};
let store = ctx.choose_store_for_query(query);

let Some(components) = store.all_components(&query.timeline, entity_path) else {
if ctx.entity_db.is_known_entity(entity_path) {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ pub fn instance_hover_card_ui(

// TODO(emilk): give data_ui an alternate "everything on this timeline" query?
// Then we can move the size view into `data_ui`.
let query = ctx.current_query();
let query = ctx.current_query_for_entity_path(&instance_path.entity_path);

if instance_path.instance_key.is_splat() {
if let Some(subtree) = ctx.entity_db.tree().subtree(&instance_path.entity_path) {
Expand Down
9 changes: 7 additions & 2 deletions crates/re_space_view/src/data_query.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use re_entity_db::{EntityProperties, EntityPropertyMap};
use re_entity_db::{external::re_data_store::LatestAtQuery, EntityProperties, EntityPropertyMap};
use re_viewer_context::{
DataQueryResult, IndicatorMatchingEntities, PerVisualizer, StoreContext, VisualizableEntities,
};
Expand All @@ -14,7 +14,12 @@ pub struct EntityOverrideContext {
/// The `SpaceViewBlueprint` is the only thing that likely implements this today
/// but we use a trait here so we don't have to pick up a full dependency on `re_viewport`.
pub trait PropertyResolver {
fn update_overrides(&self, ctx: &StoreContext<'_>, query_result: &mut DataQueryResult);
fn update_overrides(
&self,
ctx: &StoreContext<'_>,
query: &LatestAtQuery,
query_result: &mut DataQueryResult,
);
}

/// The common trait implemented for data queries
Expand Down
50 changes: 35 additions & 15 deletions crates/re_space_view/src/data_query_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ use slotmap::SlotMap;
use smallvec::SmallVec;

use re_entity_db::{
EntityDb, EntityProperties, EntityPropertiesComponent, EntityPropertyMap, EntityTree,
external::re_data_store::LatestAtQuery, EntityDb, EntityProperties, EntityPropertiesComponent,
EntityPropertyMap, EntityTree,
};
use re_log_types::{
path::RuleEffect, DataRow, EntityPath, EntityPathFilter, EntityPathRule, RowId, TimePoint,
path::RuleEffect, DataRow, EntityPath, EntityPathFilter, EntityPathRule, RowId,
};
use re_types_core::archetypes::Clear;
use re_viewer_context::{
DataQueryId, DataQueryResult, DataResult, DataResultHandle, DataResultNode, DataResultTree,
IndicatorMatchingEntities, PerVisualizer, PropertyOverrides, SpaceViewClassIdentifier,
SpaceViewId, StoreContext, SystemCommand, SystemCommandSender as _, ViewSystemIdentifier,
ViewerContext, VisualizableEntities,
blueprint_timepoint, DataQueryId, DataQueryResult, DataResult, DataResultHandle,
DataResultNode, DataResultTree, IndicatorMatchingEntities, PerVisualizer, PropertyOverrides,
SpaceViewClassIdentifier, SpaceViewId, StoreContext, SystemCommand, SystemCommandSender as _,
ViewSystemIdentifier, ViewerContext, VisualizableEntities,
};

use crate::{
Expand Down Expand Up @@ -66,11 +67,12 @@ impl DataQueryBlueprint {
pub fn try_from_db(
id: DataQueryId,
blueprint_db: &EntityDb,
query: &LatestAtQuery,
space_view_class_identifier: SpaceViewClassIdentifier,
) -> Option<Self> {
let expressions = blueprint_db
.store()
.query_timeless_component::<QueryExpressions>(&id.as_entity_path())
.query_latest_component::<QueryExpressions>(&id.as_entity_path(), query)
.map(|c| c.value)?;

let entity_path_filter = EntityPathFilter::from(&expressions);
Expand Down Expand Up @@ -128,7 +130,7 @@ impl DataQueryBlueprint {
}

fn save_expressions(&self, ctx: &ViewerContext<'_>, entity_path_filter: &EntityPathFilter) {
let timepoint = TimePoint::timeless();
let timepoint = blueprint_timepoint();

let expressions_component = QueryExpressions::from(entity_path_filter);

Expand Down Expand Up @@ -351,24 +353,36 @@ impl DataQueryPropertyResolver<'_> {
/// may include properties from the `SpaceView` or `DataQuery`.
/// - The individual overrides are found by walking an override subtree under the `data_query/<id>/individual_overrides`
/// - The group overrides are found by walking an override subtree under the `data_query/<id>/group_overrides`
fn build_override_context(&self, ctx: &StoreContext<'_>) -> EntityOverrideContext {
fn build_override_context(
&self,
ctx: &StoreContext<'_>,
query: &LatestAtQuery,
) -> EntityOverrideContext {
re_tracing::profile_function!();

let mut root: EntityProperties = Default::default();
for prefix in &self.default_stack {
if let Some(overrides) = ctx
.blueprint
.store()
.query_timeless_component::<EntityPropertiesComponent>(prefix)
.query_latest_component::<EntityPropertiesComponent>(prefix, query)
{
root = root.with_child(&overrides.value.0);
}
}

EntityOverrideContext {
root,
individual: self.resolve_entity_overrides_for_path(ctx, &self.individual_override_root),
group: self.resolve_entity_overrides_for_path(ctx, &self.recursive_override_root),
individual: self.resolve_entity_overrides_for_path(
ctx,
query,
&self.individual_override_root,
),
group: self.resolve_entity_overrides_for_path(
ctx,
query,
&self.recursive_override_root,
),
}
}

Expand All @@ -381,6 +395,7 @@ impl DataQueryPropertyResolver<'_> {
fn resolve_entity_overrides_for_path(
&self,
ctx: &StoreContext<'_>,
query: &LatestAtQuery,
override_root: &EntityPath,
) -> EntityPropertyMap {
re_tracing::profile_function!();
Expand All @@ -392,7 +407,7 @@ impl DataQueryPropertyResolver<'_> {
tree.visit_children_recursively(&mut |path: &EntityPath| {
if let Some(props) = blueprint
.store()
.query_timeless_component_quiet::<EntityPropertiesComponent>(path)
.query_latest_component_quiet::<EntityPropertiesComponent>(path, query)
{
let overridden_path =
EntityPath::from(&path.as_slice()[override_root.len()..path.len()]);
Expand Down Expand Up @@ -473,9 +488,14 @@ impl DataQueryPropertyResolver<'_> {

impl<'a> PropertyResolver for DataQueryPropertyResolver<'a> {
/// Recursively walk the [`DataResultTree`] and update the [`PropertyOverrides`] for each node.
fn update_overrides(&self, ctx: &StoreContext<'_>, query_result: &mut DataQueryResult) {
fn update_overrides(
&self,
ctx: &StoreContext<'_>,
query: &LatestAtQuery,
query_result: &mut DataQueryResult,
) {
re_tracing::profile_function!();
let entity_overrides = self.build_override_context(ctx);
let entity_overrides = self.build_override_context(ctx, query);

if let Some(root) = query_result.tree.root_handle() {
self.update_overrides_recursive(
Expand Down
7 changes: 3 additions & 4 deletions crates/re_space_view_spatial/src/contexts/depth_offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ impl ViewContextSystem for EntityDepthOffsets {
// Use a BTreeSet for entity hashes to get a stable order.
let mut entities_per_draw_order = BTreeMap::<DrawOrder, BTreeSet<DrawOrderTarget>>::new();
for data_result in query.iter_visible_data_results(Self::identifier()) {
if let Some(draw_order) = store.query_latest_component::<DrawOrder>(
&data_result.entity_path,
&ctx.rec_cfg.time_ctrl.read().current_query(),
) {
if let Some(draw_order) = store
.query_latest_component::<DrawOrder>(&data_result.entity_path, &ctx.current_query())
{
entities_per_draw_order
.entry(draw_order.value)
.or_default()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl ViewContextSystem for TransformContext {
return;
};

let time_query = ctx.rec_cfg.time_ctrl.read().current_query();
let time_query = ctx.current_query();

// Child transforms of this space
self.gather_descendants_transforms(
Expand Down
Loading
Loading