@@ -2985,6 +2985,7 @@ def _press(self, event):
2985
2985
self .update ()
2986
2986
2987
2987
if self ._active_handle is None and not self .ignore_event_outside :
2988
+ # Start drawing a new rectangle
2988
2989
x = event .xdata
2989
2990
y = event .ydata
2990
2991
self .visible = False
@@ -3051,17 +3052,26 @@ def _release(self, event):
3051
3052
return False
3052
3053
3053
3054
def _onmove (self , event ):
3054
- """Motion notify event handler."""
3055
+ """
3056
+ Motion notify event handler.
3055
3057
3056
- state = self ._state
3057
- rotate = ('rotate' in state and
3058
- self ._active_handle in self ._corner_order )
3058
+ This can do one of four things:
3059
+ - Translate
3060
+ - Rotate
3061
+ - Re-size
3062
+ - Contine the creation of a new shape
3063
+ """
3059
3064
xy = np .array ([event .xdata , event .ydata ])
3060
3065
xy_press = np .array ([self ._eventpress .xdata , self ._eventpress .ydata ])
3061
3066
3062
3067
# The calculations are done for rotation at zero: we apply inverse
3063
3068
# transformation to events except when we rotate and move
3069
+ state = self ._state
3070
+ rotate = ('rotate' in state and
3071
+ self ._active_handle in self ._corner_order )
3064
3072
move = self ._active_handle == 'C'
3073
+ resize = self ._active_handle and not move
3074
+
3065
3075
if not move and not rotate :
3066
3076
inv_tr = self ._get_rotation_transform ().inverted ()
3067
3077
xy = inv_tr .transform (xy )
@@ -3089,8 +3099,7 @@ def _onmove(self, event):
3089
3099
np .arctan2 (a [1 ]- b [1 ], a [0 ]- b [0 ]))
3090
3100
self .rotation = np .rad2deg (self ._rotation_on_press + angle )
3091
3101
3092
- # resize an existing shape
3093
- elif self ._active_handle and self ._active_handle != 'C' :
3102
+ elif resize :
3094
3103
size_on_press = [x1 - x0 , y1 - y0 ]
3095
3104
center = [x0 + size_on_press [0 ] / 2 , y0 + size_on_press [1 ] / 2 ]
3096
3105
@@ -3143,16 +3152,15 @@ def _onmove(self, event):
3143
3152
x1 = x0 + sign * abs (y1 - y0 ) * \
3144
3153
self ._aspect_ratio_correction
3145
3154
3146
- # move existing shape
3147
- elif self ._active_handle == 'C' :
3155
+ elif move :
3148
3156
x0 , x1 , y0 , y1 = self ._extents_on_press
3149
3157
x0 += dxy [0 ]
3150
3158
x1 += dxy [0 ]
3151
3159
y0 += dxy [1 ]
3152
3160
y1 += dxy [1 ]
3153
3161
3154
- # new shape
3155
3162
else :
3163
+ # Create a new shape
3156
3164
self ._rotation = 0
3157
3165
# Don't create a new rectangle if there is already one when
3158
3166
# ignore_event_outside=True
0 commit comments