File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1524,6 +1524,7 @@ def _on_move(self, event):
15241524 dazim = - (dy / h )* 180 * np .sin (roll ) - (dx / w )* 180 * np .cos (roll )
15251525 elev = self .elev + delev
15261526 azim = self .azim + dazim
1527+ roll = self .roll
15271528 vertical_axis = self ._axis_names [self ._vertical_axis ]
15281529 self .view_init (
15291530 elev = elev ,
Original file line number Diff line number Diff line change @@ -1766,6 +1766,31 @@ def test_shared_axes_retick():
17661766 assert ax2 .get_zlim () == (- 0.5 , 2.5 )
17671767
17681768
1769+ def test_rotate ():
1770+ """Test rotating using the left mouse button."""
1771+ for roll in [0 , 30 ]:
1772+ fig = plt .figure ()
1773+ ax = fig .add_subplot (1 , 1 , 1 , projection = '3d' )
1774+ ax .view_init (0 , 0 , roll )
1775+ ax .figure .canvas .draw ()
1776+
1777+ # drag mouse horizontally to change azimuth
1778+ dx = 0.1
1779+ dy = 0.2
1780+ ax ._button_press (
1781+ mock_event (ax , button = MouseButton .LEFT , xdata = 0 , ydata = 0 ))
1782+ ax ._on_move (
1783+ mock_event (ax , button = MouseButton .LEFT ,
1784+ xdata = dx * ax ._pseudo_w , ydata = dy * ax ._pseudo_h ))
1785+ ax .figure .canvas .draw ()
1786+ roll_radians = np .deg2rad (ax .roll )
1787+ cs = np .cos (roll_radians )
1788+ sn = np .sin (roll_radians )
1789+ assert ax .elev == (- dy * 180 * cs + dx * 180 * sn )
1790+ assert ax .azim == (- dy * 180 * sn - dx * 180 * cs )
1791+ assert ax .roll == roll
1792+
1793+
17691794def test_pan ():
17701795 """Test mouse panning using the middle mouse button."""
17711796
You can’t perform that action at this time.
0 commit comments