Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ namespace rerun.blueprint.archetypes;
table SpatialInformation (
"attr.rerun.scope": "blueprint"
) {
/// The target reference frame for all transformations.
///
/// Defaults to the coordinate frame used by the space origin entity.
target_frame: rerun.components.TransformFrameId ("attr.rerun.component_optional", order: 50);

/// Whether axes should be shown at the origin.
show_axes: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions crates/store/re_types/src/reflection/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions crates/viewer/re_component_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ use re_types::components::{
AggregationPolicy, AlbedoFactor, AxisLength, Color, DepthMeter, DrawOrder, FillMode, FillRatio,
GammaCorrection, GraphType, ImagePlaneDistance, LinearSpeed, MagnificationFilter, MarkerSize,
Name, Opacity, Position2D, Position3D, Range1D, Scale3D, SeriesVisible, ShowLabels,
StrokeWidth, Text, Timestamp, TransformRelation, Translation3D, ValueRange, Vector3D,
VideoCodec, Visible,
StrokeWidth, Text, Timestamp, TransformFrameId, TransformRelation, Translation3D, ValueRange,
Vector3D, VideoCodec, Visible,
};
use re_viewer_context::gpu_bridge::colormap_edit_or_view_ui;

Expand Down Expand Up @@ -118,6 +118,7 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry
registry.add_multiline_edit_or_view::<Text>(edit_multiline_string);
registry.add_singleline_edit_or_view::<Name>(edit_singleline_string);
registry.add_multiline_edit_or_view::<Name>(edit_multiline_string);
registry.add_singleline_edit_or_view::<TransformFrameId>(edit_singleline_string);

// Enums:
// TODO(#6974): Enums editors trivial and always the same, provide them automatically!
Expand Down
1 change: 1 addition & 0 deletions crates/viewer/re_view/src/view_property_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub fn view_property_ui_with_redirect<A: Archetype + ArchetypeReflectionMarker>(
viewer_ctx: ctx.viewer_ctx,
view_id: redirect_with_view_id,
view_class_identifier: ctx.view_class_identifier,
space_origin: ctx.space_origin,
view_state: ctx.view_state,
query_result: &re_viewer_context::DataQueryResult::default(),
},
Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_view_bar_chart/src/view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ impl ViewClass for BarChartView {
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
state: &mut dyn ViewState,
_space_origin: &EntityPath,
space_origin: &EntityPath,
view_id: ViewId,
Comment on lines 140 to 144
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha, almost like this should be a view ctx.
(for another day ofc ;-))

) -> Result<(), ViewSystemExecutionError> {
list_item::list_item_scope(ui, "bar_char_selection_ui", |ui| {
let ctx = self.view_context(ctx, view_id, state);
let ctx = self.view_context(ctx, view_id, state, space_origin);
view_property_ui::<PlotBackground>(&ctx, ui);
view_property_ui::<PlotLegend>(&ctx, ui);
});
Expand Down Expand Up @@ -173,7 +173,7 @@ impl ViewClass for BarChartView {
.get::<BarChartVisualizerSystem>()?
.charts;

let ctx = self.view_context(ctx, view_id, state);
let ctx = self.view_context(ctx, view_id, state, query.space_origin);
let background = ViewProperty::from_archetype::<PlotBackground>(
blueprint_db,
ctx.blueprint_query(),
Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_view_graph/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl ViewClass for GraphView {
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
state: &mut dyn ViewState,
_space_origin: &EntityPath,
space_origin: &EntityPath,
view_id: ViewId,
) -> Result<(), ViewSystemExecutionError> {
let state = state.downcast_mut::<GraphViewState>()?;
Expand All @@ -182,7 +182,7 @@ impl ViewClass for GraphView {
});

re_ui::list_item::list_item_scope(ui, "graph_selection_ui", |ui| {
let ctx = self.view_context(ctx, view_id, state);
let ctx = self.view_context(ctx, view_id, state, space_origin);
view_property_ui::<GraphBackground>(&ctx, ui);
view_property_ui::<VisualBounds2D>(&ctx, ui);
view_property_force_ui::<ForceLink>(&ctx, ui);
Expand Down Expand Up @@ -217,7 +217,7 @@ impl ViewClass for GraphView {

let state = state.downcast_mut::<GraphViewState>()?;

let view_ctx = self.view_context(ctx, query.view_id, state);
let view_ctx = self.view_context(ctx, query.view_id, state, query.space_origin);
let params = ForceLayoutParams::get(&view_ctx)?;

let background = ViewProperty::from_archetype::<GraphBackground>(
Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_view_map/src/map_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ impl ViewClass for MapView {
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
state: &mut dyn ViewState,
_space_origin: &EntityPath,
space_origin: &EntityPath,
view_id: ViewId,
) -> Result<(), ViewSystemExecutionError> {
re_ui::list_item::list_item_scope(ui, "map_selection_ui", |ui| {
let ctx = self.view_context(ctx, view_id, state);
let ctx = self.view_context(ctx, view_id, state, space_origin);
re_view::view_property_ui::<MapZoom>(&ctx, ui);
re_view::view_property_ui::<MapBackground>(&ctx, ui);
});
Expand Down Expand Up @@ -212,7 +212,7 @@ impl ViewClass for MapView {
// Map Provider
//

let view_ctx = self.view_context(ctx, query.view_id, state);
let view_ctx = self.view_context(ctx, query.view_id, state, query.space_origin);
let map_provider = map_background
.component_or_fallback(&view_ctx, MapBackground::descriptor_provider().component)?;
if state.selected_provider != map_provider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ use re_chunk_store::LatestAtQuery;
use re_log_types::{EntityPath, EntityPathHash};
use re_tf::{TransformFrameId, TransformFrameIdHash, TreeTransform};
use re_types::components::ImagePlaneDistance;
use re_types::{ArchetypeName, archetypes};
use re_types::{ArchetypeName, archetypes, blueprint};
use re_view::{
DataResultQuery as _, HybridLatestAtResults, latest_at_with_blueprint_resolved_data,
};
use re_viewer_context::{
IdentifiedViewSystem, TransformDatabaseStoreCache, ViewContext, ViewContextSystem,
ViewContextSystemOncePerFrameResult, typed_fallback_for,
};
use re_viewport_blueprint::ViewProperty;
use vec1::smallvec_v1::SmallVec1;

type FrameIdMapping = IntMap<TransformFrameIdHash, TransformFrameId>;
Expand Down Expand Up @@ -209,8 +210,28 @@ impl ViewContextSystem for TransformTreeContext {
self.entity_transform_id_mapping =
EntityTransformIdMapping::new(ctx, &results, query.space_origin);

// Target frame is the coordinate frame of the space origin entity.
self.target_frame = self.transform_frame_id_for(query.space_origin.hash());
// Target frame - check for blueprint override first, otherwise use space origin's coordinate frame.
self.target_frame = {
let spatial_info_prop = ViewProperty::from_archetype::<
blueprint::archetypes::SpatialInformation,
>(
ctx.blueprint_db(), ctx.blueprint_query(), ctx.view_id
);

let target_frame_component = spatial_info_prop
.component_or_fallback::<TransformFrameId>(
ctx,
blueprint::archetypes::SpatialInformation::descriptor_target_frame().component,
);

match target_frame_component {
Ok(target_frame) => TransformFrameIdHash::from_str(target_frame.as_str()),
Err(err) => {
re_log::error_once!("Failed to query target frame: {err}");
self.transform_frame_id_for(query.space_origin.hash())
}
}
};

let latest_at_query = query.latest_at_query();

Expand Down
28 changes: 27 additions & 1 deletion crates/viewer/re_view_spatial/src/shared_fallbacks.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use re_types::image::ImageKind;
use re_types::{archetypes, components};
use re_types::{archetypes, blueprint, components};
use re_view::DataResultQuery as _;
use re_viewer_context::{IdentifiedViewSystem as _, QueryContext, ViewStateExt as _};

Expand Down Expand Up @@ -124,4 +124,30 @@ pub fn register_fallbacks(system_registry: &mut re_viewer_context::ViewSystemReg
components::ShowLabels(false.into())
},
);

system_registry.register_fallback_provider(
blueprint::archetypes::SpatialInformation::descriptor_target_frame().component,
|ctx| {
let space_origin = ctx.view_ctx.space_origin;
let query_result = ctx.viewer_ctx().lookup_query_result(ctx.view_ctx.view_id);

if let Some(data_result) = query_result.tree.lookup_result_by_path(space_origin.hash())
{
let results = data_result
.latest_at_with_blueprint_resolved_data::<archetypes::CoordinateFrame>(
ctx.view_ctx,
ctx.query,
);

if let Some(frame_id) = results.get_mono::<components::TransformFrameId>(
archetypes::CoordinateFrame::descriptor_frame().component,
) {
return frame_id;
}
}

// Fallback to entity path if no explicit CoordinateFrame
components::TransformFrameId::from_entity_path(space_origin)
},
);
}
7 changes: 4 additions & 3 deletions crates/viewer/re_view_spatial/src/ui_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ impl SpatialView2D {
viewer_ctx: ctx,
view_id: query.view_id,
view_class_identifier: Self::identifier(),
space_origin: query.space_origin,
view_state: state,
query_result: ctx.lookup_query_result(query.view_id),
};
Expand Down Expand Up @@ -202,7 +203,7 @@ impl SpatialView2D {

// Convert ui coordinates to/from scene coordinates.
let ui_from_scene = {
let view_ctx = self.view_context(ctx, query.view_id, state);
let view_ctx = self.view_context(ctx, query.view_id, state, query.space_origin);
let mut new_state = state.clone();
let ui_from_scene =
ui_from_scene(&view_ctx, &response, &mut new_state, &bounds_property);
Expand All @@ -212,7 +213,7 @@ impl SpatialView2D {
};
let scene_from_ui = ui_from_scene.inverse();

let view_ctx = self.view_context(ctx, query.view_id, state);
let view_ctx = self.view_context(ctx, query.view_id, state, query.space_origin);
let near_clip_plane: blueprint_components::NearClipPlane = clip_property
.component_or_fallback(
&view_ctx,
Expand Down Expand Up @@ -279,7 +280,7 @@ impl SpatialView2D {
};
let mut view_builder = ViewBuilder::new(ctx.render_ctx(), target_config)?;

let view_ctx = self.view_context(ctx, query.view_id, state); // Recreate view state to handle context editing during picking.
let view_ctx = self.view_context(ctx, query.view_id, state, query.space_origin); // Recreate view state to handle context editing during picking.

for draw_data in system_output.drain_draw_data() {
view_builder.queue_draw(ctx.render_ctx(), draw_data);
Expand Down
Loading
Loading