Skip to content

Commit

Permalink
Move time series space view to its own crate
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jun 7, 2023
1 parent b42f4f0 commit 13ca40b
Show file tree
Hide file tree
Showing 18 changed files with 423 additions and 334 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

0 comments on commit 13ca40b

Please sign in to comment.