Coverage for /builds/kinetik161/ase/ase/gui/rotate.py: 86.36%
22 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
1import ase.gui.ui as ui
2from ase.gui.i18n import _
3from ase.utils import irotate, rotate
6class Rotate:
7 update = True
9 def __init__(self, gui):
10 self.gui = gui
11 win = ui.Window(_('Rotate'), wmtype='utility')
12 win.add(_('Rotation angles:'))
13 self.rotate = [ui.SpinBox(42.0, -360, 360, 1, self.change)
14 for i in '123']
15 win.add(self.rotate)
16 win.add(ui.Button(_('Update'), self.update_angles))
17 win.add(_('Note:\nYou can rotate freely\n'
18 'with the mouse, by holding\n'
19 'down mouse button 2.'))
20 self.update_angles()
22 def change(self):
23 x, y, z = (float(a.value) for a in self.rotate)
24 self.gui.axes = rotate(f'{x:f}x,{y:f}y,{z:f}z')
25 self.gui.set_frame()
27 def update_angles(self):
28 angles = irotate(self.gui.axes)
29 for r, a in zip(self.rotate, angles):
30 r.value = a