Skip to content

Commit

Permalink
adding +/= and - buttons as zoom in/out options
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Aug 20, 2020
1 parent f3380aa commit b64d37c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cellpose/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ def keyPressEvent(self, event):
self.undo_action()
if event.key() == QtCore.Qt.Key_0:
self.clear_all()
if event.key() == QtCore.Qt.Key_Minus or event.key() == QtCore.Qt.Key_Equal:
self.p0.keyPressEvent(event)

def check_gpu(self):
if utils.use_gpu():
Expand Down
25 changes: 23 additions & 2 deletions cellpose/guiparts.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, parent=None):
<p class="has-line-data" data-line-start="5" data-line-end="6">Main GUI mouse controls:</p>
<ul>
<li class="has-line-data" data-line-start="7" data-line-end="8">Pan = left-click + drag</li>
<li class="has-line-data" data-line-start="8" data-line-end="9">Zoom = scroll wheel</li>
<li class="has-line-data" data-line-start="8" data-line-end="9">Zoom = scroll wheel (or +/= and - buttons) </li>
<li class="has-line-data" data-line-start="9" data-line-end="10">Full view = double left-click</li>
<li class="has-line-data" data-line-start="10" data-line-end="11">Select mask = left-click on mask</li>
<li class="has-line-data" data-line-start="11" data-line-end="12">Delete mask = Ctrl (or COMMAND on Mac) + left-click</li>
Expand All @@ -93,6 +93,10 @@ def __init__(self, parent=None):
</thead>
<tbody>
<tr>
<td>=/+ button // - button</td>
<td>zoom in // zoom out</td>
</tr>
<tr>
<td>CTRL+Z</td>
<td>undo previously drawn mask/stroke</td>
</tr>
Expand Down Expand Up @@ -217,7 +221,24 @@ def __init__(self, parent=None, border=None, lockAspect=False, enableMouse=True,
pg.ViewBox.__init__(self, None, border, lockAspect, enableMouse,
invertY, enableMenu, name, invertX)
self.parent = parent

self.axHistoryPointer = -1

def keyPressEvent(self, ev):
"""
This routine should capture key presses in the current view box.
The following events are implemented:
+/= : moves forward in the zooming stack (if it exists)
- : moves backward in the zooming stack (if it exists)
"""
ev.accept()
if ev.text() == '-':
self.scaleBy([1.1, 1.1])
elif ev.text() in ['+', '=']:
self.scaleBy([0.9, 0.9])
else:
ev.ignore()

def mouseDragEvent(self, ev, axis=None):
## if axis is specified, event will only affect that axis.
if self.parent is None or (self.parent is not None and not self.parent.in_stroke):
Expand Down
4 changes: 3 additions & 1 deletion docs/gui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The GUI serves two main functions:
Main GUI mouse controls (works in all views):

- Pan = left-click + drag
- Zoom = scroll wheel
- Zoom = scroll wheel (or +/= and - buttons)
- Full view = double left-click
- Select mask = left-click on mask
- Delete mask = Ctrl (or Command on Mac) + left-click
Expand All @@ -52,6 +52,8 @@ have to as densely label.
| Keyboard shortcuts | Description |
+=====================+===============================================+
| CTRL+H | help |
+---------------------+-----------------------------------------------+
| =/+ // - | zoom in // zoom out |
+---------------------+-----------------------------------------------+
| CTRL+Z | undo previously drawn mask/stroke |
+---------------------+-----------------------------------------------+
Expand Down

0 comments on commit b64d37c

Please sign in to comment.