Changeset 6185 for vmdshow/trunk/vmdserver.tcl
- Timestamp:
- Mar 23, 2016, 12:02:24 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vmdshow/trunk/vmdserver.tcl
r5122 r6185 69 69 set Sendqueue "" 70 70 set Scenes(@CURRENT) "" 71 set tmpDir "" 71 72 72 73 set parser [interp create -safe] 73 74 74 75 foreach 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 109 128 } { 110 129 $parser alias $cmd $cmd … … 146 165 } 147 166 $parser alias tellme cmd_tellme 167 $parser alias set_temporary_directory server_set_temporary_directory 148 168 149 169 # ---------------------------------------------------------------------- … … 297 317 display shadows off 298 318 319 if 0 { 299 320 foreach nmol [molinfo list] { 300 321 set max [molinfo $nmol get numreps] … … 303 324 } 304 325 } 326 } 305 327 } 306 328 end { … … 310 332 display shadows $DisplayProps(shadows) 311 333 334 if 0 { 312 335 # restore rendering methods for all representations 313 336 foreach nmol [molinfo list] { … … 317 340 } 318 341 } 342 } 319 343 } 320 344 default { … … 408 432 # DCD, PSF, etc. 409 433 # ---------------------------------------------------------------------- 410 proc cmd_load {args} { 411 global MolInfo MolNames 434 proc cmd_load { fileList } { 435 puts stderr "cmd_load fileList=$fileList\n" 436 global MolInfo MolNames tmpDir 412 437 413 438 # clear all existing molecules … … 419 444 420 445 # load new files 421 if {![regexp {^@name:} $ args]} {446 if {![regexp {^@name:} $fileList]} { 422 447 # 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" 425 451 426 452 set slot 0 427 foreach file $args { 453 foreach file $fileList { 454 puts stderr "file=$file\n" 428 455 if {[regexp {^@name:(.+)} $file match name]} { 429 456 set op "new" 430 457 continue 431 458 } 459 if { $tmpDir != "" } { 460 set tmpFile [file join $tmpDir [file tail $file]] 461 if { [file exists $tmpFile] } { 462 set file $tmpFile 463 } 464 } 432 465 mol $op $file waitfor all 433 466 if { ![info exists name] } { 467 puts stderr "can't find name file=$file" 468 } 434 469 if {$op eq "new"} { 435 470 set newnum [lindex [molinfo list] end] … … 452 487 453 488 # ---------------------------------------------------------------------- 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>? 456 491 # USAGE: scene clear 457 # USAGE: scene forget ? <name> <name>...?492 # USAGE: scene forget ?id id...? 458 493 # 459 494 # Used to define and manipulate scenes of the trajectory information 460 495 # 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" 462 497 # operation executes that script to show the scene. The "clear" 463 498 # operation clears the current scene (usually in preparation for 464 499 # showing another scene). The "forget" operation erases one or more 465 # scene definitions; if no names are specified, then all scenes are500 # scene definitions; if no ids are specified, then all scenes are 466 501 # forgotten. 467 502 # ---------------------------------------------------------------------- … … 472 507 define { 473 508 if {[llength $args] != 2} { 474 error "wrong # args: should be \"scene define namescript\""475 } 476 set name[lindex $args 0]509 error "wrong # args: should be \"scene define id script\"" 510 } 511 set id [lindex $args 0] 477 512 set script [lindex $args 1] 478 set Scenes($ name) $script513 set Scenes($id) $script 479 514 } 480 515 show { 481 516 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] {, }]" 487 522 } 488 523 … … 513 548 $parser eval [list array set mol [array get MolInfo]] 514 549 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\"" 517 552 } 518 553 … … 529 564 } 530 565 531 # store the scene namefor later532 set Scenes(@CURRENT) $ name566 # store the scene id for later 567 set Scenes(@CURRENT) $id 533 568 534 569 # if -after arg was given, send back the view after the script … … 556 591 set args [array names Scenes] 557 592 } 558 foreach name$args {559 if {$ nameeq "@CURRENT"} continue560 catch {unset Scenes($ name)}561 if {$ nameeq $Scenes(@CURRENT)} {593 foreach id $args { 594 if {$id eq "@CURRENT"} continue 595 catch {unset Scenes($id)} 596 if {$id eq $Scenes(@CURRENT)} { 562 597 set Scenes(@CURRENT) "" 563 598 } … … 768 803 global Scenes 769 804 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 774 813 775 814 lappend rval -rotate [lindex [molinfo top get rotate_matrix] 0] \ … … 781 820 } 782 821 $parser alias getview cmd_getview 822 823 proc 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 783 837 784 838 # … … 824 878 # nanoscale will spawn a new server next time we need it 825 879 if {[eof $cin]} { 826 server_exit $cin $cout 880 server_exit $cin $cout 0 827 881 } 828 882 } else { … … 838 892 if { [string match "invalid command*" $result] } { 839 893 bgerror "server received invalid command: $result" 840 exit 1894 server_exit $cin $cout 1 841 895 } 842 896 } … … 875 929 } 876 930 877 proc server_exit {cin cout } {931 proc server_exit {cin cout code} { 878 932 catch {close $cin} 879 catch {exit 0} 933 catch {exit $code} 934 880 935 } 881 936 … … 955 1010 } 956 1011 1012 proc server_set_temporary_directory { path } { 1013 global tmpDir 1014 1015 set tmpDir $path 1016 } 1017 957 1018 proc server_send_result {cout cmd {data ""}} { 958 1019 global Sendqueue
Note: See TracChangeset
for help on using the changeset viewer.