Changeset 5050


Ignore:
Timestamp:
Feb 28, 2015 7:23:06 PM (5 years ago)
Author:
mmc
Message:

Merge from mdshowcase: Changes to the VMD server to support the "pick" mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vmdshow/trunk/vmdserver.tcl

    r4978 r5050  
    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.
     154# ----------------------------------------------------------------------
     155proc cmd_queryinfo {x y args} {
     156    global DisplayProps MolNames MolInfo
     157
     158    # be careful -- VMD uses coordinates from LOWER-left corner of window
     159    set vmdy [expr {$DisplayProps(frameh)-$y}]
     160
     161    set vals [pick $x $vmdy]
     162    if {$vals ne ""} {
     163        array set data $vals
     164
     165        # map the molecule ID back to the name used within MD Showcase
     166        foreach molname $MolNames {
     167            if {$MolInfo($molname) == $data(mol)} {
     168                set data(molname) $molname
     169                break
     170            }
     171        }
     172
     173        # pass back the click coord on screen so we know where this came from
     174        set data(screenx) $x
     175        set data(screeny) $y
     176
     177        set vals [array get data]
     178    }
     179    return $vals
     180}
     181$parser alias queryinfo cmd_queryinfo
     182
     183# ----------------------------------------------------------------------
    150184# USAGE: resize <w> <h>
    151185#
     
    328362# ----------------------------------------------------------------------
    329363proc cmd_load {args} {
    330     global MolInfo
     364    global MolInfo MolNames
    331365
    332366    # clear all existing molecules
     
    335369    }
    336370    catch {unset MolInfo}
     371    set MolNames ""
    337372
    338373    # load new files
     
    352387        if {$op eq "new"} {
    353388            set newnum [lindex [molinfo list] end]
     389            if {[lsearch -exact MolNames $name] < 0} {
     390                lappend MolNames $name
     391            }
    354392            set MolInfo($name) $newnum
    355393            set MolInfo($slot) $newnum
     
    752790                server_oops $cout $result
    753791                if { [string match "invalid command*" $result] } {
    754                     bgerror "I got a invalid command: $result"
     792                    bgerror "server received invalid command: $result"
    755793                    exit 1
    756794                }
Note: See TracChangeset for help on using the changeset viewer.