Skip to content

Commit

Permalink
Separate crate for time series space view (#2324)
Browse files Browse the repository at this point in the history
<!--
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

Changed space view registry a little bit to make it easy to report
failure to find a type (`get_and_log_error`)

### 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/2324

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/9c37b91/docs
Examples preview: https://rerun.io/preview/9c37b91/examples
<!-- pr-link-docs:end -->
  • Loading branch information
Wumpf authored Jun 8, 2023
1 parent 669e115 commit f9d8a99
Show file tree
Hide file tree
Showing 18 changed files with 426 additions and 342 deletions.
22 changes: 20 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ re_space_view_bar_chart = { path = "crates/re_space_view_bar_chart", version = "
re_space_view_spatial = { path = "crates/re_space_view_spatial", 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_space_view_time_series = { path = "crates/re_space_view_time_series", 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
32 changes: 32 additions & 0 deletions crates/re_space_view_time_series/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 plots over Rerun timelines."
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "re_space_view_time_series"
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_log_types.workspace = true
re_log.workspace = true
re_renderer.workspace = true
re_space_view.workspace = true
re_tracing.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true
re_query.workspace = true
re_format.workspace = true

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

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

[![Latest version](https://img.shields.io/crates/v/re_space_view_bar_chart.svg)](https://crates.io/crates/re_space_view_bar_chart)
[![Documentation](https://docs.rs/re_space_view_bar_chart/badge.svg)](https://docs.rs/re_space_view_bar_chart)
![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 plots over Rerun timelines.

8 changes: 8 additions & 0 deletions crates/re_space_view_time_series/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Rerun time series Space View
//!
//! A Space View that shows plots over Rerun timelines.
mod scene_part;
mod space_view_class;

pub use space_view_class::TimeSeriesSpaceView;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use re_arrow_store::TimeRange;
use re_log_types::{Component, InstanceKey};
use re_log_types::{Component, ComponentName, InstanceKey};
use re_query::{range_entity_with_primary, QueryError};
use re_viewer_context::{AnnotationMap, DefaultColor, SceneQuery, ViewerContext};
use re_viewer_context::{AnnotationMap, DefaultColor, ScenePart, SceneQuery, ViewerContext};

// ---
use crate::TimeSeriesSpaceView;

#[derive(Clone, Debug)]
pub struct PlotPointAttrs {
Expand Down Expand Up @@ -59,17 +59,41 @@ pub struct SceneTimeSeries {
pub lines: Vec<PlotSeries>,
}

impl SceneTimeSeries {
/// Loads all plots into the scene according to the given query.
pub(crate) fn load(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) {
impl ScenePart<TimeSeriesSpaceView> for SceneTimeSeries {
fn archetype(&self) -> re_viewer_context::ArchetypeDefinition {
vec1::Vec1::try_from(Self::archetype_array()).unwrap() // TODO(wumpf): `archetype` should return a fixed sized array.
}

fn populate(
&mut self,
ctx: &mut ViewerContext<'_>,
query: &SceneQuery<'_>,
_space_view_state: &<TimeSeriesSpaceView as re_viewer_context::SpaceViewClass>::State,
_scene_context: &<TimeSeriesSpaceView as re_viewer_context::SpaceViewClass>::Context,
_highlights: &re_viewer_context::SpaceViewHighlights,
) -> Vec<re_renderer::QueueableDrawData> {
re_tracing::profile_function!();

self.annotation_map.load(ctx, query);

self.load_scalars(ctx, query);

Vec::new()
}
}

impl SceneTimeSeries {
fn archetype_array() -> [ComponentName; 6] {
[
InstanceKey::name(),
re_components::Scalar::name(),
re_components::ScalarPlotProps::name(),
re_components::ColorRGBA::name(),
re_components::Radius::name(),
re_components::Label::name(),
]
}

#[inline(never)] // Better callstacks on crashes
fn load_scalars(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) {
re_tracing::profile_function!();

Expand All @@ -88,14 +112,7 @@ impl SceneTimeSeries {
TimeRange::new(i64::MIN.into(), i64::MAX.into()),
);

let components = [
InstanceKey::name(),
re_components::Scalar::name(),
re_components::ScalarPlotProps::name(),
re_components::ColorRGBA::name(),
re_components::Radius::name(),
re_components::Label::name(),
];
let components = Self::archetype_array();
let ent_views = range_entity_with_primary::<re_components::Scalar, 6>(
store, &query, ent_path, components,
);
Expand Down
Loading

1 comment on commit f9d8a99

@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: f9d8a99 Previous: 669e115 Ratio
tuid/Tuid::random 45 ns/iter (± 0) 33 ns/iter (± 0) 1.36

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

Please sign in to comment.