@@ -2822,13 +2822,13 @@ def __init__(self, ax, onselect, drawtype='box',
2822
2822
'edgecolor' , 'black' ),
2823
2823
** cbook .normalize_kwargs (handle_props , Line2D )}
2824
2824
2825
- self ._corner_order = ['NW ' , 'NE ' , 'SE ' , 'SW ' ]
2825
+ self ._corner_order = ['SW ' , 'SE ' , 'NE ' , 'NW ' ]
2826
2826
xc , yc = self .corners
2827
2827
self ._corner_handles = ToolHandles (self .ax , xc , yc ,
2828
2828
marker_props = self ._handle_props ,
2829
2829
useblit = self .useblit )
2830
2830
2831
- self ._edge_order = ['W' , 'N ' , 'E' , 'S ' ]
2831
+ self ._edge_order = ['W' , 'S ' , 'E' , 'N ' ]
2832
2832
xe , ye = self .edge_centers
2833
2833
self ._edge_handles = ToolHandles (self .ax , xe , ye , marker = 's' ,
2834
2834
marker_props = self ._handle_props ,
@@ -2868,6 +2868,7 @@ def _press(self, event):
2868
2868
# button, ...
2869
2869
if self ._interactive and self ._selection_artist .get_visible ():
2870
2870
self ._set_active_handle (event )
2871
+ self ._extents_on_press = self .extents
2871
2872
else :
2872
2873
self ._active_handle = None
2873
2874
@@ -2933,22 +2934,31 @@ def _release(self, event):
2933
2934
2934
2935
self .update ()
2935
2936
self ._active_handle = None
2937
+ self ._extents_on_press = None
2936
2938
2937
2939
return False
2938
2940
2939
2941
def _onmove (self , event ):
2940
2942
"""Motion notify event handler."""
2943
+
2944
+
2941
2945
# resize an existing shape
2942
2946
if self ._active_handle and self ._active_handle != 'C' :
2943
2947
x0 , x1 , y0 , y1 = self ._extents_on_press
2948
+ # Switch variables so that only x1 and/or y1 are updated on move.
2949
+ if self ._active_handle in ['W' , 'SW' , 'NW' ]:
2950
+ x0 , x1 = x1 , event .xdata
2951
+ if self ._active_handle in ['S' , 'SW' , 'SE' ]:
2952
+ y0 , y1 = y1 , event .ydata
2953
+
2944
2954
if self ._active_handle in ['E' , 'W' ] + self ._corner_order :
2945
2955
x1 = event .xdata
2946
2956
if self ._active_handle in ['N' , 'S' ] + self ._corner_order :
2947
2957
y1 = event .ydata
2948
2958
2949
2959
# move existing shape
2950
- elif (( 'move' in self . _state or self ._active_handle == 'C' or
2951
- (self .drag_from_anywhere and self ._contains (event ) )) and
2960
+ elif (self ._active_handle == 'C' or
2961
+ (self .drag_from_anywhere and self ._contains (event )) and
2952
2962
self ._extents_on_press is not None ):
2953
2963
x0 , x1 , y0 , y1 = self ._extents_on_press
2954
2964
dx = event .xdata - self ._eventpress .xdata
@@ -3086,7 +3096,6 @@ def _set_active_handle(self, event):
3086
3096
3087
3097
if 'move' in self ._state :
3088
3098
self ._active_handle = 'C'
3089
- self ._extents_on_press = self .extents
3090
3099
# Set active handle as closest handle, if mouse click is close enough.
3091
3100
elif m_dist < self .grab_range * 2 :
3092
3101
# Prioritise center handle over other handles
@@ -3097,7 +3106,6 @@ def _set_active_handle(self, event):
3097
3106
if self .drag_from_anywhere and self ._contains (event ):
3098
3107
# Check if we've clicked inside the region
3099
3108
self ._active_handle = 'C'
3100
- self ._extents_on_press = self .extents
3101
3109
else :
3102
3110
self ._active_handle = None
3103
3111
return
@@ -3108,15 +3116,6 @@ def _set_active_handle(self, event):
3108
3116
# Closest to an edge handle
3109
3117
self ._active_handle = self ._edge_order [e_idx ]
3110
3118
3111
- # Save coordinates of rectangle at the start of handle movement.
3112
- x0 , x1 , y0 , y1 = self .extents
3113
- # Switch variables so that only x1 and/or y1 are updated on move.
3114
- if self ._active_handle in ['W' , 'SW' , 'NW' ]:
3115
- x0 , x1 = x1 , event .xdata
3116
- if self ._active_handle in ['N' , 'NW' , 'NE' ]:
3117
- y0 , y1 = y1 , event .ydata
3118
- self ._extents_on_press = x0 , x1 , y0 , y1
3119
-
3120
3119
def _contains (self , event ):
3121
3120
"""Return True if event is within the patch."""
3122
3121
return self ._selection_artist .contains (event , radius = 0 )[0 ]
0 commit comments