Changeset 666
- Timestamp:
- Dec 4, 2009 5:09:59 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/excledt.tcl
- Property rcs:date changed from 2002/07/18 20:50:04 to 2003/04/10 21:55:15
- Property rcs:lines changed from +25 -15 to +180 -374
- Property rcs:rev changed from 1.8 to 1.9
r630 r666 1 1 # $Id$ 2 2 3 # create the main Excluded Region window 3 4 proc ExclReaddata {box} { 4 5 global expgui … … 24 25 } 25 26 27 # get the data to plot using hstdump (tcldump does not show the excluded data) 26 28 proc ExclReaddata_hst {box} { 27 29 global expgui reflns graph … … 39 41 # use hstdmp without an experiment name so that output 40 42 # is not sent to the .LST file 41 exec $expgui(gsasexe)/hstdmp< excl$hst.inp > excl$hst.out43 exec [file join $expgui(gsasexe) hstdmp] < excl$hst.inp > excl$hst.out 42 44 set input [open excl$hst.out r] 43 45 catch {file delete excl$hst.inp} … … 127 129 } 128 130 } 129 plotdata 130 } 131 132 # convert x values to d-space 133 proc tod {xlist hst} { 134 global expmap 135 if {[string range $expmap(htype_$hst) 2 2] == "T"} { 136 return [toftod $xlist $hst] 137 } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { 138 return [tttod $xlist $hst] 139 } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { 140 return [engtod $xlist $hst] 141 } else { 142 return {} 143 } 144 } 145 146 # convert tof to d-space 147 proc toftod {toflist hst} { 148 set difc [expr {[histinfo $hst difc]/1000.}] 149 set difc2 [expr {$difc*$difc}] 150 set difa [expr {[histinfo $hst difa]/1000.}] 151 set zero [expr {[histinfo $hst zero]/1000.}] 152 set ans {} 153 foreach tof $toflist { 154 if {$tof == 0.} { 155 lappend ans 0. 156 } elseif {$tof == 1000.} { 157 lappend ans 1000. 158 } else { 159 set td [expr {$tof-$zero}] 160 lappend ans [expr {$td*($difc2+$difa*$td)/ \ 161 ($difc2*$difc+2.0*$difa*$td)}] 162 } 163 } 164 return $ans 165 } 166 167 # convert two-theta to d-space 168 proc tttod {twotheta hst} { 169 set lamo2 [expr {0.5 * [histinfo $hst lam1]}] 170 set zero [expr [histinfo $hst zero]/100.] 171 set ans {} 172 set cnv [expr {acos(0.)/180.}] 173 foreach tt $twotheta { 174 if {$tt == 0.} { 175 lappend ans 99999. 176 } elseif {$tt == 1000.} { 177 lappend ans 0. 178 } else { 179 lappend ans [expr {$lamo2 / sin($cnv*($tt-$zero))}] 180 } 181 } 182 return $ans 183 } 184 185 # convert energy (edx-ray) to d-space 186 # (note that this ignores the zero correction) 187 proc engtod {eng hst} { 188 set lam [histinfo $hst lam1] 189 set zero [histinfo $hst zero] 190 set ans {} 191 set v [expr {12.398/(2.0*[sind[expr ($lam/2.0)]])}] 192 foreach e $eng { 193 if {$e == 0.} { 194 lappend ans 1000. 195 } elseif {$e == 1000.} { 196 lappend ans 0. 197 } else { 198 lappend ans [expr {$v/$e}] 199 } 200 } 201 return $ans 202 } 203 204 # convert x values to Q 205 proc toQ {xlist hst} { 206 global expmap 207 if {[string range $expmap(htype_$hst) 2 2] == "T"} { 208 return [toftoQ $xlist $hst] 209 } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { 210 return [tttoQ $xlist $hst] 211 } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { 212 return [engtoQ $xlist $hst] 213 } else { 214 return {} 215 } 216 } 217 # convert tof to Q 218 proc toftoQ {toflist hst} { 219 set difc [expr {[histinfo $hst difc]/1000.}] 220 set difc2 [expr {$difc*$difc}] 221 set difa [expr {[histinfo $hst difa]/1000.}] 222 set zero [expr {[histinfo $hst zero]/1000.}] 223 set 2pi [expr {4.*acos(0.)}] 224 set ans {} 225 foreach tof $toflist { 226 if {$tof == 0.} { 227 lappend ans 99999. 228 } elseif {$tof == 1000.} { 229 lappend ans 0. 230 } else { 231 set td [expr {$tof-$zero}] 232 lappend ans [expr {$2pi * \ 233 ($difc2*$difc+2.0*$difa*$td)/($td*($difc2+$difa*$td))}] 234 } 235 } 236 return $ans 237 } 238 239 # convert two-theta to Q 240 proc tttoQ {twotheta hst} { 241 set lamo2 [expr {0.5 * [histinfo $hst lam1]}] 242 set zero [expr [histinfo $hst zero]/100.] 243 set ans {} 244 set cnv [expr {acos(0.)/180.}] 245 set 2pi [expr {4.*acos(0.)}] 246 foreach tt $twotheta { 247 if {$tt == 0.} { 248 lappend ans 0. 249 } elseif {$tt == 1000.} { 250 lappend ans 1000. 251 } else { 252 lappend ans [expr {$2pi * sin($cnv*($tt-$zero)) / $lamo2}] 253 } 254 } 255 return $ans 256 } 257 # convert energy (edx-ray) to Q 258 # (note that this ignores the zero correction) 259 proc engtoQ {eng hst} { 260 set lam [histinfo $hst lam1] 261 set zero [histinfo $hst zero] 262 set ans {} 263 set v [expr {12.398/(2.0*[sind[expr ($lam/2.0)]])}] 264 set 2pi [expr {4.*acos(0.)}] 265 foreach e $eng { 266 if {$e == 0.} { 267 lappend ans 0. 268 } elseif {$e == 1000.} { 269 lappend ans 1000. 270 } else { 271 lappend ans [expr {$2pi * $e / $v}] 272 } 273 } 274 return $ans 275 } 276 proc sind {angle} { 277 return [expr {sin($angle*acos(0.)/90.)}] 278 } 279 280 # convert d-space values to 2theta, TOF or KeV 281 proc fromd {dlist hst} { 282 global expmap 283 if {[string range $expmap(htype_$hst) 2 2] == "T"} { 284 set difc [expr {[histinfo $hst difc]/1000.}] 285 set difa [expr {[histinfo $hst difa]/1000.}] 286 set zero [expr {[histinfo $hst zero]/1000.}] 287 set ans {} 288 foreach d $dlist { 289 if {$d == 0.} { 290 lappend ans 0. 291 } elseif {$d == 1000.} { 292 lappend ans 1000. 293 } else { 294 lappend ans [expr {$difc*$d + $difa*$d*$d + $zero}] 295 } 296 } 297 return $ans 298 } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { 299 set lamo2 [expr {0.5 * [histinfo $hst lam1]}] 300 set zero [expr [histinfo $hst zero]/100.] 301 set ans {} 302 set cnv [expr {180./acos(0.)}] 303 foreach d $dlist { 304 if {$d == 99999.} { 305 lappend ans 0 306 } elseif {$d == 0.} { 307 lappend ans 1000. 308 } else { 309 lappend ans [expr {$cnv*asin($lamo2/$d) + $zero}] 310 } 311 } 312 return $ans 313 } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { 314 set lam [histinfo $hst lam1] 315 set zero [histinfo $hst zero] 316 set v [expr {12.398/(2.0*[sind[expr ($lam/2.0)]])}] 317 set ans {} 318 foreach d $dlist { 319 if {$d == 1000.} { 320 lappend ans 0 321 } elseif {$d == 0.} { 322 lappend ans 1000. 323 } else { 324 lappend ans [expr {$v/$d}] 325 } 326 } 327 return $ans 328 } else { 329 return {} 330 } 331 } 332 333 # convert Q values to 2theta, TOF or KeV 334 proc fromQ {Qlist hst} { 335 global expmap 336 if {[string range $expmap(htype_$hst) 2 2] == "T"} { 337 set difc [expr {[histinfo $hst difc]/1000.}] 338 set difa [expr {[histinfo $hst difa]/1000.}] 339 set zero [expr {[histinfo $hst zero]/1000.}] 340 set ans {} 341 foreach Q $Qlist { 342 if {$Q == 0.} { 343 lappend ans 1000. 344 } elseif {$Q == 99999.} { 345 lappend ans 1000. 346 } else { 347 set d [expr {4.*acos(0.)/$Q}] 348 lappend ans [expr {$difc*$d + $difa*$d*$d + $zero}] 349 } 350 } 351 return $ans 352 } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} { 353 set lamo4pi [expr {[histinfo $hst lam1]/(8.*acos(0.))}] 354 set zero [expr [histinfo $hst zero]/100.] 355 set ans {} 356 set cnv [expr {180./acos(0.)}] 357 foreach Q $Qlist { 358 if {$Q == 0.} { 359 lappend ans 0 360 } elseif {$Q == 1000.} { 361 lappend ans 1000. 362 } else { 363 lappend ans [expr {$cnv*asin($Q*$lamo4pi) + $zero}] 364 } 365 } 366 return $ans 367 } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { 368 set lam [histinfo $hst lam1] 369 set zero [histinfo $hst zero] 370 set v [expr {12.398/(2.0*[sind[expr ($lam/2.0)]])}] 371 set ans {} 372 set 2pi [expr {4.*acos(0.)}] 373 foreach Q $Qlist { 374 if {$Q == 1000.} { 375 lappend ans 0 376 } elseif {$Q == 0.} { 377 lappend ans 1000. 378 } else { 379 lappend ans [expr {$Q * $v/$2pi}] 380 } 381 } 382 return $ans 383 } else { 384 return {} 385 } 386 } 387 388 proc plotdata {args} { 131 plotExclData 132 } 133 134 # plot the pattern with the requested x-axis units & the excluded regions 135 proc plotExclData {args} { 389 136 global peakinfo reflns 390 137 global graph expgui … … 456 203 } 457 204 205 # show or hide the plot legend 458 206 proc setlegend {box legend} { 459 207 global blt_version … … 473 221 } 474 222 223 # show tickmark options 475 224 proc minioptionsbox {num} { 476 225 global blt_version tcl_platform peakinfo expgui … … 653 402 } 654 403 404 # display the excluded regions with orange markers 655 405 proc ShowExlMarks {} { 656 406 global graph … … 734 484 } 735 485 486 # called using the mouse to delete an excluded region 736 487 proc exclDel {bindtag x y} { 737 488 global graph expgui … … 792 543 } 793 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 794 549 proc exclAdd {bindtag x y} { 795 550 global graph … … 802 557 } 803 558 559 # reset the "add region mode" (see exclAdd) 804 560 proc exclReset {bindtag} { 805 561 global graph … … 810 566 } 811 567 568 # highlight the potential excluded region (see exclAdd) 812 569 proc exclMove {bindtag x y} { 813 570 global graph … … 821 578 } 822 579 580 # Called by a mouse click to complete a new excluded region (see exclAdd) 823 581 proc exclDone {bindtag x y} { 824 582 global graph … … 874 632 set ans ok 875 633 } 876 if {$ans == "ok"} {877 global expgui 878 incr expgui(changed) 879 set hst $graph(hst)880 set exclist [histinfo $hst excl] 881 lappend exclist [list $p1 $p2]882 set oldtmax [lindex [lindex $exclist end] 0]883 CheckForOverlappingRegions $exclist 884 if {$oldtmax < [set tmax [lindex [lindex $exclist end] 0]]} { 885 histinfo $hst dmin set [tod $tmax $hst]886 HighLimitChanged 887 } elseif {$oldtmax != [set tmax [lindex [lindex $exclist end] 0]]} { 888 histinfo $hst dmin set [tod $tmax $hst] 889 } else { 890 891 892 893 894 } 895 ShowExlMarks 896 FillExclRegionBox 897 } 898 } 899 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 900 658 proc CheckForOverlappingRegions {exclist} { 901 659 global expgui graph … … 933 691 } 934 692 693 # called in response to the File/"Set Min/Max Range" menu button 935 694 proc setminormax {} { 936 695 global expmap graph expgui 937 if {[string trim [string range $expmap(htype_$graph(hst)) 3 3]] == "D"} { 938 if {[string range $expmap(htype_$graph(hst)) 2 2] == "T"} { 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"} { 939 699 set fac 1000. 940 } elseif {[string range $expmap(htype_$ graph(hst)) 2 2] == "E"} {700 } elseif {[string range $expmap(htype_$hst) 2 2] == "E"} { 941 701 set fac 1. 942 702 } else { 943 703 set fac 100. 944 } 945 set start [expr {[histinfo $ graph(hst)dstart]/$fac}]946 set step [expr {[histinfo $ graph(hst)dstep]/$fac}]947 set points [histinfo $ graph(hst)dpoints]704 } 705 set start [expr {[histinfo $hst dstart]/$fac}] 706 set step [expr {[histinfo $hst dstep]/$fac}] 707 set points [histinfo $hst dpoints] 948 708 set end [expr {$start + $points*$step}] 949 SetDummyRangeBox $ graph(hst)$start $end $step709 SetDummyRangeBox $hst $start $end $step 950 710 return 951 711 } … … 994 754 ] -col 2 -row 0 995 755 set exclist [histinfo $hst excl] 756 set oldtmin [lindex [lindex $exclist 0] 1] 996 757 set oldtmax [lindex [lindex $exclist end] 0] 997 758 if {$graph(xunits) == 1} { … … 1015 776 set startchanges $expgui(changed) 1016 777 catch { 778 # did anything change? 1017 779 if {$graph(tmin) != $start(tmin)} { 1018 780 incr expgui(changed) 1019 781 if {$graph(xunits) == 1} { 1020 782 set tmax [fromd $graph(tmin) $hst] 1021 incr highchange 1022 set item [list $tmax [lindex [lindex $exclist end] 1]] 1023 set exclist [lreplace $exclist end end $item] 1024 histinfo $hst dmin set [tod $tmax $hst] 783 set exclist [lreplace $exclist end end \ 784 [list $tmax [lindex [lindex $exclist end] 1]]] 1025 785 } elseif {$graph(xunits) == 2} { 1026 786 set tmin [fromQ $graph(tmin) $hst] 1027 set item [list [lindex [lindex $exclist 0] 0] $tmin]1028 set exclist [lreplace $exclist 0 0 $item]787 set exclist [lreplace $exclist 0 0 \ 788 [list [lindex [lindex $exclist 0] 0] $tmin]] 1029 789 } else { 1030 set item [list [lindex [lindex $exclist 0] 0] $graph(tmin)]1031 set exclist [lreplace $exclist 0 0 $item]790 set exclist [lreplace $exclist 0 0 \ 791 [list [lindex [lindex $exclist 0] 0] $graph(tmin)]] 1032 792 } 1033 793 } … … 1038 798 if {$graph(xunits) == 1} { 1039 799 set tmin [fromd $graph(tmax) $hst] 1040 set item [list [lindex [lindex $exclist 0] 0] $tmin]1041 set exclist [lreplace $exclist 0 0 $item]800 set exclist [lreplace $exclist 0 0 \ 801 [list [lindex [lindex $exclist 0] 0] $tmin]] 1042 802 } elseif {$graph(xunits) == 2} { 1043 803 set tmax [fromQ $graph(tmax) $hst] 1044 incr highchange 1045 set item [list $tmax [lindex [lindex $exclist end] 1]] 1046 set exclist [lreplace $exclist end end $item] 1047 histinfo $hst dmin set [tod $tmax $hst] 804 set exclist [lreplace $exclist end end \ 805 [list $tmax [lindex [lindex $exclist end] 1]]] 1048 806 } else { 1049 incr highchange 1050 set item [list $graph(tmax) [lindex [lindex $exclist end] 1]] 1051 set exclist [lreplace $exclist end end $item] 1052 histinfo $hst dmin set [tod $graph(tmax) $hst] 807 set exclist [lreplace $exclist end end \ 808 [list $graph(tmax) [lindex [lindex $exclist end] 1]]] 1053 809 } 1054 810 } 1055 811 } 1056 812 if {$startchanges != $expgui(changed)} { 1057 histinfo $hst excl set $exclist1058 813 CheckForOverlappingRegions $exclist 814 CheckQmaxChanged $oldtmin $oldtmax 815 updateplot 1059 816 } else { 1060 817 return 1061 818 } 1062 if {$highchange && \ 1063 $oldtmax < [set tmax [lindex [lindex $exclist end] 0]]} { 1064 histinfo $hst dmin set [tod $tmax $hst] 1065 HighLimitChanged 1066 } elseif {$oldtmax != [set tmax [lindex [lindex $exclist end] 0]]} { 1067 histinfo $hst dmin set [tod $tmax $hst] 1068 updateplot 1069 } else { 1070 updateplot 1071 } 1072 } 1073 1074 proc HighLimitChanged {} { 1075 global graph expgui 1076 set msg "The upper data limit has changed.\nYou must run POWPREF to " 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 " 1077 851 append msg "to see the full range of data displayed. Do you want to " 1078 852 append msg "run POWPREF (& possibly GENLES with zero cycles)?" … … 1095 869 set expgui(autoexpload) $auto 1096 870 updateplot 1097 CheckTmax 1098 } 1099 1100 # find out what the maximum point really is 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. 1101 877 proc CheckTmax {} { 1102 878 global graph expgui … … 1125 901 append msg "You are suggested to set the lower d limit to $d A\n" 1126 902 } elseif {$graph(xunits) == 2} { 1127 set msg "The upperdata limit ([toQ [lindex [lindex $exclist end] 0] $hst] A-1) "903 set msg "The high Q data limit ([toQ [lindex [lindex $exclist end] 0] $hst] A-1) " 1128 904 set q [toQ $max $hst] 1129 905 append msg "is much larger than the largest data point ($q A-1)\n" 1130 906 append msg "You are suggested to set the upper Q limit to $q A-1\n" 1131 907 } else { 1132 set msg "The upperdata limit ([lindex [lindex $exclist end] 0]) "908 set msg "The high Q (low d) data limit ([lindex [lindex $exclist end] 0]) " 1133 909 append msg "is much larger than the largest data point ($max)\n" 1134 append msg "You are suggested to set the upperlimit to $max\n"910 append msg "You are suggested to set the limit to $max\n" 1135 911 } 1136 912 append msg "OK to make this change?" … … 1143 919 set exclist [lreplace $exclist end end $item] 1144 920 histinfo $hst excl set $exclist 921 histinfo $hst dmin set [tod $max $hst] 1145 922 updateplot 1146 923 return … … 1149 926 } 1150 927 1151 proc CheckChanges {} { 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} { 1152 932 global expgui graph 1153 933 set hst $graph(hst) 1154 if {$expgui(changed) == 0} return 1155 set msg "The excluded regions/ranges have changed.\nYou must run POWPREF before " 1156 append msg "running GENLES. Do you want to run POWPREF and optionally " 1157 append msg "GENLES with zero cycles now?" 1158 set ans [MyMessageBox -parent . -message $msg -title "Process limits?"\ 1159 -helplink "expguierr.html ProcessRegions" \ 1160 -type {Skip {Run POWPREF} {Run POWPREF & GENLES}}] 1161 global expgui env 1162 if {$ans == "run powpref"} { 1163 set cmd powpref 1164 } elseif {$ans == "skip"} { 1165 return 1166 } else { 1167 set cmd "powpref genles" 1168 expinfo cycles set 0 1169 } 1170 set auto $expgui(autoexpload) 1171 set expgui(autoexpload) 1 1172 #set expgui(autoiconify) 0 1173 runGSASwEXP $cmd 1174 set expgui(autoexpload) $auto 1175 } 1176 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 1177 944 proc EditExclRegion {reg "msg {}"} { 1178 945 global graph expmap expgui … … 1180 947 set startchanges $expgui(changed) 1181 948 set exclist [histinfo $hst excl] 949 set oldtmin [lindex [lindex $exclist 0] 1] 1182 950 set oldtmax [lindex [lindex $exclist end] 0] 1183 951 set i [expr {$reg -1}] … … 1244 1012 -col 2 -row 3 1245 1013 } 1014 # save starting values as tmin & tmax 1246 1015 foreach v {tmin tmax} { 1247 1016 set $v $graph($v) … … 1268 1037 } 1269 1038 }]} { 1039 # recursive call -- should not happen too many times 1270 1040 EditExclRegion $reg "Invalid value entered, try again" 1271 1041 return … … 1285 1055 } 1286 1056 }]} { 1057 # recursive call -- should not happen too many times 1287 1058 EditExclRegion $reg "Invalid value entered, try again" 1288 1059 return … … 1291 1062 incr expgui(changed) 1292 1063 } 1293 if {$expgui(changed) != $startchanges} { 1294 histinfo $hst excl set $exclist 1295 CheckForOverlappingRegions $exclist 1296 if {$reg == [llength $exclist]} { 1297 histinfo $hst dmin set [tod $tmin $hst] 1298 } 1299 if {$oldtmax < [set tmax [lindex [lindex $exclist end] 0]]} { 1300 histinfo $hst dmin set [tod $tmin $hst] 1301 HighLimitChanged 1302 } elseif {$oldtmax != [set tmax [lindex [lindex $exclist end] 0]]} { 1303 histinfo $hst dmin set [tod $tmin $hst] 1304 updateplot 1305 } else { 1306 updateplot 1307 } 1308 FillExclRegionBox 1309 } 1310 } 1311 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. 1312 1074 proc scheduleFillExclRegionBox {} { 1313 1075 global graph … … 1317 1079 after idle FillExclRegionBox 1318 1080 } 1319 # put the background regions into buttons 1081 1082 # put the background regions into buttons and resize the slider 1320 1083 proc FillExclRegionBox {} { 1321 1084 global graph expmap … … 1505 1268 proc ShowExcl {} { 1506 1269 global graph peakinfo expgui expmap 1507 # save the starting number of cycles 1270 # save the starting number of cycles & starting point 1508 1271 set cycsav [expinfo cycles] 1272 set startchanges $expgui(changed) 1509 1273 set graph(hst) [lindex $expgui(curhist) 0] 1510 1274 if {[llength $expgui(curhist)] == 0} { … … 1576 1340 -label "Set Min/Max Range" -command setminormax 1577 1341 $graph(exclmenu).file.menu add command \ 1578 -label "Update Plot" -command "CheckChanges ;updateplot"1342 -label "Update Plot" -command "CheckChanges $startchanges;updateplot" 1579 1343 $graph(exclmenu).file.menu add command \ 1580 1344 -label "Make PostScript" -command makepostscriptout 1581 1345 $graph(exclmenu).file.menu add command \ 1582 -label Finish -command "CheckChanges ;destroy $graph(exclbox)"1346 -label Finish -command "CheckChanges $startchanges;destroy $graph(exclbox)" 1583 1347 1584 1348 pack [menubutton $graph(exclmenu).options -text Options -underline 0 \ … … 1591 1355 $graph(exclmenu).options.menu.tick add radiobutton \ 1592 1356 -label "Manual Placement" \ 1593 -value 0 -variable expgui(autotick) -command plot data1357 -value 0 -variable expgui(autotick) -command plotExclData 1594 1358 $graph(exclmenu).options.menu.tick add radiobutton \ 1595 1359 -label "Auto locate" \ 1596 -value 1 -variable expgui(autotick) -command plot data1360 -value 1 -variable expgui(autotick) -command plotExclData 1597 1361 $graph(exclmenu).options.menu.tick add separator 1598 1362 foreach num {1 2 3 4 5 6 7 8 9} { … … 1613 1377 foreach var {excl calc obs} lbl {Excluded Calculated Observed} { 1614 1378 $graph(exclmenu).options.menu.color add command -label $lbl \ 1615 -command "set graph(color_$var) \[tk_chooseColor -initialcolor \$graph(color_$var) -title \"Choose \$lbl color\"]; plot data"1379 -command "set graph(color_$var) \[tk_chooseColor -initialcolor \$graph(color_$var) -title \"Choose \$lbl color\"]; plotExclData" 1616 1380 } 1617 1381 $graph(exclmenu).options.menu add cascade -label "X units" \ … … 1665 1429 -column 1 -row 4 -columnspan 5 -sticky nsew 1666 1430 grid [button $bb.cw -text "Save &\nFinish" \ 1667 -command "CheckChanges ;destroy $graph(exclbox)"] \1431 -command "CheckChanges $startchanges;destroy $graph(exclbox)"] \ 1668 1432 -col 4 -row 1 -columnspan 2 -sticky ns 1669 1433 … … 1742 1506 bind $graph(exclbox) <Key-Z> {BLTmanualZoom} 1743 1507 updateplot 1744 trace variable peakinfo w plot data1508 trace variable peakinfo w plotExclData 1745 1509 1746 1510 # catch exits -- launch POWPREF; if changes non-zero 1747 wm protocol $graph(exclbox) WM_DELETE_WINDOW {CheckChanges;destroy $graph(exclbox)}1511 wm protocol $graph(exclbox) WM_DELETE_WINDOW "CheckChanges $startchanges;destroy $graph(exclbox)" 1748 1512 # respond to resize events 1749 1513 bind $graph(exclbox) <Configure> scheduleFillExclRegionBox 1750 bind all <Control-KeyPress-c> {CheckChanges;destroy $graph(exclbox)}1514 bind all <Control-KeyPress-c> "CheckChanges $startchanges;destroy $graph(exclbox)" 1751 1515 putontop $graph(exclbox) 1752 1516 wm deiconify $graph(exclbox) … … 1988 1752 updateplot 1989 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 }
Note: See TracChangeset
for help on using the changeset viewer.