Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from ase.gui.i18n import _
3import ase.gui.ui as ui
6class Settings:
7 def __init__(self, gui):
8 self.gui = gui
9 win = ui.Window(_('Settings'))
11 # Constraints
12 win.add(_('Constraints:'))
13 win.add([ui.Button(_('Fix'), self.constrain_selected),
14 '/',
15 ui.Button(_('release'), self.release_selected),
16 _(' selected atoms')])
17 win.add(ui.Button(_('Clear all constraints'), self.clear_constraints))
19 # Visibility
20 win.add(_('Visibility:'))
21 win.add([ui.Button(_('Hide'), self.hide_selected),
22 '/',
23 ui.Button(_('show'), self.show_selected),
24 _(' selected atoms')])
25 win.add(ui.Button(_('View all atoms'), self.view_all))
27 # Miscellaneous
28 win.add(_('Miscellaneous:'))
29 self.scale = ui.SpinBox(self.gui.images.atom_scale,
30 0.2, 2.0, 0.1, self.scale_radii)
31 win.add([_('Scale atomic radii:'), self.scale])
32 self.force_vector_scale = ui.SpinBox(
33 self.gui.force_vector_scale,
34 0.0, 1e32, 0.1,
35 rounding=2,
36 callback=self.scale_force_vectors
37 )
38 win.add([_('Scale force vectors:'), self.force_vector_scale])
39 self.velocity_vector_scale = ui.SpinBox(
40 self.gui.velocity_vector_scale,
41 0.0, 1e32, 0.1,
42 rounding=2,
43 callback=self.scale_velocity_vectors
44 )
45 win.add([_('Scale velocity vectors:'), self.velocity_vector_scale])
47 def scale_radii(self):
48 self.gui.images.atom_scale = self.scale.value
49 self.gui.draw()
50 return True
52 def scale_force_vectors(self):
53 self.gui.force_vector_scale = float(self.force_vector_scale.value)
54 self.gui.draw()
55 return True
57 def scale_velocity_vectors(self):
58 self.gui.velocity_vector_scale = float(self.velocity_vector_scale.value)
59 self.gui.draw()
60 return True
62 def hide_selected(self):
63 self.gui.images.visible[self.gui.images.selected] = False
64 self.gui.draw()
66 def show_selected(self):
67 self.gui.images.visible[self.gui.images.selected] = True
68 self.gui.draw()
70 def view_all(self):
71 self.gui.images.visible[:] = True
72 self.gui.draw()
74 def constrain_selected(self):
75 self.gui.images.set_dynamic(self.gui.images.selected, False)
76 self.gui.draw()
78 def release_selected(self):
79 self.gui.images.set_dynamic(self.gui.images.selected, True)
80 self.gui.draw()
82 def clear_constraints(self):
83 # This clears *all* constraints. But when we constrain, we
84 # only add FixAtoms....
85 for atoms in self.gui.images:
86 atoms.constraints = []
87 self.gui.draw()