1 | # this should get moved elsewhere |
---|
2 | |
---|
3 | proc anomalous_load {args} { |
---|
4 | catch {unset temp} |
---|
5 | # trap if more than one histogram is selected unless global mode |
---|
6 | if {$::expgui(globalmode) == 0 && [llength $::expgui(curhist)] > 1} { |
---|
7 | set ::expgui(curhist) [lindex $::expgui(curhist) 0] |
---|
8 | } |
---|
9 | |
---|
10 | set histnum $::expgui(curhist) |
---|
11 | set histlbl [lindex $::expmap(powderlist) $histnum] |
---|
12 | |
---|
13 | #determine list of histograms with the same wavelength |
---|
14 | set ::anom_list "" |
---|
15 | set ::anom_wave [histinfo $histlbl lam1] |
---|
16 | 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 |
---|
22 | } |
---|
23 | #puts "this wavelength is found in histogram $::anom_list" |
---|
24 | |
---|
25 | set ::anom_atomcount 0 |
---|
26 | set ::anom_abort [histinfo $histlbl anomff] |
---|
27 | |
---|
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 | } |
---|
46 | } |
---|
47 | |
---|
48 | proc anomalous_editor {args} { |
---|
49 | if {$::anom_atomcount == 0} {return} |
---|
50 | catch {destroy .anomalous} |
---|
51 | set anomal .anomalous |
---|
52 | toplevel $anomal |
---|
53 | wm title $anomal "Anomalous Dispersion Terms" |
---|
54 | wm geometry $anomal 520x370+10+10 |
---|
55 | putontop $anomal |
---|
56 | |
---|
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 the following histograms\n with wavelength $::anom_wave angstroms:"] -row 0 -column 0 |
---|
59 | grid [label $anomal.list.lbl1a -text "$::anom_list"] -row 1 -column 0 |
---|
60 | |
---|
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 "abort" -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*"] \ |
---|
67 | -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 |
---|
70 | |
---|
71 | grid [frame $anomal.info -bd 2 -relief groove -width 600] -row 1 -column 0 -sticky ns |
---|
72 | |
---|
73 | set top $anomal.info |
---|
74 | set main $anomal.info |
---|
75 | |
---|
76 | grid [label $top.toplabel1 -text "Type" -width 8] -column 0 -row 0 |
---|
77 | grid [label $top.toplabel2 -anchor center -text " \u0394f'" -width 8] -column 2 -row 0 |
---|
78 | grid [label $top.toplabel3 -anchor center -text " \u0394f\"" -width 8] -column 4 -row 0 |
---|
79 | 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 |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | proc anomalous_save {args} { |
---|
87 | set histnum $::expgui(curhist) |
---|
88 | puts $histnum |
---|
89 | set histlbl [lindex $::expmap(powderlist) $histnum] |
---|
90 | puts $histlbl |
---|
91 | set x "" |
---|
92 | set atomcount 0 |
---|
93 | foreach atom [histinfo $histlbl anomff] { |
---|
94 | incr atomcount |
---|
95 | lappend x "$::anom_lbl($atomcount) $::anom_fp($atomcount) $::anom_f2p($atomcount)" |
---|
96 | } |
---|
97 | puts $x |
---|
98 | foreach test $::anom_list { |
---|
99 | histinfo $test anomff set $x |
---|
100 | } |
---|
101 | incr ::expgui(changed) |
---|
102 | afterputontop |
---|
103 | destroy .anomalous |
---|
104 | } |
---|
105 | |
---|
106 | proc anomalous_abort {args} { |
---|
107 | set histnum $::expgui(curhist) |
---|
108 | set histlbl [lindex $::expmap(powderlist) $histnum] |
---|
109 | histinfo $histlbl anomff set $::anom_abort |
---|
110 | afterputontop |
---|
111 | destroy .anomalous |
---|
112 | } |
---|
113 | |
---|
114 | proc Edit_Anomalous {args} { |
---|
115 | anomalous_load |
---|
116 | anomalous_editor |
---|
117 | } |
---|