re_viewer_context/view/
mod.rs

1//! Rerun View class definition
2//!
3//! Defines a framework & utilities for defining classes of views in the Rerun viewer.
4//! Does not implement any concrete view.
5
6// TODO(andreas): Can we move some of these to the `re_view` crate?
7mod highlights;
8mod named_system;
9mod spawn_heuristics;
10mod system_execution_output;
11mod view_class;
12mod view_class_placeholder;
13mod view_class_registry;
14mod view_context;
15mod view_context_system;
16mod view_query;
17mod view_states;
18mod visualizer_entity_subscriber;
19mod visualizer_system;
20
21pub use highlights::{
22    OptionalViewEntityHighlight, ViewEntityHighlight, ViewHighlights, ViewOutlineMasks,
23};
24pub use named_system::{IdentifiedViewSystem, PerSystemEntities, ViewSystemIdentifier};
25pub use spawn_heuristics::{RecommendedView, ViewSpawnHeuristics};
26pub use system_execution_output::SystemExecutionOutput;
27pub use view_class::{
28    ViewClass, ViewClassExt, ViewClassLayoutPriority, ViewState, ViewStateExt,
29    VisualizableFilterContext,
30};
31pub use view_class_placeholder::ViewClassPlaceholder;
32pub use view_class_registry::{ViewClassRegistry, ViewClassRegistryError, ViewSystemRegistrator};
33pub use view_context::ViewContext;
34pub use view_context_system::{
35    ViewContextCollection, ViewContextSystem, ViewContextSystemStaticExecResult,
36};
37pub use view_query::{
38    DataResult, OverridePath, PerSystemDataResults, PropertyOverrides, SmallVisualizerSet,
39    ViewQuery,
40};
41pub use view_states::ViewStates;
42pub use visualizer_entity_subscriber::DataBasedVisualizabilityFilter;
43pub use visualizer_system::{VisualizerCollection, VisualizerQueryInfo, VisualizerSystem};
44
45// ---------------------------------------------------------------------------
46
47#[derive(Debug, thiserror::Error)]
48pub enum ViewSystemExecutionError {
49    #[error("View context system {0} not found")]
50    ContextSystemNotFound(&'static str),
51
52    #[error("View part system {0} not found")]
53    VisualizerSystemNotFound(&'static str),
54
55    #[error(transparent)]
56    QueryError(Box<re_query::QueryError>),
57
58    #[error(transparent)]
59    DeserializationError(Box<re_types::DeserializationError>),
60
61    #[error("Failed to create draw data: {0}")]
62    DrawDataCreationError(Box<dyn std::error::Error>),
63
64    #[error("Error accessing map view tiles.")]
65    MapTilesError,
66
67    #[error(transparent)]
68    GpuTransferError(#[from] re_renderer::CpuWriteGpuReadError),
69
70    #[error("Failed to downcast view's to the {0}.")]
71    StateCastError(&'static str),
72
73    #[error(transparent)]
74    ComponentFallbackError(#[from] crate::ComponentFallbackError),
75
76    #[error(transparent)]
77    ViewBuilderError(#[from] re_renderer::view_builder::ViewBuilderError),
78}
79
80const _: () = assert!(
81    std::mem::size_of::<ViewSystemExecutionError>() <= 64,
82    "Error type is too large. Try to reduce its size by boxing some of its variants.",
83);
84
85// Convenience conversions for some re_renderer error types since these are so frequent.
86
87impl From<re_renderer::renderer::LineDrawDataError> for ViewSystemExecutionError {
88    fn from(val: re_renderer::renderer::LineDrawDataError) -> Self {
89        Self::DrawDataCreationError(Box::new(val))
90    }
91}
92
93impl From<re_renderer::renderer::PointCloudDrawDataError> for ViewSystemExecutionError {
94    fn from(val: re_renderer::renderer::PointCloudDrawDataError) -> Self {
95        Self::DrawDataCreationError(Box::new(val))
96    }
97}
98
99impl From<re_types::DeserializationError> for ViewSystemExecutionError {
100    fn from(val: re_types::DeserializationError) -> Self {
101        Self::DeserializationError(Box::new(val))
102    }
103}