Skip to content

Commit

Permalink
Introduce a new archetype for Containers (#4580)
Browse files Browse the repository at this point in the history
### What
- Resolves: #4285
- Depends on egui_tiles PR:
rerun-io/egui_tiles#40

**Best reviewed commit-by-commit**

This introduces a new blueprint archetype for Containers.

Although eventually we want to do direct modification of the blueprint
via the same sort of `set_` pattern, I decided it would make for easier
starting point / sanity check to re-implement an equivalent
"end-of-frame" sync.

This now only runs when some form of manual edit has happened to the
blueprint. A simplfication pass also keeps us from storing the trivial
tabs back into the store, making the ContainerBlueprint structure a
better authoritative view of our layout for things like the Tree UI.

Since it's still somewhat unstable, the new behavior is guarded by a new
experimental flag that can be enabled / disabled.

### Important Details
When building up the TileTree from the blueprint we use TileIds that are
a function of the BlueprintId for the containing tile. This simplifies
construction since we know from our `IncludedContents` component exactly
which tiles the inserted content will map to, even if it hasn't been
inserted yet.

When mapping the tile back to the blueprint store, we still need to scan
all of the tiles to figure out what content ids they should map to. If
the tile-id matches a known cotntainer-id from the blueprint, then we
update the corresponding container, preserving the id. We also do some
simplification during this pass and "trivial tabs" instead get mapped
directly to their space-views so they don't need to show up in the
blueprint container.

### Known issues
- Grid holes aren't tracked because egui_tiles doesn't expose these
through a public API.

### 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 newly built examples:
[app.rerun.io](https://app.rerun.io/pr/4580/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/4580/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/4580/index.html?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

- [PR Build Summary](https://build.rerun.io/pr/4580)
- [Docs
preview](https://rerun.io/preview/68e28bbea937694f026734f69893c24f1be6692b/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/68e28bbea937694f026734f69893c24f1be6692b/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
jleibs authored Dec 21, 2023
1 parent 54fc68e commit 99c2d35
Show file tree
Hide file tree
Showing 91 changed files with 4,315 additions and 496 deletions.
84 changes: 46 additions & 38 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ indent = "0.1"
indicatif = "0.17.7" # Progress bar
infer = "0.15" # infer MIME type by checking the magic number signaturefer MIME type by checking the magic number signature
insta = "1.23"
itertools = "0.11" # updating itertools is blocked on the next egui_tiles update
itertools = "0.12" # updating itertools is blocked on the next egui_tiles update
js-sys = "0.3"
# No lazy_static - use `std::sync::OnceLock` or `once_cell` instead
libc = "0.2"
Expand Down Expand Up @@ -279,3 +279,5 @@ debug = true
# egui_extras = { path = "../../egui/crates/egui_extras" }
# egui-wgpu = { path = "../../egui/crates/egui-wgpu" }
# emath = { path = "../../egui/crates/emath" }

egui_tiles = { git = "https://github.com/rerun-io/egui_tiles", rev = "dcdcde10b493683f3e97db47d128683bec0e65b9" } # https://github.com/rerun-io/egui_tiles/pull/40
10 changes: 10 additions & 0 deletions crates/re_query/src/archetype_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@ impl<A: Archetype> ArchetypeView<A> {

/// Convert an `ArchetypeView` back into a native Archetype instance
pub fn to_archetype(&self) -> crate::Result<A> {
for component in A::required_components().iter() {
if self
.components
.get(component)
.map_or(true, |cwi| cwi.is_empty())
{
return Err(QueryError::PrimaryNotFound(*component));
}
}

Ok(A::from_arrow_components(
self.components
.values()
Expand Down
13 changes: 10 additions & 3 deletions crates/re_types/definitions/rerun/blueprint.fbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
include "./blueprint/components/active_tab.fbs";
include "./blueprint/components/auto_layout.fbs";
include "./blueprint/components/auto_space_views.fbs";
include "./blueprint/components/container_kind.fbs";
include "./blueprint/components/entities_determined_by_user.fbs";
include "./blueprint/components/entity_properties_component.fbs";
include "./blueprint/components/included_contents.fbs";
include "./blueprint/components/included_queries.fbs";
include "./blueprint/components/included_space_views.fbs";
include "./blueprint/components/name.fbs";
include "./blueprint/components/panel_view.fbs";
include "./blueprint/components/primary_weights.fbs";
include "./blueprint/components/query_expressions.fbs";
include "./blueprint/components/root_container.fbs";
include "./blueprint/components/secondary_weights.fbs";
include "./blueprint/components/space_view_class.fbs";
include "./blueprint/components/space_view_maximized.fbs";
include "./blueprint/components/space_view_origin.fbs";
include "./blueprint/components/space_view_class.fbs";
include "./blueprint/components/included_space_views.fbs";
include "./blueprint/components/included_queries.fbs";
include "./blueprint/components/viewport_layout.fbs";

include "./blueprint/archetypes/container_blueprint.fbs";
include "./blueprint/archetypes/space_view_blueprint.fbs";
include "./blueprint/archetypes/viewport_blueprint.fbs";
Loading

0 comments on commit 99c2d35

Please sign in to comment.