Changeset 6186


Ignore:
Timestamp:
Mar 23, 2016 12:07:30 AM (8 years ago)
Author:
ldelgass
Message:

merge from trunk

Location:
vmdshow/branches/0.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vmdshow/branches/0.1

  • vmdshow/branches/0.1/vmdserver.tcl

    r5123 r6186  
    6969set Sendqueue ""
    7070set Scenes(@CURRENT) ""
     71set tmpDir ""
    7172
    7273set parser [interp create -safe]
    7374
    7475foreach cmd {
    75   axes
    76   color
    77   gettimestep
    78   graphics
    79   imd
    80   label
    81   vmd_label
    82   light
    83   material
    84   measure
    85   mobile
    86   mol
    87   molinfo
    88   molecule
    89   mouse
    90   parallel
    91   plugin
    92   rawtimestep
    93   render
    94   rotate
    95   rotmat
    96   scale
    97   vmd_scale
    98   spaceball
    99   stage
    100   tkrender
    101   tool
    102   translate
    103   user
    104   vmdcollab
    105   vmdcon
    106   vmdinfo
    107   vmdbench
    108   volmap
     76    axes
     77    color
     78    gettimestep
     79    graphics
     80    imd
     81    label
     82    vmd_label
     83    light
     84    material
     85    measure
     86    mobile
     87    mol
     88    molinfo
     89    molecule
     90    mouse
     91    parallel
     92    plugin
     93    rawtimestep
     94    render
     95    rotate
     96    rotmat
     97    scale
     98    vmd_scale
     99    spaceball
     100    stage
     101    tkrender
     102    tool
     103    translate
     104    user
     105
     106    vecadd
     107    veccross
     108    vecdist
     109    vecdot
     110    vecinvert
     111    veclength
     112    veclength2
     113    vecmean
     114    vecmul
     115    vecnorm
     116    vecscale
     117    vecscale
     118    vecstddev
     119    vecsub
     120    vecsum
     121    veczero
     122   
     123    vmdcollab
     124    vmdcon
     125    vmdinfo
     126    vmdbench
     127    volmap
    109128} {
    110129    $parser alias $cmd $cmd
     
    146165}
    147166$parser alias tellme cmd_tellme
     167$parser alias set_temporary_directory server_set_temporary_directory
    148168
    149169# ----------------------------------------------------------------------
     
    297317            display shadows off
    298318
     319            if 0 {
    299320            foreach nmol [molinfo list] {
    300321                set max [molinfo $nmol get numreps]
     
    303324                }
    304325            }
     326            }
    305327        }
    306328        end {
     
    310332            display shadows $DisplayProps(shadows)
    311333
     334            if 0 {
    312335            # restore rendering methods for all representations
    313336            foreach nmol [molinfo list] {
     
    317340                }
    318341            }
     342            }
    319343        }
    320344        default {
     
    408432# DCD, PSF, etc.
    409433# ----------------------------------------------------------------------
    410 proc cmd_load {args} {
    411     global MolInfo MolNames
     434proc cmd_load { fileList } {
     435    puts stderr "cmd_load fileList=$fileList\n"
     436    global MolInfo MolNames tmpDir
    412437
    413438    # clear all existing molecules
     
    419444
    420445    # load new files
    421     if {![regexp {^@name:} $args]} {
     446    if {![regexp {^@name:} $fileList]} {
    422447        # make sure that there is at least one name in the list
    423         set args [linsert $args 0 "@name:0"]
    424     }
     448        set fileList [linsert $fileList 0 "@name:0"]
     449    }
     450    puts stderr "2. cmd_load fileList=$fileList"
    425451
    426452    set slot 0
    427     foreach file $args {
     453    foreach file $fileList {
     454    puts stderr "file=$file\n"
    428455        if {[regexp {^@name:(.+)} $file match name]} {
    429456            set op "new"
    430457            continue
    431458        }
     459        if { $tmpDir != "" } {
     460            set tmpFile [file join $tmpDir [file tail $file]]
     461            if { [file exists $tmpFile] } {
     462                set file $tmpFile
     463            }
     464        }
    432465        mol $op $file waitfor all
    433 
     466        if { ![info exists name] } {
     467            puts stderr "can't find name file=$file"
     468        }
    434469        if {$op eq "new"} {
    435470            set newnum [lindex [molinfo list] end]
     
    452487
    453488# ----------------------------------------------------------------------
    454 # USAGE: scene define <name> <script>
    455 # USAGE: scene show <name> ?-before <viewCmd>? ?-after <viewCmd>?
     489# USAGE: scene define id <script>
     490# USAGE: scene show id ?-before <viewCmd>? ?-after <viewCmd>?
    456491# USAGE: scene clear
    457 # USAGE: scene forget ?<name> <name>...?
     492# USAGE: scene forget ?id id...?
    458493#
    459494# Used to define and manipulate scenes of the trajectory information
    460495# loaded previously by the "load" command.  The "define" operation
    461 # defines the script that loads a scene called <name>.  The "show"
     496# defines the script that loads a scene called <id>.  The "show"
    462497# operation executes that script to show the scene.  The "clear"
    463498# operation clears the current scene (usually in preparation for
    464499# showing another scene).  The "forget" operation erases one or more
    465 # scene definitions; if no names are specified, then all scenes are
     500# scene definitions; if no ids are specified, then all scenes are
    466501# forgotten.
    467502# ----------------------------------------------------------------------
     
    472507        define {
    473508            if {[llength $args] != 2} {
    474                 error "wrong # args: should be \"scene define name script\""
    475             }
    476             set name [lindex $args 0]
     509                error "wrong # args: should be \"scene define id script\""
     510            }
     511            set id [lindex $args 0]
    477512            set script [lindex $args 1]
    478             set Scenes($name) $script
     513            set Scenes($id) $script
    479514        }
    480515        show {
    481516            if {[llength $args] < 1 || [llength $args] > 5} {
    482                 error "wrong # args: should be \"scene show name ?-before cmd? ?-after cmd?\""
    483             }
    484             set name [lindex $args 0]
    485             if {![info exists Scenes($name)]} {
    486                 error "bad scene name \"$name\": should be one of [join [array names Scenes] {, }]"
     517                error "wrong # args: should be \"scene show id ?-before cmd? ?-after cmd?\""
     518            }
     519            set id [lindex $args 0]
     520            if {![info exists Scenes($id)]} {
     521                error "bad scene id \"$id\": should be one of [join [array names Scenes] {, }]"
    487522            }
    488523
     
    513548            $parser eval [list array set mol [array get MolInfo]]
    514549
    515             if {[catch {$parser eval $Scenes($name)} result]} {
    516                 error "$result\nwhile loading scene \"$name\""
     550            if {[catch {$parser eval $Scenes($id)} result]} {
     551                error "$result\nwhile loading scene \"$id\""
    517552            }
    518553
     
    529564            }
    530565
    531             # store the scene name for later
    532             set Scenes(@CURRENT) $name
     566            # store the scene id for later
     567            set Scenes(@CURRENT) $id
    533568
    534569            # if -after arg was given, send back the view after the script
     
    556591                set args [array names Scenes]
    557592            }
    558             foreach name $args {
    559                 if {$name eq "@CURRENT"} continue
    560                 catch {unset Scenes($name)}
    561                 if {$name eq $Scenes(@CURRENT)} {
     593            foreach id $args {
     594                if {$id eq "@CURRENT"} continue
     595                catch {unset Scenes($id)}
     596                if {$id eq $Scenes(@CURRENT)} {
    562597                    set Scenes(@CURRENT) ""
    563598                }
     
    768803    global Scenes
    769804
    770     if {[llength [molinfo list]] == 0} { return "" }
    771     if {$Scenes(@CURRENT) eq ""} { return "" }
    772 
    773     set rval [list $Scenes(@CURRENT)]  ;# start with the scene name
     805    if { [llength [molinfo list]] == 0 } {
     806        return ""
     807    }
     808    if { $Scenes(@CURRENT) eq "" } {
     809        return ""
     810    }
     811
     812    set rval [list $Scenes(@CURRENT)]  ;# start with the scene id
    774813
    775814    lappend rval -rotate [lindex [molinfo top get rotate_matrix] 0] \
     
    781820}
    782821$parser alias getview cmd_getview
     822
     823proc cmd_atomselect {args} {
     824    global parser
     825   
     826    foreach arg $args {
     827        if { $arg == "writepdb" } {
     828            error "autoselect \"writepdb\" option is disallowed"
     829        }
     830    }
     831    set cmd [eval atomselect $args]
     832    $parser alias $cmd $cmd
     833    return $cmd
     834}
     835   
     836$parser alias atomselect cmd_atomselect
    783837
    784838#
     
    824878        # nanoscale will spawn a new server next time we need it
    825879        if {[eof $cin]} {
    826             server_exit $cin $cout
     880            server_exit $cin $cout 0
    827881        }
    828882    } else {
     
    838892                if { [string match "invalid command*" $result] } {
    839893                    bgerror "server received invalid command: $result"
    840                     exit 1
     894                    server_exit $cin $cout 1
    841895                }
    842896            }
     
    875929}
    876930
    877 proc server_exit {cin cout} {
     931proc server_exit {cin cout code} {
    878932    catch {close $cin}
    879     catch {exit 0}
     933    catch {exit $code}
     934   
    880935}
    881936
     
    9551010}
    9561011
     1012proc server_set_temporary_directory { path } {
     1013    global tmpDir
     1014
     1015    set tmpDir $path
     1016}
     1017
    9571018proc server_send_result {cout cmd {data ""}} {
    9581019    global Sendqueue
Note: See TracChangeset for help on using the changeset viewer.