Skip to content

Commit

Permalink
Initial Space View trait & port of text space views to the new Space …
Browse files Browse the repository at this point in the history
…View trait system (#2281)

<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

Main pieces of:
* #2249 
* #1873 

Introduces a new framework for space view classes that will eventually
replace `ViewCategory` (right now the systems live side by side,
creating some oddities).
Ports text & text-box space views to this new system.

### Why

This paves the way for more structured space views, more streamlined
blueprint configuration and user defined space views.
In fact, this PR already enables user defined space views, but does not
yet expose a way to add them to the viewport (this can be done with some
small hacks to the space view adding code though and works very well!)

### Future work / discussion

There is still a lot of open question on the space view trait and it
will require changes as we move the other space views over to it.

Most notably, archetypes are defined by have no effect yet!
Overall, scene definition can be regarded as experimental at this point.
I chose to have a hard separation of `SceneElement` (the successor of
`ScenePart`) in the hope of providing a more powerful framework and an
easy hook for future parallelization. We'll need to see how this pans
out though!

Unlike planned, the definition of the space view class trait (as well as
implementation utilities) are not in a separate crate, but part of the
viewer context since global access to the space view type registry
proved very valuable.
We could still separate some parts of it out if desirable, but this
seems not very important at the moment.

### 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)

<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2281
  • Loading branch information
Wumpf authored May 31, 2023
1 parent 96b0a0a commit fe1869e
Show file tree
Hide file tree
Showing 37 changed files with 1,101 additions and 316 deletions.
38 changes: 37 additions & 1 deletion Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ re_renderer = { path = "crates/re_renderer", version = "0.7.0-alpha.0", default-
re_sdk = { path = "crates/re_sdk", version = "0.7.0-alpha.0", default-features = false }
re_sdk_comms = { path = "crates/re_sdk_comms", version = "0.7.0-alpha.0", default-features = false }
re_smart_channel = { path = "crates/re_smart_channel", version = "0.7.0-alpha.0", default-features = false }
re_space_view_text = { path = "crates/re_space_view_text", version = "0.7.0-alpha.0", default-features = false }
re_space_view_text_box = { path = "crates/re_space_view_text_box", version = "0.7.0-alpha.0", default-features = false }
re_string_interner = { path = "crates/re_string_interner", version = "0.7.0-alpha.0", default-features = false }
re_tensor_ops = { path = "crates/re_tensor_ops", version = "0.7.0-alpha.0", default-features = false }
re_time_panel = { path = "crates/re_time_panel", version = "=0.7.0-alpha.0", default-features = false }
Expand Down Expand Up @@ -102,6 +104,7 @@ time = { version = "0.3", default-features = false, features = [
] }
tinyvec = { version = "1.6", features = ["alloc", "rustc_1_55"] }
tokio = { version = "1.24", default-features = false }
vec1 = "1.8"
web-time = "0.2.0"
wgpu = { version = "0.16.1" }
wgpu-core = { version = "0.16.1" }
Expand Down
32 changes: 32 additions & 0 deletions crates/re_space_view_text/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
authors.workspace = true
description = "A Space View that shows text entries in a table and scrolls with the active time."
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "re_space_view_text"
publish = true
readme = "README.md"
repository.workspace = true
rust-version.workspace = true
version.workspace = true
include = ["../../LICENSE-APACHE", "../../LICENSE-MIT", "**/*.rs", "Cargo.toml"]

[package.metadata.docs.rs]
all-features = true

[dependencies]
re_arrow_store.workspace = true
re_components.workspace = true
re_data_store.workspace = true
re_data_ui.workspace = true
re_log_types.workspace = true
re_log.workspace = true
re_query.workspace = true
re_tracing.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true

egui.workspace = true
egui_extras.workspace = true
vec1.workspace = true
11 changes: 11 additions & 0 deletions crates/re_space_view_text/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# re_space_view_text

Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates.

[![Latest version](https://img.shields.io/crates/v/re_space_view_text.svg)](https://crates.io/crates/re_space_view_text)
[![Documentation](https://docs.rs/re_space_view_text/badge.svg)](https://docs.rs/re_space_view_text)
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)

A Space View that shows text entries in a table and scrolls with the active time.

8 changes: 8 additions & 0 deletions crates/re_space_view_text/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Rerun Text Space Views
//!
//! A Space View that shows text entries in a table and scrolls with the active time.
mod scene_element;
mod space_view_class;

pub use space_view_class::TextSpaceView;
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ use re_arrow_store::TimeRange;
use re_data_store::EntityPath;
use re_log_types::{Component as _, InstanceKey, RowId};
use re_query::{range_entity_with_primary, QueryError};
use re_viewer_context::{SceneQuery, ViewerContext};
use re_viewer_context::{ArchetypeDefinition, SceneElementImpl, SceneQuery, ViewerContext};

use super::ui::ViewTextFilters;

// ---
use super::space_view_class::TextSpaceViewState;

#[derive(Debug, Clone)]
pub struct TextEntry {
Expand All @@ -31,24 +29,27 @@ pub struct SceneText {
pub text_entries: Vec<TextEntry>,
}

impl SceneText {
/// Loads all text components into the scene according to the given query.
pub(crate) fn load(
impl SceneElementImpl for SceneText {
type State = TextSpaceViewState;

fn archetype(&self) -> ArchetypeDefinition {
vec1::vec1![re_components::TextEntry::name()]
}

fn populate(
&mut self,
ctx: &ViewerContext<'_>,
ctx: &mut ViewerContext<'_>,
query: &SceneQuery<'_>,
filters: &ViewTextFilters,
state: &TextSpaceViewState,
) {
re_tracing::profile_function!();

let store = &ctx.log_db.entity_db.data_store;

for entity_path in query.entity_paths {
let ent_path = entity_path;

// Early filtering: if we're not showing it the view, there isn't much point
// in querying it to begin with... at least for now.
if !filters.is_entity_path_visible(ent_path) {
if !state.filters.is_entity_path_visible(ent_path) {
return;
}

Expand Down Expand Up @@ -76,7 +77,7 @@ impl SceneText {
// Early filtering once more, see above.
let is_visible = level
.as_ref()
.map_or(true, |lvl| filters.is_log_level_visible(lvl));
.map_or(true, |lvl| state.filters.is_log_level_visible(lvl));

if is_visible {
self.text_entries.push(TextEntry {
Expand All @@ -98,4 +99,8 @@ impl SceneText {
}
}
}

fn as_any(&self) -> &dyn std::any::Any {
self
}
}
Loading

1 comment on commit fe1869e

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.25.

Benchmark suite Current: fe1869e Previous: 96b0a0a Ratio
batch_points_arrow/encode_log_msg 121947 ns/iter (± 971) 92919 ns/iter (± 728) 1.31

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.