Changeset 543
- Timestamp:
- Dec 4, 2009 5:07:56 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/atomcons.tcl
- Property rcs:date changed from 2001/09/04 22:07:47 to 2002/01/22 22:55:35
- Property rcs:lines changed from +2 -3 to +203 -80
- Property rcs:rev changed from 1.11 to 1.12
r418 r543 5 5 set expcons(height) 300 6 6 7 # this is used to create the contents ofthe constraint page7 # this is used once to create the constraint page 8 8 proc MakeConstraintsPane {} { 9 global expgui expcons 9 global expgui expcons expmap 10 10 # create the notebook 11 11 grid [NoteBook $expgui(consFrame).n -bd 2 -side bottom] -sticky news 12 source [file join $expgui(scriptdir) profcons.tcl] 13 } 14 15 # this is used to update the contents of the constraint page when displayed 16 proc DisplayConstraintsPane {} { 17 global expgui expcons expmap 12 18 # create pages for each of the constraint "subpages" 19 catch {$expgui(consFrame).n delete atomic} 20 catch {$expgui(consFrame).n delete macro} 21 catch {$expgui(consFrame).n delete profile} 22 set atom normal 23 set mm disabled 24 if {[llength $expmap(phasetype)] == 0} { 25 set atom disabled 26 } elseif {[lindex $expmap(phasetype) 0] == 4} { 27 set mm normal 28 if {[llength $expmap(phasetype)] == 1} { 29 set atom disabled 30 } 31 } 13 32 set expcons(atommaster) [\ 14 33 $expgui(consFrame).n insert end atomic -text Atomic \ 34 -state $atom \ 15 35 -createcmd "MakeAtomsConstraintsPane" \ 16 -raisecmd "DisplayAtomConstraints"] 36 -raisecmd "DisplayAtomConstraints"] 37 set expcons(mmatommaster) [\ 38 $expgui(consFrame).n insert end macro -text Macromol \ 39 -state $mm \ 40 -createcmd "MakeAtomsConstraintsPane mm" \ 41 -raisecmd "DisplayAtomConstraints mm"] 17 42 # profile constraints page 18 catch { 19 source [file join $expgui(scriptdir) profcons.tcl] 20 set expcons(profilemaster) [\ 21 $expgui(consFrame).n insert end profile -text Profile \ 22 -createcmd "MakeProfileConstraintsPane" \ 23 -raisecmd "DisplayProfileConstraints"] 24 } 25 } 26 27 # this is used to update the contents of the constraint page when displayed 28 proc DisplayConstraintsPane {} { 29 global expgui 43 set expcons(profilemaster) [\ 44 $expgui(consFrame).n insert end profile -text Profile \ 45 -createcmd "MakeProfileConstraintsPane" \ 46 -raisecmd "DisplayProfileConstraints"] 30 47 set page [$expgui(consFrame).n raise] 31 48 # open the atom constraints page if no page is open 32 49 if {$page == ""} { 33 set page atomic 34 $expgui(consFrame).n raise atomic 50 foreach page [$expgui(consFrame).n pages] { 51 # loop to the first non-disabled page 52 if {[$expgui(consFrame).n itemcget $page -state] == "normal"} { 53 $expgui(consFrame).n raise $page 54 return 55 } 56 } 35 57 } else { 36 58 set pageupdate [$expgui(consFrame).n itemcget $page -raisecmd] … … 39 61 } 40 62 41 # fill the atom constraints pane42 proc MakeAtomsConstraintsPane { } {63 # fill the atom/mm constraints pane 64 proc MakeAtomsConstraintsPane {"mode {}"} { 43 65 global expgui expcons 44 45 grid [button $expcons(atommaster).new -text "New Constraint" \ 46 -command "EditAtomConstraint new"] \ 66 if {$mode == "mm"} { 67 set frm mmatommaster 68 } else { 69 set frm atommaster 70 } 71 72 grid [button $expcons($frm).new -text "New Constraint" \ 73 -command "EditAtomConstraint new [list $mode]"] \ 47 74 -column 0 -sticky sw -row 1 48 grid [button $expcons( atommaster).del -text "Delete" \49 -command "DeleteAtomConstraints "] \75 grid [button $expcons($frm).del -text "Delete" \ 76 -command "DeleteAtomConstraints [list $mode]"] \ 50 77 -column 1 -sticky se -row 1 51 grid [canvas $expcons( atommaster).canvas \78 grid [canvas $expcons($frm).canvas \ 52 79 -scrollregion {0 0 5000 500} -width 0 -height 250 \ 53 -yscrollcommand "$expcons( atommaster).scroll set"] \80 -yscrollcommand "$expcons($frm).scroll set"] \ 54 81 -column 0 -row 0 -columnspan 2 -sticky nsew 55 grid columnconfigure $expcons( atommaster) 0 -weight 156 grid rowconfigure $expcons( atommaster) 0 -weight 157 grid rowconfigure $expcons( atommaster) 1 -pad 558 scrollbar $expcons( atommaster).scroll \59 -command "$expcons( atommaster).canvas yview"60 } 61 62 63 # this is called to display the constraints on atomic parameters64 proc DisplayAtomConstraints { } {82 grid columnconfigure $expcons($frm) 0 -weight 1 83 grid rowconfigure $expcons($frm) 0 -weight 1 84 grid rowconfigure $expcons($frm) 1 -pad 5 85 scrollbar $expcons($frm).scroll \ 86 -command "$expcons($frm).canvas yview" 87 } 88 89 90 # this is called to display the constraints on atomic/mm parameters 91 proc DisplayAtomConstraints {"mode {}"} { 65 92 global expgui expcons expmap 66 catch {destroy $expcons(atommaster).canvas.fr} 67 set top [frame $expcons(atommaster).canvas.fr] 68 $expcons(atommaster).canvas create window 0 0 -anchor nw -window $top 93 if {$mode == "mm"} { 94 set frm mmatommaster 95 } else { 96 set frm atommaster 97 } 98 catch {destroy $expcons($frm).canvas.fr} 99 set top [frame $expcons($frm).canvas.fr] 100 $expcons($frm).canvas create window 0 0 -anchor nw -window $top 69 101 70 102 # get a list of constraints … … 108 140 set row 0 109 141 set col -1 110 foreach lbl {# "" Phase \ 111 "" Atom(s) Variable Multiplier \ 112 "" Atom(s) Variable Multiplier \ 113 "" Delete} { 142 if {$mode == "mm"} { 143 set head {# "" "" \ 144 "" Atom(s) Variable Multiplier \ 145 "" Atom(s) Variable Multiplier \ 146 "" Delete} 147 } else { 148 set head {# "" Phase \ 149 "" Atom(s) Variable Multiplier \ 150 "" Atom(s) Variable Multiplier \ 151 "" Delete} 152 } 153 foreach lbl $head { 114 154 incr col 115 155 if {$lbl != ""} { … … 119 159 # make some column headings into buttons 120 160 foreach col {0 2 4 5} val {num phase atom var} { 121 $top.t$col config -relief raised -bd 2 122 bind $top.t$col <1> "set expcons(sortmode) $val; DisplayAtomConstraints" 161 catch { 162 $top.t$col config -relief raised -bd 2 163 bind $top.t$col <1> \ 164 "set expcons(sortmode) $val; DisplayAtomConstraints [list $mode]" 165 } 123 166 } 124 167 # extra column spacing … … 149 192 set phprev 0 150 193 incr row -1 194 set col 1 151 195 foreach key [lsort [array names atomlist]] { 152 196 regexp {(.*)_(.*)_(.*)} $key dummy phase var mult … … 159 203 grid rowconfig $top $row -minsize 1 160 204 } 161 grid [label $top.c${col}$row -text $phase] \ 162 -column [incr col] -row [incr row] 205 if {$mode == "mm"} { 206 incr col 207 incr row 208 } else { 209 grid [label $top.c${col}$row -text $phase] \ 210 -column [incr col] -row [incr row] 211 } 163 212 set phprev $phase 164 213 } … … 169 218 } 170 219 grid [label $top.c${col}$row \ 171 -text [CompressList $atomlist($key)]] \ 220 -justify left \ 221 -text [CompressList $atomlist($key) 20]] \ 172 222 -column [incr col] -row $row -sticky w 173 223 grid [label $top.c${col}$row -text $var] \ … … 181 231 } 182 232 grid [button $top.but$row -text "edit" \ 183 -command "EditAtomConstraint $num "] \233 -command "EditAtomConstraint $num [list $mode]"] \ 184 234 -column 1 -row $startrow \ 185 235 -rowspan [expr 1 + $row - $startrow] … … 215 265 update idletasks 216 266 set sizes [grid bbox $top] 217 $expcons( atommaster).canvas config -scrollregion $sizes267 $expcons($frm).canvas config -scrollregion $sizes 218 268 set hgt [lindex $sizes 3] 219 269 # set the maximum height for the canvas from the frame … … 223 273 # use the scroll for BIG constraint lists 224 274 if {$hgt > $maxheight} { 225 grid $expcons( atommaster).scroll -sticky ns -column 2 -row 0226 } 227 $expcons( atommaster).canvas config \275 grid $expcons($frm).scroll -sticky ns -column 2 -row 0 276 } 277 $expcons($frm).canvas config \ 228 278 -height $maxheight \ 229 279 -width [lindex $sizes 2] … … 235 285 regexp {(.*)_(.*)_(.*)} $key dummy var phase atom 236 286 append msg " $var for atom $atom (phase $phase) is in" 237 append msg " constraints [CompressList $varlist($key) ]\n"287 append msg " constraints [CompressList $varlist($key) 40]\n" 238 288 } 239 289 } … … 249 299 250 300 # this is called to delete an atomic constraint 251 proc DeleteAtomConstraints { } {301 proc DeleteAtomConstraints {mode} { 252 302 global expcons expgui 253 303 # get the constraints to delete … … 266 316 incr expgui(changed) 267 317 } 268 DisplayAtomConstraints 318 DisplayAtomConstraints $mode 269 319 } 270 320 271 321 # called to edit a single constraint set 272 proc EditAtomConstraint {num args} {322 proc EditAtomConstraint {num mode} { 273 323 global expcons expmap expgui 274 324 275 325 set top {.editcons} 276 326 catch {toplevel $top} 327 328 if {$mode == "mm"} {pleasewait "making window..."} 329 277 330 bind $top <Key-F1> "MakeWWWHelp expgui6.html EditAtomConstraints" 278 331 eval destroy [grid slaves $top] … … 305 358 306 359 grid [button $top.add -text "New Column" \ 307 -command "NewAtomConstraintColumn $top $cfr $num "] \360 -command "NewAtomConstraintColumn $top $cfr $num [list $mode]"] \ 308 361 -column 0 -row 3 -columnspan 2 -sticky ew 309 362 grid [button $top.done -text "Save" \ 310 -command "SaveAtomConstraint $num $top "] \363 -command "SaveAtomConstraint $num $top [list $mode]"] \ 311 364 -column 0 -row 4 -sticky ns 312 365 grid [button $top.quit -text "Cancel\nChanges" \ 313 -command "CancelEditConstraint $top "] -column 1 -row 4366 -command "CancelEditConstraint $top $num"] -column 1 -row 4 314 367 grid [button $top.help -text Help -bg yellow \ 315 368 -command "MakeWWWHelp expgui6.html EditAtomConstraints"] \ … … 318 371 set col 0 319 372 set row 1 320 foreach lbl {Phase Atom(s) Variable Multiplier} { 373 if {$mode == "mm"} { 374 set head {Atom(s) Variable Multiplier} 375 incr row 2 376 } else { 377 set head {Phase Atom(s) Variable Multiplier} 378 } 379 foreach lbl $head { 321 380 # row separator 322 381 grid [frame $cfr.spc$row -bd 8 -bg white] \ … … 358 417 eval trace vdelete expcons(phase$ic) $v 359 418 } 360 MakeAtomConstraintColumn $cfr $ic $col $num 419 MakeAtomConstraintColumn $cfr $ic $col $num $mode 361 420 incr col 3 362 421 # set the various variables … … 367 426 trace variable expcons(phase$ic) w "FillAtomsConstraintList $ic {}" 368 427 } 369 if {$num == "new"} {NewAtomConstraintColumn $top $cfr $num }428 if {$num == "new"} {NewAtomConstraintColumn $top $cfr $num $mode} 370 429 trace variable expcons(var1) w SetVarConstraintMenu 371 430 SetVarConstraintMenu … … 382 441 $top.canvas config -height [lindex $sizes 3] -width $width 383 442 # force the window to stay on top 443 if {$mode == "mm"} {donewait} 384 444 putontop $top 385 445 tkwait window $top … … 388 448 389 449 # called when the "Cancel Changes" button is pressed 390 proc CancelEditConstraint {top} { 450 proc CancelEditConstraint {top num} { 451 global expcons 452 if {$expcons(var1) == ""} {destroy $top; return} 453 if {$num == "new"} {destroy $top; return} 391 454 set ans [MyMessageBox -type "{Abandon Changes} {Continue Edit}" \ 392 455 -parent [winfo toplevel $top] -default "abandon changes" \ … … 398 461 399 462 # called to make each column in the atom parameter dialog 400 proc MakeAtomConstraintColumn {cfr ic col num } {463 proc MakeAtomConstraintColumn {cfr ic col num mode} { 401 464 global expmap expcons expgui 402 465 set row 1 … … 407 470 grid columnconfig $cfr $col -minsize 2 -pad 2 408 471 409 eval tk_optionMenu $cfr.phase$ic expcons(phase$ic) $expmap(phaselist) 410 grid $cfr.phase$ic -column [incr col] -row [incr row 2] -columnspan 2 472 # there should be more than one phase 473 if {[lindex $expmap(phasetype) 0] == 4} { 474 set list [lrange $expmap(phaselist) 1 end] 475 } else { 476 set list $expmap(phaselist) 477 } 478 if {$mode != "mm"} { 479 eval tk_optionMenu $cfr.phase$ic expcons(phase$ic) $list 480 grid $cfr.phase$ic -column [incr col] -row [incr row 2] -columnspan 2 481 } else { 482 incr col 483 incr row 2 484 } 411 485 # make the listbox 412 486 set expcons(atomlistbox$ic) $cfr.lb$ic 413 grid [listbox $cfr.lb$ic -height 10 -width 12 \ 487 if {$mode == "mm"} { 488 set wid 21 489 } else { 490 set wid 12 491 } 492 grid [listbox $cfr.lb$ic -height 10 -width $wid \ 414 493 -exportselection 0 -selectmode extended \ 415 494 -yscrollcommand " $cfr.sb$ic set"] \ … … 419 498 grid [scrollbar $cfr.sb$ic -command "$cfr.lb$ic yview"] \ 420 499 -column [expr 1+$col] -row $row -sticky wns 421 if {$num == "new"} { 500 if {$mode == "mm" && $num == "new"} { 501 set expcons(varmenu$ic) [tk_optionMenu $cfr.var$ic expcons(var$ic) \ 502 FRA X Y Z UIS XYZU] 503 $expcons(varmenu$ic) insert 5 separator 504 } elseif {$mode == "mm"} { 505 set expcons(varmenu$ic) [tk_optionMenu $cfr.var$ic expcons(var$ic) \ 506 FRA X Y Z UIS] 507 } elseif {$num == "new"} { 422 508 set expcons(varmenu$ic) [tk_optionMenu $cfr.var$ic expcons(var$ic) \ 423 509 FRAC X Y Z UISO U11 U22 U33 U12 U23 U13 MX MY MZ XYZU Uxx XYZU+-F] … … 434 520 435 521 # called when the "New column" button is pressed to add a new constraint 436 proc NewAtomConstraintColumn {top cfr num } {522 proc NewAtomConstraintColumn {top cfr num mode} { 437 523 global expcons expmap expgui 438 524 set col -3 … … 440 526 for {set ic 1} {$ic < 500} {incr ic} { 441 527 incr col 3 442 if [winfo exists $cfr. phase$ic] continue528 if [winfo exists $cfr.lb$ic] continue 443 529 # delete traces on expcons(phase$ic) 444 530 foreach v [ trace vinfo expcons(phase$ic)] { 445 531 eval trace vdelete expcons(phase$ic) $v 446 532 } 447 MakeAtomConstraintColumn $cfr $ic $col $num 533 MakeAtomConstraintColumn $cfr $ic $col $num $mode 448 534 # set the various variables to initial values 449 535 set expcons(atmlst$ic) {} 450 if {[llength $expmap(phaselist)] == 1} { 536 if {$mode == "mm"} { 537 set expcons(phase$ic) 1 538 FillAtomsConstraintList $ic {} 539 } elseif {[lindex $expmap(phasetype) 0] != 4 \ 540 && [llength $expmap(phaselist)] == 1} { 451 541 set expcons(phase$ic) $expmap(phaselist) 542 FillAtomsConstraintList $ic {} 543 } elseif {[lindex $expmap(phasetype) 0] == 4 \ 544 && [llength $expmap(phaselist)] == 2} { 545 set expcons(phase$ic) [lindex $expmap(phaselist) 1] 452 546 FillAtomsConstraintList $ic {} 453 547 } else { … … 482 576 switch $expcons(var1) { 483 577 FRAC {set allowed FRAC} 578 FRA {set allowed FRA} 484 579 X - 485 580 Y - … … 487 582 XYZU {set allowed XYZU} 488 583 UISO {set allowed UISO} 584 UIS {set allowed UIS} 489 585 XYZU+-F {set allowed XYZU+-F} 490 586 U11 - … … 534 630 # fill the atoms box 535 631 set phase $expcons(phase$ic) 632 if {[lindex $expmap(phasetype) [expr {$phase -1}]] == 4} { 633 set cmd mmatominfo 634 set mm 1 635 } else { 636 set cmd atominfo 637 set mm 0 638 } 536 639 $expcons(atomlistbox$ic) delete 0 end 537 640 set atmlst {} … … 539 642 # sort on atom type 540 643 foreach atom $expmap(atomlist_$phase) { 541 lappend atmlst "$atom [ atominfo$phase $atom type]"644 lappend atmlst "$atom [$cmd $phase $atom type]" 542 645 } 543 646 set atmlst [lsort -ascii -index 1 $atmlst] … … 551 654 # sort on x 552 655 foreach atom $expmap(atomlist_$phase) { 553 lappend atmlst "$atom [ atominfo$phase $atom x]"656 lappend atmlst "$atom [$cmd $phase $atom x]" 554 657 } 555 658 set atmlst [lsort -real -index 1 $atmlst] … … 557 660 # sort on y 558 661 foreach atom $expmap(atomlist_$phase) { 559 lappend atmlst "$atom [ atominfo$phase $atom y]"662 lappend atmlst "$atom [$cmd $phase $atom y]" 560 663 } 561 664 set atmlst [lsort -real -index 1 $atmlst] … … 563 666 # sort on z 564 667 foreach atom $expmap(atomlist_$phase) { 565 lappend atmlst "$atom [ atominfo$phase $atom z]"668 lappend atmlst "$atom [$cmd $phase $atom z]" 566 669 } 567 670 set atmlst [lsort -real -index 1 $atmlst] … … 574 677 set atom [lindex $tuple 0] 575 678 lappend expcons(atmlst$ic) $atom 576 $expcons(atomlistbox$ic) insert end [format "%-6s%3d %-6s" \ 577 [atominfo $phase $atom label] \ 578 $atom \ 579 [atominfo $phase $atom type]] 679 if {$mm} { 680 $expcons(atomlistbox$ic) insert end [\ 681 format "%-6s%-3s%-2s%3d%4d %-6s" \ 682 [$cmd $phase $atom label] \ 683 [$cmd $phase $atom residue] \ 684 [$cmd $phase $atom group] \ 685 [$cmd $phase $atom resnum] \ 686 $atom \ 687 [$cmd $phase $atom type]] 688 } else { 689 $expcons(atomlistbox$ic) insert end [format "%-6s%3d %-6s" \ 690 [$cmd $phase $atom label] \ 691 $atom \ 692 [$cmd $phase $atom type]] 693 } 580 694 # select the atom if appropriate 581 695 if {[lsearch $atomselectlist $atom] != -1} { … … 589 703 590 704 # this is called to change an atomic constraint 591 proc SaveAtomConstraint {num top } {705 proc SaveAtomConstraint {num top mode} { 592 706 global expcons expgui 593 707 # special variables XYZU & Uxx should only occur with num == "new" 594 708 # then add new constraints 709 if {$expcons(var1) == ""} return 595 710 set varlist {{}} 596 711 if {$expcons(var1) == "XYZU+-F"} {set varlist "X Y Z UISO FRAC"} 597 if {$expcons(var1) == "XYZU"} {set varlist "X Y Z UISO"} 712 if {$expcons(var1) == "XYZU"} { 713 if {$mode == "mm"} { 714 set varlist "X Y Z UIS" 715 } else { 716 set varlist "X Y Z UISO" 717 } 718 } 598 719 if {$expcons(var1) == "Uxx"} {set varlist "U11 U22 U33 U12 U23 U13"} 720 set atomlist {} 599 721 foreach var $varlist { 600 722 set clist {} … … 645 767 } 646 768 } 769 if {$atomlist == ""} return 647 770 # maximum number of parameters in a constraint is 500 648 771 if {[llength $clist] > 500} { … … 672 795 } 673 796 destroy $top 674 DisplayAtomConstraints 675 } 797 DisplayAtomConstraints $mode 798 }
Note: See TracChangeset
for help on using the changeset viewer.