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

[ENH] Canvas: Add zoom #2841

Merged
merged 1 commit into from
Jan 19, 2018
Merged

[ENH] Canvas: Add zoom #2841

merged 1 commit into from
Jan 19, 2018

Conversation

janezd
Copy link
Contributor

@janezd janezd commented Dec 22, 2017

Issue

Zooming is currently rather rigid. There is also no zooming out.

Description of changes

Add zooming by ⌘+scroll; zooming is continuous on trackpads, and discrete with mouse.
Add zooming by ⌘+ and ⌘- ,and reset by ⌘0.
Remove the zoom toggle button from the toolbar.

Includes
  • Code changes
  • Tests
  • Documentation

@codecov-io
Copy link

codecov-io commented Dec 22, 2017

Codecov Report

Merging #2841 into master will decrease coverage by 0.18%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2841      +/-   ##
==========================================
- Coverage   81.91%   81.72%   -0.19%     
==========================================
  Files         326      326              
  Lines       55997    55700     -297     
==========================================
- Hits        45868    45523     -345     
- Misses      10129    10177      +48

@janezd janezd changed the title [WIP] [RFC] Canvas: Add zoom [RFC] Canvas: Add zoom Dec 22, 2017
@janezd janezd changed the title [RFC] Canvas: Add zoom Canvas: Add zoom Jan 5, 2018
@janezd
Copy link
Contributor Author

janezd commented Jan 5, 2018

@ales-erjavec, can you take a quick look?

@@ -2,10 +2,11 @@
Canvas Graphics View
"""
import logging
from math import floor, copysign
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

floor is unused

def wheelEvent(self, event: QWheelEvent):
# use mouse position as anchor while zooming
self.setTransformationAnchor(2)
if event.modifiers() & Qt.ControlModifier:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and event.buttons() == Qt.NoButtons:

if event.modifiers() & Qt.ControlModifier:
delta = event.angleDelta().y()
if QT_VERSION >= 0x050300 \
and event.source() != Qt.MouseEventNotSynthesized \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://doc.qt.io/qt-5/qwheelevent.html#source says it was introduced in Qt 5.5.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to 0x050500. The documentation for the corresponding enum says that the enum exists from 5.3. I don't know how would you get the source then.

@lanzagar lanzagar added this to the 3.10 milestone Jan 19, 2018
@lanzagar lanzagar changed the title Canvas: Add zoom [ENH] Canvas: Add zoom Jan 19, 2018
@lanzagar lanzagar merged commit 17f3105 into biolab:master Jan 19, 2018
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.

4 participants