Callback for mouse button releases in zoom-to-rectangle mode.
(self, event)
| 779 | 'rubberband', self, data=(x1, y1, x2, y2)) |
| 780 | |
| 781 | def _release(self, event): |
| 782 | """Callback for mouse button releases in zoom-to-rectangle mode.""" |
| 783 | |
| 784 | for zoom_id in self._ids_zoom: |
| 785 | self.figure.canvas.mpl_disconnect(zoom_id) |
| 786 | self._ids_zoom = [] |
| 787 | |
| 788 | if not self._xypress: |
| 789 | self._cancel_action() |
| 790 | return |
| 791 | |
| 792 | done_ax = [] |
| 793 | |
| 794 | for cur_xypress in self._xypress: |
| 795 | x, y = event.x, event.y |
| 796 | lastx, lasty, a, _ind, view = cur_xypress |
| 797 | # ignore singular clicks - 5 pixels is a threshold |
| 798 | if abs(x - lastx) < 5 or abs(y - lasty) < 5: |
| 799 | self._cancel_action() |
| 800 | return |
| 801 | |
| 802 | # detect twinx, twiny Axes and avoid double zooming |
| 803 | twinx = any(a.get_shared_x_axes().joined(a, a1) for a1 in done_ax) |
| 804 | twiny = any(a.get_shared_y_axes().joined(a, a1) for a1 in done_ax) |
| 805 | done_ax.append(a) |
| 806 | |
| 807 | if self._button_pressed == 1: |
| 808 | direction = 'in' |
| 809 | elif self._button_pressed == 3: |
| 810 | direction = 'out' |
| 811 | else: |
| 812 | continue |
| 813 | |
| 814 | a._set_view_from_bbox((lastx, lasty, x, y), direction, |
| 815 | self._zoom_mode, twinx, twiny) |
| 816 | |
| 817 | self._zoom_mode = None |
| 818 | self.toolmanager.get_tool(_views_positions).push_current() |
| 819 | self._cancel_action() |
| 820 | |
| 821 | |
| 822 | class ToolPan(ZoomPanBase): |
nothing calls this directly
no test coverage detected