Skip to content

Commit

Permalink
Make visual time range on views a view property that can be set from …
Browse files Browse the repository at this point in the history
…python code (#6164)

### What

* Part of [#6083](#6083)


And _some_ related refactors that I got engulfed with on this quest:
* document fate of remaining `EntityProperties`
* simplify `DataResult` formation by dropping overrides from the
`OverrideContext`
* took the opportunity to call out `EntityProperties` as
`legacy_properties` in a lot of places which makes it easier to read
these changes
* make it explicit when we want to use latest-at query by introducing
`QueryRange` type

Python API not great yet, will improve and provide examples in an
upcoming iteration.


Planned direct follow-ups to this PR:
* finally remove old History types that we still convert to
* should fix the rest of #6135
if it isn't already by this PR
* make python interface actually nice 
* add examples & more docs

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6164?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6164?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6164)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
Wumpf authored Apr 30, 2024
1 parent 27f8a35 commit b7a72cb
Show file tree
Hide file tree
Showing 52 changed files with 1,351 additions and 669 deletions.
25 changes: 15 additions & 10 deletions crates/re_entity_db/src/entity_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,48 +94,53 @@ impl FromIterator<(EntityPath, EntityProperties)> for EntityPropertyMap {
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct EntityProperties {
pub interactive: bool,
pub interactive: bool, // TODO(andreas): similar to `visible`, needs to become a regular (slightly special - doesn't show up in archetypes) component.

/// What kind of color mapping should be applied (none, map, texture, transfer..)?
pub color_mapper: EditableAutoValue<ColorMapper>,
pub color_mapper: EditableAutoValue<ColorMapper>, // TODO(andreas): should become a component and be part of the DepthImage and regular Images (with limitation to mono channel image).

/// Distance of the projection plane (frustum far plane).
///
/// Only applies to pinhole cameras when in a spatial view, using 3D navigation.
pub pinhole_image_plane_distance: EditableAutoValue<f32>,
pub pinhole_image_plane_distance: EditableAutoValue<f32>, // TODO(#6084): should be a regular component on the Pinhole archetype.

/// Should the depth texture be backprojected into a point cloud?
///
/// Only applies to tensors with meaning=depth that are affected by a pinhole transform.
///
/// The default for 3D views is `true`, but for 2D views it is `false`.
pub backproject_depth: EditableAutoValue<bool>,
pub backproject_depth: EditableAutoValue<bool>, // TODO(andreas): should be a component on the DepthImage archetype.

/// How many depth units per world-space unit. e.g. 1000 for millimeters.
///
/// This corresponds to `re_components::Tensor::meter`.
pub depth_from_world_scale: EditableAutoValue<f32>,
pub depth_from_world_scale: EditableAutoValue<f32>, // TODO(andreas): Just remove once we can edit meter & be able to set semi-clever defaults per visualizer.

/// Used to scale the radii of the points in the resulting point cloud.
pub backproject_radius_scale: EditableAutoValue<f32>,
pub backproject_radius_scale: EditableAutoValue<f32>, // TODO(andreas): should be a component on the DepthImage archetype.

/// Whether to show the 3D transform visualization at all.
// TODO(andreas): should go away once we can disable visualizer. Revisit how to collectively enable/disable these on an entire view.
// To consider: Make a TransformAxis archetype whose indicator is what enables the visualizer
// -> size etc. are now part of this archetype, not the `Transform` archetype
// -> `TransformAxis` itself doesn't have a required component, but the visualizer has. Just like in SeriesLines & Scalar.
// TODO(andreas)/TODO(jleibs): There's a pattern here that we should capture & formalize in the API / codegen / definitions.
pub transform_3d_visible: EditableAutoValue<bool>,

/// The length of the arrows in the entity's own coordinate system (space).
pub transform_3d_size: EditableAutoValue<f32>,
pub transform_3d_size: EditableAutoValue<f32>, // TODO(andreas): should be a component on the Transform3D/TransformAxis archetype.

/// Should the legend be shown (for plot space views).
pub show_legend: EditableAutoValue<bool>,
pub show_legend: EditableAutoValue<bool>, // TODO(andreas): BarChart is still using it, we already have the legend archteype!

/// The location of the legend (for plot space views).
///
/// This is an Option instead of an EditableAutoValue to let each space view class decide on
/// what's the best default.
pub legend_location: Option<LegendCorner>,
pub legend_location: Option<LegendCorner>, // TODO(andreas): BarChart is still using it, we already have the legend archteype!

/// What kind of data aggregation to perform (for plot space views).
pub time_series_aggregator: EditableAutoValue<TimeSeriesAggregator>,
pub time_series_aggregator: EditableAutoValue<TimeSeriesAggregator>, // TODO(andreas): Should be a component probably on SeriesLine, but today it would become a view property.
}

#[cfg(feature = "serde")]
Expand Down
1 change: 1 addition & 0 deletions crates/re_query/src/latest_at/to_archetype/.gitattributes

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

1 change: 1 addition & 0 deletions crates/re_query/src/latest_at/to_archetype/mod.rs

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

58 changes: 58 additions & 0 deletions crates/re_query/src/latest_at/to_archetype/visible_time_range.rs

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

23 changes: 11 additions & 12 deletions crates/re_space_view/src/data_query.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
use nohash_hasher::IntMap;

use re_entity_db::{external::re_data_store::LatestAtQuery, EntityProperties, EntityPropertyMap};
use re_types::ComponentName;
use re_entity_db::{external::re_data_store::LatestAtQuery, EntityDb, EntityProperties};
use re_log_types::Timeline;
use re_viewer_context::{
DataQueryResult, OverridePath, PerVisualizer, StoreContext, VisualizableEntities,
DataQueryResult, PerVisualizer, QueryRange, SpaceViewClassRegistry, StoreContext,
VisualizableEntities,
};

pub struct EntityOverrideContext {
pub root: EntityProperties,
pub individual: EntityPropertyMap,
pub recursive: EntityPropertyMap,
pub legacy_space_view_properties: EntityProperties,

/// Base component overrides that are inherited by all entities.
pub root_component_overrides: IntMap<ComponentName, OverridePath>,
/// Query range that data results should fall back to if they don't specify their own.
pub default_query_range: QueryRange,
}

/// Trait for resolving properties needed by most implementations of [`DataQuery`]
Expand All @@ -22,8 +19,10 @@ pub struct EntityOverrideContext {
pub trait PropertyResolver {
fn update_overrides(
&self,
ctx: &StoreContext<'_>,
query: &LatestAtQuery,
blueprint: &EntityDb,
blueprint_query: &LatestAtQuery,
active_timeline: &Timeline,
space_view_class_registry: &SpaceViewClassRegistry,
query_result: &mut DataQueryResult,
);
}
Expand Down
10 changes: 5 additions & 5 deletions crates/re_space_view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ pub use screenshot::ScreenshotMode;
pub use space_view::SpaceViewBlueprint;
pub use space_view_contents::SpaceViewContents;
pub use sub_archetypes::{
edit_blueprint_component, entity_path_for_space_view_sub_archetype, get_blueprint_component,
query_space_view_sub_archetype, query_space_view_sub_archetype_or_default,
space_view_sub_archetype,
edit_blueprint_component, entity_path_for_view_property, get_blueprint_component,
query_view_property, query_view_property_or_default, view_property,
};
pub use visual_time_range::{
query_visual_history, time_range_boundary_to_visible_history_boundary,
visible_history_boundary_to_time_range_boundary, visible_time_range_to_time_range,
query_visual_history, time_range_from_visible_time_range,
visible_history_boundary_from_time_range_boundary,
visible_history_boundary_to_time_range_boundary,
};
pub use visualizable::determine_visualizable_entities;

Expand Down
Loading

0 comments on commit b7a72cb

Please sign in to comment.