MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _on_move

Method _on_move

lib/mpl_toolkits/mplot3d/axes3d.py:1753–1850  ·  view source on GitHub ↗

Mouse moving. By default, button-1 rotates, button-2 pans, and button-3 zooms; these buttons can be modified via `mouse_init`.

(self, event)

Source from the content-addressed store, hash-verified

1751 return p
1752
1753 def _on_move(self, event):
1754 """
1755 Mouse moving.
1756
1757 By default, button-1 rotates, button-2 pans, and button-3 zooms;
1758 these buttons can be modified via `mouse_init`.
1759 """
1760
1761 if not self.button_pressed:
1762 return
1763
1764 if self.get_navigate_mode() is not None:
1765 # we don't want to rotate if we are zooming/panning
1766 # from the toolbar
1767 return
1768
1769 if self.M is None:
1770 return
1771
1772 x, y = event.xdata, event.ydata
1773 # In case the mouse is out of bounds.
1774 if x is None or event.inaxes != self:
1775 return
1776
1777 dx, dy = x - self._sx, y - self._sy
1778 w = self._pseudo_w
1779 h = self._pseudo_h
1780
1781 # Rotation
1782 if self.button_pressed in self._rotate_btn:
1783 # rotate viewing point
1784 # get the x and y pixel coords
1785 if dx == 0 and dy == 0:
1786 return
1787
1788 style = mpl.rcParams['axes3d.mouserotationstyle']
1789 if style == 'azel':
1790 roll = np.deg2rad(self.roll)
1791 delev = -(dy/h)*180*np.cos(roll) + (dx/w)*180*np.sin(roll)
1792 dazim = -(dy/h)*180*np.sin(roll) - (dx/w)*180*np.cos(roll)
1793 elev = self.elev + delev
1794 azim = self.azim + dazim
1795 roll = self.roll
1796 else:
1797 q = _Quaternion.from_cardan_angles(
1798 *np.deg2rad((self.elev, self.azim, self.roll)))
1799
1800 if style == 'trackball':
1801 k = np.array([0, -dy/h, dx/w])
1802 nk = np.linalg.norm(k)
1803 th = nk / mpl.rcParams['axes3d.trackballsize']
1804 dq = _Quaternion(np.cos(th), k*np.sin(th)/nk)
1805 else: # 'sphere', 'arcball'
1806 current_vec = self._arcball(self._sx/w, self._sy/h)
1807 new_vec = self._arcball(x/w, y/h)
1808 if style == 'sphere':
1809 dq = _Quaternion.rotate_from_to(current_vec, new_vec)
1810 else: # 'arcball'

Callers

nothing calls this directly

Calls 15

_arcballMethod · 0.95
view_initMethod · 0.95
drag_panMethod · 0.95
_scale_axis_limitsMethod · 0.95
_QuaternionClass · 0.85
get_navigate_modeMethod · 0.80
from_cardan_anglesMethod · 0.80
rotate_from_toMethod · 0.80
as_cardan_anglesMethod · 0.80
normMethod · 0.45
transformMethod · 0.45
start_panMethod · 0.45

Tested by

no test coverage detected