next up previous contents index
Next: 16.5.3 Drawing a line Up: 16.5 Trace on the Previous: 16.5.1 Information about the

16.5.2 Making a sphere appear when an atom is picked

Similarly, you can use the callback to generate a sphere when an atom is picked.

proc pick_sphere {args} {
      global vmd_pick_atom vmd_pick_mol
      # get the coordinates
      lassign [[atomselect $vmd_pick_mol "index $vmd_pick_atom"] \
            get {x y z}] x y z
      # draw the sphere
      draw sphere "$x $y $z" radius 1
}
and establish the trace:

trace variable vmd_pick_atom w pick_sphere

Whenever you click on an atom, a sphere will appear at the same location. Since the graphics and the molecule aren't the same graphics object, you may need to reset view to make them aligned.

To turn the trace off:

trace vdelete vmd_pick_atom w pick_sphere



Sergei Izrailev
Fri Jul 25 17:07:27 CDT 1997