feat(observers): scroll-to-zoom on axis gutters in PlotObserver#262
Merged
Conversation
When the cursor is over the left (y-axis) or bottom (x-axis) gutter: - Disable scroll-to-pan so the plot doesn't consume the events - Convert vertical scroll delta to a zoom factor via exp(delta/200) - Apply axis-specific zoom centered on the hovered position Plot-area behavior (scroll pans, pinch zooms) is unchanged. Closes #260
…ations - Increase background sine curve from 301 to 2001 points so it stays smooth when zoomed into the region where evaluations cluster near π/2 - Loosen golden section tolerance from 1e-12 to 1e-6, cutting the evaluated point count roughly in half (~29 vs ~58 iterations) - Fix pre-existing clippy::needless_borrows_for_generic_args in ode title
Replace uniform spacing with a cubic remap u³ (u ∈ [-1, 1]). The cubic has zero slope at u=0, so sample density is highest near π/2 where the evaluated points cluster and where zooming in previously revealed line segments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements scroll-to-zoom on axis gutters in
PlotObserver, resolving #260.What changes
When the cursor is over an axis gutter:
How it works
PlotAppnow storesplot_rect: Option<egui::Rect>— the inner plot rect captured fromplot_ui.transform().frame()at the end of each frame. On the next frame this rect is used to hit-test the cursor against the left and bottom gutters.When a gutter is active:
allow_scroll(false)prevents the plot from consuming scroll events as pansmooth_scroll_delta.yis converted to a zoom factor viaexp(delta / 200.0)— the same scale egui_plot uses internally for scroll-to-zoomplot_ui.zoom_bounds_around_hovered(factor)applies the zoom centered on the hovered position;BoundsModification::Zoomautomatically disables auto-bounds, so noset_auto_boundscall is neededThe zoom is guarded on
scroll_delta.y != 0.0so auto-bounds aren't disabled on frames with no scroll activity.