Changeset 5122 for vmdshow/trunk


Ignore:
Timestamp:
Mar 11, 2015 5:10:58 PM (9 years ago)
Author:
mmc
Message:

Ported changes over from trunk: Added support for shift-click in
"pick" operation, so that you can click on multiple atoms and measure
bond lengths and angles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vmdshow/trunk/vmdserver.tcl

    r5050 r5122  
    148148
    149149# ----------------------------------------------------------------------
    150 # USAGE: queryinfo <x> <y> ?-add?
    151 #
    152 # Resizes the visualization window to the given width <w> and height
    153 # <h>.  The next image sent should be this size.
     150# USAGE: queryinfo <x> <y> ?-prev atomid atomid?
     151# USAGE: queryinfo <x> <y> ?-prev atomid?
     152# USAGE: queryinfo <x> <y>
     153#
     154# Picks the atom at screen coordinate <x>,<y> and returns information
     155# about it.  If one previous atom is specified, then this command
     156# returns the bond length between the previous atom and the current
     157# one.  If two previous atoms are specified, then it returns the
     158# angle between the three atoms.
    154159# ----------------------------------------------------------------------
    155160proc cmd_queryinfo {x y args} {
    156161    global DisplayProps MolNames MolInfo
     162
     163    # handle command arguments
     164    set prevatoms ""
     165    while {[llength $args] > 0} {
     166        set option [lindex $args 0]
     167        set args [lrange $args 1 end]
     168        if {$option eq "-prev"} {
     169            while {[llength $args] > 0} {
     170                set val [lindex $args 0]
     171                if {[regexp {^[0-9]} $val]} {
     172                    lappend prevatoms $val
     173                    set args [lrange $args 1 end]
     174                } else {
     175                    break
     176                }
     177            }
     178        } else {
     179            error "bad option \"$option\": should be -prev"
     180        }
     181    }
    157182
    158183    # be careful -- VMD uses coordinates from LOWER-left corner of window
     
    175200        set data(screeny) $y
    176201
     202        # if there are -prev atoms, query extra info
     203        set curr [list $data(index) $data(mol)]
     204        set meas $prevatoms
     205        set i [lsearch -exact $meas $curr]
     206        if {$i >= 0} {
     207            set meas [lreplace $meas $i $i]
     208        }
     209        set meas [linsert $meas 0 $curr]
     210        set meas [lrange $meas 0 2]
     211
     212        switch -- [llength $meas] {
     213            2 {
     214                set data(bondlength) [measure bond $meas]
     215            }
     216            3 {
     217                set data(bondlength) [measure bond [lrange $meas 0 1]]
     218                set data(bondlength2) [measure bond [lrange $meas 1 2]]
     219                set data(angle) [measure angle $meas]
     220            }
     221        }
     222
     223        # convert data back to return value
    177224        set vals [array get data]
    178225    }
Note: See TracChangeset for help on using the changeset viewer.