Skip to content

Commit

Permalink
Add ShowLabels component, which controls whether instances’ labels …
Browse files Browse the repository at this point in the history
…are shown. (#7249)

* Implements #3465

### What
* Each archetype which has labels gets a `ShowLabels` non-repeated
component. (I figured having it set per-instance would be hardly ever
useful.)
* Visualizers pass this component to `process_labels()`.
* `process_labels()` uses it to override the existing “show labels if
less than 30” policy.
* Refactoring: `process_labels()` and friends now take a struct instead
of 8 separate parameters. This makes the callsites more legible and
maintainable, and might eventually be useful for further refinement of
the label rendering system (it's basically a "ComponentData" struct for
labels).

One element is currently missing: the automatic policy is not expressed
as a component fallback. That means that the viewer UI does not know
about it and won't display the real fallback value, but a bogus constant
`true`. Other than that, it should be fully ready to go, so feel free to
either merge or wait for that further work as you see fit.

### 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)
* [ ] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7249?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/7249?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)!
* [X] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7249)
- [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`.

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
kpreid and emilk authored Aug 24, 2024
1 parent dff92b4 commit dc4e3f3
Show file tree
Hide file tree
Showing 90 changed files with 1,318 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ table Arrows2D (
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3200);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3250);

/// An optional floating point value that specifies the 2D drawing order.
///
/// Objects with higher values are drawn on top of those with lower values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ table Arrows3D (
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3200);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3250);

/// Optional class Ids for the points.
///
/// The [components.ClassId] provides colors and labels if not specified explicitly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ table Boxes2D (
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3000);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3050);

/// An optional floating point value that specifies the 2D drawing order.
///
/// Objects with higher values are drawn on top of those with lower values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ table Boxes3D (
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3200);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3250);

/// Optional [components.ClassId]s for the boxes.
///
/// The [components.ClassId] provides colors and labels if not specified explicitly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ table Ellipsoids3D (
/// Optional text labels for the ellipsoids.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3200);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3250);

/// Optional class ID for the ellipsoids.
///
/// The class ID provides colors and labels if not specified explicitly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ table LineStrips2D (
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3000);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3050);

/// An optional floating point value that specifies the 2D drawing order of each line strip.
///
/// Objects with higher values are drawn on top of those with lower values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ table LineStrips3D (
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3000);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3050);

/// Optional [components.ClassId]s for the lines.
///
/// The [components.ClassId] provides colors and labels if not specified explicitly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ table Points2D (
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3000);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3050);

/// An optional floating point value that specifies the 2D drawing order.
///
/// Objects with higher values are drawn on top of those with lower values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ table Points3D (
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3000);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3100);

/// Optional class Ids for the points.
///
/// The [components.ClassId] provides colors and labels if not specified explicitly.
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/components.fbs

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

20 changes: 20 additions & 0 deletions crates/store/re_types/definitions/rerun/components/show_labels.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

namespace rerun.components;

// ---

/// Whether the entity's [components.Text] label is shown.
///
/// The main purpose of this component existing separately from the labels themselves
/// is to be overridden when desired, to allow hiding and showing from the viewer and
/// blueprints.
struct ShowLabels (
"attr.arrow.transparent",
"attr.python.aliases": "bool",
"attr.python.array_aliases": "bool, npt.NDArray[np.bool_]",
"attr.rust.derive": "Copy, PartialEq, Eq",
"attr.rust.tuple_struct"
) {
/// Whether the entity's [components.Text] label is shown.
show_labels: rerun.datatypes.Bool (order: 100);
}
39 changes: 35 additions & 4 deletions crates/store/re_types/src/archetypes/arrows2d.rs

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

39 changes: 35 additions & 4 deletions crates/store/re_types/src/archetypes/arrows3d.rs

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

Loading

0 comments on commit dc4e3f3

Please sign in to comment.