Coverage for /builds/kinetik161/ase/ase/gui/settings.py: 62.00%
50 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 _
5class Settings:
6 def __init__(self, gui):
7 self.gui = gui
8 win = ui.Window(_('Settings'), wmtype='utility')
10 # Constraints
11 win.add(_('Constraints:'))
12 win.add([ui.Button(_('Fix'), self.constrain_selected),
13 '/',
14 ui.Button(_('release'), self.release_selected),
15 _(' selected atoms')])
16 win.add(ui.Button(_('Clear all constraints'), self.clear_constraints))
18 # Visibility
19 win.add(_('Visibility:'))
20 win.add([ui.Button(_('Hide'), self.hide_selected),
21 '/',
22 ui.Button(_('show'), self.show_selected),
23 _(' selected atoms')])
24 win.add(ui.Button(_('View all atoms'), self.view_all))
26 # Miscellaneous
27 win.add(_('Miscellaneous:'))
28 self.scale = ui.SpinBox(self.gui.images.atom_scale,
29 0.2, 2.0, 0.1, self.scale_radii)
30 win.add([_('Scale atomic radii:'), self.scale])
31 self.force_vector_scale = ui.SpinBox(
32 self.gui.force_vector_scale,
33 0.0, 1e32, 0.1,
34 rounding=2,
35 callback=self.scale_force_vectors
36 )
37 win.add([_('Scale force vectors:'), self.force_vector_scale])
38 self.velocity_vector_scale = ui.SpinBox(
39 self.gui.velocity_vector_scale,
40 0.0, 1e32, 0.1,
41 rounding=2,
42 callback=self.scale_velocity_vectors
43 )
44 win.add([_('Scale velocity vectors:'), self.velocity_vector_scale])
46 def scale_radii(self):
47 self.gui.images.atom_scale = self.scale.value
48 self.gui.draw()
49 return True
51 def scale_force_vectors(self):
52 self.gui.force_vector_scale = float(self.force_vector_scale.value)
53 self.gui.draw()
54 return True
56 def scale_velocity_vectors(self):
57 self.gui.velocity_vector_scale = float(self.velocity_vector_scale.value)
58 self.gui.draw()
59 return True
61 def hide_selected(self):
62 self.gui.images.visible[self.gui.images.selected] = False
63 self.gui.draw()
65 def show_selected(self):
66 self.gui.images.visible[self.gui.images.selected] = True
67 self.gui.draw()
69 def view_all(self):
70 self.gui.images.visible[:] = True
71 self.gui.draw()
73 def constrain_selected(self):
74 self.gui.images.set_dynamic(self.gui.images.selected, False)
75 self.gui.draw()
77 def release_selected(self):
78 self.gui.images.set_dynamic(self.gui.images.selected, True)
79 self.gui.draw()
81 def clear_constraints(self):
82 # This clears *all* constraints. But when we constrain, we
83 # only add FixAtoms....
84 for atoms in self.gui.images:
85 atoms.constraints = []
86 self.gui.draw()