Changeset 543 for trunk/atomcons.tcl


Ignore:
Timestamp:
Dec 4, 2009 5:07:56 PM (11 years ago)
Author:
toby
Message:

# on 2002/01/22 22:55:35, toby did:
Major changes to add MM constraints

source profcons.tcl when the main pane is created
create the subpanes each time the main pane

is created (in case phases get added)

Most routines now take the phase type as an arg

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  
    55set expcons(height) 300
    66
    7 # this is used to create the contents of the constraint page
     7# this is used once to create the constraint page
    88proc MakeConstraintsPane {} {
    9     global expgui expcons
     9    global expgui expcons expmap
    1010    # create the notebook
    1111    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
     16proc DisplayConstraintsPane {} {
     17    global expgui expcons expmap
    1218    # 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    }
    1332    set expcons(atommaster) [\
    1433            $expgui(consFrame).n insert end atomic -text Atomic \
     34            -state $atom \
    1535            -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"]
    1742    # 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"]   
    3047    set page [$expgui(consFrame).n raise]
    3148    # open the atom constraints page if no page is open
    3249    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        }
    3557    } else {
    3658        set pageupdate [$expgui(consFrame).n itemcget $page -raisecmd]
     
    3961}
    4062
    41 # fill the atom constraints pane
    42 proc MakeAtomsConstraintsPane {} {
     63# fill the atom/mm constraints pane
     64proc MakeAtomsConstraintsPane {"mode {}"} {
    4365    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]"] \
    4774            -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]"] \
    5077            -column 1 -sticky se -row 1
    51     grid [canvas $expcons(atommaster).canvas \
     78    grid [canvas $expcons($frm).canvas \
    5279            -scrollregion {0 0 5000 500} -width 0 -height 250 \
    53             -yscrollcommand "$expcons(atommaster).scroll set"] \
     80            -yscrollcommand "$expcons($frm).scroll set"] \
    5481            -column 0 -row 0 -columnspan 2 -sticky nsew
    55     grid columnconfigure $expcons(atommaster) 0 -weight 1
    56     grid rowconfigure $expcons(atommaster) 0 -weight 1
    57     grid rowconfigure $expcons(atommaster) 1 -pad 5
    58     scrollbar $expcons(atommaster).scroll \
    59             -command "$expcons(atommaster).canvas yview"
    60 }
    61 
    62 
    63 # this is called to display the constraints on atomic parameters
    64 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
     91proc DisplayAtomConstraints {"mode {}"} {
    6592    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
    69101
    70102    # get a list of constraints
     
    108140    set row 0
    109141    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 {
    114154        incr col
    115155        if {$lbl != ""} {
     
    119159    # make some column headings into buttons
    120160    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        }
    123166    }
    124167    # extra column spacing
     
    149192        set phprev 0
    150193        incr row -1
     194        set col 1
    151195        foreach key [lsort [array names atomlist]] {
    152196            regexp {(.*)_(.*)_(.*)} $key dummy phase var mult
     
    159203                    grid rowconfig $top $row -minsize 1
    160204                }
    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                }
    163212                set phprev $phase
    164213            }
     
    169218            }
    170219            grid [label $top.c${col}$row \
    171                     -text [CompressList $atomlist($key)]] \
     220                    -justify left \
     221                    -text [CompressList $atomlist($key) 20]] \
    172222                    -column [incr col] -row $row -sticky w
    173223            grid [label $top.c${col}$row -text $var] \
     
    181231        }
    182232        grid [button $top.but$row -text "edit" \
    183                 -command "EditAtomConstraint $num"] \
     233                -command "EditAtomConstraint $num [list $mode]"] \
    184234                -column 1 -row $startrow \
    185235                -rowspan [expr 1 + $row - $startrow]
     
    215265    update idletasks
    216266    set sizes [grid bbox $top]
    217     $expcons(atommaster).canvas config -scrollregion $sizes
     267    $expcons($frm).canvas config -scrollregion $sizes
    218268    set hgt [lindex $sizes 3]
    219269    # set the maximum height for the canvas from the frame
     
    223273    # use the scroll for BIG constraint lists
    224274    if {$hgt > $maxheight} {
    225         grid $expcons(atommaster).scroll -sticky ns -column 2 -row 0
    226     }
    227     $expcons(atommaster).canvas config \
     275        grid $expcons($frm).scroll -sticky ns -column 2 -row 0
     276    }
     277    $expcons($frm).canvas config \
    228278            -height $maxheight \
    229279            -width [lindex $sizes 2]
     
    235285            regexp {(.*)_(.*)_(.*)} $key dummy var phase atom
    236286            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"
    238288        }
    239289    }
     
    249299
    250300# this is called to delete an atomic constraint
    251 proc DeleteAtomConstraints {} {
     301proc DeleteAtomConstraints {mode} {
    252302    global expcons expgui
    253303    # get the constraints to delete
     
    266316        incr expgui(changed)
    267317    }
    268     DisplayAtomConstraints
     318    DisplayAtomConstraints $mode
    269319}
    270320
    271321# called to edit a single constraint set
    272 proc EditAtomConstraint {num args} {
     322proc EditAtomConstraint {num mode} {
    273323    global expcons expmap expgui
    274324
    275325    set top {.editcons}
    276326    catch {toplevel $top}
     327
     328    if {$mode == "mm"} {pleasewait "making window..."}
     329
    277330    bind $top <Key-F1> "MakeWWWHelp expgui6.html EditAtomConstraints"
    278331    eval destroy [grid slaves $top]
     
    305358
    306359    grid [button $top.add -text "New Column" \
    307             -command "NewAtomConstraintColumn $top $cfr $num"] \
     360            -command "NewAtomConstraintColumn $top $cfr $num [list $mode]"] \
    308361            -column 0 -row 3  -columnspan 2 -sticky ew
    309362    grid [button $top.done -text "Save" \
    310             -command "SaveAtomConstraint $num $top"] \
     363            -command "SaveAtomConstraint $num $top [list $mode]"] \
    311364            -column 0 -row 4 -sticky ns
    312365    grid [button $top.quit -text "Cancel\nChanges" \
    313             -command "CancelEditConstraint $top"]  -column 1 -row 4
     366            -command "CancelEditConstraint $top $num"]  -column 1 -row 4
    314367    grid [button $top.help -text Help -bg yellow \
    315368            -command "MakeWWWHelp expgui6.html EditAtomConstraints"] \
     
    318371    set col 0
    319372    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 {
    321380        # row separator
    322381        grid [frame $cfr.spc$row -bd 8 -bg white] \
     
    358417            eval trace vdelete expcons(phase$ic) $v
    359418        }
    360         MakeAtomConstraintColumn $cfr $ic $col $num
     419        MakeAtomConstraintColumn $cfr $ic $col $num $mode
    361420        incr col 3
    362421        # set the various variables
     
    367426        trace variable expcons(phase$ic) w "FillAtomsConstraintList $ic {}"
    368427    }
    369     if {$num == "new"} {NewAtomConstraintColumn $top $cfr $num}
     428    if {$num == "new"} {NewAtomConstraintColumn $top $cfr $num $mode}
    370429    trace variable expcons(var1) w SetVarConstraintMenu
    371430    SetVarConstraintMenu
     
    382441    $top.canvas config -height [lindex $sizes 3] -width $width
    383442    # force the window to stay on top
     443    if {$mode == "mm"} {donewait}
    384444    putontop $top
    385445    tkwait window $top
     
    388448
    389449# called when the "Cancel Changes" button is pressed
    390 proc CancelEditConstraint {top} {
     450proc CancelEditConstraint {top num} {
     451    global expcons
     452    if {$expcons(var1) == ""} {destroy $top; return}
     453    if {$num == "new"} {destroy $top; return}
    391454    set ans [MyMessageBox -type "{Abandon Changes} {Continue Edit}" \
    392455            -parent [winfo toplevel $top] -default "abandon changes" \
     
    398461
    399462# called to make each column in the atom parameter dialog
    400 proc MakeAtomConstraintColumn {cfr ic col num} {
     463proc MakeAtomConstraintColumn {cfr ic col num mode} {
    401464    global expmap expcons expgui
    402465    set row 1
     
    407470    grid columnconfig $cfr $col -minsize 2 -pad 2
    408471
    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    }
    411485    # make the listbox
    412486    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 \
    414493            -exportselection 0 -selectmode extended \
    415494            -yscrollcommand " $cfr.sb$ic set"] \
     
    419498    grid [scrollbar $cfr.sb$ic -command "$cfr.lb$ic yview"] \
    420499            -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"} {
    422508        set expcons(varmenu$ic) [tk_optionMenu $cfr.var$ic expcons(var$ic) \
    423509                FRAC X Y Z UISO U11 U22 U33 U12 U23 U13 MX MY MZ XYZU Uxx XYZU+-F]
     
    434520
    435521# called when the "New column" button is pressed to add a new constraint
    436 proc NewAtomConstraintColumn {top cfr num} {
     522proc NewAtomConstraintColumn {top cfr num mode} {
    437523    global expcons expmap expgui
    438524    set col -3
     
    440526    for {set ic 1} {$ic < 500} {incr ic} {
    441527        incr col 3
    442         if [winfo exists $cfr.phase$ic] continue
     528        if [winfo exists $cfr.lb$ic] continue
    443529        # delete traces on expcons(phase$ic)
    444530        foreach v [ trace vinfo expcons(phase$ic)] {
    445531            eval trace vdelete expcons(phase$ic) $v
    446532        }
    447         MakeAtomConstraintColumn $cfr $ic $col $num
     533        MakeAtomConstraintColumn $cfr $ic $col $num $mode
    448534        # set the various variables to initial values
    449535        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} {
    451541            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]
    452546            FillAtomsConstraintList $ic {}
    453547        } else {
     
    482576    switch $expcons(var1) {
    483577        FRAC {set allowed FRAC}
     578        FRA {set allowed FRA}
    484579        X -
    485580        Y -
     
    487582        XYZU {set allowed XYZU}
    488583        UISO {set allowed UISO}
     584        UIS {set allowed UIS}
    489585        XYZU+-F {set allowed XYZU+-F}
    490586        U11 -
     
    534630    # fill the atoms box
    535631    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    }   
    536639    $expcons(atomlistbox$ic) delete 0 end
    537640    set atmlst {}
     
    539642        # sort on atom type
    540643        foreach atom $expmap(atomlist_$phase) {
    541             lappend atmlst "$atom [atominfo $phase $atom type]"
     644            lappend atmlst "$atom [$cmd $phase $atom type]"
    542645        }
    543646        set atmlst [lsort -ascii -index 1 $atmlst]
     
    551654        # sort on x
    552655        foreach atom $expmap(atomlist_$phase) {
    553             lappend atmlst "$atom [atominfo $phase $atom x]"
     656            lappend atmlst "$atom [$cmd $phase $atom x]"
    554657        }
    555658        set atmlst [lsort -real -index 1 $atmlst]
     
    557660        # sort on y
    558661        foreach atom $expmap(atomlist_$phase) {
    559             lappend atmlst "$atom [atominfo $phase $atom y]"
     662            lappend atmlst "$atom [$cmd $phase $atom y]"
    560663        }
    561664        set atmlst [lsort -real -index 1 $atmlst]
     
    563666        # sort on z
    564667        foreach atom $expmap(atomlist_$phase) {
    565             lappend atmlst "$atom [atominfo $phase $atom z]"
     668            lappend atmlst "$atom [$cmd $phase $atom z]"
    566669        }
    567670        set atmlst [lsort -real -index 1 $atmlst]
     
    574677        set atom [lindex $tuple 0]
    575678        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        }
    580694        # select the atom if appropriate
    581695        if {[lsearch $atomselectlist $atom] != -1} {
     
    589703
    590704# this is called to change an atomic constraint
    591 proc SaveAtomConstraint {num top} {
     705proc SaveAtomConstraint {num top mode} {
    592706    global expcons expgui
    593707    # special variables XYZU & Uxx should only occur with num == "new"
    594708    # then add new constraints
     709    if {$expcons(var1) == ""} return
    595710    set varlist {{}}
    596711    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    }
    598719    if {$expcons(var1) == "Uxx"} {set varlist "U11 U22 U33 U12 U23 U13"}
     720    set atomlist {}
    599721    foreach var $varlist {
    600722        set clist {}
     
    645767            }
    646768        }
     769        if {$atomlist == ""} return
    647770        # maximum number of parameters in a constraint is 500
    648771        if {[llength $clist] > 500} {
     
    672795    }
    673796    destroy $top
    674     DisplayAtomConstraints
    675 }
     797    DisplayAtomConstraints $mode
     798}
Note: See TracChangeset for help on using the changeset viewer.