1 | # $Id: excledt.tcl 666 2009-12-04 23:09:59Z toby $ |
---|
2 | |
---|
3 | # create the main Excluded Region window |
---|
4 | proc ExclReaddata {box} { |
---|
5 | global expgui |
---|
6 | # if [catch { |
---|
7 | set loadtime [time { |
---|
8 | ExclReaddata_hst $box |
---|
9 | # }] |
---|
10 | if $expgui(debug) { |
---|
11 | tk_dialog .time "Timing info" \ |
---|
12 | "Histogram loading took $loadtime" "" 0 OK |
---|
13 | } |
---|
14 | # } errmsg] { |
---|
15 | if $expgui(debug) { |
---|
16 | catch {console show} |
---|
17 | error $errmsg |
---|
18 | } |
---|
19 | # $box config -title "Read error" |
---|
20 | # tk_dialog .err "Read Error" "Read Error -- $errmsg" \ |
---|
21 | # error 0 OK |
---|
22 | # update |
---|
23 | # } |
---|
24 | $box element show [lsort -decreasing [$box element show]] |
---|
25 | } |
---|
26 | |
---|
27 | # get the data to plot using hstdump (tcldump does not show the excluded data) |
---|
28 | proc ExclReaddata_hst {box} { |
---|
29 | global expgui reflns graph |
---|
30 | global peakinfo |
---|
31 | update |
---|
32 | set hst $graph(hst) |
---|
33 | # parse the output of a file |
---|
34 | # use histdmp for histogram info |
---|
35 | set input [open excl$hst.inp w] |
---|
36 | puts $input "[file rootname [file tail $expgui(expfile)]]" |
---|
37 | puts $input "L" |
---|
38 | puts $input "$hst" |
---|
39 | puts $input "0" |
---|
40 | close $input |
---|
41 | # use hstdmp without an experiment name so that output |
---|
42 | # is not sent to the .LST file |
---|
43 | exec [file join $expgui(gsasexe) hstdmp] < excl$hst.inp > excl$hst.out |
---|
44 | set input [open excl$hst.out r] |
---|
45 | catch {file delete excl$hst.inp} |
---|
46 | # initalize arrays |
---|
47 | set num -1 |
---|
48 | set xlist {} |
---|
49 | set obslist {} |
---|
50 | set calclist {} |
---|
51 | set allxlist {} |
---|
52 | set graph(xcaption) {} |
---|
53 | set exclistx {} |
---|
54 | set exclistobs {} |
---|
55 | # define a list of reflection positions for each phase |
---|
56 | for {set i 1} {$i < 10} {incr i} { |
---|
57 | set reflns($i) {} |
---|
58 | } |
---|
59 | set i 0 |
---|
60 | while {[gets $input line] >= 0} { |
---|
61 | incr i |
---|
62 | # run update every 200th line |
---|
63 | if {$i > 200} {set i 0; update} |
---|
64 | if [scan $line %d num] { |
---|
65 | if {$num > 0} { |
---|
66 | set Ispec 0 |
---|
67 | set X -999 |
---|
68 | scan [string range $line 8 end] %e%e%e%e \ |
---|
69 | X Iobs Icalc Ispec |
---|
70 | #puts $line |
---|
71 | lappend allxlist $X |
---|
72 | # eliminate excluded points |
---|
73 | if {$Ispec > 0.0 && $X >= 0} { |
---|
74 | lappend xlist $X |
---|
75 | lappend obslist $Iobs |
---|
76 | lappend calclist $Icalc |
---|
77 | } elseif {$X != -999} { |
---|
78 | lappend exclistx $X |
---|
79 | lappend exclistobs $Iobs |
---|
80 | } |
---|
81 | if [regexp {[1-9]} [string range $line 6 7] ph] { |
---|
82 | lappend reflns($ph) $X |
---|
83 | } |
---|
84 | } |
---|
85 | } else { |
---|
86 | regexp {Time|Theta|keV} $line graph(xcaption) |
---|
87 | } |
---|
88 | } |
---|
89 | close $input |
---|
90 | if {$graph(xcaption) == "Theta"} {set graph(xcaption) "2-Theta"} |
---|
91 | # convert the x units, if requested |
---|
92 | if {$graph(xunits) == 1} { |
---|
93 | set xlist [tod $xlist $hst] |
---|
94 | set exclistx [tod $exclistx $hst] |
---|
95 | set graph(xcaption) d-space |
---|
96 | } elseif {$graph(xunits) == 2} { |
---|
97 | set xlist [toQ $xlist $hst] |
---|
98 | set exclistx [toQ $exclistx $hst] |
---|
99 | set graph(xcaption) Q |
---|
100 | } |
---|
101 | catch {file delete excl$hst.out} |
---|
102 | catch { |
---|
103 | if {[llength $allxlist] > 0} { |
---|
104 | allxvec set $allxlist |
---|
105 | xvec set $xlist |
---|
106 | obsvec set $obslist |
---|
107 | calcvec set $calclist |
---|
108 | diffvec set [obsvec - calcvec] |
---|
109 | exxvec set $exclistx |
---|
110 | exobsvec set $exclistobs |
---|
111 | global obsvec calcvec diffvec |
---|
112 | set maxdiff [set diffvec(max)] |
---|
113 | set cmin [set calcvec(min)] |
---|
114 | set omin [set obsvec(min)] |
---|
115 | set cmax [set calcvec(max)] |
---|
116 | set omax [set obsvec(max)] |
---|
117 | foreach {expgui(min) expgui(max)} {0 0} {} |
---|
118 | catch { |
---|
119 | set expgui(min) [expr $omin < $cmin ? $omin : $cmin] |
---|
120 | set expgui(max) [expr $omax > $cmax ? $omax : $cmax] |
---|
121 | set ymin1 [expr $cmin - 1.1*$maxdiff] |
---|
122 | set ymin2 [expr $omin - 1.1*$maxdiff] |
---|
123 | if {$ymin1 < $ymin2} { |
---|
124 | diffvec set [diffvec + $ymin1] |
---|
125 | } { |
---|
126 | diffvec set [diffvec + $ymin2] |
---|
127 | } |
---|
128 | } |
---|
129 | } |
---|
130 | } |
---|
131 | plotExclData |
---|
132 | } |
---|
133 | |
---|
134 | # plot the pattern with the requested x-axis units & the excluded regions |
---|
135 | proc plotExclData {args} { |
---|
136 | global peakinfo reflns |
---|
137 | global graph expgui |
---|
138 | |
---|
139 | set hst $graph(hst) |
---|
140 | $graph(plot) config -title \ |
---|
141 | "[file tail $expgui(expfile)] cycle [expinfo cyclesrun] Hist $hst" |
---|
142 | $graph(plot) xaxis config -title $graph(xcaption) |
---|
143 | $graph(plot) yaxis config -title $graph(ycaption) |
---|
144 | setlegend $graph(plot) $graph(legend) |
---|
145 | # reconfigure the data display |
---|
146 | $graph(plot) element configure 3 \ |
---|
147 | -symbol $peakinfo(obssym) -color $graph(color_obs) \ |
---|
148 | -pixels [expr 0.125 * $peakinfo(obssize)]i |
---|
149 | $graph(plot) element config 2 -color $graph(color_calc) |
---|
150 | $graph(plot) element config 12 \ |
---|
151 | -symbol $peakinfo(exclsym) -color $graph(color_excl) \ |
---|
152 | -pixels [expr 0.125 * $peakinfo(exclsize)]i |
---|
153 | |
---|
154 | foreach vec {xvec obsvec calcvec diffvec exxvec exobsvec} { |
---|
155 | $vec notify now |
---|
156 | } |
---|
157 | # now deal with tick marks |
---|
158 | for {set i 1} {$i < 10} {incr i} { |
---|
159 | if {$expgui(autotick)} { |
---|
160 | set div [expr ( $expgui(max) - $expgui(min) )/40.] |
---|
161 | set ymin [expr $expgui(min) - ($i+1) * $div] |
---|
162 | set ymax [expr $expgui(min) - $i * $div] |
---|
163 | } else { |
---|
164 | set ymin $peakinfo(min$i) |
---|
165 | set ymax $peakinfo(max$i) |
---|
166 | } |
---|
167 | set j 0 |
---|
168 | if [set peakinfo(flag$i)] { |
---|
169 | if {$graph(xunits) == 1} { |
---|
170 | set Xlist [tod $reflns($i) $hst] |
---|
171 | } elseif {$graph(xunits) == 2} { |
---|
172 | set Xlist [toQ $reflns($i) $hst] |
---|
173 | } else { |
---|
174 | set Xlist $reflns($i) |
---|
175 | } |
---|
176 | foreach X $Xlist { |
---|
177 | incr j |
---|
178 | catch { |
---|
179 | $graph(plot) marker create line -name peaks${i}_$j |
---|
180 | } |
---|
181 | $graph(plot) marker config peaks${i}_$j -under 1 \ |
---|
182 | -coords "$X $ymin $X $ymax" |
---|
183 | catch { |
---|
184 | $graph(plot) marker config peaks${i}_$j \ |
---|
185 | $graph(MarkerColorOpt) [list $peakinfo(color$i)] |
---|
186 | if $peakinfo(dashes$i) { |
---|
187 | $graph(plot) marker config peaks${i}_$j -dashes "5 5" |
---|
188 | } |
---|
189 | } |
---|
190 | } |
---|
191 | catch {$graph(plot) element create phase$i} |
---|
192 | catch { |
---|
193 | $graph(plot) element config phase$i -color $peakinfo(color$i) |
---|
194 | } |
---|
195 | } else { |
---|
196 | eval $graph(plot) marker delete [$graph(plot) marker names peaks${i}_*] |
---|
197 | eval $graph(plot) element delete [$graph(plot) element names phase$i] |
---|
198 | } |
---|
199 | } |
---|
200 | # force an update of the plot as BLT may not |
---|
201 | $graph(plot) config -title [$graph(plot) cget -title] |
---|
202 | update |
---|
203 | } |
---|
204 | |
---|
205 | # show or hide the plot legend |
---|
206 | proc setlegend {box legend} { |
---|
207 | global blt_version |
---|
208 | if {$blt_version >= 2.3 && $blt_version < 8.0} { |
---|
209 | if $legend { |
---|
210 | $box legend config -hide no |
---|
211 | } else { |
---|
212 | $box legend config -hide yes |
---|
213 | } |
---|
214 | } else { |
---|
215 | if $legend { |
---|
216 | $box legend config -mapped yes |
---|
217 | } else { |
---|
218 | $box legend config -mapped no |
---|
219 | } |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | # show tickmark options |
---|
224 | proc minioptionsbox {num} { |
---|
225 | global blt_version tcl_platform peakinfo expgui |
---|
226 | set bx .opt$num |
---|
227 | catch {destroy $bx} |
---|
228 | toplevel $bx |
---|
229 | wm iconname $bx "Phase $num options" |
---|
230 | wm title $bx "Phase $num options" |
---|
231 | |
---|
232 | set i $num |
---|
233 | pack [label $bx.0 -text "Phase $i reflns" ] -side top |
---|
234 | pack [checkbutton $bx.1 -text "Show reflections" \ |
---|
235 | -variable peakinfo(flag$i)] -side top |
---|
236 | # remove option that does not work |
---|
237 | if {$blt_version != 8.0 || $tcl_platform(platform) != "windows"} { |
---|
238 | pack [checkbutton $bx.2 -text "Use dashed line" \ |
---|
239 | -variable peakinfo(dashes$i)] -side top |
---|
240 | } |
---|
241 | if !$expgui(autotick) { |
---|
242 | pack [frame $bx.p$i -bd 2 -relief groove] -side top |
---|
243 | # pack [checkbutton $bx.p$i.0 -text "Show phase $i reflns" \ |
---|
244 | # -variable peakinfo(flag$i)] -side left -anchor w |
---|
245 | pack [label $bx.p$i.1 -text " Y min:"] -side left |
---|
246 | pack [entry $bx.p$i.2 -textvariable peakinfo(min$i) -width 5] \ |
---|
247 | -side left |
---|
248 | pack [label $bx.p$i.3 -text " Y max:"] -side left |
---|
249 | pack [entry $bx.p$i.4 -textvariable peakinfo(max$i) -width 5] \ |
---|
250 | -side left |
---|
251 | } |
---|
252 | pack [frame $bx.c$i -bd 2 -relief groove] -side top |
---|
253 | |
---|
254 | pack [label $bx.c$i.5 -text " color:"] -side left |
---|
255 | pack [entry $bx.c$i.6 -textvariable peakinfo(color$i) -width 12] \ |
---|
256 | -side left |
---|
257 | pack [button $bx.c$i.2 -bg $peakinfo(color$i) -state disabled] -side left |
---|
258 | pack [button $bx.c$i.1 -text "Color\nmenu" \ |
---|
259 | -command "setcolor $i"] -side left |
---|
260 | pack [frame $bx.b] -side top |
---|
261 | pack [button $bx.b.4 -command "destroy $bx" -text Close ] -side right |
---|
262 | } |
---|
263 | |
---|
264 | proc setcolor {num} { |
---|
265 | global peakinfo |
---|
266 | set color [tk_chooseColor -initialcolor $peakinfo(color$num) -title "Choose color"] |
---|
267 | if {$color == ""} return |
---|
268 | set peakinfo(color$num) $color |
---|
269 | } |
---|
270 | |
---|
271 | proc makepostscriptout {} { |
---|
272 | global graph |
---|
273 | if !$graph(printout) { |
---|
274 | set out [open "| $graph(outcmd) >& plot.msg" w] |
---|
275 | catch { |
---|
276 | puts $out [$graph(plot) postscript output -landscape 1 \ |
---|
277 | -decorations no -height 7.i -width 9.5i] |
---|
278 | close $out |
---|
279 | } msg |
---|
280 | catch { |
---|
281 | set out [open plot.msg r] |
---|
282 | if {$msg != ""} {append msg "\n"} |
---|
283 | append msg [read $out] |
---|
284 | close $out |
---|
285 | catch {file delete plot.msg} |
---|
286 | } |
---|
287 | if {$msg != ""} { |
---|
288 | tk_dialog .msg "file created" \ |
---|
289 | "Postscript file processed with command \ |
---|
290 | $graph(outcmd). Result: $msg" "" 0 OK |
---|
291 | } else { |
---|
292 | tk_dialog .msg "file created" \ |
---|
293 | "Postscript file processed with command \ |
---|
294 | $graph(outcmd)" "" 0 OK |
---|
295 | } |
---|
296 | } else { |
---|
297 | $graph(plot) postscript output $graph(outname) -landscape 1 \ |
---|
298 | -decorations no -height 7.i -width 9.5i |
---|
299 | tk_dialog .msg "file created" \ |
---|
300 | "Postscript file $graph(outname) created" "" 0 OK |
---|
301 | } |
---|
302 | } |
---|
303 | |
---|
304 | proc setprintopt {page} { |
---|
305 | global graph |
---|
306 | if $graph(printout) { |
---|
307 | $page.4.1 config -fg black |
---|
308 | $page.4.2 config -fg black -state normal |
---|
309 | $page.6.1 config -fg #888 |
---|
310 | $page.6.2 config -fg #888 -state disabled |
---|
311 | } else { |
---|
312 | $page.4.1 config -fg #888 |
---|
313 | $page.4.2 config -fg #888 -state disabled |
---|
314 | $page.6.1 config -fg black |
---|
315 | $page.6.2 config -fg black -state normal |
---|
316 | } |
---|
317 | } |
---|
318 | |
---|
319 | proc setpostscriptout {} { |
---|
320 | global graph tcl_platform |
---|
321 | set box .out |
---|
322 | catch {destroy $box} |
---|
323 | toplevel $box |
---|
324 | wm title $box "Postscript options" |
---|
325 | focus $box |
---|
326 | pack [frame $box.4] -side top -anchor w -fill x |
---|
327 | pack [checkbutton $box.4.a -text "Write PostScript files" \ |
---|
328 | -variable graph(printout) -offvalue 0 -onvalue 1 \ |
---|
329 | -command "setprintopt $box"] -side left -anchor w |
---|
330 | pack [entry $box.4.2 -textvariable graph(outname)] -side right -anchor w |
---|
331 | pack [label $box.4.1 -text "PostScript file name:"] -side right -anchor w |
---|
332 | pack [frame $box.6] -side top -anchor w -fill x |
---|
333 | pack [checkbutton $box.6.a -text "Print PostScript files" \ |
---|
334 | -variable graph(printout) -offvalue 1 -onvalue 0 \ |
---|
335 | -command "setprintopt $box" ] -side left -anchor w |
---|
336 | pack [entry $box.6.2 -textvariable graph(outcmd)] -side right -anchor w |
---|
337 | pack [label $box.6.1 -text "Command to print files:"] -side right -anchor w |
---|
338 | |
---|
339 | pack [button $box.a -text "Close" -command "destroy $box"] -side top |
---|
340 | if {$tcl_platform(platform) == "windows"} { |
---|
341 | set graph(printout) 1 |
---|
342 | $box.4.a config -state disabled |
---|
343 | $box.6.a config -fg #888 -state disabled |
---|
344 | } |
---|
345 | setprintopt $box |
---|
346 | } |
---|
347 | |
---|
348 | proc getsymopts {"sym obs"} { |
---|
349 | global expgui peakinfo |
---|
350 | set box .out |
---|
351 | catch {destroy $box} |
---|
352 | toplevel $box |
---|
353 | focus $box |
---|
354 | wm title .out "Set $sym symbol" |
---|
355 | pack [frame $box.d] -side left -anchor n |
---|
356 | pack [label $box.d.t -text "Symbol type"] -side top |
---|
357 | set expgui(sym) $peakinfo(${sym}sym) |
---|
358 | set expgui(size) $peakinfo(${sym}size) |
---|
359 | foreach symbol {square circle diamond plus cross \ |
---|
360 | splus scross} \ |
---|
361 | symbol_name {square circle diamond plus cross \ |
---|
362 | thin-plus thin-cross} { |
---|
363 | pack [radiobutton $box.d.$symbol \ |
---|
364 | -text $symbol_name -variable expgui(sym) \ |
---|
365 | -value $symbol] -side top -anchor w |
---|
366 | } |
---|
367 | pack [frame $box.e] -side left -anchor n -fill y |
---|
368 | pack [label $box.e.l -text "Symbol Size"] -side top |
---|
369 | pack [scale $box.e.s -variable expgui(size) \ |
---|
370 | -from .1 -to 3 -resolution 0.05] -side top |
---|
371 | pack [frame $box.a] -side bottom |
---|
372 | pack [button $box.a.1 -text "Apply" -command "setsymopts $sym"] -side left |
---|
373 | pack [button $box.a.2 -text "Close" -command "destroy $box"] -side left |
---|
374 | } |
---|
375 | proc setsymopts {sym} { |
---|
376 | global peakinfo expgui |
---|
377 | if {$peakinfo(${sym}sym) != $expgui(sym)} {set peakinfo(${sym}sym) $expgui(sym)} |
---|
378 | if {$peakinfo(${sym}size) != $expgui(size)} {set peakinfo(${sym}size) $expgui(size)} |
---|
379 | } |
---|
380 | |
---|
381 | proc updateplot {} { |
---|
382 | global env tcl_platform graph expgui |
---|
383 | set hst $graph(hst) |
---|
384 | $graph(plot) config -title "Please wait: loading histogram $hst" |
---|
385 | exxvec set {} |
---|
386 | exobsvec set {} |
---|
387 | exxvec notify now |
---|
388 | exobsvec notify now |
---|
389 | eval $graph(plot) marker delete [$graph(plot) marker names] |
---|
390 | |
---|
391 | ExclReaddata $graph(plot) |
---|
392 | ShowExlMarks |
---|
393 | $graph(plot) element config 3 -color $graph(color_obs) |
---|
394 | $graph(plot) element config 2 -color $graph(color_calc) |
---|
395 | $graph(plot) element config 12 -color $graph(color_excl) |
---|
396 | foreach vec {xvec obsvec calcvec diffvec exxvec exobsvec} { |
---|
397 | $vec notify now |
---|
398 | } |
---|
399 | FillExclRegionBox |
---|
400 | $graph(plot) config -title \ |
---|
401 | "[file tail $expgui(expfile)] cycle [expinfo cyclesrun] Hist $hst" |
---|
402 | } |
---|
403 | |
---|
404 | # display the excluded regions with orange markers |
---|
405 | proc ShowExlMarks {} { |
---|
406 | global graph |
---|
407 | eval $graph(plot) marker delete [$graph(plot) marker names excl*] |
---|
408 | set hst $graph(hst) |
---|
409 | set exclist [histinfo $hst excl] |
---|
410 | set i 0 |
---|
411 | foreach rng $exclist { |
---|
412 | if {$graph(xunits) == 1} { |
---|
413 | set rng [tod $rng $hst] |
---|
414 | } elseif {$graph(xunits) == 2} { |
---|
415 | set rng [toQ $rng $hst] |
---|
416 | } |
---|
417 | set x1 [lindex [lsort -real $rng] 0] |
---|
418 | set x2 [lindex [lsort -real $rng] end] |
---|
419 | $graph(plot) marker create line -under 1 -name excl[incr i] \ |
---|
420 | -coords "$x1 -Inf $x2 -Inf" \ |
---|
421 | $graph(MarkerColorOpt) $graph(color_excl) -linewidth 3 |
---|
422 | # copy any points that should be excluded |
---|
423 | set l [lsort -integer [xvec search $x1 $x2]] |
---|
424 | if {$l != ""} { |
---|
425 | set n1 [lindex $l 0] |
---|
426 | set n2 [lindex $l end] |
---|
427 | exxvec append [xvec range $n1 $n2] |
---|
428 | exobsvec append [obsvec range $n1 $n2] |
---|
429 | } |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | # change the binding of the mouse, based on the selected mode |
---|
434 | proc exclEditMode {b bb} { |
---|
435 | global zoom graph |
---|
436 | # save the zoom and unzoom commands |
---|
437 | if [catch {set zoom(in)}] { |
---|
438 | # get binding |
---|
439 | set zoom(bindtag) $graph(plot) |
---|
440 | catch { |
---|
441 | if {[bind bltZoomGraph] != ""} { |
---|
442 | set zoom(bindtag) bltZoomGraph |
---|
443 | } |
---|
444 | } |
---|
445 | set zoom(in) [bind $zoom(bindtag) <1>] |
---|
446 | set zoom(out) [bind $zoom(bindtag) <3>] |
---|
447 | # check for really new BLT where binding is handled differently |
---|
448 | if {$zoom(in) == ""} { |
---|
449 | foreach zoom(bindtag) [bindtags $graph(plot)] { |
---|
450 | set zoom(in) [bind $zoom(bindtag) <1>] |
---|
451 | set zoom(out) [bind $zoom(bindtag) <3>] |
---|
452 | if {$zoom(in) != ""} break |
---|
453 | } |
---|
454 | } |
---|
455 | } |
---|
456 | |
---|
457 | foreach c {1 2 3} { |
---|
458 | if {$c == $b} { |
---|
459 | $bb.l.b$c config -relief sunken |
---|
460 | } else { |
---|
461 | $bb.l.b$c config -relief raised |
---|
462 | } |
---|
463 | } |
---|
464 | |
---|
465 | # reset previous mode; if in the middle |
---|
466 | if {[string trim [bind $graph(plot) <Motion>]] != ""} { |
---|
467 | if {[lindex [bind $graph(plot) <Motion>] 0] == "exclMove"} { |
---|
468 | exclReset $zoom(bindtag) |
---|
469 | } else { |
---|
470 | blt::ResetZoom $graph(plot) |
---|
471 | } |
---|
472 | } |
---|
473 | if {$b == 2} { |
---|
474 | bind $zoom(bindtag) <1> "exclAdd $zoom(bindtag) %x %y" |
---|
475 | $graph(plot) config -cursor arrow |
---|
476 | } elseif {$b == 3} { |
---|
477 | bind $zoom(bindtag) <1> "exclDel $zoom(bindtag) %x %y" |
---|
478 | $graph(plot) config -cursor circle |
---|
479 | } else { |
---|
480 | bind $zoom(bindtag) <1> $zoom(in) |
---|
481 | bind $zoom(bindtag) <3> $zoom(out) |
---|
482 | $graph(plot) config -cursor crosshair |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | # called using the mouse to delete an excluded region |
---|
487 | proc exclDel {bindtag x y} { |
---|
488 | global graph expgui |
---|
489 | set x1 [$graph(plot) xaxis invtransform $x] |
---|
490 | set hst $graph(hst) |
---|
491 | if {$graph(xunits) == 1} { |
---|
492 | set x1 [fromd $x1 $hst] |
---|
493 | } elseif {$graph(xunits) == 2} { |
---|
494 | set x1 [fromQ $x1 $hst] |
---|
495 | } |
---|
496 | set exclist [histinfo $hst excl] |
---|
497 | # don't delete the high or low ranges |
---|
498 | if {$x1 <= [lindex [lindex $exclist 0] 1] || \ |
---|
499 | $x1 >= [lindex [lindex $exclist end] 0]} { |
---|
500 | bell |
---|
501 | return |
---|
502 | } |
---|
503 | set newlist {} |
---|
504 | set msg "" |
---|
505 | foreach rng $exclist { |
---|
506 | if {$x1 < [lindex $rng 0] || $x1 > [lindex $rng 1]} { |
---|
507 | lappend newlist $rng |
---|
508 | } else { |
---|
509 | if {$graph(xunits) == 1} { |
---|
510 | set drng [tod $rng $hst] |
---|
511 | set msg "Delete excluded region from " |
---|
512 | append msg "[format %.5f [lindex $drng 1]] A " |
---|
513 | append msg "to [format %.5f [lindex $drng 0]] A?" |
---|
514 | } elseif {$graph(xunits) == 2} { |
---|
515 | set qrng [toQ $rng $hst] |
---|
516 | set msg "Delete excluded region from " |
---|
517 | append msg "[format %.5f [lindex $qrng 0]] A-1 " |
---|
518 | append msg "to [format %.5f [lindex $qrng 1]] A-1?" |
---|
519 | } else { |
---|
520 | set msg "Delete excluded region from [lindex $rng 0] to [lindex $rng 1]?" |
---|
521 | } |
---|
522 | global graph |
---|
523 | if {$graph(exclPrompt)} { |
---|
524 | set ans [MyMessageBox -parent . -message $msg \ |
---|
525 | -helplink "expguierr.html ExcludeRegion" \ |
---|
526 | -title "Delete region" -type okcancel] |
---|
527 | } else { |
---|
528 | set ans ok |
---|
529 | } |
---|
530 | if {$ans == "ok"} { |
---|
531 | incr expgui(changed) |
---|
532 | } else { |
---|
533 | lappend newlist $rng |
---|
534 | } |
---|
535 | } |
---|
536 | } |
---|
537 | if {[llength $newlist] == [llength $exclist]} { |
---|
538 | if {$msg == ""} bell |
---|
539 | } else { |
---|
540 | histinfo $hst excl set $newlist |
---|
541 | updateplot |
---|
542 | } |
---|
543 | } |
---|
544 | |
---|
545 | # called using the mouse to create a new excluded region |
---|
546 | # once this is called, mouse motion causes a region to be highlighted |
---|
547 | # using exclMove. Button 1 completes the region, by calling exclDone while |
---|
548 | # button 3 resets the mode |
---|
549 | proc exclAdd {bindtag x y} { |
---|
550 | global graph |
---|
551 | bind $graph(plot) <Motion> "exclMove $bindtag %x %y" |
---|
552 | bind $bindtag <1> "exclDone $bindtag %x %y" |
---|
553 | bind $bindtag <3> "exclReset $bindtag" |
---|
554 | set graph(excl-x1) [$graph(plot) xaxis invtransform $x] |
---|
555 | $graph(plot) marker create text -name AddExclLbl -text "Adding\nRegion" \ |
---|
556 | -bg yellow -coords "+Inf +Inf" -anchor ne |
---|
557 | } |
---|
558 | |
---|
559 | # reset the "add region mode" (see exclAdd) |
---|
560 | proc exclReset {bindtag} { |
---|
561 | global graph |
---|
562 | bind $graph(plot) <Motion> {} |
---|
563 | $graph(plot) marker delete exclShade |
---|
564 | bind $bindtag <1> "exclAdd $bindtag %x %y" |
---|
565 | $graph(plot) marker delete AddExclLbl |
---|
566 | } |
---|
567 | |
---|
568 | # highlight the potential excluded region (see exclAdd) |
---|
569 | proc exclMove {bindtag x y} { |
---|
570 | global graph |
---|
571 | set x1 $graph(excl-x1) |
---|
572 | set x2 [$graph(plot) xaxis invtransform $x] |
---|
573 | if { ![$graph(plot) marker exists "exclShade"] } { |
---|
574 | $graph(plot) marker create polygon -name "exclShade" -under 1 -fill yellow |
---|
575 | } |
---|
576 | $graph(plot) marker configure "exclShade" \ |
---|
577 | -coords "$x1 -Inf $x1 +Inf $x2 +Inf $x2 -Inf" |
---|
578 | } |
---|
579 | |
---|
580 | # Called by a mouse click to complete a new excluded region (see exclAdd) |
---|
581 | proc exclDone {bindtag x y} { |
---|
582 | global graph |
---|
583 | bind $graph(plot) <Motion> {} |
---|
584 | bind $bindtag <1> "exclAdd $bindtag %x %y" |
---|
585 | set x1 $graph(excl-x1) |
---|
586 | set x2 [$graph(plot) xaxis invtransform $x] |
---|
587 | set hst $graph(hst) |
---|
588 | if {$graph(xunits) == 1} { |
---|
589 | set x1 [fromd $x1 $hst] |
---|
590 | set x2 [fromd $x2 $hst] |
---|
591 | } elseif {$graph(xunits) == 2} { |
---|
592 | set x1 [fromQ $x1 $hst] |
---|
593 | set x2 [fromQ $x2 $hst] |
---|
594 | } |
---|
595 | catch { |
---|
596 | $graph(plot) marker delete "exclShade" |
---|
597 | } |
---|
598 | $graph(plot) marker delete AddExclLbl |
---|
599 | # get the points in the range |
---|
600 | set l [lsort -integer [allxvec search $x1 $x2]] |
---|
601 | if {[llength $l] == 0} return |
---|
602 | set p1 [allxvec index [set n1 [lindex $l 0]]] |
---|
603 | set p2 [allxvec index [set n2 [lindex $l end]]] |
---|
604 | if {$graph(xunits) == 1} { |
---|
605 | set d1 [tod $p1 $hst] |
---|
606 | set d2 [tod $p2 $hst] |
---|
607 | set msg "Exclude data from " |
---|
608 | append msg "[format %.5f $d2] A to [format %.5f $d1] A" |
---|
609 | append msg " ([expr $n2-$n1+1] points)?" |
---|
610 | set coords "$d2 -Inf $d1 -Inf" |
---|
611 | set l [lsort -integer [xvec search $d1 $d2]] |
---|
612 | } elseif {$graph(xunits) == 2} { |
---|
613 | set q1 [toQ $p1 $hst] |
---|
614 | set q2 [toQ $p2 $hst] |
---|
615 | set msg "Exclude data from " |
---|
616 | append msg "[format %.5f $q1] A-1 to [format %.5f $q2] A-1" |
---|
617 | append msg " ([expr $n2-$n1+1] points)?" |
---|
618 | set coords "$q1 -Inf $q2 -Inf" |
---|
619 | set l [lsort -integer [xvec search $q1 $q2]] |
---|
620 | } else { |
---|
621 | set msg "Exclude data from " |
---|
622 | append msg "[format %.5f $p1] to [format %.5f $p2]" |
---|
623 | append msg " ([expr $n2-$n1+1] points)?" |
---|
624 | set coords "$p1 -Inf $p2 -Inf" |
---|
625 | set l [lsort -integer [xvec search $x1 $x2]] |
---|
626 | } |
---|
627 | global graph |
---|
628 | if {$graph(exclPrompt)} { |
---|
629 | set ans [MyMessageBox -parent . -message $msg -title "Exclude?"\ |
---|
630 | -type okcancel -helplink "expguierr.html ExcludeRegion"] |
---|
631 | } else { |
---|
632 | set ans ok |
---|
633 | } |
---|
634 | if {$ans != "ok"} {return} |
---|
635 | # make the change |
---|
636 | global expgui |
---|
637 | incr expgui(changed) |
---|
638 | set hst $graph(hst) |
---|
639 | set exclist [histinfo $hst excl] |
---|
640 | set oldtmin [lindex [lindex $exclist 0] 1] |
---|
641 | set oldtmax [lindex [lindex $exclist end] 0] |
---|
642 | # add the new excluded region at the end |
---|
643 | lappend exclist [list $p1 $p2] |
---|
644 | # sort and simplify the excluded region list |
---|
645 | CheckForOverlappingRegions $exclist |
---|
646 | CheckQmaxChanged $oldtmin $oldtmax |
---|
647 | # update the plot to change the color of the points that are now excluded |
---|
648 | exxvec append [xvec range [lindex $l 0] [lindex $l end]] |
---|
649 | exobsvec append [obsvec range [lindex $l 0] [lindex $l end]] |
---|
650 | exxvec notify now |
---|
651 | exobsvec notify now |
---|
652 | ShowExlMarks |
---|
653 | FillExclRegionBox |
---|
654 | } |
---|
655 | |
---|
656 | # sort the regions and then go through the list of excluded regions and |
---|
657 | # merge regions that overlap |
---|
658 | proc CheckForOverlappingRegions {exclist} { |
---|
659 | global expgui graph |
---|
660 | set exclist [lsort -real -index 0 $exclist] |
---|
661 | set prvlow -1 |
---|
662 | set prvhigh -1 |
---|
663 | set i 0 |
---|
664 | set ip -1 |
---|
665 | foreach pair $exclist { |
---|
666 | set low [lindex $pair 0] |
---|
667 | set high [lindex $pair 1] |
---|
668 | # is there overlap with the previous range? |
---|
669 | if {$low < $prvhigh && $i != 0} { |
---|
670 | set exclist [lreplace $exclist $ip $i [list $prvlow $high]] |
---|
671 | incr expgui(changed) |
---|
672 | set prvhigh $high |
---|
673 | continue |
---|
674 | } |
---|
675 | # are there any points between the regions |
---|
676 | if {$i != 0} { |
---|
677 | set seppts [allxvec search \ |
---|
678 | [expr -.00001+$low] [expr .00001+$prvhigh]] |
---|
679 | if {[llength $seppts] == 0} { |
---|
680 | set exclist [lreplace $exclist $ip $i [list $prvlow $high]] |
---|
681 | incr expgui(changed) |
---|
682 | set prvhigh $high |
---|
683 | continue |
---|
684 | } |
---|
685 | } |
---|
686 | incr i; incr ip |
---|
687 | set prvlow $low |
---|
688 | set prvhigh $high |
---|
689 | } |
---|
690 | histinfo $graph(hst) excl set $exclist |
---|
691 | } |
---|
692 | |
---|
693 | # called in response to the File/"Set Min/Max Range" menu button |
---|
694 | proc setminormax {} { |
---|
695 | global expmap graph expgui |
---|
696 | set hst $graph(hst) |
---|
697 | if {[string trim [string range $expmap(htype_$hst) 3 3]] == "D"} { |
---|
698 | if {[string range $expmap(htype_$hst) 2 2] == "T"} { |
---|
699 | set fac 1000. |
---|
700 | } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { |
---|
701 | set fac 1. |
---|
702 | } else { |
---|
703 | set fac 100. |
---|
704 | } |
---|
705 | set start [expr {[histinfo $hst dstart]/$fac}] |
---|
706 | set step [expr {[histinfo $hst dstep]/$fac}] |
---|
707 | set points [histinfo $hst dpoints] |
---|
708 | set end [expr {$start + $points*$step}] |
---|
709 | SetDummyRangeBox $hst $start $end $step |
---|
710 | return |
---|
711 | } |
---|
712 | set box .limit |
---|
713 | toplevel $box |
---|
714 | wm title $box "Set usable range" |
---|
715 | set link excledt.html |
---|
716 | grid [button $box.help -text Help -bg yellow \ |
---|
717 | -command "MakeWWWHelp $link"] -col 98 -row 0 |
---|
718 | bind $box <Key-F1> "MakeWWWHelp $link" |
---|
719 | |
---|
720 | set hst $graph(hst) |
---|
721 | if {$graph(xunits) == 1} { |
---|
722 | set var d |
---|
723 | set unit A |
---|
724 | } elseif {$graph(xunits) == 2} { |
---|
725 | set var Q |
---|
726 | set unit A-1 |
---|
727 | } elseif {[string range $expmap(htype_$hst) 2 2] == "T"} { |
---|
728 | set var TOF |
---|
729 | set unit ms |
---|
730 | } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { |
---|
731 | set var 2theta |
---|
732 | set unit deg |
---|
733 | } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { |
---|
734 | set var Energy |
---|
735 | set unit KeV |
---|
736 | } else { |
---|
737 | set var ? |
---|
738 | set unit ? |
---|
739 | } |
---|
740 | if {$graph(xunits) != 0} { |
---|
741 | } |
---|
742 | grid [label $box.t -text "Set usable data range, histogram $hst"] \ |
---|
743 | -col 0 -columnspan 4 -row 0 |
---|
744 | grid [label $box.lu -text "($unit)"] -col 2 -row 1 -rowspan 2 |
---|
745 | grid [label $box.lmn -text "$var minimum"] -col 0 -row 1 |
---|
746 | grid [entry $box.emn -textvariable graph(tmin) -width 10] -col 1 -row 1 |
---|
747 | grid [label $box.lmx -text "$var maximum"] -col 0 -row 2 |
---|
748 | grid [entry $box.emx -textvariable graph(tmax) -width 10] -col 1 -row 2 |
---|
749 | grid [frame $box.c] -col 0 -columnspan 99 -row 99 |
---|
750 | grid [button $box.c.1 -text Set -command "destroy $box"\ |
---|
751 | ] -col 1 -row 0 |
---|
752 | grid [button $box.c.2 -text Quit \ |
---|
753 | -command "foreach i {min max} {set graph(\$i) {}}; destroy $box" \ |
---|
754 | ] -col 2 -row 0 |
---|
755 | set exclist [histinfo $hst excl] |
---|
756 | set oldtmin [lindex [lindex $exclist 0] 1] |
---|
757 | set oldtmax [lindex [lindex $exclist end] 0] |
---|
758 | if {$graph(xunits) == 1} { |
---|
759 | set graph(tmax) [format %.4f [tod [lindex [lindex $exclist 0] 1] $hst]] |
---|
760 | set graph(tmin) [format %.4f [tod [lindex [lindex $exclist end] 0] $hst]] |
---|
761 | } elseif {$graph(xunits) == 2} { |
---|
762 | set graph(tmin) [format %.4f [toQ [lindex [lindex $exclist 0] 1] $hst]] |
---|
763 | set graph(tmax) [format %.4f [toQ [lindex [lindex $exclist end] 0] $hst]] |
---|
764 | } else { |
---|
765 | set graph(tmin) [lindex [lindex $exclist 0] 1] |
---|
766 | set graph(tmax) [lindex [lindex $exclist end] 0] |
---|
767 | } |
---|
768 | foreach v {tmin tmax} {set start($v) $graph($v)} |
---|
769 | bind $box <Return> "$box.c.1 invoke" |
---|
770 | putontop $box |
---|
771 | tkwait window $box |
---|
772 | # fix grab... |
---|
773 | afterputontop |
---|
774 | |
---|
775 | set highchange 0 |
---|
776 | set startchanges $expgui(changed) |
---|
777 | catch { |
---|
778 | # did anything change? |
---|
779 | if {$graph(tmin) != $start(tmin)} { |
---|
780 | incr expgui(changed) |
---|
781 | if {$graph(xunits) == 1} { |
---|
782 | set tmax [fromd $graph(tmin) $hst] |
---|
783 | set exclist [lreplace $exclist end end \ |
---|
784 | [list $tmax [lindex [lindex $exclist end] 1]]] |
---|
785 | } elseif {$graph(xunits) == 2} { |
---|
786 | set tmin [fromQ $graph(tmin) $hst] |
---|
787 | set exclist [lreplace $exclist 0 0 \ |
---|
788 | [list [lindex [lindex $exclist 0] 0] $tmin]] |
---|
789 | } else { |
---|
790 | set exclist [lreplace $exclist 0 0 \ |
---|
791 | [list [lindex [lindex $exclist 0] 0] $graph(tmin)]] |
---|
792 | } |
---|
793 | } |
---|
794 | } |
---|
795 | catch { |
---|
796 | if {$graph(tmax) != $start(tmax)} { |
---|
797 | incr expgui(changed) |
---|
798 | if {$graph(xunits) == 1} { |
---|
799 | set tmin [fromd $graph(tmax) $hst] |
---|
800 | set exclist [lreplace $exclist 0 0 \ |
---|
801 | [list [lindex [lindex $exclist 0] 0] $tmin]] |
---|
802 | } elseif {$graph(xunits) == 2} { |
---|
803 | set tmax [fromQ $graph(tmax) $hst] |
---|
804 | set exclist [lreplace $exclist end end \ |
---|
805 | [list $tmax [lindex [lindex $exclist end] 1]]] |
---|
806 | } else { |
---|
807 | set exclist [lreplace $exclist end end \ |
---|
808 | [list $graph(tmax) [lindex [lindex $exclist end] 1]]] |
---|
809 | } |
---|
810 | } |
---|
811 | } |
---|
812 | if {$startchanges != $expgui(changed)} { |
---|
813 | CheckForOverlappingRegions $exclist |
---|
814 | CheckQmaxChanged $oldtmin $oldtmax |
---|
815 | updateplot |
---|
816 | } else { |
---|
817 | return |
---|
818 | } |
---|
819 | } |
---|
820 | |
---|
821 | # check to see if Qmax (2theta max or TOF min) has changed, |
---|
822 | # if so, other parts of the .EXP file must be changed |
---|
823 | proc CheckQmaxChanged {oldtmin oldtmax} { |
---|
824 | global graph expmap |
---|
825 | set hst $graph(hst) |
---|
826 | set exclist [histinfo $hst excl] |
---|
827 | if {[string range $expmap(htype_$hst) 2 2] == "T"} { |
---|
828 | set tmin [lindex [lindex $exclist 0] 1] |
---|
829 | if {$oldtmin != $tmin} { |
---|
830 | # edited minimum time -- reset d-min & set CHANS -- use EXPEDT |
---|
831 | SetTminTOF $tmin [winfo parent $graph(plot)] |
---|
832 | # Qmax got bigger. Show the new data? |
---|
833 | if {$tmin < $oldtmin} {QmaxIncreased} |
---|
834 | } |
---|
835 | } else { |
---|
836 | set tmax [lindex [lindex $exclist end] 0] |
---|
837 | if {$oldtmax != $tmax} { |
---|
838 | # edited 2theta or Energy max -- reset d-min |
---|
839 | histinfo $hst dmin set [tod $tmax $hst] |
---|
840 | if {$tmax > $oldtmax} {QmaxIncreased} |
---|
841 | } |
---|
842 | } |
---|
843 | } |
---|
844 | |
---|
845 | # if Qmax has changed, give the user the option to update now so that the |
---|
846 | # new data may be seen in the plot |
---|
847 | proc QmaxIncreased {} { |
---|
848 | global graph expgui expmap |
---|
849 | set hst $graph(hst) |
---|
850 | set msg "The high Q (low d-space) data limit has changed.\nYou must run POWPREF to " |
---|
851 | append msg "to see the full range of data displayed. Do you want to " |
---|
852 | append msg "run POWPREF (& possibly GENLES with zero cycles)?" |
---|
853 | set ans [MyMessageBox -parent . -message $msg -title "Process limits?"\ |
---|
854 | -helplink "expguierr.html ProcessRegions" \ |
---|
855 | -type {Skip {Run POWPREF} {Run POWPREF & GENLES}}] |
---|
856 | if {$ans == "skip"} { |
---|
857 | updateplot |
---|
858 | return |
---|
859 | } elseif {$ans == "run powpref"} { |
---|
860 | set cmd powpref |
---|
861 | } else { |
---|
862 | set cmd "powpref genles" |
---|
863 | expinfo cycles set 0 |
---|
864 | } |
---|
865 | set auto $expgui(autoexpload) |
---|
866 | set expgui(autoexpload) 1 |
---|
867 | #set expgui(autoiconify) 0 |
---|
868 | runGSASwEXP $cmd |
---|
869 | set expgui(autoexpload) $auto |
---|
870 | updateplot |
---|
871 | if {[string range $expmap(htype_$hst) 2 2] != "T"} {CheckTmax} |
---|
872 | } |
---|
873 | |
---|
874 | # check the maximum 2theta/energy value against the excluded region |
---|
875 | # and reset the limit if it is too high. This is because POWPREF & GENLES |
---|
876 | # can be really slow when there are lots of extra reflections generated. |
---|
877 | proc CheckTmax {} { |
---|
878 | global graph expgui |
---|
879 | # clone xvec |
---|
880 | xvec dup temp |
---|
881 | set hst $graph(hst) |
---|
882 | if {$graph(xunits) == 1} { |
---|
883 | temp sort |
---|
884 | set max [fromd [temp index 0] $hst] |
---|
885 | set step [expr abs($max - [fromd [temp index 1] $hst])] |
---|
886 | } elseif {$graph(xunits) == 2} { |
---|
887 | temp sort -reverse |
---|
888 | set max [fromQ [temp index 0] $hst] |
---|
889 | set step [expr abs($max - [fromQ [temp index 1] $hst])] |
---|
890 | } else { |
---|
891 | temp sort -reverse |
---|
892 | set max [temp index 0] |
---|
893 | set step [expr $max - [temp index 1]] |
---|
894 | } |
---|
895 | set exclist [histinfo $hst excl] |
---|
896 | if {[lindex [lindex $exclist end] 0] > $max + 10*$step} { |
---|
897 | if {$graph(xunits) == 1} { |
---|
898 | set msg "The lower data limit ([tod [lindex [lindex $exclist end] 0] $hst] A) " |
---|
899 | set d [tod $max $hst] |
---|
900 | append msg "is much smaller than the smallest data point ($d A)\n" |
---|
901 | append msg "You are suggested to set the lower d limit to $d A\n" |
---|
902 | } elseif {$graph(xunits) == 2} { |
---|
903 | set msg "The high Q data limit ([toQ [lindex [lindex $exclist end] 0] $hst] A-1) " |
---|
904 | set q [toQ $max $hst] |
---|
905 | append msg "is much larger than the largest data point ($q A-1)\n" |
---|
906 | append msg "You are suggested to set the upper Q limit to $q A-1\n" |
---|
907 | } else { |
---|
908 | set msg "The high Q (low d) data limit ([lindex [lindex $exclist end] 0]) " |
---|
909 | append msg "is much larger than the largest data point ($max)\n" |
---|
910 | append msg "You are suggested to set the limit to $max\n" |
---|
911 | } |
---|
912 | append msg "OK to make this change?" |
---|
913 | set ans [MyMessageBox -parent . -message $msg -title "Reset limits?"\ |
---|
914 | -helplink "expguierr.html RegionTooBig" \ |
---|
915 | -type {OK Cancel}] |
---|
916 | if {$ans == "ok"} { |
---|
917 | set item [list [expr $max+$step] [lindex [lindex $exclist end] 1]] |
---|
918 | incr expgui(changed) |
---|
919 | set exclist [lreplace $exclist end end $item] |
---|
920 | histinfo $hst excl set $exclist |
---|
921 | histinfo $hst dmin set [tod $max $hst] |
---|
922 | updateplot |
---|
923 | return |
---|
924 | } |
---|
925 | } |
---|
926 | } |
---|
927 | |
---|
928 | # CheckChanges is called before "exiting" (closing the window) to make |
---|
929 | # sure that POWPREF gets run before GENLES so that changes made here |
---|
930 | # take effect |
---|
931 | proc CheckChanges {startchanges} { |
---|
932 | global expgui graph |
---|
933 | set hst $graph(hst) |
---|
934 | if {$expgui(changed) == $startchanges} return |
---|
935 | set expgui(needpowpref) 2 |
---|
936 | set msg "Excluded regions/data range" |
---|
937 | if {[string first $msg $expgui(needpowpref_why)] == -1} { |
---|
938 | append expgui(needpowpref_why) "\t$msg were changed\n" |
---|
939 | } |
---|
940 | } |
---|
941 | |
---|
942 | # called in response to pressing one of the excluded region buttons |
---|
943 | # on the bottom bar |
---|
944 | proc EditExclRegion {reg "msg {}"} { |
---|
945 | global graph expmap expgui |
---|
946 | set hst $graph(hst) |
---|
947 | set startchanges $expgui(changed) |
---|
948 | set exclist [histinfo $hst excl] |
---|
949 | set oldtmin [lindex [lindex $exclist 0] 1] |
---|
950 | set oldtmax [lindex [lindex $exclist end] 0] |
---|
951 | set i [expr {$reg -1}] |
---|
952 | set range [lindex $exclist $i] |
---|
953 | toplevel [set box .edit] |
---|
954 | wm title $box "Edit excluded region" |
---|
955 | set beg minimum |
---|
956 | set end maximum |
---|
957 | set graph(tmin) [format %.4f [lindex $range 0]] |
---|
958 | set graph(tmax) [format %.4f [lindex $range 1]] |
---|
959 | if {$msg != ""} { |
---|
960 | grid [label $box.0 -text $msg -fg red] \ |
---|
961 | -col 1 -row 0 -columnspan 99 |
---|
962 | } |
---|
963 | if {$graph(xunits) == 1} { |
---|
964 | set var d-space |
---|
965 | set unit A |
---|
966 | set beg maximum |
---|
967 | set end minimum |
---|
968 | set graph(tmin) [format %.4f [tod [lindex $range 0] $hst]] |
---|
969 | set graph(tmax) [format %.4f [tod [lindex $range 1] $hst]] |
---|
970 | } elseif {$graph(xunits) == 2} { |
---|
971 | set var Q |
---|
972 | set unit A-1 |
---|
973 | set graph(tmin) [format %.4f [toQ [lindex $range 0] $hst]] |
---|
974 | set graph(tmax) [format %.4f [toQ [lindex $range 1] $hst]] |
---|
975 | } elseif {[string range $expmap(htype_$hst) 2 2] == "T"} { |
---|
976 | set var TOF |
---|
977 | set unit ms |
---|
978 | } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { |
---|
979 | set var 2theta |
---|
980 | set unit deg |
---|
981 | } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { |
---|
982 | set var Energy |
---|
983 | set unit KeV |
---|
984 | } else { |
---|
985 | set var ? |
---|
986 | set unit ? |
---|
987 | } |
---|
988 | if {$reg == 1} { |
---|
989 | grid [label $box.1 -text "Editing Data Limits ($unit)"] \ |
---|
990 | -col 1 -row 1 -columnspan 99 |
---|
991 | grid [label $box.2 -text "$beg $var "] \ |
---|
992 | -col 1 -row 2 |
---|
993 | grid [entry $box.3 -width 12 -textvariable graph(tmax)] \ |
---|
994 | -col 2 -row 2 |
---|
995 | } elseif {$reg == [llength $exclist]} { |
---|
996 | grid [label $box.1 -text "Editing Data Limits ($unit)"] \ |
---|
997 | -col 1 -row 1 -columnspan 99 |
---|
998 | grid [label $box.2 -text "$end $var "] \ |
---|
999 | -col 1 -row 2 |
---|
1000 | grid [entry $box.3 -width 12 -textvariable graph(tmin)] \ |
---|
1001 | -col 2 -row 2 |
---|
1002 | } else { |
---|
1003 | grid [label $box.1 -text "Editing excluded region #$reg in $var ($unit)"] \ |
---|
1004 | -col 1 -row 1 -columnspan 99 |
---|
1005 | grid [label $box.2 -text "$beg $var "] \ |
---|
1006 | -col 1 -row 2 |
---|
1007 | grid [entry $box.3 -width 12 -textvariable graph(tmin)] \ |
---|
1008 | -col 2 -row 2 |
---|
1009 | grid [label $box.4 -text "$end $var "] \ |
---|
1010 | -col 1 -row 3 |
---|
1011 | grid [entry $box.5 -width 12 -textvariable graph(tmax)] \ |
---|
1012 | -col 2 -row 3 |
---|
1013 | } |
---|
1014 | # save starting values as tmin & tmax |
---|
1015 | foreach v {tmin tmax} { |
---|
1016 | set $v $graph($v) |
---|
1017 | } |
---|
1018 | bind $box <Return> "destroy .edit" |
---|
1019 | grid [frame $box.c] -col 1 -row 99 -columnspan 99 |
---|
1020 | grid [button $box.c.1 -text "OK" -command "destroy .edit"] \ |
---|
1021 | -col 1 -row 1 |
---|
1022 | grid [button $box.c.2 -text "Cancel" \ |
---|
1023 | -command "set graph(tmin) $tmin; set graph(tmax) $tmax;destroy .edit"] \ |
---|
1024 | -col 2 -row 1 |
---|
1025 | putontop $box |
---|
1026 | tkwait window $box |
---|
1027 | afterputontop |
---|
1028 | if {$tmin != $graph(tmin)} { |
---|
1029 | if {[catch { |
---|
1030 | expr $graph(tmin) |
---|
1031 | if {$graph(xunits) == 1} { |
---|
1032 | set tmin [fromd $graph(tmin) $hst] |
---|
1033 | } elseif {$graph(xunits) == 2} { |
---|
1034 | set tmin [fromQ $graph(tmin) $hst] |
---|
1035 | } else { |
---|
1036 | set tmin $graph(tmin) |
---|
1037 | } |
---|
1038 | }]} { |
---|
1039 | # recursive call -- should not happen too many times |
---|
1040 | EditExclRegion $reg "Invalid value entered, try again" |
---|
1041 | return |
---|
1042 | } |
---|
1043 | set exclist [lreplace $exclist $i $i [lreplace $range 0 0 $tmin]] |
---|
1044 | incr expgui(changed) |
---|
1045 | } |
---|
1046 | if {$tmax != $graph(tmax)} { |
---|
1047 | if {[catch { |
---|
1048 | expr $graph(tmax) |
---|
1049 | if {$graph(xunits) == 1} { |
---|
1050 | set tmax [fromd $graph(tmax) $hst] |
---|
1051 | } elseif {$graph(xunits) == 2} { |
---|
1052 | set tmax [fromQ $graph(tmax) $hst] |
---|
1053 | } else { |
---|
1054 | set tmax $graph(tmax) |
---|
1055 | } |
---|
1056 | }]} { |
---|
1057 | # recursive call -- should not happen too many times |
---|
1058 | EditExclRegion $reg "Invalid value entered, try again" |
---|
1059 | return |
---|
1060 | } |
---|
1061 | set exclist [lreplace $exclist $i $i [lreplace $range 1 1 $tmax]] |
---|
1062 | incr expgui(changed) |
---|
1063 | } |
---|
1064 | # did anything change? |
---|
1065 | if {$expgui(changed) == $startchanges} {return} |
---|
1066 | # check and save the changed regions |
---|
1067 | CheckForOverlappingRegions $exclist |
---|
1068 | CheckQmaxChanged $oldtmin $oldtmax |
---|
1069 | updateplot |
---|
1070 | } |
---|
1071 | |
---|
1072 | # this is done in response to a change in the window size (<Configure>) |
---|
1073 | # the change is done only when idle and only gets done once. |
---|
1074 | proc scheduleFillExclRegionBox {} { |
---|
1075 | global graph |
---|
1076 | # is an update pending? |
---|
1077 | if {$graph(FillExclRegionBox)} return |
---|
1078 | set graph(FillExclRegionBox) 1 |
---|
1079 | after idle FillExclRegionBox |
---|
1080 | } |
---|
1081 | |
---|
1082 | # put the background regions into buttons and resize the slider |
---|
1083 | proc FillExclRegionBox {} { |
---|
1084 | global graph expmap |
---|
1085 | set hst $graph(hst) |
---|
1086 | set can $graph(ExclCanvas) |
---|
1087 | set scroll $graph(ExclScroll) |
---|
1088 | |
---|
1089 | catch {destroy [set top $can.fr]} |
---|
1090 | frame $top -class SmallFont |
---|
1091 | $can create window 0 0 -anchor nw -window $top |
---|
1092 | set exclist [histinfo $hst excl] |
---|
1093 | set col 0 |
---|
1094 | if {[string trim [string range $expmap(htype_$graph(hst)) 3 3]] == "D"} { |
---|
1095 | $graph(bbox).bl.1 config -text "Dummy\nHistogram" |
---|
1096 | foreach c {2 3} { |
---|
1097 | $graph(bbox).l.b$c config -state disabled |
---|
1098 | } |
---|
1099 | if {[string range $expmap(htype_$graph(hst)) 2 2] == "T"} { |
---|
1100 | set fac 1000. |
---|
1101 | } elseif {[string range $expmap(htype_$graph(hst)) 2 2] == "E"} { |
---|
1102 | set fac 1. |
---|
1103 | } else { |
---|
1104 | set fac 100. |
---|
1105 | } |
---|
1106 | set start [expr {[histinfo $graph(hst) dstart]/$fac}] |
---|
1107 | set step [expr {[histinfo $graph(hst) dstep]/$fac}] |
---|
1108 | set points [histinfo $graph(hst) dpoints] |
---|
1109 | set end [expr {$start + $points*$step}] |
---|
1110 | grid [label $top.$col -text "Range:" \ |
---|
1111 | -padx 0 -pady 1 -bd 4] \ |
---|
1112 | -row 0 -col $col |
---|
1113 | incr col |
---|
1114 | if {$graph(xunits) == 1} { |
---|
1115 | foreach i {min max} \ |
---|
1116 | v [lsort -real [tod [list $start $end] $graph(hst)]] { |
---|
1117 | grid [label $top.$col -text "$i\n[format %.4f $v]" \ |
---|
1118 | -padx 3 -pady 1 -bd 2 -relief groove] \ |
---|
1119 | -row 0 -col $col -sticky ns |
---|
1120 | incr col |
---|
1121 | } |
---|
1122 | grid [label $top.$col -text "\xc5" \ |
---|
1123 | -padx 0 -pady 1 -bd 4] \ |
---|
1124 | -row 0 -col $col -sticky nsw -ipadx 5 |
---|
1125 | incr col |
---|
1126 | grid [label $top.$col -text "points\n$points" \ |
---|
1127 | -padx 3 -pady 1 -bd 2 -relief groove] \ |
---|
1128 | -row 0 -col $col -sticky ns |
---|
1129 | incr col |
---|
1130 | } elseif {$graph(xunits) == 2} { |
---|
1131 | foreach i {min max} \ |
---|
1132 | v [lsort -real [toQ [list $start $end] $graph(hst)]] { |
---|
1133 | grid [label $top.$col -text "$i\n[format %.3f $v]" \ |
---|
1134 | -padx 3 -pady 1 -bd 2 -relief groove] -row 0 -col $col -sticky ns |
---|
1135 | incr col |
---|
1136 | } |
---|
1137 | grid [label $top.$col -text "\xc5" \ |
---|
1138 | -padx 0 -pady 1] \ |
---|
1139 | -row 0 -col $col |
---|
1140 | incr col |
---|
1141 | grid [label $top.$col -text "-1\n" \ |
---|
1142 | -padx 0 -pady 0] \ |
---|
1143 | -row 0 -col $col -sticky nsw -ipadx 5 |
---|
1144 | incr col |
---|
1145 | grid [label $top.$col -text "points\n$points" \ |
---|
1146 | -padx 3 -pady 1 -bd 2 -relief groove] -row 0 -col $col -sticky ns |
---|
1147 | incr col |
---|
1148 | } else { |
---|
1149 | foreach i {start step end} { |
---|
1150 | grid [label $top.$col -text "$i\n[set $i]" \ |
---|
1151 | -padx 3 -pady 1 -bd 2 -relief groove] \ |
---|
1152 | -row 0 -col $col -sticky ns |
---|
1153 | incr col |
---|
1154 | } |
---|
1155 | } |
---|
1156 | grid [button $top.b$col -text "Set" \ |
---|
1157 | -command "SetDummyRangeBox $graph(hst) $start $end $step"] \ |
---|
1158 | -sticky ns -row 0 -col $col |
---|
1159 | } else { |
---|
1160 | $graph(bbox).bl.1 config -text "Excluded\nRegions" |
---|
1161 | foreach c {2 3} { |
---|
1162 | $graph(bbox).l.b$c config -state normal |
---|
1163 | } |
---|
1164 | foreach rng $exclist { |
---|
1165 | if {$graph(xunits) == 1} { |
---|
1166 | set rng [tod $rng $hst] |
---|
1167 | if {$col == 0} { |
---|
1168 | set lbl ">[format %.4f [lindex $rng 1]]" |
---|
1169 | } else { |
---|
1170 | set lbl "[format %.4f [lindex $rng 0]]\nto [format %.4f [lindex $rng 1]]" |
---|
1171 | } |
---|
1172 | incr col |
---|
1173 | if {$col == [llength $exclist]} { |
---|
1174 | set lbl "<[format %.4f [lindex $rng 0]]" |
---|
1175 | } |
---|
1176 | } else { |
---|
1177 | if {$graph(xunits) == 2} { |
---|
1178 | set rng [toQ $rng $hst] |
---|
1179 | } |
---|
1180 | if {$col == 0} { |
---|
1181 | set lbl "<[format %.3f [lindex $rng 1]]" |
---|
1182 | } else { |
---|
1183 | set lbl "[format %.3f [lindex $rng 0]]\nto [format %.3f [lindex $rng 1]]" |
---|
1184 | } |
---|
1185 | incr col |
---|
1186 | if {$col == [llength $exclist]} { |
---|
1187 | set lbl ">[format %.3f [lindex $rng 0]]" |
---|
1188 | } |
---|
1189 | } |
---|
1190 | grid [button $top.$col -text $lbl -command "EditExclRegion $col" \ |
---|
1191 | -padx 1 -pady 1] -row 0 -col $col -sticky ns |
---|
1192 | } |
---|
1193 | } |
---|
1194 | update idletasks |
---|
1195 | set sizes [grid bbox $top] |
---|
1196 | $can config -scrollregion $sizes -height [lindex $sizes 3] |
---|
1197 | if {[lindex $sizes 2] <= [winfo width $can]} { |
---|
1198 | grid forget $scroll |
---|
1199 | } else { |
---|
1200 | grid $graph(ExclScroll) -column 1 -row 4 -columnspan 5 -sticky nsew |
---|
1201 | } |
---|
1202 | # clear flag |
---|
1203 | set graph(FillExclRegionBox) 0 |
---|
1204 | } |
---|
1205 | |
---|
1206 | # manual zoom option |
---|
1207 | proc BLTmanualZoom {} { |
---|
1208 | global graph |
---|
1209 | catch {toplevel .zoom} |
---|
1210 | wm title .zoom "Manual zoom" |
---|
1211 | eval destroy [grid slaves .zoom] |
---|
1212 | raise .zoom |
---|
1213 | wm title .zoom {Manual Scaling} |
---|
1214 | grid [label .zoom.l1 -text minimum] -row 1 -column 2 |
---|
1215 | grid [label .zoom.l2 -text maximum] -row 1 -column 3 |
---|
1216 | grid [label .zoom.l3 -text x] -row 2 -column 1 |
---|
1217 | grid [label .zoom.l4 -text y] -row 3 -column 1 |
---|
1218 | grid [entry .zoom.xmin -textvariable graph(xmin) -width 10] -row 2 -column 2 |
---|
1219 | grid [entry .zoom.xmax -textvariable graph(xmax) -width 10] -row 2 -column 3 |
---|
1220 | grid [entry .zoom.ymin -textvariable graph(ymin) -width 10] -row 3 -column 2 |
---|
1221 | grid [entry .zoom.ymax -textvariable graph(ymax) -width 10] -row 3 -column 3 |
---|
1222 | grid [frame .zoom.b] -row 4 -column 1 -columnspan 3 |
---|
1223 | grid [button .zoom.b.1 -text "Set Scaling" \ |
---|
1224 | -command "SetManualZoom set"] -row 4 -column 1 -columnspan 2 |
---|
1225 | grid [button .zoom.b.2 -text Reset \ |
---|
1226 | -command "SetManualZoom clear"] -row 4 -column 3 |
---|
1227 | grid [button .zoom.b.3 -text Close -command "destroy .zoom"] -row 4 -column 4 |
---|
1228 | grid rowconfigure .zoom 1 -weight 1 -pad 5 |
---|
1229 | grid rowconfigure .zoom 2 -weight 1 -pad 5 |
---|
1230 | grid rowconfigure .zoom 3 -weight 1 -pad 5 |
---|
1231 | grid rowconfigure .zoom 4 -weight 0 -pad 5 |
---|
1232 | grid columnconfigure .zoom 1 -weight 1 -pad 20 |
---|
1233 | grid columnconfigure .zoom 1 -weight 1 |
---|
1234 | grid columnconfigure .zoom 3 -weight 1 -pad 10 |
---|
1235 | foreach item {min min max max} \ |
---|
1236 | format {3 2 3 2} \ |
---|
1237 | axis {x y x y} { |
---|
1238 | set val [$graph(plot) ${axis}axis cget -${item}] |
---|
1239 | set graph(${axis}${item}) {(auto)} |
---|
1240 | catch {set graph(${axis}${item}) [format %.${format}f $val]} |
---|
1241 | } |
---|
1242 | putontop .zoom |
---|
1243 | tkwait window .zoom |
---|
1244 | afterputontop |
---|
1245 | } |
---|
1246 | |
---|
1247 | proc SetManualZoom {mode} { |
---|
1248 | global graph |
---|
1249 | if {$mode == "clear"} { |
---|
1250 | foreach item {xmin ymin xmax ymax} { |
---|
1251 | set graph($item) {(auto)} |
---|
1252 | } |
---|
1253 | } |
---|
1254 | foreach item {xmin ymin xmax ymax} { |
---|
1255 | if {[catch {expr $graph($item)}]} { |
---|
1256 | set $item "" |
---|
1257 | } else { |
---|
1258 | set $item $graph($item) |
---|
1259 | } |
---|
1260 | } |
---|
1261 | # reset the zoomstack |
---|
1262 | catch {Blt_ZoomStack $graph(plot)} |
---|
1263 | catch {$graph(plot) xaxis config -min $xmin -max $xmax} |
---|
1264 | catch {$graph(plot) yaxis config -min $ymin -max $ymax} |
---|
1265 | } |
---|
1266 | |
---|
1267 | # code to create the EXCLEDT box |
---|
1268 | proc ShowExcl {} { |
---|
1269 | global graph peakinfo expgui expmap |
---|
1270 | # save the starting number of cycles & starting point |
---|
1271 | set cycsav [expinfo cycles] |
---|
1272 | set startchanges $expgui(changed) |
---|
1273 | set graph(hst) [lindex $expgui(curhist) 0] |
---|
1274 | if {[llength $expgui(curhist)] == 0} { |
---|
1275 | set graph(hst) [lindex $expmap(powderlist) 0] |
---|
1276 | } else { |
---|
1277 | set graph(hst) [lindex $expmap(powderlist) $graph(hst)] |
---|
1278 | } |
---|
1279 | set graph(exclbox) .excl |
---|
1280 | catch {toplevel $graph(exclbox)} |
---|
1281 | wm title $graph(exclbox) "Excluded Region/Data Range Edit" |
---|
1282 | eval destroy [winfo children $graph(exclbox)] |
---|
1283 | # create the graph |
---|
1284 | if [catch { |
---|
1285 | set graph(plot) [graph $graph(exclbox).g -plotbackground white] |
---|
1286 | } errmsg] { |
---|
1287 | MyMessageBox -parent . -title "BLT Error" \ |
---|
1288 | -message "BLT Setup Error: could not create a graph \ |
---|
1289 | (error msg: $errmsg). \ |
---|
1290 | There is a problem with the setup of BLT on your system. \ |
---|
1291 | See the expgui.html file for more info." \ |
---|
1292 | -helplink "expgui.html blt" \ |
---|
1293 | -icon warning -type Skip -default "skip" |
---|
1294 | destroy $graph(exclbox) |
---|
1295 | return |
---|
1296 | } |
---|
1297 | if [catch { |
---|
1298 | Blt_ZoomStack $graph(plot) |
---|
1299 | } errmsg] { |
---|
1300 | MyMessageBox -parent . -title "BLT Error" \ |
---|
1301 | -message "BLT Setup Error: could not access a Blt_ routine \ |
---|
1302 | (msg: $errmsg). \ |
---|
1303 | The pkgIndex.tcl is probably not loading bltGraph.tcl. |
---|
1304 | See the expgui.html file for more info." \ |
---|
1305 | -helplink "expgui.html blt" \ |
---|
1306 | -icon warning -type {"Limp Ahead"} -default "limp Ahead" |
---|
1307 | } |
---|
1308 | $graph(plot) element create 3 -color black -linewidth 0 -label Obs \ |
---|
1309 | -symbol $peakinfo(obssym) -color $graph(color_obs) \ |
---|
1310 | -pixels [expr 0.125 * $peakinfo(obssize)]i |
---|
1311 | $graph(plot) element create 2 -label Calc -color $graph(color_calc) \ |
---|
1312 | -symbol none |
---|
1313 | $graph(plot) element create 12 -line 0 -label "Excl" \ |
---|
1314 | -color $graph(color_excl) \ |
---|
1315 | -symbol $peakinfo(exclsym) \ |
---|
1316 | -pixels [expr 0.15 * $peakinfo(exclsize)]i |
---|
1317 | $graph(plot) element show "3 2 12 1" |
---|
1318 | $graph(plot) element config 3 -xdata xvec -ydata obsvec |
---|
1319 | $graph(plot) element config 2 -xdata xvec -ydata calcvec |
---|
1320 | $graph(plot) element config 12 -xdata exxvec -ydata exobsvec |
---|
1321 | |
---|
1322 | $graph(plot) yaxis config -title {} |
---|
1323 | setlegend $graph(plot) $graph(legend) |
---|
1324 | |
---|
1325 | set graph(exclmenu) [frame $graph(exclbox).a -bd 3 -relief groove] |
---|
1326 | pack [menubutton $graph(exclmenu).file -text File -underline 0 \ |
---|
1327 | -menu $graph(exclmenu).file.menu] -side left |
---|
1328 | menu $graph(exclmenu).file.menu |
---|
1329 | $graph(exclmenu).file.menu add cascade -label Tickmarks \ |
---|
1330 | -menu $graph(exclmenu).file.menu.tick |
---|
1331 | menu $graph(exclmenu).file.menu.tick |
---|
1332 | foreach num {1 2 3 4 5 6 7 8 9} { |
---|
1333 | $graph(exclmenu).file.menu.tick add checkbutton -label "Phase $num" \ |
---|
1334 | -variable peakinfo(flag$num) |
---|
1335 | } |
---|
1336 | $graph(exclmenu).file.menu add cascade -label Histogram \ |
---|
1337 | -menu $graph(exclmenu).file.menu.hist -state disabled |
---|
1338 | |
---|
1339 | $graph(exclmenu).file.menu add command \ |
---|
1340 | -label "Set Min/Max Range" -command setminormax |
---|
1341 | $graph(exclmenu).file.menu add command \ |
---|
1342 | -label "Update Plot" -command "CheckChanges $startchanges;updateplot" |
---|
1343 | $graph(exclmenu).file.menu add command \ |
---|
1344 | -label "Make PostScript" -command makepostscriptout |
---|
1345 | $graph(exclmenu).file.menu add command \ |
---|
1346 | -label Finish -command "CheckChanges $startchanges;destroy $graph(exclbox)" |
---|
1347 | |
---|
1348 | pack [menubutton $graph(exclmenu).options -text Options -underline 0 \ |
---|
1349 | -menu $graph(exclmenu).options.menu] \ |
---|
1350 | -side left |
---|
1351 | menu $graph(exclmenu).options.menu |
---|
1352 | $graph(exclmenu).options.menu add cascade -label "Configure Tickmarks" \ |
---|
1353 | -menu $graph(exclmenu).options.menu.tick |
---|
1354 | menu $graph(exclmenu).options.menu.tick |
---|
1355 | $graph(exclmenu).options.menu.tick add radiobutton \ |
---|
1356 | -label "Manual Placement" \ |
---|
1357 | -value 0 -variable expgui(autotick) -command plotExclData |
---|
1358 | $graph(exclmenu).options.menu.tick add radiobutton \ |
---|
1359 | -label "Auto locate" \ |
---|
1360 | -value 1 -variable expgui(autotick) -command plotExclData |
---|
1361 | $graph(exclmenu).options.menu.tick add separator |
---|
1362 | foreach num {1 2 3 4 5 6 7 8 9} { |
---|
1363 | $graph(exclmenu).options.menu.tick add command -label "Phase $num" \ |
---|
1364 | -command "minioptionsbox $num" |
---|
1365 | } |
---|
1366 | $graph(exclmenu).options.menu add cascade -label "Symbol Type" \ |
---|
1367 | -menu $graph(exclmenu).options.menu.sym |
---|
1368 | menu $graph(exclmenu).options.menu.sym |
---|
1369 | foreach var {excl obs} lbl {Excluded Observed} { |
---|
1370 | $graph(exclmenu).options.menu.sym add command -label $lbl \ |
---|
1371 | -command "getsymopts $var" |
---|
1372 | } |
---|
1373 | |
---|
1374 | $graph(exclmenu).options.menu add cascade -label "Symbol color" \ |
---|
1375 | -menu $graph(exclmenu).options.menu.color |
---|
1376 | menu $graph(exclmenu).options.menu.color |
---|
1377 | foreach var {excl calc obs} lbl {Excluded Calculated Observed} { |
---|
1378 | $graph(exclmenu).options.menu.color add command -label $lbl \ |
---|
1379 | -command "set graph(color_$var) \[tk_chooseColor -initialcolor \$graph(color_$var) -title \"Choose \$lbl color\"]; plotExclData" |
---|
1380 | } |
---|
1381 | $graph(exclmenu).options.menu add cascade -label "X units" \ |
---|
1382 | -menu $graph(exclmenu).options.menu.xunits |
---|
1383 | menu $graph(exclmenu).options.menu.xunits |
---|
1384 | $graph(exclmenu).options.menu.xunits add radiobutton \ |
---|
1385 | -label "As collected" \ |
---|
1386 | -variable graph(xunits) -value 0 \ |
---|
1387 | -command updateplot |
---|
1388 | $graph(exclmenu).options.menu.xunits add radiobutton -label "d-space" \ |
---|
1389 | -variable graph(xunits) -value 1 \ |
---|
1390 | -command updateplot |
---|
1391 | $graph(exclmenu).options.menu.xunits add radiobutton -label "Q" \ |
---|
1392 | -variable graph(xunits) -value 2 \ |
---|
1393 | -command updateplot |
---|
1394 | |
---|
1395 | $graph(exclmenu).options.menu add checkbutton -label "Include legend" \ |
---|
1396 | -variable graph(legend) \ |
---|
1397 | -command {setlegend $graph(plot) $graph(legend)} |
---|
1398 | $graph(exclmenu).options.menu add checkbutton -label "Prompt on add/del" \ |
---|
1399 | -variable graph(exclPrompt) |
---|
1400 | $graph(exclmenu).options.menu add command -label "Set PS output" \ |
---|
1401 | -command setpostscriptout |
---|
1402 | |
---|
1403 | set graph(bbox) [set bb $graph(exclbox).b] |
---|
1404 | catch {pack [frame $bb -bd 3 -relief sunken] -side bottom -fill both} |
---|
1405 | grid [label $bb.top -text "Excluded Region Editing"] \ |
---|
1406 | -col 0 -row 0 -columnspan 4 |
---|
1407 | grid [button $bb.help -text Help -bg yellow \ |
---|
1408 | -command "MakeWWWHelp excledt.html"] \ |
---|
1409 | -column 5 -row 0 -rowspan 1 -sticky ne |
---|
1410 | |
---|
1411 | grid [frame $bb.l -bd 3 -relief groove] \ |
---|
1412 | -col 0 -row 1 -columnspan 2 -sticky nse |
---|
1413 | grid [label $bb.l.1 -text "Mouse click\naction"] -col 0 -row 0 |
---|
1414 | foreach c {1 2 3} l {zoom "Add\nregion" "Delete\nregion"} { |
---|
1415 | grid [button $graph(bbox).l.b$c -text $l -command "exclEditMode $c $bb"] \ |
---|
1416 | -col $c -row 0 -sticky ns |
---|
1417 | } |
---|
1418 | exclEditMode 1 $bb |
---|
1419 | |
---|
1420 | grid [frame $bb.bl] \ |
---|
1421 | -col 0 -row 3 -rowspan 2 -sticky nsew |
---|
1422 | grid [label $graph(bbox).bl.1 -text "Excluded\nRegions"] -col 0 -row 0 |
---|
1423 | grid [canvas [set graph(ExclCanvas) $bb.bc] \ |
---|
1424 | -scrollregion {0 0 5000 500} -width 0 -height 0 \ |
---|
1425 | -xscrollcommand "$bb.bs set"] \ |
---|
1426 | -column 1 -row 3 -columnspan 5 -sticky nsew |
---|
1427 | grid [scrollbar [set graph(ExclScroll) $bb.bs] -command "$bb.bc xview" \ |
---|
1428 | -orient horizontal] \ |
---|
1429 | -column 1 -row 4 -columnspan 5 -sticky nsew |
---|
1430 | grid [button $bb.cw -text "Save &\nFinish" \ |
---|
1431 | -command "CheckChanges $startchanges;destroy $graph(exclbox)"] \ |
---|
1432 | -col 4 -row 1 -columnspan 2 -sticky ns |
---|
1433 | |
---|
1434 | grid columnconfigure $bb 1 -weight 1 |
---|
1435 | grid columnconfigure $bb 5 -weight 1 |
---|
1436 | grid rowconfigure $bb 3 -weight 1 |
---|
1437 | grid rowconfigure $bb 5 -weight 1 |
---|
1438 | |
---|
1439 | pack $graph(exclmenu) -side top -fill both |
---|
1440 | pack $graph(plot) -fill both -expand yes |
---|
1441 | |
---|
1442 | # fill the histogram menu |
---|
1443 | if {[llength $expmap(powderlist)] > 15} { |
---|
1444 | set expgui(plotlist) {} |
---|
1445 | $graph(exclmenu).file.menu entryconfigure Histogram -state normal |
---|
1446 | menu $graph(exclmenu).file.menu.hist |
---|
1447 | set i 0 |
---|
1448 | foreach num [lsort -integer $expmap(powderlist)] { |
---|
1449 | incr i |
---|
1450 | lappend expgui(plotlist) $num |
---|
1451 | if {$i == 1} { |
---|
1452 | set num1 $num |
---|
1453 | menu $graph(exclmenu).file.menu.hist.$num1 |
---|
1454 | } |
---|
1455 | $graph(exclmenu).file.menu.hist.$num1 add radiobutton \ |
---|
1456 | -label $num -value $num \ |
---|
1457 | -variable graph(hst) \ |
---|
1458 | -command updateplot |
---|
1459 | if {$i >= 10} { |
---|
1460 | set i 0 |
---|
1461 | $graph(exclmenu).file.menu.hist add cascade \ |
---|
1462 | -label "$num1-$num" \ |
---|
1463 | -menu $graph(exclmenu).file.menu.hist.$num1 |
---|
1464 | } |
---|
1465 | } |
---|
1466 | if {$i != 0} { |
---|
1467 | $graph(exclmenu).file.menu.hist add cascade \ |
---|
1468 | -label "$num1-$num" \ |
---|
1469 | -menu $graph(exclmenu).file.menu.hist.$num1 |
---|
1470 | } |
---|
1471 | } elseif {[llength $expmap(powderlist)] > 1} { |
---|
1472 | $graph(exclmenu).file.menu entryconfigure Histogram -state normal |
---|
1473 | menu $graph(exclmenu).file.menu.hist |
---|
1474 | set i 0 |
---|
1475 | foreach num [lsort -integer $expmap(powderlist)] { |
---|
1476 | foreach num [lsort -integer $expmap(powderlist)] { |
---|
1477 | lappend expgui(plotlist) $num |
---|
1478 | $graph(exclmenu).file.menu.hist add radiobutton \ |
---|
1479 | -label $num -value $num \ |
---|
1480 | -variable graph(hst) \ |
---|
1481 | -command updateplot |
---|
1482 | } |
---|
1483 | } |
---|
1484 | } else { |
---|
1485 | set expgui(plotlist) [lindex $expmap(powderlist) 0] |
---|
1486 | } |
---|
1487 | |
---|
1488 | # N = load next histogram |
---|
1489 | bind $graph(exclbox) <Key-n> { |
---|
1490 | global expgui graph |
---|
1491 | set i [lsearch $expgui(plotlist) $graph(hst)] |
---|
1492 | incr i |
---|
1493 | if {$i >= [llength $expgui(plotlist)]} {set i 0} |
---|
1494 | set graph(hst) [lindex $expgui(plotlist) $i] |
---|
1495 | updateplot |
---|
1496 | } |
---|
1497 | bind $graph(exclbox) <Key-N> { |
---|
1498 | global expgui graph |
---|
1499 | set i [lsearch $expgui(plotlist) $graph(hst)] |
---|
1500 | incr i |
---|
1501 | if {$i >= [llength $expgui(plotlist)]} {set i 0} |
---|
1502 | set graph(hst) [lindex $expgui(plotlist) $i] |
---|
1503 | set cycle [getcycle];readdata .g |
---|
1504 | } |
---|
1505 | bind $graph(exclbox) <Key-z> {BLTmanualZoom} |
---|
1506 | bind $graph(exclbox) <Key-Z> {BLTmanualZoom} |
---|
1507 | updateplot |
---|
1508 | trace variable peakinfo w plotExclData |
---|
1509 | |
---|
1510 | # catch exits -- launch POWPREF; if changes non-zero |
---|
1511 | wm protocol $graph(exclbox) WM_DELETE_WINDOW "CheckChanges $startchanges;destroy $graph(exclbox)" |
---|
1512 | # respond to resize events |
---|
1513 | bind $graph(exclbox) <Configure> scheduleFillExclRegionBox |
---|
1514 | bind all <Control-KeyPress-c> "CheckChanges $startchanges;destroy $graph(exclbox)" |
---|
1515 | putontop $graph(exclbox) |
---|
1516 | wm deiconify $graph(exclbox) |
---|
1517 | tkwait window $graph(exclbox) |
---|
1518 | afterputontop |
---|
1519 | bind all <Control-c> catchQuit |
---|
1520 | # reset the number of cycles if they have changed |
---|
1521 | if {$cycsav != [expinfo cycles]} { |
---|
1522 | global entryvar |
---|
1523 | set entryvar(cycles) $cycsav |
---|
1524 | } |
---|
1525 | } |
---|
1526 | |
---|
1527 | proc SetDummyRangeBox {hst tmin tmax tstep} { |
---|
1528 | global newhist expmap |
---|
1529 | if {[histinfo $hst dtype] != "CONST"} { |
---|
1530 | MyMessageBox -parent $np -title "Change Range Error" \ |
---|
1531 | -message "This histogram (#$hst) does not have constant steps. The range must be changed in EXPEDT." \ |
---|
1532 | -icon error -type ok -default ok \ |
---|
1533 | -helplink "excledt.html editdummy" |
---|
1534 | return |
---|
1535 | } |
---|
1536 | catch {toplevel [set np ".dummy"]} |
---|
1537 | wm title $np "Dummy Histogram Range" |
---|
1538 | eval destroy [winfo children $np] |
---|
1539 | # delete old traces, if any |
---|
1540 | foreach var {tmin tmax tstep} { |
---|
1541 | foreach v [ trace vinfo newhist($var)] { |
---|
1542 | eval trace vdelete newhist($var) $v |
---|
1543 | } |
---|
1544 | } |
---|
1545 | # set defaults to current values |
---|
1546 | foreach v {tmin tmax tstep} {set newhist($v) [set $v]} |
---|
1547 | trace variable newhist(tmin) w "ValidateDummyRange $np $hst" |
---|
1548 | trace variable newhist(tmax) w "ValidateDummyRange $np $hst" |
---|
1549 | trace variable newhist(tstep) w "ValidateDummyRange $np $hst" |
---|
1550 | pack [frame $np.d1] |
---|
1551 | grid [label $np.d1.l1 -text min] -col 1 -row 1 |
---|
1552 | grid [label $np.d1.l2 -text max] -col 2 -row 1 |
---|
1553 | grid [label $np.d1.l3 -text step] -col 3 -row 1 |
---|
1554 | grid [label $np.d1.lu -text ""] -col 4 -row 1 -rowspan 2 |
---|
1555 | grid [entry $np.d1.e1 -width 10 -textvariable newhist(tmin)] -col 1 -row 2 |
---|
1556 | grid [entry $np.d1.e2 -width 10 -textvariable newhist(tmax)] -col 2 -row 2 |
---|
1557 | grid [entry $np.d1.e3 -width 10 -textvariable newhist(tstep)] -col 3 -row 2 |
---|
1558 | grid [label $np.d1.m1 -anchor w -padx 5] -col 1 -row 3 -sticky ew |
---|
1559 | grid [label $np.d1.m2 -anchor w -padx 5] -col 2 -row 3 -sticky ew |
---|
1560 | label $np.dl1 -text "Data range:" |
---|
1561 | label $np.dl2 -text "Allowed" |
---|
1562 | label $np.dl3 -text "\n" -justify left -fg blue |
---|
1563 | grid [frame $np.f6] -column 0 -row 99 -columnspan 5 -sticky ew |
---|
1564 | grid [button $np.f6.b6a -text Set \ |
---|
1565 | -command "SetDummyRange $np $hst"] -column 0 -row 0 |
---|
1566 | bind $np <Return> "SetDummyRange $np $hst" |
---|
1567 | grid [button $np.f6.b6b -text Cancel \ |
---|
1568 | -command "destroy $np"] -column 1 -row 0 |
---|
1569 | set link "excledt.html editdummy" |
---|
1570 | bind $np <Key-F1> "MakeWWWHelp $link" |
---|
1571 | grid [button $np.f6.help -text Help -bg yellow \ |
---|
1572 | -command "MakeWWWHelp $link"] \ |
---|
1573 | -column 2 -row 0 -sticky e |
---|
1574 | grid columnconfigure $np.f6 2 -weight 1 |
---|
1575 | |
---|
1576 | $np.d1.m1 config -text {} |
---|
1577 | $np.d1.m2 config -text {} |
---|
1578 | grid $np.dl1 -column 0 -row 8 |
---|
1579 | grid $np.d1 -column 1 -row 8 -rowspan 2 -columnspan 4 -sticky e |
---|
1580 | grid $np.dl3 -column 0 -columnspan 99 -row 10 -sticky ew |
---|
1581 | grid [label $np.l1 -text "Set range for dummy histogram $hst" \ |
---|
1582 | -justify center -anchor center -bg beige] \ |
---|
1583 | -row 0 -column 0 -columnspan 5 -sticky ew |
---|
1584 | if {[string range $expmap(htype_$hst) 2 2] == "T"} { |
---|
1585 | $np.dl1 config -text "Data range:\n(TOF)" |
---|
1586 | $np.d1.lu config -text millisec |
---|
1587 | grid $np.dl2 -column 0 -row 9 |
---|
1588 | catch { |
---|
1589 | set line [histinfo $hst ITYP] |
---|
1590 | $np.d1.m1 config -text [lindex $line 1] |
---|
1591 | $np.d1.m2 config -text [lindex $line 2] |
---|
1592 | } |
---|
1593 | } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { |
---|
1594 | $np.dl1 config -text "Data range:\n(2Theta)" |
---|
1595 | $np.d1.lu config -text degrees |
---|
1596 | $np.d1.m1 config -text >0. |
---|
1597 | $np.d1.m2 config -text <180. |
---|
1598 | } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { |
---|
1599 | $np.dl1 config -text "Data range:\n(Energy)" |
---|
1600 | $np.d1.lu config -text KeV |
---|
1601 | $np.d1.m1 config -text 1. |
---|
1602 | $np.d1.m2 config -text 200. |
---|
1603 | grid $np.dl2 -column 0 -row 9 |
---|
1604 | } |
---|
1605 | ValidateDummyRange $np $hst |
---|
1606 | putontop $np |
---|
1607 | grab $np |
---|
1608 | tkwait window $np |
---|
1609 | afterputontop |
---|
1610 | } |
---|
1611 | |
---|
1612 | proc ValidateDummyRange {np hst args} { |
---|
1613 | # validate input |
---|
1614 | global newhist expmap |
---|
1615 | set msg {} |
---|
1616 | $np.dl3 config -text "\n" |
---|
1617 | foreach e {e1 e2 e3} v {tmin tmax tstep} { |
---|
1618 | if [catch {expr $newhist($v)}] { |
---|
1619 | $np.d1.$e config -fg red |
---|
1620 | append msg "Value of $newhist($v) is invalid for $v\n" |
---|
1621 | } else { |
---|
1622 | $np.d1.$e config -fg black |
---|
1623 | } |
---|
1624 | } |
---|
1625 | if {$newhist(tmax) <= $newhist(tmin)} { |
---|
1626 | $np.d1.e1 config -fg red |
---|
1627 | $np.d1.e2 config -fg red |
---|
1628 | return "Tmax <= Tmin\n" |
---|
1629 | } |
---|
1630 | |
---|
1631 | |
---|
1632 | set dmin -1 |
---|
1633 | set dmax -1 |
---|
1634 | if {[string range $expmap(htype_$hst) 2 2] == "T"} { |
---|
1635 | catch { |
---|
1636 | set line [histinfo $hst ITYP] |
---|
1637 | set tmin [lindex $line 1] |
---|
1638 | set tmax [lindex $line 2] |
---|
1639 | if {$newhist(tmin) <$tmin } { |
---|
1640 | $np.d1.e1 config -fg red |
---|
1641 | append msg "Min value of $newhist(tmin) msec is invalid.\n" |
---|
1642 | } |
---|
1643 | if {$newhist(tmax) >$tmax } { |
---|
1644 | $np.d1.e2 config -fg red |
---|
1645 | append msg "Max value of $newhist(tmax) msec is invalid.\n" |
---|
1646 | } |
---|
1647 | set difc [histinfo $hst difc] |
---|
1648 | set dmin [expr {1000. * $newhist(tmin) / $difc}] |
---|
1649 | set dmax [expr {1000. * $newhist(tmax) / $difc}] |
---|
1650 | } |
---|
1651 | } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { |
---|
1652 | if {$newhist(tmin) <= 0 } { |
---|
1653 | $np.d1.e1 config -fg red |
---|
1654 | append msg "Min value of $newhist(tmin) degrees is invalid.\n" |
---|
1655 | } |
---|
1656 | if {$newhist(tmax) >=180 } { |
---|
1657 | $np.d1.e2 config -fg red |
---|
1658 | append msg "Max value of $newhist(tmax) degrees is invalid.\n" |
---|
1659 | } |
---|
1660 | catch { |
---|
1661 | set lam [histinfo $hst lam1] |
---|
1662 | set dmin [expr {$lam * 0.5 / sin(acos(0.)*$newhist(tmax)/180.)}] |
---|
1663 | set dmax [expr {$lam * 0.5 / sin(acos(0.)*$newhist(tmin)/180.)}] |
---|
1664 | } |
---|
1665 | } else { |
---|
1666 | if {$newhist(tmin) <1 } { |
---|
1667 | $np.d1.e1 config -fg red |
---|
1668 | append msg "Min value of $newhist(tmin) KeV is invalid.\n" |
---|
1669 | } |
---|
1670 | if {$newhist(tmax) >200 } { |
---|
1671 | $np.d1.e2 config -fg red |
---|
1672 | append msg "Max value of $newhist(tmax) KeV is invalid.\n" |
---|
1673 | } |
---|
1674 | catch { |
---|
1675 | set ang [histinfo $hst lam1] |
---|
1676 | set dmin [expr {12.398/ (2.0*sin($ang*acos(0.)/180) * \ |
---|
1677 | $newhist(tmax))}] |
---|
1678 | set dmax [expr {12.398/ (2.0*sin($ang*acos(0.)/180) * \ |
---|
1679 | $newhist(tmin))}] |
---|
1680 | } |
---|
1681 | } |
---|
1682 | if {$msg != ""} {return $msg} |
---|
1683 | set pnts -1 |
---|
1684 | catch { |
---|
1685 | set pnts [expr {1+int(($newhist(tmax) - $newhist(tmin))/$newhist(tstep))}] |
---|
1686 | set qmin [expr {4.*acos(0)/$dmax}] |
---|
1687 | set qmax [expr {4.*acos(0)/$dmin}] |
---|
1688 | } |
---|
1689 | if {$pnts <= 0} { |
---|
1690 | $np.d1.e3 config -fg red |
---|
1691 | append msg "Step value of $newhist(tstep) is invalid.\n" |
---|
1692 | } |
---|
1693 | if {$pnts >20000} { |
---|
1694 | $np.d1.e3 config -fg red |
---|
1695 | append msg "Step value of $newhist(tstep) is too small (>20000 points).\n" |
---|
1696 | } |
---|
1697 | if {$msg != ""} {return $msg} |
---|
1698 | if {$dmin > 0 && $dmax > 0} { |
---|
1699 | catch { |
---|
1700 | set msg [format \ |
---|
1701 | " %d points.%s D-space range: %.2f-%.2f \xc5, Q: %.2f-%.2f/\xc5" \ |
---|
1702 | $pnts "\n" $dmin $dmax $qmin $qmax] |
---|
1703 | $np.dl3 config -text $msg |
---|
1704 | } |
---|
1705 | } |
---|
1706 | if {$msg != ""} {return ""} |
---|
1707 | $np.dl3 config -text [format { %d points.%s Range: ?} $pnts "\n"] |
---|
1708 | return "Invalid data range -- something is wrong!" |
---|
1709 | } |
---|
1710 | |
---|
1711 | proc SetDummyRange {np hst} { |
---|
1712 | global newhist expmap |
---|
1713 | # validate last time |
---|
1714 | set msg [ValidateDummyRange $np $hst] |
---|
1715 | if {$msg != ""} { |
---|
1716 | MyMessageBox -parent $np -title "Change Range Error" \ |
---|
1717 | -message "The following error(s) were found in your input:\n$msg" \ |
---|
1718 | -icon error -type ok -default ok \ |
---|
1719 | -helplink "excledt.html editdummy" |
---|
1720 | return |
---|
1721 | } |
---|
1722 | set pnts [expr {1+int(($newhist(tmax) - $newhist(tmin))/$newhist(tstep))}] |
---|
1723 | |
---|
1724 | if {[string range $expmap(htype_$hst) 2 2] == "T"} { |
---|
1725 | lappend exclist "0 [expr {$newhist(tmin)-$newhist(tstep)}]" \ |
---|
1726 | "[expr {$newhist(tmax)+$newhist(tstep)}] 1000." |
---|
1727 | histinfo $hst excl set $exclist |
---|
1728 | histinfo $hst dpoints set $pnts |
---|
1729 | histinfo $hst dstart set [expr {$newhist(tmin)*1000.}] |
---|
1730 | histinfo $hst dstep set [expr {$newhist(tstep)*1000.}] |
---|
1731 | histinfo $hst dmin set [tod $newhist(tmin) $hst] |
---|
1732 | } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { |
---|
1733 | lappend exclist "0 [expr {$newhist(tmin)-$newhist(tstep)}]" \ |
---|
1734 | "[expr {$newhist(tmax)+$newhist(tstep)}] 1000." |
---|
1735 | histinfo $hst excl set $exclist |
---|
1736 | histinfo $hst dpoints set $pnts |
---|
1737 | histinfo $hst dstart set [expr {$newhist(tmin)*100.}] |
---|
1738 | histinfo $hst dstep set [expr {$newhist(tstep)*100.}] |
---|
1739 | histinfo $hst dmin set [tod $newhist(tmax) $hst] |
---|
1740 | } else { |
---|
1741 | lappend exclist "0 [expr {$newhist(tmin)-$newhist(tstep)}]" \ |
---|
1742 | "[expr {$newhist(tmax)+$newhist(tstep)}] 1000." |
---|
1743 | histinfo $hst excl set $exclist |
---|
1744 | histinfo $hst dpoints set $pnts |
---|
1745 | histinfo $hst dstart set $newhist(tmin) |
---|
1746 | histinfo $hst dstep set $newhist(tstep) |
---|
1747 | histinfo $hst dmin set [tod $newhist(tmax) $hst] |
---|
1748 | } |
---|
1749 | global expgui |
---|
1750 | incr expgui(changed) 5 |
---|
1751 | destroy $np |
---|
1752 | updateplot |
---|
1753 | } |
---|
1754 | |
---|
1755 | # set the minimum tof/d-space using the EXPEDT program |
---|
1756 | proc SetTminTOF {tmin parent} { |
---|
1757 | global expgui reflns graph tcl_platform |
---|
1758 | set hst $graph(hst) |
---|
1759 | set input [open excl$hst.inp w] |
---|
1760 | puts $input "Y" |
---|
1761 | puts $input "p h e $hst" |
---|
1762 | puts $input "T" |
---|
1763 | puts $input "$tmin" |
---|
1764 | puts $input "/" |
---|
1765 | puts $input "x x x" |
---|
1766 | puts $input "x" |
---|
1767 | close $input |
---|
1768 | # Save the current exp file |
---|
1769 | savearchiveexp |
---|
1770 | # disable the file changed monitor |
---|
1771 | set expgui(expModifiedLast) 0 |
---|
1772 | set expnam [file root [file tail $expgui(expfile)]] |
---|
1773 | set err [catch { |
---|
1774 | if {$tcl_platform(platform) == "windows"} { |
---|
1775 | exec [file join $expgui(gsasexe) expedt.exe] $expnam < excl$hst.inp >& excl$hst.out |
---|
1776 | } else { |
---|
1777 | exec [file join $expgui(gsasexe) expedt] $expnam < excl$hst.inp >& excl$hst.out |
---|
1778 | } |
---|
1779 | } errmsg] |
---|
1780 | loadexp $expgui(expfile) |
---|
1781 | catch {file delete excl$hst.inp} |
---|
1782 | if {$expgui(showexptool) || $err} { |
---|
1783 | set fp [open excl$hst.out r] |
---|
1784 | set out [read $fp] |
---|
1785 | close $fp |
---|
1786 | if {$errmsg != ""} { |
---|
1787 | append errmsg "\n" $out |
---|
1788 | } else { |
---|
1789 | set errmsg $out |
---|
1790 | } |
---|
1791 | set msg "Please review the result from changing the TOF minimum." |
---|
1792 | if {$err} {append msg "\nIt appears an error occurred!"} |
---|
1793 | ShowBigMessage $parent.msg $msg $errmsg OK "" $err |
---|
1794 | } |
---|
1795 | } |
---|