@@ -189,6 +189,43 @@ def onselect(epress, erelease):
189189 tool ._corner_handles .artist .get_markeredgecolor (), 'b' )
190190
191191
192+ @pytest .mark .parametrize ('selector_class' , [widgets .RectangleSelector ,
193+ widgets .EllipseSelector ])
194+ def test_rectangle_rotate (selector_class ):
195+ ax = get_ax ()
196+
197+ def onselect (epress , erelease ):
198+ pass
199+
200+ tool = selector_class (ax , onselect = onselect , interactive = True )
201+ # Draw rectangle
202+ do_event (tool , 'press' , xdata = 100 , ydata = 100 )
203+ do_event (tool , 'onmove' , xdata = 130 , ydata = 140 )
204+ do_event (tool , 'release' , xdata = 130 , ydata = 140 )
205+ assert tool .extents == (100 , 130 , 100 , 140 )
206+
207+ # Rotate anticlockwise using top-right corner
208+ do_event (tool , 'on_key_press' , key = 'r' )
209+ do_event (tool , 'press' , xdata = 130 , ydata = 140 )
210+ do_event (tool , 'onmove' , xdata = 100 , ydata = 150 )
211+ do_event (tool , 'release' , xdata = 100 , ydata = 200 )
212+ do_event (tool , 'on_key_release' , key = 'r' )
213+ # Extents shouldn't change (as shape of rectangle hasn't changed)
214+ assert tool .extents == (100 , 130 , 100 , 140 )
215+ # Corners should move
216+ # The third corner is at (100, 150), as the diagonal of the rectangle has
217+ # length 50 (it is a 3,4,5 scaled right angled triangle)
218+ assert tool .corners == ((100 , 124 , 100 , 76 ), (100 , 118 , 150 , 132 ))
219+
220+ # Scale using top-right corner
221+ do_event (tool , 'press' , xdata = 100 , ydata = 150 )
222+ do_event (tool , 'onmove' , xdata = 100 , ydata = 125 )
223+ do_event (tool , 'release' , xdata = 100 , ydata = 125 )
224+ assert tool .extents == (100 , 115 , 100 , 120 )
225+ # The bottom-left corner doesn't move, the top-right moves to (100, 125)
226+ assert tool .corners == ((100 , 112 , 100 , 88 ), (100 , 109 , 125 , 116 ))
227+
228+
192229def check_span (* args , ** kwargs ):
193230 ax = get_ax ()
194231
0 commit comments