|
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 os
|
|
51 | 52 | import matplotlib.colors as colors
|
52 | 53 | import matplotlib.transforms as transforms
|
53 | 54 | import matplotlib.widgets as widgets
|
54 |
| -#import matplotlib.path as path |
55 | 55 | from matplotlib import rcParams
|
56 | 56 | from matplotlib import is_interactive
|
57 | 57 | from matplotlib import get_backend
|
@@ -2756,6 +2756,13 @@ def __init__(self, canvas):
|
2756 | 2756 | self.mode = '' # a mode string for the status bar
|
2757 | 2757 | self.set_history_buttons()
|
2758 | 2758 |
|
| 2759 | + @partial(canvas.mpl_connect, 'draw_event') |
| 2760 | + def define_home(event): |
| 2761 | + self.push_current() |
| 2762 | + # The decorator sets `define_home` to the callback cid, so we can |
| 2763 | + # disconnect it after the first use. |
| 2764 | + canvas.mpl_disconnect(define_home) |
| 2765 | + |
2759 | 2766 | def set_message(self, s):
|
2760 | 2767 | """Display a message on toolbar or in status bar"""
|
2761 | 2768 | pass
|
@@ -2906,11 +2913,6 @@ def press_pan(self, event):
|
2906 | 2913 | return
|
2907 | 2914 |
|
2908 | 2915 | x, y = event.x, event.y
|
2909 |
| - |
2910 |
| - # push the current view to define home if stack is empty |
2911 |
| - if self._views.empty(): |
2912 |
| - self.push_current() |
2913 |
| - |
2914 | 2916 | self._xypress = []
|
2915 | 2917 | for i, a in enumerate(self.canvas.figure.get_axes()):
|
2916 | 2918 | if (x is not None and y is not None and a.in_axes(event) and
|
@@ -2946,11 +2948,6 @@ def press_zoom(self, event):
|
2946 | 2948 | return
|
2947 | 2949 |
|
2948 | 2950 | x, y = event.x, event.y
|
2949 |
| - |
2950 |
| - # push the current view to define home if stack is empty |
2951 |
| - if self._views.empty(): |
2952 |
| - self.push_current() |
2953 |
| - |
2954 | 2951 | self._xypress = []
|
2955 | 2952 | for i, a in enumerate(self.canvas.figure.get_axes()):
|
2956 | 2953 | if (x is not None and y is not None and a.in_axes(event) and
|
|
0 commit comments