Skip to content

Add a zoom-to-mouse-position option to the 3D viewer#592

Open
markomarkovic wants to merge 1 commit into
CadQuery:masterfrom
markomarkovic:zoom-to-mouse
Open

Add a zoom-to-mouse-position option to the 3D viewer#592
markomarkovic wants to merge 1 commit into
CadQuery:masterfrom
markomarkovic:zoom-to-mouse

Conversation

@markomarkovic

@markomarkovic markomarkovic commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Adds a Zoom to mouse position viewer preference. When enabled, the mouse wheel zooms toward the point under the cursor instead of the view center.

  • New viewer preference Zoom to mouse position (default: off), so the existing entered-zoom behavior is unchanged unless the user opts in.
  • When enabled, wheelEvent zooms via the view's StartZoomAtPoint / ZoomAtPoint; when disabled it keeps the original SetZoom.
  • The per-notch zoom factor is matched to the existing ZOOM_STEP, so a wheel notch moves the same amount in both modes.

Changes

  • cq_editor/widgets/occt_widget.pyZOOM_AT_POINT_STEP constant, _zoom_to_cursor flag, set_zoom_to_cursor(), and the wheelEvent branch.
  • cq_editor/widgets/viewer.py — the preference and its wiring in updatePreferences.
  • tests/test_app.pytest_viewer_zoom_to_mouse covering both wheel paths and the preference wiring.

Testing

pytest tests/test_app.py — the new test and the existing viewer tests pass.

Claude AI assisted with the implementation under my direction; design, testing, and review are mine.

When the "Zoom to mouse position" preference is enabled, the mouse wheel
zooms toward the point under the cursor via the view's ZoomAtPoint instead
of the centered SetZoom. The preference defaults to off, preserving the
existing centered-zoom behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant