Skip to content

Commit

Permalink
Refactor naming of SpaceViewClass and changed TextSpaceView name …
Browse files Browse the repository at this point in the history
…to "Text Log" (#4386)

### What

Space View names are now user-facing, so I wanted to change "TextLog" to
"Text Log", consistent with all other multi-word space view names. In
the process, I ended up refactoring the way names is handled for
`SpaceViewClass`s ~~and `ViewSystem`s~~, such that they all provide a
convenient `ClassName::NAME` constant to use throughout the code.

### 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 [app.rerun.io](https://app.rerun.io/pr/4386) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/4386)
- [Docs
preview](https://rerun.io/preview/700b50bc390cb857067a2f3242f4225dffe08e5d/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/700b50bc390cb857067a2f3242f4225dffe08e5d/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
abey79 authored and teh-cmc committed Nov 30, 2023
1 parent 7f7a1fc commit 48983df
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 57 deletions.
6 changes: 2 additions & 4 deletions crates/re_space_view_bar_chart/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use re_log_types::EntityPath;
use re_space_view::controls;
use re_types::datatypes::TensorBuffer;
use re_viewer_context::{
auto_color, SpaceViewClass, SpaceViewClassName, SpaceViewClassRegistryError, SpaceViewId,
auto_color, SpaceViewClass, SpaceViewClassRegistryError, SpaceViewId,
SpaceViewSystemExecutionError, ViewContextCollection, ViewPartCollection, ViewQuery,
ViewerContext,
};
Expand All @@ -17,9 +17,7 @@ pub struct BarChartSpaceView;
impl SpaceViewClass for BarChartSpaceView {
type State = ();

fn name(&self) -> SpaceViewClassName {
"Bar Chart".into()
}
const NAME: &'static str = "Bar Chart";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_HISTOGRAM
Expand Down
8 changes: 1 addition & 7 deletions crates/re_space_view_spatial/src/space_view_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ use crate::{
#[derive(Default)]
pub struct SpatialSpaceView2D;

impl SpatialSpaceView2D {
pub const NAME: &'static str = "2D";
}

impl SpaceViewClass for SpatialSpaceView2D {
type State = SpatialSpaceViewState;

fn name(&self) -> re_viewer_context::SpaceViewClassName {
Self::NAME.into()
}
const NAME: &'static str = "2D";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_2D
Expand Down
8 changes: 1 addition & 7 deletions crates/re_space_view_spatial/src/space_view_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ use crate::{
#[derive(Default)]
pub struct SpatialSpaceView3D;

impl SpatialSpaceView3D {
pub const NAME: &'static str = "3D";
}

impl SpaceViewClass for SpatialSpaceView3D {
type State = SpatialSpaceViewState;

fn name(&self) -> re_viewer_context::SpaceViewClassName {
Self::NAME.into()
}
const NAME: &'static str = "3D";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_3D
Expand Down
6 changes: 2 additions & 4 deletions crates/re_space_view_tensor/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use re_types::{
tensor_data::{DecodedTensor, TensorDataMeaning},
};
use re_viewer_context::{
gpu_bridge, gpu_bridge::colormap_dropdown_button_ui, SpaceViewClass, SpaceViewClassName,
gpu_bridge, gpu_bridge::colormap_dropdown_button_ui, SpaceViewClass,
SpaceViewClassRegistryError, SpaceViewId, SpaceViewState, SpaceViewSystemExecutionError,
TensorStatsCache, ViewContextCollection, ViewPartCollection, ViewQuery, ViewerContext,
};
Expand Down Expand Up @@ -136,9 +136,7 @@ impl PerTensorState {
impl SpaceViewClass for TensorSpaceView {
type State = ViewTensorState;

fn name(&self) -> SpaceViewClassName {
"Tensor".into()
}
const NAME: &'static str = "Tensor";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_TENSOR
Expand Down
10 changes: 4 additions & 6 deletions crates/re_space_view_text_document/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use egui::Label;

use re_viewer_context::external::re_data_store::EntityProperties;
use re_viewer_context::{
external::re_log_types::EntityPath, SpaceViewClass, SpaceViewClassName,
SpaceViewClassRegistryError, SpaceViewId, SpaceViewState, SpaceViewSystemExecutionError,
ViewContextCollection, ViewPartCollection, ViewQuery, ViewerContext,
external::re_log_types::EntityPath, SpaceViewClass, SpaceViewClassRegistryError, SpaceViewId,
SpaceViewState, SpaceViewSystemExecutionError, ViewContextCollection, ViewPartCollection,
ViewQuery, ViewerContext,
};

use crate::view_part_system::TextDocumentEntry;
Expand Down Expand Up @@ -49,9 +49,7 @@ pub struct TextDocumentSpaceView;
impl SpaceViewClass for TextDocumentSpaceView {
type State = TextDocumentSpaceViewState;

fn name(&self) -> SpaceViewClassName {
"Text Document".into()
}
const NAME: &'static str = "Text Document";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_TEXTBOX
Expand Down
6 changes: 2 additions & 4 deletions crates/re_space_view_text_log/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use re_data_ui::item_ui;
use re_log_types::{EntityPath, TimePoint, Timeline};
use re_types::components::TextLogLevel;
use re_viewer_context::{
level_to_rich_text, AutoSpawnHeuristic, PerSystemEntities, SpaceViewClass, SpaceViewClassName,
level_to_rich_text, AutoSpawnHeuristic, PerSystemEntities, SpaceViewClass,
SpaceViewClassRegistryError, SpaceViewId, SpaceViewState, SpaceViewSystemExecutionError,
ViewContextCollection, ViewPartCollection, ViewQuery, ViewerContext,
};
Expand Down Expand Up @@ -42,9 +42,7 @@ pub struct TextSpaceView;
impl SpaceViewClass for TextSpaceView {
type State = TextSpaceViewState;

fn name(&self) -> SpaceViewClassName {
"TextLog".into()
}
const NAME: &'static str = "Text Log";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_TEXTBOX
Expand Down
10 changes: 2 additions & 8 deletions crates/re_space_view_time_series/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use re_viewer_context::external::re_data_store::{
EditableAutoValue, EntityProperties, LegendCorner,
};
use re_viewer_context::{
SpaceViewClass, SpaceViewClassName, SpaceViewClassRegistryError, SpaceViewId, SpaceViewState,
SpaceViewClass, SpaceViewClassRegistryError, SpaceViewId, SpaceViewState,
SpaceViewSystemExecutionError, ViewContextCollection, ViewPartCollection, ViewQuery,
ViewerContext,
};
Expand All @@ -34,16 +34,10 @@ impl SpaceViewState for TimeSeriesSpaceViewState {
#[derive(Default)]
pub struct TimeSeriesSpaceView;

impl TimeSeriesSpaceView {
pub const NAME: &'static str = "Time Series";
}

impl SpaceViewClass for TimeSeriesSpaceView {
type State = TimeSeriesSpaceViewState;

fn name(&self) -> SpaceViewClassName {
Self::NAME.into()
}
const NAME: &'static str = "Time Series";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_CHART
Expand Down
4 changes: 2 additions & 2 deletions crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use re_types::{
use re_ui::list_item::ListItem;
use re_ui::ReUi;
use re_viewer_context::{
gpu_bridge::colormap_dropdown_button_ui, Item, SpaceViewClassName, SpaceViewId, SystemCommand,
SystemCommandSender as _, UiVerbosity, ViewerContext,
gpu_bridge::colormap_dropdown_button_ui, Item, SpaceViewClass, SpaceViewClassName, SpaceViewId,
SystemCommand, SystemCommandSender as _, UiVerbosity, ViewerContext,
};
use re_viewport::{external::re_space_view::QueryExpressions, Viewport, ViewportBlueprint};

Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/visible_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use re_log_types::{EntityPath, TimeRange, TimeType, TimeZone};
use re_space_view_spatial::{SpatialSpaceView2D, SpatialSpaceView3D};
use re_space_view_time_series::TimeSeriesSpaceView;
use re_types_core::ComponentName;
use re_viewer_context::{SpaceViewClassName, ViewerContext};
use re_viewer_context::{SpaceViewClass, SpaceViewClassName, ViewerContext};

/// These space views support the Visible History feature.
static VISIBLE_HISTORY_SUPPORTED_SPACE_VIEWS: once_cell::sync::Lazy<HashSet<SpaceViewClassName>> =
Expand Down
7 changes: 6 additions & 1 deletion crates/re_viewer_context/src/space_view/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ pub trait SpaceViewClass: std::marker::Sized {
/// State of a space view.
type State: SpaceViewState + Default + 'static;

/// Name for this space view class.
const NAME: &'static str;

/// Name of this space view class.
///
/// Used for both ui display and identification.
/// Must be unique within a viewer session.
fn name(&self) -> SpaceViewClassName;
fn name(&self) -> SpaceViewClassName {
Self::NAME.into()
}

/// Icon used to identify this space view class.
fn icon(&self) -> &'static re_ui::Icon;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
SpaceViewClass, SpaceViewClassName, SpaceViewClassRegistryError, SpaceViewSystemExecutionError,
SpaceViewClass, SpaceViewClassRegistryError, SpaceViewSystemExecutionError,
SpaceViewSystemRegistry, ViewContextCollection, ViewPartCollection, ViewQuery, ViewerContext,
};
use re_data_store::EntityProperties;
Expand All @@ -11,9 +11,7 @@ pub struct SpaceViewClassPlaceholder;
impl SpaceViewClass for SpaceViewClassPlaceholder {
type State = ();

fn name(&self) -> SpaceViewClassName {
"Unknown Space View Class".into()
}
const NAME: &'static str = "Unknown Space View Class";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_UNKNOWN
Expand Down
4 changes: 2 additions & 2 deletions crates/re_viewport/src/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use re_space_view_time_series::TimeSeriesSpaceView;
use re_types::blueprint::SpaceViewComponent;
use re_viewer_context::{
DataQueryId, DataResult, DynSpaceViewClass, PerSystemDataResults, PerSystemEntities,
SpaceViewClassName, SpaceViewHighlights, SpaceViewId, SpaceViewState, SpaceViewSystemRegistry,
StoreContext, ViewerContext,
SpaceViewClass, SpaceViewClassName, SpaceViewHighlights, SpaceViewId, SpaceViewState,
SpaceViewSystemRegistry, StoreContext, ViewerContext,
};

// ----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use re_viewer::external::{
re_renderer, re_ui,
re_viewer_context::{
HoverHighlight, Item, SelectionHighlight, SpaceViewClass, SpaceViewClassLayoutPriority,
SpaceViewClassName, SpaceViewClassRegistryError, SpaceViewId, SpaceViewState,
SpaceViewSystemExecutionError, SpaceViewSystemRegistry, UiVerbosity, ViewContextCollection,
ViewPartCollection, ViewQuery, ViewerContext,
SpaceViewClassRegistryError, SpaceViewId, SpaceViewState, SpaceViewSystemExecutionError,
SpaceViewSystemRegistry, UiVerbosity, ViewContextCollection, ViewPartCollection, ViewQuery,
ViewerContext,
},
};

Expand Down Expand Up @@ -69,10 +69,7 @@ impl SpaceViewClass for ColorCoordinatesSpaceView {
// State type as described above.
type State = ColorCoordinatesSpaceViewState;

fn name(&self) -> SpaceViewClassName {
// Name and identifier of this Space View.
"Color Coordinates".into()
}
const NAME: &'static str = "Color Coordinates";

fn icon(&self) -> &'static re_ui::Icon {
&re_ui::icons::SPACE_VIEW_SCATTERPLOT
Expand Down

0 comments on commit 48983df

Please sign in to comment.