next up previous contents index
Next: 13.2.7 Animation Up: 13.2 Tutorials and Examples Previous: 13.2.5 Adding a label

13.2.6 Interface to picking

 

When an atom is picked with the mouse, the Tcl variable vmd_pick_mol gets set to the moleule id of the picked molecule, and vmd_pick_atom contains the atom index. The Tcl command trace can be used to call a function when those values change.      

As an example of what can be done with this, the following statements will put a sphere around each atom when it has been picked with the mouse. To turn it off, execute
trace vdelete vmd_pick_atom w sphere_pick.

proc sphere_pick {name element op} {
     # get the atom and molecule picked
     global vmd_pick_atom vmd_pick_mol
     # get the coordinates
     set sel [atomselect $vmd_pick_mol "index $vmd_pick_atom"]
     lassign [$sel get {x y z}] coords
     draw sphere $coords radius 1.0
}
trace variable vmd_pick_atom w sphere_pick



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