Changeset 20
- Timestamp:
- Dec 4, 2009 4:59:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expgui
- Property rcs:date changed from 1999/01/01 18:34:49 to 1999/01/06 04:15:12
- Property rcs:lines changed from +136 -65 to +439 -266
- Property rcs:rev changed from 1.4 to 1.5
r16 r20 7 7 # start out blank with a "load from option"? 8 8 # 9 # access to GENLES & EXPEDT (merge in tkGSAS)10 #11 # look for external changes to the EXP file and warn/reload12 # add a mtime to loadexp and chain a routine to check the mtime for a new value13 # reset the mtime in SaveAsFile14 #15 9 # idea: 16 10 # a scroll list for all histogram refinement flags ; click on takes you to the 17 11 # appropriate menu. 18 12 # 19 # to allow globalaccess on phase page13 # to allow "global" access on phase page 20 14 # change buttons from radio to multiple 21 15 # -- or display all 9 cell flag/damps and all atoms … … 32 26 33 27 if {$argv != ""} { 34 set exp file[lindex $argv 0]35 if {[string toupper [file extension $exp file]] != ".EXP"} {36 append exp file".EXP"28 set expgui(expfile) [lindex $argv 0] 29 if {[string toupper [file extension $expgui(expfile)]] != ".EXP"} { 30 append expgui(expfile) ".EXP" 37 31 } 38 32 } else { 39 33 # windows needs this update or focus gets screwed up after tk_getOpenFile 40 34 update 41 set exp file[tk_getOpenFile -defaultextension .EXP \35 set expgui(expfile) [tk_getOpenFile -defaultextension .EXP \ 42 36 -filetypes {{"GSAS Experiment" ".EXP"}} -parent .] 43 37 } 44 if {$expfile == ""} exit 45 if ![file exists $expfile] { 46 tk_dialog .expFileErrorMsg "File Open Error" \ 47 "File $expfile does not exist" error 0 "Exit" 48 exit 49 } 38 if {$expgui(expfile) == ""} exit 50 39 51 40 set expgui(debug) 0 … … 61 50 # default is archive = on 62 51 set expgui(archive) 1 63 #---------------------------------------------------------------- 64 # where are we? 65 set expgui(script) [info script] 66 # translate links -- go six levels deep 67 foreach i {1 2 3 4 5 6} { 68 if {[file type $expgui(script)] == "link"} { 69 set link [file readlink $expgui(script)] 70 if { [file pathtype $link] == "absolute" } { 71 h set expgui(script) $link 72 } { 73 set expgui(script) [file dirname $expgui(script)]/$link 74 } 75 } else { 76 break 77 } 78 } 79 set expgui(scriptdir) [file dirname $expgui(script) ] 80 #---------------------------------------------------------------- 81 # fetch EXP routines 82 source [file join $expgui(scriptdir) readexp.tcl] 83 84 # constants 52 # save the name of the wish executable 53 set wishshell [info nameofexecutable] 54 # misc constants 85 55 set expgui(coordfont) "-*-courier-bold-r-normal--12-*" 86 56 set expgui(histfont) "-*-courier-bold-r-normal--12-*" 57 set liveplot(hst) 1 58 set liveplot(legend) 1 87 59 88 60 #============================================================================= … … 105 77 } 106 78 # >>>>>>>>>>>>>>>> End of Profile Terms >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 79 #---------------------------------------------------------------- 80 # where are we? 81 set expgui(script) [info script] 82 # translate links -- go six levels deep 83 foreach i {1 2 3 4 5 6} { 84 if {[file type $expgui(script)] == "link"} { 85 set link [file readlink $expgui(script)] 86 if { [file pathtype $link] == "absolute" } { 87 h set expgui(script) $link 88 } { 89 set expgui(script) [file dirname $expgui(script)]/$link 90 } 91 } else { 92 break 93 } 94 } 95 set expgui(scriptdir) [file dirname $expgui(script) ] 96 set expgui(gsasdir) [file dirname $expgui(scriptdir)] 97 set expgui(gsasexe) [file join $ expgui(gsasdir) exe] 98 #---------------------------------------------------------------- 99 # fetch EXP file processing routines 100 source [file join $expgui(scriptdir) readexp.tcl] 101 # commands for running GSAS programs 102 source [file join $expgui(scriptdir) gsascmds.tcl] 103 # contents of GSAS menus 104 source [file join $expgui(scriptdir) gsasmenu.tcl] 105 #--------------------------------------------------------------------------- 106 # override options with locally defined values 107 if [file exists [file join $expgui(scriptdir) localconfig]] { 108 source [file join $expgui(scriptdir) localconfig] 109 } 110 if [file exists [file join ~ .gsas_config]] { 111 source [file join ~ .gsas_config] 112 } 113 #--------------------------------------------------------------------------- 114 if ![file exists $expgui(expfile)] { 115 set ans [tk_dialog .expFileErrorMsg "File Open Error" \ 116 "File $expgui(expfile) does not exist" error 0 "Exit" "Create"] 117 if $ans { 118 # create an "empty" exp file 119 createexp $expgui(expfile) \ 120 [getstring "title for experiment $expgui(expfile)" 60 0] 121 } else { 122 exit 123 } 124 } 125 107 126 # 108 127 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> … … 115 134 catch { 116 135 unset exparray 117 unset expmap118 136 } 119 137 expload $expfile … … 121 139 mapexp 122 140 set expgui(expModifiedLast) [file mtime $expfile] 123 set expgui(last_History) [string trim [lindex [exphistory last] 1]]141 set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ] 124 142 # set the window/icon title 125 143 wm title . $expfile … … 174 192 set expgui(globalmode) 0 175 193 set expgui(printopt) "Print Options ([expinfo print])" 194 set entryvar(title) [expinfo title] 176 195 global printopts 177 196 foreach num [array names printopts] { … … 181 200 # enable traces on entryvar 182 201 set entrycmd(trace) 1 202 # set fo extaction on LS page 203 SetupExtractHist 183 204 # start checking for external changes 184 205 afterawhile … … 194 215 {} 0 "Save and reread" "Reread without Save" "Cancel reread command"] 195 216 switch $decision { 196 0 { savearchiveexp $expfile } 197 1 { } 198 2 { return } 199 } 200 } 201 loadexp $expfile 217 0 { savearchiveexp } 218 1 { } 219 2 { return } 220 } 221 } 222 loadexp $expgui(expfile) 223 } 224 225 proc CreateNewExp {} { 226 global expgui 227 set newexpfile [newexp] 228 if {$newexpfile == ""} return 229 # create an "empty" exp file 230 createexp $newexpfile \ 231 [getstring "title for experiment $newexpfile" 60 0] 232 set expgui(expfile) $newexpfile 233 loadexp $expgui(expfile) 202 234 } 203 235 204 236 proc SaveAsFile {} { 205 global exp file expgui237 global expgui 206 238 set newexpfile [tk_getSaveFile -defaultextension .EXP \ 207 239 -filetypes {{"GSAS Experiment" ".EXP"}} -parent . \ 208 -initialdir [file dirname $exp file] \209 -initialfile [file tail $exp file] ]240 -initialdir [file dirname $expgui(expfile)] \ 241 -initialfile [file tail $expgui(expfile)] ] 210 242 if {$newexpfile == ""} return 211 set exp file$newexpfile212 expwrite $exp file243 set expgui(expfile) $newexpfile 244 expwrite $expgui(expfile) 213 245 set expgui(changed) 0 214 set expgui(expModifiedLast) [file mtime $exp file]215 set expgui(last_History) [string trim [lindex [exphistory last] 1]]246 set expgui(expModifiedLast) [file mtime $expgui(expfile)] 247 set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ] 216 248 # set the window/icon title 217 wm title . $exp file249 wm title . $expgui(expfile) 218 250 set expgui(titleunchanged) 1 219 wm iconname . [file tail $exp file]251 wm iconname . [file tail $expgui(expfile)] 220 252 } 221 253 222 254 # called to read a different .EXP file 223 255 proc readnewexp {} { 224 global expgui expfile256 global expgui 225 257 if $expgui(changed) { 226 258 set decision [tk_dialog .instrSaveData {Save .EXP changes} \ … … 228 260 {} 0 "Save and read" "Read without Save" "Cancel read command"] 229 261 switch $decision { 230 0 { savearchiveexp $expfile}231 1 { 232 2 { 262 0 { savearchiveexp } 263 1 { } 264 2 { return } 233 265 } 234 266 } 235 267 set newexpfile [tk_getOpenFile -defaultextension .EXP \ 236 268 -filetypes {{"GSAS Experiment" ".EXP"}} -parent . \ 237 -initialdir [file dirname $exp file] ]269 -initialdir [file dirname $expgui(expfile)] ] 238 270 if {$newexpfile == ""} return 239 set exp file$newexpfile240 loadexp $exp file271 set expgui(expfile) $newexpfile 272 loadexp $expgui(expfile) 241 273 } 242 274 … … 248 280 249 281 catch { 282 if {$entrycmd($elem) == ""} return 250 283 incr expgui(changed) 251 284 if $expgui(debug) {puts "$entrycmd($elem) set $entryvar($elem) "} 252 285 if {$entrycmd($elem) == ""} return 253 286 if [catch { 254 eval $entrycmd($elem) set $entryvar($elem)287 eval $entrycmd($elem) set [list $entryvar($elem)] 255 288 if {[lindex $entrycmd($elem) 0] == "atominfo"} { 256 289 after idle {DisplayAllAtoms noreset} … … 274 307 # reset routine is used for debugging 275 308 proc reset {} { 276 global expgui script argv expfile309 global expgui script argv 277 310 set script $expgui(script) 278 set argv $exp file311 set argv $expgui(expfile) 279 312 # remove traces 280 313 global entryvar … … 289 322 eval trace vdelete entryvar $cmd 290 323 } 291 foreach a {exparray expmap expgui entryvar entrycmd} { 324 foreach a { 325 exparray expmap expgui entryvar entrycmd 326 expgui_menulist expgui_cmdlist expgui_helplist 327 } { 292 328 global $a 293 329 catch {unset $a} … … 307 343 NIST Center for Neutron Research\n\n\ 308 344 1998, Not subject to copyright\n\n\ 309 Revision [lindex $expgui(Revision) 1] (readexp.tcl [lindex $expmap(Revision) 1])" \ 345 Revision [lindex $expgui(Revision) 1] (readexp.tcl [lindex $expmap(Revision) 1])\n\n\ 346 Generalized Structure Analysis System (GSAS)\n\ 347 A. C. Larson and\n R. B. Von Dreele,\n LANSCE, Los Alamos\n\n\ 348 " \ 310 349 info 0 OK 311 350 } … … 321 360 322 361 proc whenidle {} { 323 global expgui expfile362 global expgui 324 363 if $expgui(titleunchanged) { 325 364 if {$expgui(changed) != 0} { 326 wm title . "$exp file(modified)"365 wm title . "$expgui(expfile) (modified)" 327 366 set expgui(titleunchanged) 0 328 367 } 329 368 } 330 #puts whenidle 331 if {[file mtime $expfile] != $expgui(expModifiedLast)} { 369 if {[file mtime $expgui(expfile)] != $expgui(expModifiedLast)} { 332 370 if {$expgui(changed) == 0} { 333 371 set ans [tk_dialog .expFileErrorMsg "Reload?" \ 334 "File $exp filehas been modified by another program. \372 "File $expgui(expfile) has been modified by another program. \ 335 373 Do you want to load the newer version or loose the modifications \ 336 374 by editing the current version?" \ … … 338 376 } else { 339 377 set ans [tk_dialog .expFileErrorMsg "Reload?" \ 340 "File $exp filehas been modified by another program \378 "File $expgui(expfile) has been modified by another program \ 341 379 and you have made $expgui(changed) changes to this version. \ 342 380 Do you want to load the newer version or loose the modifications \ … … 345 383 } 346 384 if {$ans == 0} { 347 loadexp $exp file385 loadexp $expgui(expfile) 348 386 } elseif {$ans == 1} { 349 387 # reset the time to the next version 350 set expgui(expModifiedLast) [file mtime $exp file]388 set expgui(expModifiedLast) [file mtime $expgui(expfile)] 351 389 } elseif {$ans == 2} { 352 savearchiveexp $expfile390 savearchiveexp 353 391 } 354 392 } … … 363 401 # save the .EXP file before exiting? 364 402 proc confirmBeforeSave {} { 365 global expgui expfile403 global expgui 366 404 if !$expgui(changed) { 367 405 return "Continue" … … 371 409 {} 0 "Save and Exit" "Exit without Save" "Cancel exit command"] 372 410 switch $decision { 373 0 { savearchiveexp $expfile; return "Continue" } 374 1 { return "Continue" } 375 2 { return "Cancel" } 376 } 377 } 378 379 # save and optionally archive the expfile 380 proc savearchiveexp {expfile} { 381 global expgui tcl_platform expmap 382 if !$expgui(changed) return 383 if $expgui(archive) { 384 catch { 385 set expnam [file rootname $expfile] 386 if {$tcl_platform(platform) == "windows"} { 387 if ![file executable [file join $expgui(scriptdir) pkzip.exe]] { 388 # archive w/o pkzip 389 set files [glob -nocomplain ${expnam}!*.exp] 390 if {$files == ""} { 391 set num -1 392 } else { 393 set file [lindex [lsort -decreasing $files] 0] 394 regexp {!([0-9]+)\.EXP} [string toupper $file] a num 411 0 { savearchiveexp; return "Continue" } 412 1 { return "Continue" } 413 2 { return "Cancel" } 414 } 415 } 416 417 proc archiveexp {} { 418 global expgui tcl_platform 419 catch { 420 set expnam [file rootname $expgui(expfile)] 421 if {$tcl_platform(platform) == "windows"} { 422 if ![file executable [file join $expgui(scriptdir) pkzip.exe]] { 423 # archive w/o pkzip 424 set files [glob -nocomplain ${expnam}!*.exp] 425 if {$files == ""} { 426 set num -1 427 } else { 428 set file [lindex [lsort -decreasing $files] 0] 429 regexp {!([0-9]+)\.EXP} [string toupper $file] a num 430 } 431 set file $expnam![format "%3.3d" [incr num]].EXP 432 file copy $expnam.EXP $file 433 set fp [open $expnam.lst a] 434 puts $fp "\n--------------------------------------------------------------" 435 puts $fp "Archiving $expnam.EXP as $file" 436 puts $fp "--------------------------------------------------------------\n" 437 close $fp 438 } else { 439 # archive with PKZIP 440 # need to limit expnam to 8 characters 441 set sexp [string toupper [string range [file root [file tail $expnam] ] 0 7]] 442 # PKZIP can't handle long dir names either 443 cd [set dir [file dirname $expnam]] 444 set num -1 445 # get the versions from the listing 446 if [file exists $sexp.zip] { 447 set fp [open "| [file join $expgui(scriptdir) pkzip.exe] -vb $sexp" r] 448 while {[gets $fp line] >= 0} { 449 regexp "$sexp\.0?0?(\[0-9\]+)" [string toupper $line] junk n 450 catch {if {$n > $num} {set num $n}} 395 451 } 396 set file $expnam![format "%3.3d" [incr num]].EXP397 file copy $expnam.EXP $file398 set fp [open $expnam.lst a]399 puts $fp "\n--------------------------------------------------------------"400 puts $fp "Archiving $expnam.EXP as $file"401 puts $fp "--------------------------------------------------------------\n"402 close $fp403 } else {404 # archive with PKZIP405 # need to limit expnam to 8 characters406 set sexp [string toupper [string range [file root [file tail $expnam] ] 0 7]]407 # PKZIP can't handle long dir names either408 cd [set dir [file dirname $expnam]]409 set num -1410 # get the versions from the listing411 if [file exists $sexp.zip] {412 set fp [open "| [file join $expgui(scriptdir) pkzip.exe] -vb $sexp" r]413 while {[gets $fp line] >= 0} {414 regexp "$sexp\.0?0?(\[0-9\]+)" [string toupper $line] junk n415 catch {if {$n > $num} {set num $n}}416 }417 close $fp418 }419 incr num420 set file $sexp.[format "%3.3d" $num]421 file copy -force $expnam.EXP $file422 exec [file join $expgui(scriptdir) pkzip.exe] -m $expnam $file > x.x &423 set fp [open $expnam.lst a]424 puts $fp "\n--------------------------------------------------------------"425 puts $fp "Archiving $expnam.EXP as $file in [file join $dir $sexp.ZIP]"426 puts $fp "--------------------------------------------------------------\n"427 452 close $fp 428 453 } 454 incr num 455 set file $sexp.[format "%3.3d" $num] 456 file copy -force $expnam.EXP $file 457 exec [file join $expgui(scriptdir) pkzip.exe] -m $expnam $file > x.x & 458 set fp [open $expnam.lst a] 459 puts $fp "\n--------------------------------------------------------------" 460 puts $fp "Archiving $expnam.EXP as $file in [file join $dir $sexp.ZIP]" 461 puts $fp "--------------------------------------------------------------\n" 462 close $fp 463 } 464 } else { 465 set files [glob -nocomplain $expnam.EXP.*] 466 if {$files == ""} { 467 set file $expnam.EXP.000 429 468 } else { 430 set files [glob -nocomplain $expnam.EXP.*] 431 if {$files == ""} { 432 set file $expnam.EXP.000 433 } else { 434 set file [lindex [lsort -decreasing $files] 0] 435 regexp {.*\.EXP.0?0?([0-9]*).*} $file junk number 436 incr number 437 set file $expnam.EXP.[format "%3.3d" $number] 438 } 439 exec cp $expfile $file 440 if [catch {exec gzip $file}] { 441 exec echo "\n----------------------------------------------" >> $expnam.LST 442 exec echo " Archiving $expnam.EXP as $file " >> $expnam.LST 443 exec echo "----------------------------------------------\n" >> $expnam.LST 444 } else { 445 exec echo "\n----------------------------------------------" >> $expnam.LST 446 exec echo " Archiving $expnam.EXP as $file.gz " >> $expnam.LST 447 exec echo "----------------------------------------------\n" >> $expnam.LST 448 } 469 set file [lindex [lsort -decreasing $files] 0] 470 regexp {.*\.EXP.0?0?([0-9]*).*} $file junk number 471 incr number 472 set file $expnam.EXP.[format "%3.3d" $number] 449 473 } 450 } errmsg 451 if {$errmsg != ""} { 452 tk_dialog .warn Confirm "Error in archive: $errmsg" warning 0 OK 453 } 454 } 455 # add a header 474 exec cp $expgui(expfile) $file 475 if [catch {exec gzip $file}] { 476 exec echo "\n----------------------------------------------" >> $expnam.LST 477 exec echo " Archiving $expnam.EXP as $file " >> $expnam.LST 478 exec echo "----------------------------------------------\n" >> $expnam.LST 479 } else { 480 exec echo "\n----------------------------------------------" >> $expnam.LST 481 exec echo " Archiving $expnam.EXP as $file.gz " >> $expnam.LST 482 exec echo "----------------------------------------------\n" >> $expnam.LST 483 } 484 } 485 } errmsg 486 if {$errmsg != ""} { 487 tk_dialog .warn Confirm "Error in archive: $errmsg" warning 0 OK 488 } 489 } 490 491 # save and optionally archive the expfile 492 proc savearchiveexp {} { 493 global expgui expmap 494 if !$expgui(changed) return 495 if $expgui(archive) archiveexp 496 # add a history record 456 497 exphistory add " EXPGUI [lindex $expgui(Revision) 1] [lindex $expmap(Revision) 1] ($expgui(changed) changes) -- [clock format [clock seconds]]" 457 498 # now save the file 458 expwrite $exp file499 expwrite $expgui(expfile) 459 500 set expgui(changed) 0 460 set expgui(expModifiedLast) [file mtime $exp file]461 set expgui(last_History) [string trim [lindex [exphistory last] 1]]462 wm title . $exp file501 set expgui(expModifiedLast) [file mtime $expgui(expfile)] 502 set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ] 503 wm title . $expgui(expfile) 463 504 set expgui(titleunchanged) 1 464 505 } … … 472 513 -command "SelectOnePhase $num"] -side left 473 514 } 474 # set the default data to be the first phase and the first histogram475 set expgui(lasthist) [lindex $expmap(powderlist) 0]476 515 } 477 516 … … 486 525 $expgui(phaseFrame).top.ps.$n config -relief raised 487 526 } 488 } 527 } 489 528 set crsPhase $num 490 if {$crsPhase == ""} return 529 # no phase is selected 530 if {$crsPhase == ""} { 531 # disable traces on entryvar 532 set entrycmd(trace) 0 533 set entrycmd(phasename) "" 534 set entryvar(phasename) "" 535 foreach ent {a b c alpha beta gamma cellref celldamp} { 536 set entrycmd($ent) "" 537 set entryvar($ent) "" 538 } 539 # enable traces on entryvar 540 set entrycmd(trace) 1 541 return 542 } 543 491 544 set expgui(curPhase) $crsPhase 492 545 # we have a phase … … 499 552 ########################################################## 500 553 # phase title 501 set entrycmd(phasename) {}554 set entrycmd(phasename) "phaseinfo $crsPhase name" 502 555 set entryvar(phasename) [phaseinfo $crsPhase name] 503 556 # cell parameters & flags … … 830 883 proc sethistlist {} { 831 884 global expgui expmap 832 set expgui(curhist) 0885 set expgui(curhist) {} 833 886 foreach lbox $expgui(HistSelectList) { 834 887 $lbox.title delete 0 end … … 858 911 } 859 912 } 913 set histlist {} 860 914 if {$expgui(hsorttype) == "type"} { 861 915 # sort on histogram type … … 892 946 set expmap(histlistboxcontents) [lsort -real -index 1 $histlist] 893 947 } 948 # select the first histogram in the list by default (if there are any) 949 if {[llength $histlist] > 0} {set expgui(curhist) 0} 950 894 951 # title field needs to match longest title 895 952 foreach lbox $expgui(HistSelectList) { … … 963 1020 lappend histlist [lindex $expmap(powderlist) $item] 964 1021 } 1022 # must have at least one histogram selected here 1023 if {[llength $histlist] == 0} { 1024 set expgui(backtermlbl) "" 1025 set expgui(backtypelbl) "" 1026 foreach var {bref bdamp} { 1027 set entrycmd($var) "" 1028 set entryvar($var) "" 1029 } 1030 $expgui(histFrame).top.txt config -text "No Selected Histograms" 1031 grid $expgui(histFrame).top -column 1 -row 0 -sticky nsew 1032 set expgui(bkglbl) "" 1033 eval destroy [grid slaves $expgui(diffBox)] 1034 set entrycmd(trace) 1 1035 return 1036 } 1037 965 1038 if {$expgui(globalmode) != 0} { 966 1039 set expgui(backtermlbl) "" … … 1317 1390 } 1318 1391 1392 # must have at least one histogram selected here 1393 if {[llength $histlist] == 0} { 1394 foreach var {scale sref sdamp} { 1395 set entrycmd($var) "" 1396 set entryvar($var) "" 1397 } 1398 set parm [grid info $expgui(scaleBox).but1] 1399 if {$parm != ""} { 1400 grid forget $expgui(scaleBox).but1 1401 eval grid $expgui(scaleBox).ent1 $parm 1402 } 1403 # destroy the contents of the frame 1404 set phaseFractf1 $expgui(FracBox).f 1405 eval destroy [grid slaves $phaseFractf1] 1406 # reenable traces on entryvar 1407 set entrycmd(trace) 1 1408 return 1409 } 1410 1319 1411 #-------------- 1320 1412 # Scale factor … … 1424 1516 1425 1517 if {$expgui(globalmode) == 0} { 1518 # must have at least one histogram selected here 1519 if {[llength $expgui(curhist)] == 0} return 1426 1520 set hist [lindex $expmap(powderlist) $expgui(curhist)] 1427 1521 # Create one frame for each Phase. … … 1487 1581 lappend histlist [lindex $expmap(powderlist) $item] 1488 1582 } 1583 # must have at least one histogram selected here 1584 if {[llength $histlist] == 0} return 1489 1585 # loop through histograms & phases, set up an array by type 1490 1586 catch {unset ptypearray histarray phasearray} … … 1623 1719 set expgui(printopt) "Print Options ([expinfo print])" 1624 1720 } 1721 1722 # need to respond to mouse presses -- control variable associated with extract Fobs 1723 # and set the LeBail extraction flags 1724 proc SetupExtractHist {} { 1725 global expgui entrycmd entryvar expmap 1726 1727 # display the selected histograms 1728 $expgui(lsFrame).hs.lbox selection clear 0 end 1729 foreach h $expgui(curhist) { 1730 $expgui(lsFrame).hs.lbox selection set $h 1731 } 1732 # disable traces on entryvar for right now 1733 set entrycmd(trace) 0 1734 1735 # get histogram list 1736 set histlist {} 1737 foreach item $expgui(curhist) { 1738 lappend histlist [lindex $expmap(powderlist) $item] 1739 } 1740 set entrycmd(fobsextract) "histinfo [list $histlist] foextract" 1741 if {[llength $histlist] == 0} { 1742 foreach phase {1 2 3 4 5 6 7 8 9} { 1743 $expgui(lsFrame).f1.a.l$phase config -fg grey 1744 set expgui(Fextract$phase) {} 1745 #foreach item "a.ca$phase a.cb$phase a.cc$phase" 1746 foreach item "a.ca$phase a.cc$phase" { 1747 $expgui(lsFrame).f1.$item config -state disabled -bd 1 1748 } 1749 } 1750 } elseif {[llength $histlist] == 1} { 1751 set entryvar(fobsextract) [histinfo $histlist foextract] 1752 foreach phase {1 2 3 4 5 6 7 8 9} { 1753 # is the phase present? 1754 if {[lsearch -exact $expmap(phaselist_$histlist) $phase] == -1} { 1755 $expgui(lsFrame).f1.a.l$phase config -fg grey 1756 set expgui(Fextract$phase) {} 1757 # foreach item "a.ca$phase a.cb$phase a.cc$phase" 1758 foreach item "a.ca$phase a.cc$phase" { 1759 $expgui(lsFrame).f1.$item config -state disabled -bd 1 1760 } 1761 } else { 1762 $expgui(lsFrame).f1.a.l$phase config -fg black 1763 # foreach item "a.ca$phase a.cb$phase a.cc$phase" 1764 foreach item "a.ca$phase a.cc$phase" { 1765 $expgui(lsFrame).f1.$item config -state normal -bd 2 1766 } 1767 set expgui(Fextract$phase) [hapinfo $histlist $phase extmeth] 1768 } 1769 } 1770 } elseif {[llength $histlist] > 1} { 1771 # multiple histograms need phases in any histogram 1772 foreach phase {1 2 3 4 5 6 7 8 9} { 1773 set gotphase($phase) 0 1774 } 1775 foreach hist $histlist { 1776 foreach phase $expmap(phaselist_$hist) { 1777 set gotphase($phase) 1 1778 } 1779 } 1780 foreach phase {1 2 3 4 5 6 7 8 9} { 1781 set expgui(Fextract$phase) {} 1782 if $gotphase($phase) { 1783 $expgui(lsFrame).f1.a.l$phase config -fg black 1784 foreach item "a.ca$phase a.cb$phase a.cc$phase" { 1785 $expgui(lsFrame).f1.$item config -state normal -bd 2 1786 } 1787 } else { 1788 $expgui(lsFrame).f1.a.l$phase config -fg grey 1789 foreach item "a.ca$phase a.cb$phase a.cc$phase" { 1790 $expgui(lsFrame).f1.$item config -state disabled -bd 1 1791 } 1792 } 1793 } 1794 } 1795 # reenable traces 1796 set entrycmd(trace) 1 1797 } 1798 # respond to a change in the fobs extraction method for a phase 1799 # force the main extraction flag on, if fobs extraction is selected for any phase 1800 proc HistExtractSet {phase} { 1801 global expgui entryvar expmap 1802 foreach item $expgui(curhist) { 1803 lappend histlist [lindex $expmap(powderlist) $item] 1804 } 1805 hapinfo $histlist $phase extmeth set $expgui(Fextract$phase) 1806 if {$expgui(Fextract$phase) != 0} {set entryvar(fobsextract) 1} 1807 } 1625 1808 #---------------------------- Global Edit Functions ------------------------ 1626 1809 proc editbackground {} { 1627 1810 global expgui expmap entrycmd 1811 set histlist {} 1812 foreach n $expgui(curhist) { 1813 lappend histlist [lindex $expmap(powderlist) $n] 1814 } 1815 if {[llength $histlist] == 0} return 1816 1628 1817 set w .back 1629 1818 catch {destroy $w} 1630 1819 toplevel $w -bg beige 1631 set histlist {}1632 foreach n $expgui(curhist) {1633 lappend histlist [lindex $expmap(powderlist) $n]1634 }1635 1820 if {$expgui(globalmode) != 0} { 1636 1821 wm title $w "Edit Background" … … 2040 2225 pack $expgui(fm) -fill x -side top -anchor n 2041 2226 2227 # create a button bar 2228 pack [frame .bar -relief raised -bd 2 -bg beige] -fill x -side top -anchor n 2229 2042 2230 # Creating the notebook with 5 panes: Phase, Histogram, Scaling, Profile 2043 2231 # & LS controls … … 2051 2239 .n pageconfigure phasePane -raisecmd \ 2052 2240 "set expgui(pagenow) phaseFrame; DisplayAllAtoms noreset" 2241 # lappend expgui(frameactionlist) "phaseFrame {DisplayAllAtoms noreset}" 2053 2242 .n add histPane -label "Histogram" -underline 0 2054 2243 .n pageconfigure histPane -raisecmd \ … … 2072 2261 set expgui(lsFrame) [.n subwidget lsPane] 2073 2262 } else { 2074 pack [frame . bar] -side top -anchor w2263 pack [frame .frmbar] -side top -anchor w 2075 2264 pack [frame .n] -anchor w -fill both -expand yes 2076 2265 foreach item {lsFrame phaseFrame histFrame fracFrame profFrame} \ 2077 page { Phase Histogram Scaling Profile "LS Controls"} {2078 pack [button . bar.$item -text $page -bd 2 \2266 page {"LS Controls" Phase Histogram Scaling Profile } { 2267 pack [button .frmbar.$item -text $page -bd 2 \ 2079 2268 -command "RaisePage $item"] -side left 2080 2269 set expgui($item) [frame .n.$item -relief flat] 2081 2270 } 2082 2271 lappend expgui(frameactionlist) "lsFrame SetupExtractHist" 2272 lappend expgui(frameactionlist) "phaseFrame {DisplayAllAtoms noreset}" 2083 2273 lappend expgui(frameactionlist) "histFrame DisplayHistogram" 2084 2274 lappend expgui(frameactionlist) "fracFrame DisplayFrac" 2085 2275 lappend expgui(frameactionlist) "profFrame DisplayProfile" 2086 lappend expgui(GlobalModeAllDisable) "histFrame {. bar.histFrame config}"2087 lappend expgui(GlobalModeAllDisable) "profFrame {. bar.profFrame config}"2276 lappend expgui(GlobalModeAllDisable) "histFrame {.frmbar.histFrame config}" 2277 lappend expgui(GlobalModeAllDisable) "profFrame {.frmbar.profFrame config}" 2088 2278 } 2089 2279 … … 2094 2284 foreach item {phaseFrame histFrame fracFrame profFrame lsFrame} { 2095 2285 if {$item == $nextpage} { 2096 . bar.$item config -relief flat2286 .frmbar.$item config -relief flat 2097 2287 } else { 2098 . bar.$item config -relief raised2288 .frmbar.$item config -relief raised 2099 2289 } 2100 2290 } … … 2118 2308 set frame3 [frame $expgui(phaseFrame).frame3 -width 100 -relief raised -borderwidth 4 -bg beige] 2119 2309 2120 grid $expgui(phaseFrame).top -sticky n ws -row 0 -column 02310 grid $expgui(phaseFrame).top -sticky news -row 0 -column 0 2121 2311 grid $frameLatt -sticky news -row 2 -column 0 2122 2312 grid $fbig -sticky news -row 3 -column 0 … … 2127 2317 grid columnconfigure $expgui(phaseFrame) 0 -weight 1 2128 2318 grid rowconfigure $expgui(phaseFrame) 3 -weight 1 2129 grid [frame $expgui(phaseFrame).top.ps] -column 0 -row 0 2319 grid [frame $expgui(phaseFrame).top.ps] -column 0 -row 0 -sticky w 2130 2320 # this is where the buttons will go 2131 2321 pack [label $expgui(phaseFrame).top.ps.0 -text "Phases: "] -side left 2132 2322 2133 2134 grid [label $expgui(phaseFrame).top.lA -textvariable entryvar(phasename) \ 2135 -fg blue -anchor center] -column 1 -row 0 2323 grid [label $expgui(phaseFrame).top.lA -text " Phase name:" \ 2324 -fg blue ] -column 1 -row 0 -sticky e 2325 grid [entry $expgui(phaseFrame).top.lB -textvariable entryvar(phasename) \ 2326 -fg blue -width 45] -column 2 -row 0 -sticky e 2136 2327 grid columnconfigure $expgui(phaseFrame).top 1 -weight 1 2137 2328 # ------------- Lattice Parameter Box ------------------ … … 2532 2723 } 2533 2724 } 2534 # need to respond to mouse presses -- control variable associated with extract Fobs2535 # and set the LeBail extraction flags2536 proc SetupExtractHist {} {2537 global expgui entrycmd entryvar expmap2538 2539 # display the selected histograms2540 $expgui(lsFrame).hs.lbox selection clear 0 end2541 foreach h $expgui(curhist) {2542 $expgui(lsFrame).hs.lbox selection set $h2543 }2544 # disable traces on entryvar for right now2545 set entrycmd(trace) 02546 2547 # get histogram list2548 set histlist {}2549 foreach item $expgui(curhist) {2550 lappend histlist [lindex $expmap(powderlist) $item]2551 }2552 set entrycmd(fobsextract) "histinfo [list $histlist] foextract"2553 if {[llength $histlist] == 1} {2554 set entryvar(fobsextract) [histinfo $histlist foextract]2555 foreach phase {1 2 3 4 5 6 7 8 9} {2556 # is the phase present?2557 if {[lsearch -exact $expmap(phaselist_$histlist) $phase] == -1} {2558 $expgui(lsFrame).f1.a.l$phase config -fg grey2559 set expgui(Fextract$phase) {}2560 # foreach item "a.ca$phase a.cb$phase a.cc$phase"2561 foreach item "a.ca$phase a.cc$phase" {2562 $expgui(lsFrame).f1.$item config -state disabled -bd 12563 }2564 } else {2565 $expgui(lsFrame).f1.a.l$phase config -fg black2566 # foreach item "a.ca$phase a.cb$phase a.cc$phase"2567 foreach item "a.ca$phase a.cc$phase" {2568 $expgui(lsFrame).f1.$item config -state normal -bd 22569 }2570 set expgui(Fextract$phase) [hapinfo $histlist $phase extmeth]2571 }2572 }2573 } else {2574 # multiple histograms need phases in any histogram2575 foreach phase {1 2 3 4 5 6 7 8 9} {2576 set gotphase($phase) 02577 }2578 foreach hist $histlist {2579 foreach phase $expmap(phaselist_$hist) {2580 set gotphase($phase) 12581 }2582 }2583 foreach phase {1 2 3 4 5 6 7 8 9} {2584 set expgui(Fextract$phase) {}2585 if $gotphase($phase) {2586 $expgui(lsFrame).f1.a.l$phase config -fg black2587 foreach item "a.ca$phase a.cb$phase a.cc$phase" {2588 $expgui(lsFrame).f1.$item config -state normal -bd 22589 }2590 } else {2591 $expgui(lsFrame).f1.a.l$phase config -fg grey2592 foreach item "a.ca$phase a.cb$phase a.cc$phase" {2593 $expgui(lsFrame).f1.$item config -state disabled -bd 12594 }2595 }2596 }2597 }2598 # reenable traces2599 set entrycmd(trace) 12600 }2601 # respond to a change in the fobs extraction method for a phase2602 # force the main extraction flag on, if fobs extraction is selected for any phase2603 proc HistExtractSet {phase} {2604 global expgui entryvar expmap2605 foreach item $expgui(curhist) {2606 lappend histlist [lindex $expmap(powderlist) $item]2607 }2608 hapinfo $histlist $phase extmeth set $expgui(Fextract$phase)2609 if {$expgui(Fextract$phase) != 0} {set entryvar(fobsextract) 1}2610 }2611 2725 2612 2726 pack [frame $expgui(lsFrame).f1] -fill both -expand true 2613 2727 grid rowconfigure $expgui(lsFrame).f1 4 -weight 1 2614 grid [label $expgui(lsFrame).f1.his1 -pady 6 -text "Last History:"] -row 0 -column 0 2728 set row 0 2729 grid [label $expgui(lsFrame).f1.his1 -pady 6 -text "Last History:"] -row $row -column 0 2615 2730 grid [label $expgui(lsFrame).f1.his2 -relief sunken -bd 2 -pady 6 \ 2616 2731 -textvariable expgui(last_History)] \ 2617 -row 0 -column 1 -columnspan 5 -sticky w 2732 -row $row -column 1 -columnspan 5 -sticky w 2733 incr row 2734 grid [label $expgui(lsFrame).f1.tit1 -pady 6 -text "Title:"] -row $row -column 0 2735 grid [entry $expgui(lsFrame).f1.tit2 \ 2736 -textvariable entryvar(title) -width 48] \ 2737 -row $row -column 1 -columnspan 5 -sticky w 2738 set entrycmd(title) "expinfo title" 2739 2740 incr row 2618 2741 grid [frame $expgui(lsFrame).f1.b -bd 4 -relief groove] \ 2619 -row 1-column 0 -columnspan 2 -pady 32742 -row $row -column 0 -columnspan 2 -pady 3 2620 2743 grid [label $expgui(lsFrame).f1.b.lcyc -text "Number of Cycles"] -row 0 -column 0 2621 2744 grid [entry $expgui(lsFrame).f1.b.ecyc -width 3 \ … … 2623 2746 grid [menubutton $expgui(lsFrame).f1.lprint -textvariable expgui(printopt) \ 2624 2747 -menu $expgui(lsFrame).f1.lprint.menu -bd 4 -relief raised \ 2625 ] -row 1-column 22748 ] -row $row -column 2 2626 2749 menu $expgui(lsFrame).f1.lprint.menu 2627 2750 foreach num [lsort [array names printopts]] { … … 2630 2753 -variable entryvar(printopt$num) 2631 2754 } 2632 grid [frame $expgui(lsFrame).f1.c -bd 4 -relief groove] -row 1-column 32755 grid [frame $expgui(lsFrame).f1.c -bd 4 -relief groove] -row $row -column 3 2633 2756 grid [label $expgui(lsFrame).f1.c.fol -text "Extract Fobs"] -row 0 -column 2 2634 2757 grid [checkbutton $expgui(lsFrame).f1.c.foc -variable entryvar(fobsextract)] -row 0 -column 3 2635 2636 grid [frame $expgui(lsFrame).f1.a -bd 4 -relief groove] -row 3-column 0 -columnspan 62758 incr row 2759 grid [frame $expgui(lsFrame).f1.a -bd 4 -relief groove] -row $row -column 0 -columnspan 6 2637 2760 foreach num {1 2 3 4 5 6 7 8 9} { 2638 2761 grid [label $expgui(lsFrame).f1.a.l$num -text $num] -row 1 -column $num … … 2659 2782 #grid [label $expgui(lsFrame).f1.a.t3a -text "(Le Bail method)" -anchor c] -column 10 -row 4 2660 2783 # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ END OF LS PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 2784 #------------------------------------------------------------------------- 2785 #------------------------------------------------------------------------- 2661 2786 #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv THE MENU BAR vvvvvvvvvvvvvvvvvvvvvv 2662 2787 … … 2668 2793 -command "reset" 2669 2794 } 2795 $expgui(fm).file.menu add command -label "expnam" -underline 0 \ 2796 -command readnewexp 2670 2797 $expgui(fm).file.menu add command -label "Save" -underline 0 \ 2671 -command {savearchiveexp $expfile}2798 -command savearchiveexp 2672 2799 $expgui(fm).file.menu add command -label "Save As" -underline 1 \ 2673 2800 -command "SaveAsFile" 2674 2801 $expgui(fm).file.menu add command -label "Reread .EXP file" -underline 0 \ 2675 -command {rereadexp $expfile} 2676 $expgui(fm).file.menu add command -label "Other .EXP file" -underline 0 \ 2677 -command {readnewexp} 2802 -command {rereadexp $expgui(expfile)} 2678 2803 #$expgui(fm).file.menu add command -label "Close" -underline 0 2679 $expgui(fm).file.menu add command -label "Exit" -underline 1 -command catchQuit2680 2804 2681 2805 #---- help menu button 2682 2806 menubutton $expgui(fm).help -text Help -underline 0 -menu $expgui(fm).help.menu 2683 2807 menu $expgui(fm).help.menu 2684 $expgui(fm).help.menu add command - label "About..." -underline 0 -command { About }2685 #$expgui(fm).help.menu add command -label "GSAStk" -underline 0 -command { GSAStkHelp } 2808 $expgui(fm).help.menu add command -command showhelp -label "Help on Command" 2809 $expgui(fm).help.menu add command -label "About..." -underline 0 -command About 2686 2810 2687 2811 #---- options menu button … … 2752 2876 2753 2877 pack $expgui(fm).file $expgui(fm).option -side left -in $expgui(fm) 2878 2879 foreach menu $expgui(menunames) { 2880 set m [string tolower $menu] 2881 pack [menubutton $expgui(fm).$m -text $menu -underline 0 \ 2882 -menu $expgui(fm).$m.menu] -side left 2883 menu $expgui(fm).$m.menu 2884 } 2754 2885 pack $expgui(fm).help -side right -in $expgui(fm) 2755 2886 2887 # add the commands in expgui_menulist 2888 foreach menu [array names expgui_menulist ] { 2889 foreach cmd $expgui_menulist($menu) { 2890 set action {} 2891 catch {set action [lindex $expgui_cmdlist($cmd) 0]} 2892 if {$expgui(debug) && $action == ""} {puts "blank command for $cmd"} 2893 if {$action != "" && $action != "-"} { 2894 eval $expgui(fm).$menu.menu add command \ 2895 -label $cmd -command [list [subst $action]] 2896 } 2897 } 2898 } 2899 # setup command help 2900 foreach cmd [array names expgui_cmdlist] { 2901 set help {} 2902 catch {set help [lindex $expgui_cmdlist($cmd) 1]} 2903 if {$help == ""} { 2904 if {$expgui(debug)} {puts "no help for $cmd"} 2905 } else { 2906 # remove 2907 regsub -all \x09 $help " " help 2908 # preserve blank lines 2909 regsub -all \x0A\x0A $help "AAA1234567890AAA" help 2910 regsub -all \x0A $help " " help 2911 regsub -all "AAA1234567890AAA" $help \x0A\x0A help 2912 regsub -all " +" $help " " help 2913 set expgui_helplist($cmd) [string trim $help] 2914 } 2915 } 2916 # set up button bar 2917 foreach cmd $expgui(buttonlist) { 2918 set action {} 2919 catch {set action [lindex $expgui_cmdlist($cmd) 0]} 2920 if {$expgui(debug) && $action == ""} {puts "blank command for $cmd"} 2921 if {$action != ""} { 2922 pack [eval button .bar.$cmd -bg beige \ 2923 -text $cmd -command [list [subst $action]]] -side left 2924 } 2925 } 2926 2927 $expgui(fm).file.menu add command -label "Exit" -underline 1 -command catchQuit 2756 2928 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF MENU DEFINITION ^^^^^^^^^^^^^^^^^^^ 2929 2757 2930 2758 2931 # handle indirect exits … … 2760 2933 bind . <Control-c> catchQuit 2761 2934 2762 loadexp $exp file2935 loadexp $expgui(expfile)
Note: See TracChangeset
for help on using the changeset viewer.