Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor naming of SpaceViewClass and changed TextSpaceView name to "Text Log" #4386

Merged
merged 4 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -10,8 +10,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
Loading