@@ -79,7 +79,6 @@ def __init__(
79
79
80
80
if rect is None :
81
81
rect = [0.0 , 0.0 , 1.0 , 1.0 ]
82
- self ._cids = []
83
82
84
83
self .initial_azim = azim
85
84
self .initial_elev = elev
@@ -115,6 +114,12 @@ def __init__(
115
114
self ._zcid = None
116
115
117
116
self .mouse_init ()
117
+ self .figure .canvas .mpl_connect (
118
+ 'motion_notify_event' , self ._on_move ),
119
+ self .figure .canvas .mpl_connect (
120
+ 'button_press_event' , self ._button_press ),
121
+ self .figure .canvas .mpl_connect (
122
+ 'button_release_event' , self ._button_release ),
118
123
self .set_top_view ()
119
124
120
125
self .patch .set_linewidth (0 )
@@ -1004,8 +1009,7 @@ def get_proj(self):
1004
1009
1005
1010
def mouse_init (self , rotate_btn = 1 , zoom_btn = 3 ):
1006
1011
"""
1007
- Initializes mouse button callbacks to enable 3D rotation of the axes.
1008
- Also optionally sets the mouse buttons for 3D rotation and zooming.
1012
+ Set the mouse buttons for 3D rotation and zooming.
1009
1013
1010
1014
Parameters
1011
1015
----------
@@ -1015,20 +1019,16 @@ def mouse_init(self, rotate_btn=1, zoom_btn=3):
1015
1019
The mouse button or buttons to use to zoom the 3D axes.
1016
1020
"""
1017
1021
self .button_pressed = None
1018
- self ._cids = [
1019
- self .figure .canvas .mpl_connect (
1020
- 'motion_notify_event' , self ._on_move ),
1021
- self .figure .canvas .mpl_connect (
1022
- 'button_press_event' , self ._button_press ),
1023
- self .figure .canvas .mpl_connect (
1024
- 'button_release_event' , self ._button_release ),
1025
- ]
1026
1022
# coerce scalars into array-like, then convert into
1027
1023
# a regular list to avoid comparisons against None
1028
1024
# which breaks in recent versions of numpy.
1029
1025
self ._rotate_btn = np .atleast_1d (rotate_btn ).tolist ()
1030
1026
self ._zoom_btn = np .atleast_1d (zoom_btn ).tolist ()
1031
1027
1028
+ def disable_mouse_rotation (self ):
1029
+ """Disable mouse buttons for 3D rotation and zooming."""
1030
+ self .mouse_init (rotate_btn = [], zoom_btn = [])
1031
+
1032
1032
def can_zoom (self ):
1033
1033
"""
1034
1034
Return *True* if this axes supports the zoom box button functionality.
@@ -1069,13 +1069,6 @@ def cla(self):
1069
1069
1070
1070
self .grid (rcParams ['axes3d.grid' ])
1071
1071
1072
- def disable_mouse_rotation (self ):
1073
- """Disable mouse button callbacks."""
1074
- # Disconnect the various events we set.
1075
- for cid in self ._cids :
1076
- self .figure .canvas .mpl_disconnect (cid )
1077
- self ._cids = []
1078
-
1079
1072
def _button_press (self , event ):
1080
1073
if event .inaxes == self :
1081
1074
self .button_pressed = event .button
0 commit comments