next up previous contents index
Next: Drawing a line from Up: Trace on the pick Previous: Information about the picked

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



Justin Gullingsrud
Tue Apr 6 09:22:39 CDT 1999