Skip to content

Commit

Permalink
Rename VisualBounds to VisualBounds2D, Introduce VisualBounds2D compo…
Browse files Browse the repository at this point in the history
…nent replacing Range2D component (#6333)

### What

This changeset makes the 2D visual bound more similar to what we want it
to look like once introducing `DataRange`, i.e. it means that when we
fix:
* #6247

the api won't break

### 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 examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6333?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6333?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/6333)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
Wumpf committed May 15, 2024
1 parent 5bee7cc commit 5189de8
Show file tree
Hide file tree
Showing 78 changed files with 453 additions and 447 deletions.
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/component_ui_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub fn create_component_ui_registry() -> ComponentUiRegistry {
add_to_registry::<re_types::components::LineStrip2D>(&mut registry);
add_to_registry::<re_types::components::LineStrip3D>(&mut registry);
add_to_registry::<re_types::components::Range1D>(&mut registry);
add_to_registry::<re_types::components::Range2D>(&mut registry);
add_to_registry::<re_types::components::Resolution>(&mut registry);
add_to_registry::<re_types::components::Rotation3D>(&mut registry);
add_to_registry::<re_types::components::Material>(&mut registry);
Expand All @@ -32,6 +31,7 @@ pub fn create_component_ui_registry() -> ComponentUiRegistry {

add_to_registry::<re_types_blueprint::blueprint::components::IncludedSpaceView>(&mut registry);
add_to_registry::<re_types_blueprint::blueprint::components::SpaceViewMaximized>(&mut registry);
add_to_registry::<re_types_blueprint::blueprint::components::VisualBounds2D>(&mut registry);

register_editors(&mut registry);

Expand Down
5 changes: 3 additions & 2 deletions crates/re_data_ui/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use re_data_store::LatestAtQuery;
use re_entity_db::EntityDb;

use re_format::format_f32;
use re_types::components::{Color, LineStrip2D, LineStrip3D, Range1D, Range2D, ViewCoordinates};
use re_types::blueprint::components::VisualBounds2D;
use re_types::components::{Color, LineStrip2D, LineStrip3D, Range1D, ViewCoordinates};
use re_viewer_context::{UiLayout, ViewerContext};

use super::{data_label_for_ui_layout, label_for_ui_layout, table_for_ui_layout, DataUi};
Expand Down Expand Up @@ -195,7 +196,7 @@ impl DataUi for Range1D {
}
}

impl DataUi for Range2D {
impl DataUi for VisualBounds2D {
fn data_ui(
&self,
_ctx: &ViewerContext<'_>,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_query/src/latest_at/to_archetype/.gitattributes

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

2 changes: 1 addition & 1 deletion crates/re_query/src/latest_at/to_archetype/mod.rs

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

44 changes: 0 additions & 44 deletions crates/re_query/src/latest_at/to_archetype/visual_bounds.rs

This file was deleted.

51 changes: 51 additions & 0 deletions crates/re_query/src/latest_at/to_archetype/visual_bounds2d.rs

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

17 changes: 11 additions & 6 deletions crates/re_space_view_spatial/src/space_view_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use re_format::format_f32;
use re_log_types::EntityPath;
use re_types::{
archetypes::{DepthImage, Image},
blueprint::archetypes::{Background, VisualBounds},
blueprint::archetypes::{Background, VisualBounds2D},
blueprint::components as blueprint_components,
Archetype, ComponentName, SpaceViewClassIdentifier,
};
use re_viewer_context::{
Expand Down Expand Up @@ -283,24 +284,28 @@ impl SpaceViewClass for SpatialSpaceView2D {
fn visual_bounds_ui(ctx: &ViewerContext<'_>, space_view_id: SpaceViewId, ui: &mut egui::Ui) {
let tooltip = "The area guaranteed to be visible.\n\
Depending on the view's current aspect ratio the actually visible area might be larger either horizontally or vertically.";
re_space_view::edit_blueprint_component::<VisualBounds, re_types::components::Range2D, ()>(
re_space_view::edit_blueprint_component::<
VisualBounds2D,
blueprint_components::VisualBounds2D,
(),
>(
ctx,
space_view_id,
|range2d_opt: &mut Option<re_types::components::Range2D>| {
|bounds2d_opt: &mut Option<blueprint_components::VisualBounds2D>| {
ctx.re_ui
.grid_left_hand_label(ui, "Visible bounds")
.on_hover_text(tooltip);
ui.vertical(|ui| {
ui.style_mut().wrap = Some(false);

if let Some(range2d) = range2d_opt {
let rect = egui::Rect::from(*range2d);
if let Some(bounds2d) = bounds2d_opt {
let rect = egui::Rect::from(*bounds2d);
let (min, max) = (rect.min, rect.max);
ui.label(format!("x [{} - {}]", format_f32(min.x), format_f32(max.x),));
ui.label(format!("y [{} - {}]", format_f32(min.y), format_f32(max.y),));

if ui.button("Reset visible bounds").clicked() {
*range2d_opt = None;
*bounds2d_opt = None;
}
} else {
ui.weak("Default");
Expand Down
10 changes: 5 additions & 5 deletions crates/re_space_view_spatial/src/ui_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use re_entity_db::EntityPath;
use re_renderer::view_builder::{TargetConfiguration, ViewBuilder};
use re_space_view::controls::{DRAG_PAN2D_BUTTON, RESET_VIEW_BUTTON_TEXT, ZOOM_SCROLL_MODIFIER};
use re_types::{
archetypes::Pinhole, blueprint::archetypes::Background, blueprint::archetypes::VisualBounds,
components::ViewCoordinates,
archetypes::Pinhole, blueprint::archetypes::Background, blueprint::archetypes::VisualBounds2D,
blueprint::components as blueprint_components, components::ViewCoordinates,
};
use re_viewer_context::{
gpu_bridge, ItemSpaceContext, SpaceViewId, SpaceViewSystemExecutionError,
Expand Down Expand Up @@ -119,13 +119,13 @@ fn ui_from_scene(
}

re_space_view::edit_blueprint_component::<
VisualBounds,
re_types::components::Range2D,
VisualBounds2D,
blueprint_components::VisualBounds2D,
RectTransform,
>(
ctx,
space_view_id,
|range2d: &mut Option<re_types::components::Range2D>| {
|range2d: &mut Option<blueprint_components::VisualBounds2D>| {
// Convert to a Rect
let mut rect = range2d.map(Rect::from);

Expand Down
3 changes: 2 additions & 1 deletion crates/re_types/definitions/rerun/blueprint.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include "./blueprint/components/space_view_origin.fbs";
include "./blueprint/components/viewer_recommendation_hash.fbs";
include "./blueprint/components/visible_time_range.fbs";
include "./blueprint/components/visible.fbs";
include "./blueprint/components/visual_bounds2d.fbs";

include "./blueprint/archetypes/background.fbs";
include "./blueprint/archetypes/container_blueprint.fbs";
Expand All @@ -28,7 +29,7 @@ include "./blueprint/archetypes/space_view_blueprint.fbs";
include "./blueprint/archetypes/space_view_contents.fbs";
include "./blueprint/archetypes/viewport_blueprint.fbs";
include "./blueprint/archetypes/visible_time_ranges.fbs";
include "./blueprint/archetypes/visual_bounds.fbs";
include "./blueprint/archetypes/visual_bounds2d.fbs";

include "./blueprint/archetypes/plot_legend.fbs";
include "./blueprint/archetypes/scalar_axis.fbs";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include "arrow/attributes.fbs";
include "python/attributes.fbs";
include "rust/attributes.fbs";

include "rerun/blueprint/components/visual_bounds2d.fbs";

namespace rerun.blueprint.archetypes;


/// Controls the visual bounds of a 2D view.
///
/// Everything within these bounds are guaranteed to be visible.
/// Somethings outside of these bounds may also be visible due to letterboxing.
///
/// If no visual bounds are set, it will be determined automatically,
/// based on the bounding-box of the data or other camera information present in the view.
table VisualBounds2D (
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Copy"
) {
/// Controls the visible range of a 2D view.
///
/// Use this to control pan & zoom of the view.
range: rerun.blueprint.components.VisualBounds2D ("attr.rerun.component_required", order: 1000);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ include "python/attributes.fbs";
include "fbs/attributes.fbs";
include "rust/attributes.fbs";

include "../datatypes/range2d.fbs";
include "rerun/datatypes/range2d.fbs";

namespace rerun.components;
namespace rerun.blueprint.components;

// ---

/// An Axis-Aligned Bounding Box in 2D space.
struct Range2D (
/// Visual bounds in 2D space used for `Spatial2DView`.
struct VisualBounds2D (
"attr.docs.unreleased",
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
/// X and y ranges that should be visible.
range2d: rerun.datatypes.Range2D (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ table Spatial2DView (
///
/// Everything within these bounds are guaranteed to be visible.
/// Somethings outside of these bounds may also be visible due to letterboxing.
visual_bounds: rerun.blueprint.archetypes.VisualBounds (order: 2000);
visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 2000);

/// Configures which range on each timeline is shown by this view (unless specified differently per entity).
///
Expand Down
1 change: 0 additions & 1 deletion crates/re_types/definitions/rerun/components.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ include "./components/position2d.fbs";
include "./components/position3d.fbs";
include "./components/radius.fbs";
include "./components/range1d.fbs";
include "./components/range2d.fbs";
include "./components/resolution.fbs";
include "./components/rotation3d.fbs";
include "./components/scalar.fbs";
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/line_strips2d.rs

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

2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/points2d.rs

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

2 changes: 1 addition & 1 deletion crates/re_types/src/blueprint/archetypes/.gitattributes

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

4 changes: 2 additions & 2 deletions crates/re_types/src/blueprint/archetypes/mod.rs

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

Loading

0 comments on commit 5189de8

Please sign in to comment.