Changeset 1227 for trunk/anomal.tcl


Ignore:
Timestamp:
Dec 7, 2012 4:44:51 PM (8 years ago)
Author:
toby
Message:

fixes for anom and fourier GUIs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anomal.tcl

    r1225 r1227  
    1515     set ::anom_wave [histinfo $histlbl lam1]
    1616     foreach test $::expmap(powderlist) {
    17              #puts "[histinfo $test lam1] versus $::anom_wave"
    18              if {[histinfo $test lam1] == $::anom_wave} {
    19                 lappend ::anom_list $test
    20              }
    21      if {[llength $::anom_list] == 0} return
     17         #puts "[histinfo $test lam1] versus $::anom_wave"
     18         if {[histinfo $test lam1] == $::anom_wave} {
     19             lappend ::anom_list $test
     20         }
    2221     }
    2322     #puts "this wavelength is found in histogram $::anom_list"
     
    2625     set ::anom_abort [histinfo $histlbl anomff]
    2726
    28      if {[histinfo $histlbl anomff] == ""} {
    29         catch {destroy .anomwarning}
    30         set anomwarn .anomwarning
    31         toplevel $anomwarn
    32         wm title $anomwarn "Warning"
    33         wm geometry $anomwarn 400x200+10+10
    34         grid [frame $anomwarn.buz -bd 2 -relief groove] -column 0 -row 0 -sticky news
    35         grid [label $anomwarn.buz.text -text "No information in EXP file.  Run GENLES to generate\n\u0394f' and \u0394f\" data"]\
    36              -row 0 -column 0
    37         grid [button $anomwarn.buz.but -width 8 -text "continue" -command {destroy .anomwarning}] -column 0 -row 1
    38      }
    39      foreach temp [histinfo $histlbl anomff] {
    40              incr ::anom_atomcount
    41              set ::anom_lbl($::anom_atomcount) [lindex $temp 0]
    42              set ::anom_fp($::anom_atomcount) [lindex $temp 1]
    43              set ::anom_f2p($::anom_atomcount) [lindex $temp 2]
    44              #puts "$::anom_lbl($::anom_atomcount) $::anom_fp($::anom_atomcount) $::anom_f2p($::anom_atomcount)"
    45      }
     27    foreach temp [histinfo $histlbl anomff] {
     28        incr ::anom_atomcount
     29        set ::anom_lbl($::anom_atomcount) [lindex $temp 0]
     30        set ::anom_fp($::anom_atomcount) [lindex $temp 1]
     31        set ::anom_f2p($::anom_atomcount) [lindex $temp 2]
     32        #puts "$::anom_lbl($::anom_atomcount) $::anom_fp($::anom_atomcount) $::anom_f2p($::anom_atomcount)"
     33    }
    4634}
    4735
    4836proc anomalous_editor {args} {
    49      if {$::anom_atomcount == 0} {return}
     37    if {[llength $::anom_list] == 0} {
     38        MyMessageBox -parent . -title "No Anom Hists" \
     39            -icon warning \
     40            -message "No appropriate histograms for \u0394f' and \u0394f\" fields"
     41        return
     42    }
     43    # make a list of atom types in all phases
     44    foreach ph $::expmap(phaselist) {
     45        foreach at $::expmap(atomlist_$ph) {
     46            set typelist([atominfo $ph $at type]) ""
     47        }
     48    }
     49    # find the elements that do not have anom values already
     50    set oldff {}
     51    foreach items [histinfo [lindex $::anom_list 0] anomff] {
     52        lappend oldff [lindex $items 0]
     53    }
     54    set newff {}
     55    foreach typ [array names typelist] {
     56        if {[lsearch $oldff $typ] == -1} {lappend newff $typ}
     57    }
     58    #puts "newff = $newff"
     59    #if {$::anom_atomcount == 0} {return}
    5060     catch {destroy .anomalous}
    5161     set anomal .anomalous
    5262     toplevel $anomal
    5363     wm title $anomal "Anomalous Dispersion Terms"
    54      wm geometry $anomal 520x370+10+10
     64     #wm geometry $anomal 520x370+10+10
    5565     putontop $anomal
     66     set str {}
     67     foreach i $::anom_list {
     68         if {$str != ""} {append str ", "}
     69         append str $i
     70     }
    5671
    57      grid [frame $anomal.list -bd 2 -relief groove] -row 0 -column 0 -sticky news
    58      grid [label $anomal.list.lbl1 -text "The anomalous dispersion terms will be set for x-ray histograms\n with wavelength $::anom_wave angstroms:"] -row 0 -column 0
    59      grid [label $anomal.list.lbl1a -text "$::anom_list"] -row 1 -column 0
     72    grid [frame $anomal.list -bd 2 -relief groove] -row 0 -column 0 -sticky news
     73    grid [label $anomal.list.lbl1 -text "The anomalous dispersion terms will be set for x-ray histogram(s)\n with wavelength $::anom_wave angstroms \[histogram(s) $str\]"] -row 0 -column 0
     74    grid [frame $anomal.con -bd 2 -relief groove] -row 6  -column 0 -sticky news
     75    set cmd "anomalous_add $anomal [list $newff]"
     76    grid [button $anomal.con.addnew -text "Add new type:"  \
     77              -command $cmd] -column 0 -row 4
     78    if {[llength $oldff] >= 9 || [llength $newff] == 0} {
     79        $anomal.con.addnew configure -state disabled
     80    } else {
     81        eval tk_optionMenu $anomal.con.elem ::anom_new $newff
     82        grid $anomal.con.elem -column 1 -row 4
     83    }
     84    grid columnconfigure $anomal.con 2 -weight 1
     85    grid [button $anomal.con.save  -width 8 -text "Save"  -command {anomalous_save}] \
     86        -column 3 -row 4 -padx 3
     87    grid [button $anomal.con.abort -width 8 -text "Cancel" -command {anomalous_abort}] \
     88        -column 4 -row 4 -padx 3
     89    grid columnconfigure $anomal.con 5 -weight 1
    6090
    61      grid [frame $anomal.con -bd 2 -relief groove] -row 5  -column 0 -sticky news
    62      grid [button $anomal.con.save  -width 8 -text "Save"  -command {anomalous_save}] -column 0 -row 4 -padx 3
    63      grid [button $anomal.con.abort -width 8 -text "Cancel" -command {anomalous_abort}] -column 1 -row 4 -padx 3
    64 
    65      grid [frame $anomal.warning -bd 2 -relief groove] -row 7 -column 0 -sticky news
    66      grid [label $anomal.warning.1 -anchor center -text "*Warning.  GSAS will only store \u0394f' and \u0394f\" values \n for the first nine atom types*"] \
     91     grid [frame $anomal.warning -bd 2 -relief groove] -row 5 -column 0 -sticky news
     92     grid [label $anomal.warning.1 -text "Note: only 9 sets of \u0394f' and \u0394f\" values can be saved"] \
    6793          -columnspan 2 -column 0 -row 0 -pady 3
    68      grid [label $anomal.warning.2 -anchor center -text "Notice: \u0394f' and \u0394f\" fields are added after GENLES is run."] \
    69           -columnspan 2 -column 0 -row 1 -pady 3
     94#     grid [label $anomal.warning.2 -anchor center -text "Notice: \u0394f' and \u0394f\" fields are added after GENLES is run."] \
     95#          -columnspan 2 -column 0 -row 1 -pady 3
    7096
    7197     grid [frame $anomal.info -bd 2 -relief groove -width 600] -row 1 -column 0 -sticky ns
     98    anom_fill_table $anomal.info
     99}
    72100
    73       set top $anomal.info
    74       set main $anomal.info
     101proc anomalous_add {anomal newff} { 
     102    add_anomff $::anom_list $::anom_new
     103    incr ::expgui(changed)
     104    set oldff {}
     105    foreach items [histinfo [lindex $::anom_list 0] anomff] {
     106        lappend oldff [lindex $items 0]
     107    }
     108    set ff {}
     109    foreach typ $newff {
     110        if {[lsearch $oldff $typ] == -1} {lappend ff $typ}       
     111    }
     112    set newff $ff
     113    destroy $anomal.con.elem
     114    if {[llength $newff] == 0} {
     115        $anomal.con.addnew configure -state disabled       
     116    } else {
     117        eval tk_optionMenu $anomal.con.elem ::anom_new $newff
     118        set ::anom_new [lindex $newff 0]
     119        grid $anomal.con.elem -column 1 -row 4
     120    }
     121    anomalous_load
     122    anom_fill_table $anomal.info
     123}
    75124
     125proc anom_fill_table {top} {
     126    eval destroy [winfo children $top]
    76127     grid [label $top.toplabel1  -text "Type" -width 8] -column 0 -row 0
    77128     grid [label $top.toplabel2  -anchor center -text " \u0394f'" -width 8]  -column 2 -row 0
    78129     grid [label $top.toplabel3  -anchor center -text " \u0394f\"" -width 8] -column 4 -row 0
    79130     for {set i 1} {$i <= $::anom_atomcount} {incr i} {
    80          grid [label $main.atom_lbl($i) -text "$::anom_lbl($i)" -width 8] -column 0 -row $i
    81          grid [entry $main.atom_fp($i)  -textvariable ::anom_fp($i)  -width 8] -column 2 -row $i
    82          grid [entry $main.atom_f2p($i) -textvariable ::anom_f2p($i) -width 8] -column 4 -row $i
     131         grid [label $top.atom_lbl($i) -text "$::anom_lbl($i)" -width 8] -column 0 -row $i
     132         grid [entry $top.atom_fp($i)  -textvariable ::anom_fp($i)  -width 8] -column 2 -row $i
     133         grid [entry $top.atom_f2p($i) -textvariable ::anom_f2p($i) -width 8] -column 4 -row $i
    83134     }
    84135}
Note: See TracChangeset for help on using the changeset viewer.