|
39 | 39 | from six.moves import xrange
|
40 | 40 |
|
41 | 41 | from contextlib import contextmanager
|
| 42 | +from functools import partial |
42 | 43 | import importlib
|
43 | 44 | import io
|
44 | 45 | import itertools
|
@@ -2833,6 +2834,13 @@ def __init__(self, canvas):
|
2833 | 2834 | self.mode = '' # a mode string for the status bar
|
2834 | 2835 | self.set_history_buttons()
|
2835 | 2836 |
|
| 2837 | + @partial(canvas.mpl_connect, 'draw_event') |
| 2838 | + def define_home(event): |
| 2839 | + self.push_current() |
| 2840 | + # The decorator sets `define_home` to the callback cid, so we can |
| 2841 | + # disconnect it after the first use. |
| 2842 | + canvas.mpl_disconnect(define_home) |
| 2843 | + |
2836 | 2844 | def set_message(self, s):
|
2837 | 2845 | """Display a message on toolbar or in status bar."""
|
2838 | 2846 |
|
@@ -2982,11 +2990,6 @@ def press_pan(self, event):
|
2982 | 2990 | return
|
2983 | 2991 |
|
2984 | 2992 | x, y = event.x, event.y
|
2985 |
| - |
2986 |
| - # push the current view to define home if stack is empty |
2987 |
| - if self._views.empty(): |
2988 |
| - self.push_current() |
2989 |
| - |
2990 | 2993 | self._xypress = []
|
2991 | 2994 | for i, a in enumerate(self.canvas.figure.get_axes()):
|
2992 | 2995 | if (x is not None and y is not None and a.in_axes(event) and
|
@@ -3022,11 +3025,6 @@ def press_zoom(self, event):
|
3022 | 3025 | return
|
3023 | 3026 |
|
3024 | 3027 | x, y = event.x, event.y
|
3025 |
| - |
3026 |
| - # push the current view to define home if stack is empty |
3027 |
| - if self._views.empty(): |
3028 |
| - self.push_current() |
3029 |
| - |
3030 | 3028 | self._xypress = []
|
3031 | 3029 | for i, a in enumerate(self.canvas.figure.get_axes()):
|
3032 | 3030 | if (x is not None and y is not None and a.in_axes(event) and
|
|
0 commit comments