Skip to content

Commit

Permalink
Tensor space view can now show images (#5567)
Browse files Browse the repository at this point in the history
### What

== allow showing tensor data that was logged via the Image archetype.

* Fixes #5420


https://github.com/rerun-io/rerun/assets/1220815/8b4dab05-b50a-4946-813f-0d206f00d417


### 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/5567/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5567/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/5567/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
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5567)
- [Docs
preview](https://rerun.io/preview/d802e3bb5c024c3d7afdbdadb77493a9f4d87f80/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/d802e3bb5c024c3d7afdbdadb77493a9f4d87f80/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
Wumpf authored Mar 19, 2024
1 parent 21d010e commit f6baaad
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions crates/re_space_view_tensor/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ use re_types::{
};
use re_viewer_context::{
gpu_bridge::{self, colormap_dropdown_button_ui},
SpaceViewClass, SpaceViewClassIdentifier, SpaceViewClassRegistryError, SpaceViewId,
SpaceViewState, SpaceViewStateExt as _, SpaceViewSystemExecutionError, TensorStatsCache,
ViewQuery, ViewerContext,
IdentifiedViewSystem as _, IndicatedEntities, PerVisualizer, SpaceViewClass,
SpaceViewClassIdentifier, SpaceViewClassRegistryError, SpaceViewId, SpaceViewState,
SpaceViewStateExt as _, SpaceViewSystemExecutionError, TensorStatsCache, ViewQuery,
ViewerContext, VisualizableEntities,
};

use crate::{tensor_dimension_mapper::dimension_mapping_ui, visualizer_system::TensorSystem};
Expand Down Expand Up @@ -171,6 +172,27 @@ impl SpaceViewClass for TensorSpaceView {
Box::<ViewTensorState>::default()
}

fn choose_default_visualizers(
&self,
entity_path: &EntityPath,
visualizable_entities_per_visualizer: &PerVisualizer<VisualizableEntities>,
_indicated_entities_per_visualizer: &PerVisualizer<IndicatedEntities>,
) -> re_viewer_context::SmallVisualizerSet {
// Default implementation would not suggest the Tensor visualizer for images,
// since they're not indicated with a Tensor indicator.
// (and as of writing, something needs to be both visualizable and indicated to be shown in a visualizer)

// Keeping this implementation simple: We know there's only a single visualizer here.
if visualizable_entities_per_visualizer
.get(&TensorSystem::identifier())
.map_or(false, |entities| entities.contains(entity_path))
{
std::iter::once(TensorSystem::identifier()).collect()
} else {
Default::default()
}
}

fn selection_ui(
&self,
ctx: &ViewerContext<'_>,
Expand Down

0 comments on commit f6baaad

Please sign in to comment.