Skip to content

Commit

Permalink
Separate crate for tensor space view (#2334)
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

Moves the last Space View to the new Space View framework and a separate
crate.
One of the last pieces of #2249 

Detangles viewport from all concrete Space Views:
`cargo depgraph --all-deps --workspace-only --all-features
--dedup-transitive-deps | dot -Tpng > deps.png`

![deps](https://github.com/rerun-io/rerun/assets/1220815/c5996f26-fd31-461b-9043-484ec2fb7637)


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

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/89dd232/docs
Examples preview: https://rerun.io/preview/89dd232/examples
<!-- pr-link-docs:end -->
  • Loading branch information
Wumpf authored Jun 9, 2023
1 parent cd20d17 commit a18b39d
Show file tree
Hide file tree
Showing 18 changed files with 284 additions and 196 deletions.
37 changes: 29 additions & 8 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 @@ -47,6 +47,7 @@ re_smart_channel = { path = "crates/re_smart_channel", version = "0.7.0-alpha.0"
re_space_view = { path = "crates/re_space_view", version = "0.7.0-alpha.0", default-features = false }
re_space_view_bar_chart = { path = "crates/re_space_view_bar_chart", version = "0.7.0-alpha.0", default-features = false }
re_space_view_spatial = { path = "crates/re_space_view_spatial", version = "0.7.0-alpha.0", default-features = false }
re_space_view_tensor = { path = "crates/re_space_view_tensor", 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 }
Expand Down
41 changes: 41 additions & 0 deletions crates/re_space_view_tensor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
authors.workspace = true
description = "A Space View dedicated to visualizing tensors with arbitrary dimensionality."
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "re_space_view_tensor"
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_renderer.workspace = true
re_space_view.workspace = true
re_tensor_ops.workspace = true
re_tracing.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true

anyhow.workspace = true
ahash.workspace = true
bytemuck.workspace = true
eframe.workspace = true
egui.workspace = true
half.workspace = true
ndarray.workspace = true
thiserror.workspace = true
vec1.workspace = true
wgpu.workspace = true
11 changes: 11 additions & 0 deletions crates/re_space_view_tensor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# re_space_view_tensor

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

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

A Space View dedicated to visualizing tensors with arbitrary dimensionality.

10 changes: 10 additions & 0 deletions crates/re_space_view_tensor/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Rerun tensor Space View.
//!
//! A Space View dedicated to visualizing tensors with arbitrary dimensionality.
mod scene_part;
mod space_view_class;
mod tensor_dimension_mapper;
mod tensor_slice_to_gpu;

pub use space_view_class::TensorSpaceView;
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
use re_arrow_store::LatestAtQuery;
use re_components::{DecodedTensor, InstanceKey, Tensor};
use re_components::{DecodedTensor, Tensor};
use re_data_store::{EntityPath, EntityProperties, InstancePath};
use re_viewer_context::{SceneQuery, TensorDecodeCache, ViewerContext};
use re_log_types::{Component as _, InstanceKey};
use re_viewer_context::{
ArchetypeDefinition, ScenePart, SceneQuery, SpaceViewClass, SpaceViewHighlights,
TensorDecodeCache, ViewerContext,
};

/// A tensor scene, with everything needed to render it.
use crate::TensorSpaceView;

/// A bar chart scene, with everything needed to render it.
#[derive(Default)]
pub struct SceneTensor {
pub tensors: std::collections::BTreeMap<InstancePath, DecodedTensor>,
}

impl SceneTensor {
/// Loads all tensors into the scene according to the given query.
pub(crate) fn load(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) {
impl ScenePart<TensorSpaceView> for SceneTensor {
fn archetype(&self) -> ArchetypeDefinition {
vec1::vec1![Tensor::name()]
}

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

let store = &ctx.store_db.entity_db.data_store;
Expand All @@ -23,8 +39,12 @@ impl SceneTensor {
self.load_tensor_entity(ctx, ent_path, &props, tensor);
}
}

Vec::new()
}
}

impl SceneTensor {
fn load_tensor_entity(
&mut self,
ctx: &mut ViewerContext<'_>,
Expand Down
Loading

0 comments on commit a18b39d

Please sign in to comment.