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

Rewrite 2D panning/zooming #2531

Closed
emilk opened this issue Jun 27, 2023 · 1 comment · Fixed by #6089
Closed

Rewrite 2D panning/zooming #2531

emilk opened this issue Jun 27, 2023 · 1 comment · Fixed by #6089
Assignees
Labels
enhancement New feature or request 📺 re_viewer affects re_viewer itself ui concerns graphical user interface

Comments

@emilk
Copy link
Member

emilk commented Jun 27, 2023

Currently the panning and zooming of the 2D space views is handled by egui::ScrollArea. This has several down-sides, such as not being able to zoom out further than "full view".

We should instead allow any pan and zoom, treating it more similar to the 3D "eye".

This is the first step towards fixing a bunch of 2D issues:

To start with, it's good enough to support just panning and uniform scaling.
In the future we may want to support non-uniform scaling (including mirroring), as well as rotation.

Parameterizations

  • How do we represent this as components?
  • How do we control this from code?

One important case to consider is for the user to be able to set some 'view bounds' for the 2D spatial view.
This should act as some minimum bounds, that can grow in order to keep the aspect ratio of the actual space view, adding letterboxing to maintain a uniform axis scaling.
Again, when the space view is resized we should always see everything in the set view rectangle, but at little as possible outside.

This is similar to how egui_plot works.

So that implies that perhaps the entire 2D Eye is parameterized as a bounding-box in the space of the space-view.
Panning translates this bounding box, and zooming scales it. When rendering, this bounding box is fit to the frame of the space view.
Double-clicking resets the bounding-box to the one set via code (if it exists) or a tight bounding box of the contents (if it doesn't).

So I propose we use a component SpaceView2DBounds { rect: datatypes.Rect }.

@emilk emilk added enhancement New feature or request 👀 needs triage This issue needs to be triaged by the Rerun team labels Jun 27, 2023
@jleibs
Copy link
Member

jleibs commented Jun 27, 2023

This may be partially related, but has other non-2D aspects as well:

@emilk emilk added ui concerns graphical user interface 📺 re_viewer affects re_viewer itself and removed 👀 needs triage This issue needs to be triaged by the Rerun team labels Jul 4, 2023
@emilk emilk self-assigned this Apr 23, 2024
emilk added a commit that referenced this issue Apr 25, 2024
### What
* Closes #2531
* Closes #2490

By default the bounds are centered:

Before:
<img width="2023" alt="Screenshot 2024-04-24 at 11 46 47"
src="https://github.com/rerun-io/rerun/assets/1148717/0b8678ac-e427-4a5a-a633-011eee239fc8">

After:
<img width="2023" alt="Screenshot 2024-04-24 at 11 45 41"
src="https://github.com/rerun-io/rerun/assets/1148717/fbf6fd94-79a8-4ed2-b324-4f34672f0cb9">

### 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/6089?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/6089?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/6089)
- [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: Andreas Reich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 📺 re_viewer affects re_viewer itself ui concerns graphical user interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants