#!/usr/local/bin/wish set expgui(Revision) {$Revision: 63 $ $Date: 2009-12-04 22:59:47 +0000 (Fri, 04 Dec 2009) $} # to do: # # need to change heading and button label depending on where getExpFileName # is called from # # fixup documentation and you are done! # # global background editing & profile work differently: should both # start out blank with a "load from option"? # # idea: # a scroll list for all histogram refinement flags ; click on takes you to the # appropriate menu. # # to allow "global" access on phase page # change buttons from radio to multiple # -- or display all 9 cell flag/damps and all atoms # make editMultipleRecords work with multiple phases, also cell flag/damp # blank cell entries # add phase to atom number in listing # DisplayAllAtoms needs to loop over phases: expgui(curPhase) if {$tcl_version < 8.0} { tk_dialog .expFileErrorMsg "Version Error" \ "The program requires Tcl/Tk version 8.0 or higher" error 0 "Exit" exit } if {$argv != ""} { set expgui(expfile) $argv if {[string toupper [file extension $expgui(expfile)]] != ".EXP"} { append expgui(expfile) ".EXP" } } else { set expgui(expfile) {} } set expgui(debug) 0 catch {if $env(DEBUG) {set expgui(debug) 1}} #set expgui(debug) 1 set expgui(havetix) 1 # for debugging non-Tix version set environment variable NOTIX catch {if $env(NOTIX) {set expgui(havetix) 0}} if $expgui(havetix) { if [catch {package require Tix}] {set expgui(havetix) 0} } # default is archive = on set expgui(archive) 1 # save the name of the wish executable set wishshell [info nameofexecutable] # misc constants set expgui(coordfont) "-*-courier-bold-r-normal--12-*" set expgui(histfont) "-*-courier-bold-r-normal--12-*" set liveplot(hst) 1 set liveplot(legend) 1 set expgui(filesort) 1 #============================================================================= # Store names of profile terms. array set expgui { prof-T-1 {TOF-type1 alp-0 bet-0 sig-0 alp-1 bet-1 sig-1 rstr rsta \ sig-2 rsca s1ec s2ec } prof-T-2 {TOF-type2 alp-0 sig-0 gam-0 alp-1 sig-1 gam-1 beta sig-2 \ gam-2 switch ptec stec difc difa zero } prof-T-3 {TOF-type3 alp bet-0 bet-1 sig-0 sig-1 sig-2 gam-0 gam-1 \ gam-2 gsf g1ec g2ec rstr rsta rsca L11 L22 L33 L12 L13 L23 } prof-T-4 {TOF-type4 alp bet-0 bet-1 sig-1 sig-2 gam-2 g2ec gsf \ rstr rsta rsca eta} prof-C-1 {CW-type U V W asym F1 F2 } prof-C-2 {CW-type2 GU GV GW LX LY trns asym shft GP stec ptec sfec \ L11 L22 L33 L12 L13 L23 } prof-C-3 {CW-type3 GU GV GW GP LX LY S/L H/L trns shft stec ptec sfec \ L11 L22 L33 L12 L13 L23 } prof-C-4 {CW-type4 GU GV GW GP LX ptec trns shft sfec S/L H/L eta} } # >>>>>>>>>>>>>>>> End of Profile Terms >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #---------------------------------------------------------------- # where are we? set expgui(script) [info script] # translate links -- go six levels deep foreach i {1 2 3 4 5 6} { if {[file type $expgui(script)] == "link"} { set link [file readlink $expgui(script)] if { [file pathtype $link] == "absolute" } { set expgui(script) $link } { set expgui(script) [file dirname $expgui(script)]/$link } } else { break } } # fixup relative paths if {[file pathtype $expgui(script)] == "relative"} { set expgui(script) [file join [pwd] $expgui(script)] } set expgui(scriptdir) [file dirname $expgui(script) ] set expgui(gsasdir) [file dirname $expgui(scriptdir)] set expgui(gsasexe) [file join $expgui(gsasdir) exe] #---------------------------------------------------------------- # fetch EXP file processing routines source [file join $expgui(scriptdir) readexp.tcl] # commands for running GSAS programs source [file join $expgui(scriptdir) gsascmds.tcl] # contents of GSAS menus source [file join $expgui(scriptdir) gsasmenu.tcl] #--------------------------------------------------------------------------- # override options with locally defined values if [file exists [file join $expgui(scriptdir) localconfig]] { source [file join $expgui(scriptdir) localconfig] } if [file exists [file join ~ .gsas_config]] { source [file join ~ .gsas_config] } #--------------------------------------------------------------------------- if {$expgui(expfile) != ""} { if ![file exists $expgui(expfile)] { update set ans [tk_dialog .expFileErrorMsg "File Open Error" \ "File [file tail $expgui(expfile)] does not exist in [file dirname $expgui(expfile)]" \ error 0 "Create" "Open other"] if $ans {set expgui(expfile) {}} } } if {$expgui(expfile) == ""} { # windows needs this update or focus gets screwed up after tk_getOpenFile update set expgui(expfile) [getExpFileName old] } if {$expgui(expfile) == ""} exit # you've been warned this .EXP does not exist! if ![file exists $expgui(expfile)] { # create an "empty" exp file createexp $expgui(expfile) \ [getstring "title for experiment $expgui(expfile)" 60 0] } catch {cd [string trim [file dirname $expgui(expfile)]]} # # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # <<<<<<<<<< BEGINNING OF MAIN: GLOBAL AREA FOR DATA EXTRACTION >>>>>>>>>>> # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # load exp file and set up dialogs proc loadexp {expfile} { global expgui expmap entryvar entrycmd global exparray catch { unset exparray } expload $expfile set expgui(changed) 0 mapexp set expgui(expModifiedLast) [file mtime $expfile] set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ] # set the window/icon title wm title . $expfile set expgui(titleunchanged) 1 wm iconname . [file tail $expfile] # set the number of phases on the phase page setphases # disable the "global options" that don't make sense based # on the histograms present foreach num {1 2 3 4 5} { set flag($num) 0 } foreach h $expmap(powderlist) { if {[string range $expmap(htype_$h) 2 2] == "T"} {set flag(1) 1} if {[string range $expmap(htype_$h) 1 2] == "NC"} {set flag(2) 1} if {[string range $expmap(htype_$h) 1 2] == "XC" && \ [histinfo $h lam2] != 0.0} {set flag(3) 1} if {[string range $expmap(htype_$h) 1 2] == "XC" && \ [histinfo $h lam2] == 0.0} {set flag(4) 1} if {[string range $expmap(htype_$h) 1 2] == "XE"} {set flag(5) 1} } foreach num {1 2 3 4 5} \ lbl {TOF "CW Neutron" "Alpha12 Xray" "Monochromatic Xray" \ "Energy Disp Xray"} { if $flag($num) { $expgui(fm).option.menu.editmode entryconfigure $lbl -state normal } else { $expgui(fm).option.menu.editmode entryconfigure $lbl -state disabled } } # disable traces on entryvar until we are ready set entrycmd(trace) 0 # propogate changes on the least squares page set entryvar(cycles) [expinfo cycles] set entrycmd(cycles) "expinfo cycles" set expgui(globalmode) 0 set expgui(printopt) "Print Options ([expinfo print])" set entryvar(title) [expinfo title] global printopts foreach num [array names printopts] { set entrycmd(printopt$num) "printsetting $num" set entryvar(printopt$num) [printsetting $num] } # enable traces on entryvar set entrycmd(trace) 1 # set fo extaction on LS page SetupExtractHist # update the histogram list & the page, if shown sethistlist # update the atoms display # DisplayAllAtoms noreset SelectOnePhase $expgui(curPhase) # start checking for external changes afterawhile } # called to reread the .EXP file -- use after another program # has changed the experiment file proc rereadexp {expfile} { global expgui if $expgui(changed) { set decision [tk_dialog .instrSaveData {Save .EXP changes} \ {You have made changes to the Experiment. Rereading will cause the changes to be lost. Select an option:} \ {} 0 "Save and reread" "Reread without Save" "Cancel reread command"] switch $decision { 0 { savearchiveexp } 1 { } 2 { return } } } loadexp $expgui(expfile) } proc CreateNewExp {} { global expgui set newexpfile [newexp] if {$newexpfile == ""} return # create an "empty" exp file createexp $newexpfile \ [getstring "title for experiment $newexpfile" 60 0] set expgui(expfile) $newexpfile catch {cd [string trim [file dirname $expgui(expfile)]]} loadexp $expgui(expfile) } proc SaveAsFile {} { global expgui set newexpfile [getExpFileName new] if {$newexpfile == ""} return set expgui(expfile) $newexpfile catch {cd [string trim [file dirname $expgui(expfile)]]} expwrite $expgui(expfile) set expgui(changed) 0 set expgui(expModifiedLast) [file mtime $expgui(expfile)] set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ] # set the window/icon title wm title . $expgui(expfile) set expgui(titleunchanged) 1 wm iconname . [file tail $expgui(expfile)] } # called to read a different .EXP file proc readnewexp {} { global expgui expmap if $expgui(changed) { set decision [tk_dialog .instrSaveData {Save .EXP changes} \ {You have made changes to the Experiment. Reading a different file will cause the changes to be lost. Select an option:} \ {} 0 "Save and read" "Read without Save" "Cancel read command"] switch $decision { 0 { savearchiveexp } 1 { } 2 { return } } } set newexpfile [getExpFileName old] if {$newexpfile == ""} return set expgui(expfile) $newexpfile catch {cd [string trim [file dirname $expgui(expfile)]]} loadexp $expgui(expfile) # select the 1st phase SelectOnePhase [lindex $expmap(phaselist) 0] # select the first histogram in the list by default (if there are any) if {[llength $expmap(histlistboxcontents)] > 0} {set expgui(curhist) 0} if !$expgui(havetix) { RaisePage lsFrame } else { .n raise lsPane set expgui(pagenow) lsFrame } } #------------- set up data read/write layer ---------------------- # trace routine on entryvar proc entvartrace {array elem action} { global expgui entrycmd entryvar if !$entrycmd(trace) return catch { if {$entrycmd($elem) == ""} return incr expgui(changed) if $expgui(debug) {puts "$entrycmd($elem) set $entryvar($elem) "} if {$entrycmd($elem) == ""} return if [catch { eval $entrycmd($elem) set [list $entryvar($elem)] if {[lindex $entrycmd($elem) 0] == "atominfo"} { after idle {DisplayAllAtoms noreset} } } errmsg] {puts "entvartrace error: $errmsg"} } } # disable traces on entryvar until we are ready set entrycmd(trace) 0 trace variable entryvar w entvartrace # # # ############################################################################## ##### ##################################################### ##### PROCEDURES SECTION ##################################################### ##### ##################################################### ############################################################################## # reset routine is used for debugging proc reset {} { global expgui script argv set script $expgui(script) set argv $expgui(expfile) # remove traces global entryvar foreach cmd [trace vinfo entryvar] { eval trace vdelete entryvar $cmd } global expgui foreach cmd [trace vinfo expgui(backterms)] { eval trace vdelete entryvar $cmd } foreach cmd [trace vinfo expgui(backtype)] { eval trace vdelete entryvar $cmd } foreach a { exparray expmap expgui entryvar entrycmd expgui_menulist expgui_cmdlist expgui_helplist } { global $a catch {unset $a} } foreach w [winfo children .] { destroy $w } uplevel #0 {source $script} } # save some of the global options in ~/.gsas_config proc SaveOptions {} { global expgui env tcl_platform set fp [open [file join ~ .gsas_config] a] puts $fp "set expgui(archive) $expgui(archive)" puts $fp "set expgui(asorttype) $expgui(asorttype)" puts $fp "set expgui(hsorttype) $expgui(hsorttype)" puts $fp "set expgui(filesort) $expgui(filesort)" if {$tcl_platform(platform) != "windows"} { puts $fp "set env(GSASBACKSPACE) $env(GSASBACKSPACE)" } close $fp } proc About { } { global expgui expmap tk_dialog .about {About...} \ "EXPGUI\n\ Jonathan Wasserman and Brian Toby\n\ NIST Center for Neutron Research\n\n\ 1998, Not subject to copyright\n\n\ Revision [lindex $expgui(Revision) 1] (readexp.tcl [lindex $expmap(Revision) 1])\n\n\ Generalized Structure Analysis System (GSAS)\n\ A. C. Larson and\n R. B. Von Dreele,\n LANSCE, Los Alamos\n\n\ " \ info 0 OK } # wait until idle proc afterawhile {} { # cancel any other instances of this loop after cancel afterawhile after cancel whenidle after cancel whenidle after idle whenidle } proc whenidle {} { global expgui if $expgui(titleunchanged) { if {$expgui(changed) != 0} { wm title . "$expgui(expfile) (modified)" set expgui(titleunchanged) 0 } } if {[file mtime $expgui(expfile)] != $expgui(expModifiedLast)} { if {$expgui(changed) == 0} { set ans [tk_dialog .expFileErrorMsg "Reload?" \ "File [file tail $expgui(expfile)] has been modified by another program. \ Do you want to load the newer version or lose the modifications \ by editing the current version?" \ warning 0 "Load new" "Continue editing"] } else { set ans [tk_dialog .expFileErrorMsg "Reload?" \ "File [file tail $expgui(expfile)] has been modified by another program \ and you have made $expgui(changed) changes to this version. \ Do you want to load the newer version or lose the modifications \ by continuing to edit the current version?" \ warning 0 "Load new" "Continue editing" "Save edited version"] } if {$ans == 0} { loadexp $expgui(expfile) } elseif {$ans == 1} { # reset the time to the next version set expgui(expModifiedLast) [file mtime $expgui(expfile)] } elseif {$ans == 2} { savearchiveexp } } after 2000 afterawhile } # -------- called to confirm before exiting proc catchQuit {} { if {[confirmBeforeSave] == "Continue"} { destroy . } } # save the .EXP file before exiting? proc confirmBeforeSave {} { global expgui if !$expgui(changed) { return "Continue" } set decision [tk_dialog .instrSaveData {Save .EXP changes} \ {You have made changes to the Experiment, but the changes are not saved. Select an option:} \ {} 0 "Save and Exit" "Exit without Save" "Cancel exit command"] switch $decision { 0 { savearchiveexp; return "Continue" } 1 { return "Continue" } 2 { return "Cancel" } } } proc archiveexp {} { global expgui tcl_platform catch { set expnam [file rootname $expgui(expfile)] if {$tcl_platform(platform) == "windows"} { if ![file executable [file join $expgui(scriptdir) pkzip.exe]] { # archive w/o pkzip set files [glob -nocomplain ${expnam}!*.exp] if {$files == ""} { set num -1 } else { set file [lindex [lsort -decreasing $files] 0] regexp {!([0-9]+)\.EXP} [string toupper $file] a num } set file $expnam![format "%3.3d" [incr num]].EXP file copy $expnam.EXP $file set fp [open $expnam.lst a] puts $fp "\n--------------------------------------------------------------" puts $fp "Archiving $expnam.EXP as $file" puts $fp "--------------------------------------------------------------\n" close $fp } else { # archive with PKZIP # need to limit expnam to 8 characters set sexp [string toupper [string range [file root [file tail $expnam] ] 0 7]] # PKZIP can't handle long dir names either cd [set dir [file dirname $expnam]] set num -1 # get the versions from the listing if [file exists $sexp.zip] { set fp [open "| [file join $expgui(scriptdir) pkzip.exe] -vb $sexp" r] while {[gets $fp line] >= 0} { regexp "$sexp\.0?0?(\[0-9\]+)" [string toupper $line] junk n catch {if {$n > $num} {set num $n}} } close $fp } incr num set file $sexp.[format "%3.3d" $num] file copy -force $expnam.EXP $file exec [file join $expgui(scriptdir) pkzip.exe] -m $expnam $file > x.x & set fp [open $expnam.lst a] puts $fp "\n--------------------------------------------------------------" puts $fp "Archiving $expnam.EXP as $file in [file join $dir $sexp.ZIP]" puts $fp "--------------------------------------------------------------\n" close $fp } } else { set files [glob -nocomplain $expnam.EXP.*] if {$files == ""} { set file $expnam.EXP.000 } else { set file [lindex [lsort -decreasing $files] 0] regexp {.*\.EXP.0?0?([0-9]*).*} $file junk number incr number set file $expnam.EXP.[format "%3.3d" $number] } exec cp $expgui(expfile) $file if [catch {exec gzip $file}] { exec echo "\n----------------------------------------------" >> $expnam.LST exec echo " Archiving $expnam.EXP as $file " >> $expnam.LST exec echo "----------------------------------------------\n" >> $expnam.LST } else { exec echo "\n----------------------------------------------" >> $expnam.LST exec echo " Archiving $expnam.EXP as $file.gz " >> $expnam.LST exec echo "----------------------------------------------\n" >> $expnam.LST } } } errmsg if {$errmsg != ""} { tk_dialog .warn Confirm "Error in archive: $errmsg" warning 0 OK } } # save and optionally archive the expfile proc savearchiveexp {} { global expgui expmap if !$expgui(changed) return if $expgui(archive) archiveexp # add a history record exphistory add " EXPGUI [lindex $expgui(Revision) 1] [lindex $expmap(Revision) 1] ($expgui(changed) changes) -- [clock format [clock seconds]]" # now save the file expwrite $expgui(expfile) set expgui(changed) 0 set expgui(expModifiedLast) [file mtime $expgui(expfile)] set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ] wm title . $expgui(expfile) set expgui(titleunchanged) 1 } # set the number of phases on the phase page proc setphases {} { global expgui expmap eval destroy [pack slaves $expgui(phaseFrame).top.ps] foreach num $expmap(phaselist) { pack [button $expgui(phaseFrame).top.ps.$num -text $num \ -command "SelectOnePhase $num"] -side left } } # Procedure to respond to changes the phase. # This loads the "phases" widgets with data corresponding to the selected phase. proc SelectOnePhase {num} { global entryvar entrycmd expmap expgui foreach n $expmap(phaselist) { if {$n == $num} { $expgui(phaseFrame).top.ps.$num config -relief sunken } else { $expgui(phaseFrame).top.ps.$n config -relief raised } } set crsPhase $num # no phase is selected if {$crsPhase == ""} { # disable traces on entryvar set entrycmd(trace) 0 set entrycmd(phasename) "" set entryvar(phasename) "" foreach ent {a b c alpha beta gamma cellref celldamp} { set entrycmd($ent) "" set entryvar($ent) "" } # enable traces on entryvar set entrycmd(trace) 1 return } set expgui(curPhase) $crsPhase # we have a phase # disable traces on entryvar for right now set entrycmd(trace) 0 ########################################################## ###### SECTION: ASSIGNMENT OF DATA VARIABLES ########## ########################################################## # phase title set entrycmd(phasename) "phaseinfo $crsPhase name" set entryvar(phasename) [phaseinfo $crsPhase name] # cell parameters & flags foreach ent {a b c alpha beta gamma cellref celldamp} { set entrycmd($ent) "phaseinfo $crsPhase $ent" set entryvar($ent) [phaseinfo $crsPhase $ent] } #Procedure call: DisplayU -- Display Anisotropic/Isotropic widget or disable # initialize to diasbled DisplayAtom 0 0 DisplayU 0 0 DisplayRefFlags 0 0 $expgui(EditingAtoms) config -text "" DisplayAllAtoms # enable traces on entryvar now set entrycmd(trace) 1 } set expgui(noreenterDisplayAllAtoms) 0 # Populate expgui(atomlistbox) (ScrolledListBox) with atoms from selected phase. proc DisplayAllAtoms {"mode reset"} { global entryvar entrycmd expmap expgui # if it does not show, dont bother if {$expgui(pagenow) != "phaseFrame"} return if {$expgui(curPhase) == ""} return if $expgui(noreenterDisplayAllAtoms) return set expgui(noreenterDisplayAllAtoms) 1 if {$mode != "reset"} { # save the scrolled position set pos [lindex [$expgui(atomlistbox) yview] 0] } else { # this is a reset -- clear the selected atoms list set expgui(selectedatomlist) {} } $expgui(atomlistbox) delete 0 end # loop over atoms set maxline I set phase $expgui(curPhase) set atomlist {} if {$expgui(asorttype) == "type"} { # sort on atom type foreach atom $expmap(atomlist_$phase) { lappend atomlist "$atom [atominfo $phase $atom type] $phase" } set expmap(atomlistboxcontents) [lsort -ascii -index 1 $atomlist] } elseif {$expgui(asorttype) == "number"} { # sort on atom number foreach atom $expmap(atomlist_$phase) { lappend atomlist "$atom $atom $phase" } set expmap(atomlistboxcontents) [lsort -integer -index 1 $atomlist] } elseif {$expgui(asorttype) == "x"} { # sort on x foreach atom $expmap(atomlist_$phase) { lappend atomlist "$atom [atominfo $phase $atom x] $phase" } set expmap(atomlistboxcontents) [lsort -real -index 1 $atomlist] } elseif {$expgui(asorttype) == "y"} { # sort on y foreach atom $expmap(atomlist_$phase) { lappend atomlist "$atom [atominfo $phase $atom y] $phase" } set expmap(atomlistboxcontents) [lsort -real -index 1 $atomlist] } elseif {$expgui(asorttype) == "z"} { # sort on z foreach atom $expmap(atomlist_$phase) { lappend atomlist "$atom [atominfo $phase $atom z] $phase" } set expmap(atomlistboxcontents) [lsort -real -index 1 $atomlist] } else { error "Bad expgui(asorttype = $expgui(asorttype)" } foreach tuple $expmap(atomlistboxcontents) { set atom [lindex $tuple 0] set phase [lindex $tuple 2] set refflag {} foreach type {x u f} { if {[atominfo $phase $atom ${type}ref]} { append refflag "[string toupper $type][atominfo $phase $atom ${type}damp] " } else { append refflag " [atominfo $phase $atom ${type}damp] " } } set line [format "%3d %-6s %-6s %8s %10.6f%10.6f%10.6f%9.4f" \ $atom \ [atominfo $phase $atom label] \ [atominfo $phase $atom type] \ $refflag \ [atominfo $phase $atom x] \ [atominfo $phase $atom y] \ [atominfo $phase $atom z] \ [atominfo $phase $atom frac] ] # add temperature factors (iso/anoiso) if {[atominfo $phase $atom temptype] == "A"} { set maxline A append line [format " %9.5f%9.5f%9.5f%9.5f%9.5f%9.5f" \ [atominfo $phase $atom U11] \ [atominfo $phase $atom U22] \ [atominfo $phase $atom U33] \ [atominfo $phase $atom U12] \ [atominfo $phase $atom U23] \ [atominfo $phase $atom U13] ] } else { append line [format " %9.5f" \ [atominfo $phase $atom Uiso] ] } $expgui(atomlistbox) insert end $line } $expgui(atomtitle) delete 0 end if {$maxline == "A"} { $expgui(atomtitle) insert end [format "%10s %6s %8s %30s%9s %s" \ " name " "type " "ref/damp " "fractional coordinates " \ " Occupancy" \ "Uiso/Uij "] } else { $expgui(atomtitle) insert end [format "%10s %6s %8s %30s%9s %s" \ " name " "type " "ref/damp " "fractional coordinates " \ " Occupancy" \ "Uiso"] } if {$mode != "reset"} { # restore the selected items foreach i $expgui(selectedatomlist) { $expgui(atomlistbox) selection set $i } # restore the last scrolled position $expgui(atomlistbox) yview moveto $pos } set expgui(noreenterDisplayAllAtoms) 0 } # Procedure to select all atoms in response to a right-click proc SelectAllAtoms {} { global expgui $expgui(atomlistbox) selection set 0 end # call editRecord in case trace was called before the selection was made editRecord } # Procedure to respond to left mouse release in the atoms Pane proc editRecord { args } { global entrycmd expgui set expgui(selectedatomlist) [$expgui(atomlistbox) curselection] # disable traces on entryvar for right now set entrycmd(trace) 0 if {[llength $expgui(selectedatomlist)] == 0} { puts "How did this happen: [$expgui(atomlistbox) curselection]" } elseif {[llength $expgui(selectedatomlist)] == 1} { editOneRecord $expgui(selectedatomlist) } else { editMultipleRecords $expgui(selectedatomlist) } # reenable traces on entryvar set entrycmd(trace) 1 # repaint the atoms box in case anything was changed # DisplayAllAtoms noreset } proc editOneRecord { AtomIndex } { global expmap expgui # get atom number & phase set tuple [lindex $expmap(atomlistboxcontents) $AtomIndex] set atomnum [lindex $tuple 0] set p [lindex $tuple 2] DisplayU $atomnum $p DisplayAtom $atomnum $p DisplayRefFlags $atomnum $p $expgui(EditingAtoms) config -text "Editing atom #$atomnum -- [atominfo $p $atomnum label]" } # this will not work for a multi-phase list of atoms (yet) proc editMultipleRecords { AtomIndexList } { global expmap expgui set numberList {} # current phase set p $expgui(curPhase) foreach AtomIndex $AtomIndexList { # get atom number & phase set tuple [lindex $expmap(atomlistboxcontents) $AtomIndex] lappend numberList [lindex $tuple 0] # set p [lindex $tuple 2] } # this needs to track by phase $expgui(EditingAtoms) config -text \ "Set refinement options: atoms [CompressList $numberList]" DisplayU 0 0 DisplayAtom 0 0 # this needs to track by phase DisplayRefFlags $numberList $p } # format a string of numbers to save space, e.g. "1 2 3 4 6 7 19 13 14 15" # becomes "1-4,6,7,13-15,19" proc CompressList {numberList} { # format the number list to save space set lastnum -99 set flist {} set count 0 foreach num [lsort -integer $numberList] { set next [expr $lastnum+1] if {$num != $next} { if {$count == 0 && $flist != ""} { append flist ",$num" } elseif {$count == 1 && $flist != ""} { append flist ",$lastnum,$num" } elseif {$flist != ""} { append flist "-$lastnum,$num" } else { append flist "$num" } set lastnum $num set count 0 } else { incr count incr lastnum } } if {$count == 1 && $flist != ""} { append flist ",$lastnum" } elseif {$flist != "" && $count > 1} { append flist "-$lastnum" } return $flist } # Procedure to display Isotropic or Anisotropic temperature factors # Changes the display to one entry widget for Isotropic motion OR # 6 entry widgets for Anisotropic motion in Frame3. # or disables the widet entirly if atom = 0 proc DisplayU { atomnum p} { global expgui entryvar entrycmd if {$atomnum == 0} { set iOrA disable } else { set iOrA [atominfo $p $atomnum temptype] } set firstbox [lindex $expgui(anisolabels) 0] if { $iOrA == "A" } { $firstbox config -text "U11 " foreach item $expgui(anisolabels) { $item config -fg black } foreach item $expgui(anisoentry) var {U11 U22 U33 U12 U13 U23} { set entrycmd($var) "atominfo $p $atomnum $var" set entryvar($var) [eval $entrycmd($var)] $item config -fg black -state normal -bg white } } elseif { $iOrA == "I" || $iOrA == "disable"} { foreach item $expgui(anisolabels) { # $item config -fg grey $item config -fg beige } foreach item [lrange $expgui(anisoentry) 1 end] \ var {U22 U33 U12 U13 U23} { set entrycmd($var) "" set entryvar($var) "" $item config -fg beige -bg beige -state disabled } if { $iOrA == "disable"} { set entrycmd($var) "" set entryvar($var) "" # [lindex $expgui(anisoentry) 0] config -fg white -state disabled [lindex $expgui(anisoentry) 0] config -fg beige -bg beige -state disabled } else { set entrycmd(U11) "atominfo $p $atomnum Uiso" set entryvar(U11) [eval $entrycmd(U11)] $firstbox config -text Uiso -fg black [lindex $expgui(anisoentry) 0] config -fg black -bg white -state normal } } } # need to think about multiple phases # Procedure to display refinement flags proc DisplayRefFlags { atomnum p} { global expgui entryvar entrycmd if {$atomnum == 0} { foreach label $expgui(atomreflbl) { $label config -fg beige } foreach entry $expgui(atomref) { $entry config -state disabled -fg beige -bg beige } return } foreach label $expgui(atomreflbl) { $label config -fg black } foreach entry $expgui(atomref) { $entry config -state normal -fg black -bg beige } foreach var {xref uref fref xdamp udamp fdamp} { set entrycmd($var) "atominfo $p [list $atomnum] $var" set entryvar($var) [eval $entrycmd($var)] } } # Procedure to display an atom in the atom edit boxes proc DisplayAtom { atomnum p} { global expgui entryvar entrycmd if {$atomnum == 0} { foreach label $expgui(atomlabels) { $label config -fg beige } foreach entry $expgui(atomentry) { $entry config -state disabled -fg beige -bg beige } return } foreach label $expgui(atomlabels) { $label config -fg black } foreach entry $expgui(atomentry) { $entry config -state normal -fg black -bg white } foreach var {x y z label frac } { set entrycmd($var) "atominfo $p $atomnum $var" set entryvar($var) [eval $entrycmd($var)] } } # update the histogram list # to do: show histogram ref flags? proc sethistlist {} { global expgui expmap foreach lbox $expgui(HistSelectList) { $lbox.title delete 0 end $lbox.lbox delete 0 end if {$expgui(globalmode) != 0} { $lbox.lbox config -selectmode extended } else { $lbox.lbox config -selectmode browse } } # disable the unallowed pages in all mode if {$expgui(globalmode) == 6} { foreach pair $expgui(GlobalModeAllDisable) { if {$expgui(pagenow) == [lindex $pair 0]} { if !$expgui(havetix) { RaisePage lsFrame } else { .n raise lsPane set expgui(pagenow) lsFrame } } eval [lindex $pair 1] -state disabled } } else { foreach pair $expgui(GlobalModeAllDisable) { eval [lindex $pair 1] -state normal } } set histlist {} if {$expgui(hsorttype) == "type"} { # sort on histogram type foreach h [lsort -integer -increasing $expmap(powderlist)] { lappend histlist "$h [string range $expmap(htype_$h) 1 2]" } set expmap(histlistboxcontents) [lsort -ascii -index 1 $histlist] } elseif {$expgui(hsorttype) == "number"} { # sort on histogram number foreach h [lsort -integer -increasing $expmap(powderlist)] { lappend histlist "$h $h" } set expmap(histlistboxcontents) [lsort -integer -index 1 $histlist] } elseif {$expgui(hsorttype) == "bank"} { # sort on original bank number foreach h [lsort -integer -increasing $expmap(powderlist)] { lappend histlist "$h [histinfo $h bank]" } set expmap(histlistboxcontents) [lsort -integer -index 1 $histlist] } elseif {$expgui(hsorttype) == "angle"} { # sort on wavelength (CW) or angle (E disp.) foreach h [lsort -integer -increasing $expmap(powderlist)] { if {[string range $expmap(htype_$h) 2 2] == "T"} { set det [format %8.2f [histinfo $h tofangle]] } elseif {[string range $expmap(htype_$h) 2 2] == "C"} { set det [format %8.5f [histinfo $h lam1]] } elseif {[string range $expmap(htype_$h) 2 2] == "E"} { set det [format %8.2f [histinfo $h lam1]] } else { set det {} } lappend histlist "$h $det" } set expmap(histlistboxcontents) [lsort -real -index 1 $histlist] } # title field needs to match longest title foreach lbox $expgui(HistSelectList) { $lbox.title insert end [format "%2s %s %4s %8s %-67s" \ "h#" \ type \ bank \ "ang/wave" \ " title" \ ] } foreach tuple $expmap(histlistboxcontents) { set h [lindex $tuple 0] if {$expgui(globalmode) == 1} { if {[string range $expmap(htype_$h) 2 2] != "T"} continue } elseif {$expgui(globalmode) == 2} { if {[string range $expmap(htype_$h) 1 2] != "NC"} continue } elseif {$expgui(globalmode) == 3} { if {[string range $expmap(htype_$h) 1 2] != "XC" || \ [histinfo $h lam2] == 0.0} continue } elseif {$expgui(globalmode) == 4} { if {[string range $expmap(htype_$h) 1 2] != "XC" || \ [histinfo $h lam2] != 0.0} continue } elseif {$expgui(globalmode) == 5} { if {[string range $expmap(htype_$h) 1 2] != "XE"} continue } if {[string range $expmap(htype_$h) 2 2] == "T"} { set det [format %8.2f [histinfo $h tofangle]] } elseif {[string range $expmap(htype_$h) 2 2] == "C"} { set det [format %8.5f [histinfo $h lam1]] } elseif {[string range $expmap(htype_$h) 2 2] == "E"} { set det [format %8.2f [histinfo $h lam1]] } else { set det {} } foreach lbox $expgui(HistSelectList) { $lbox.lbox insert end [format "%2d %s %4d %8s %-67s" \ $h \ [string range $expmap(htype_$h) 1 2] \ [histinfo $h bank] \ $det \ [string range [histinfo $h title] 0 66] \ ] } } foreach set $expgui(frameactionlist) { if {$expgui(pagenow) == [lindex $set 0]} [lindex $set 1] } } #----------------------------------------------------------------------- # ----------- draw Histogram page #----------------------------------------------------------------------- proc DisplayHistogram {} { global expgui entrycmd entryvar expmap # display the selected histograms $expgui(histFrame).hs.lbox selection clear 0 end foreach h $expgui(curhist) { $expgui(histFrame).hs.lbox selection set $h } # disable traces on entryvar for right now set entrycmd(trace) 0 # get histogram list set histlist {} foreach item $expgui(curhist) { lappend histlist [lindex $expmap(powderlist) $item] } # must have at least one histogram selected here if {[llength $histlist] == 0} { set expgui(backtermlbl) "" set expgui(backtypelbl) "" foreach var {bref bdamp} { set entrycmd($var) "" set entryvar($var) "" } $expgui(histFrame).top.txt config -text "No Selected Histograms" grid $expgui(histFrame).top -column 1 -row 0 -sticky nsew set expgui(bkglbl) "" eval destroy [grid slaves $expgui(diffBox)] set entrycmd(trace) 1 return } if {$expgui(globalmode) != 0} { set expgui(backtermlbl) "" set expgui(backtypelbl) "" foreach var {bref bdamp} { set entrycmd($var) "histinfo [list $histlist] $var" set entryvar($var) [histinfo [lindex $histlist 0] $var] } } else { set hist $histlist set terms [histinfo $hist backterms] set expgui(backtermlbl) "($terms terms)" set expgui(backtypelbl) "Function type [histinfo $hist backtype]" foreach var {bref bdamp} { set entrycmd($var) "histinfo $hist $var" set entryvar($var) [eval $entrycmd($var)] } } # Top box if {$expgui(globalmode) != 0} { $expgui(histFrame).top.txt config \ -text "Selected Histograms: [CompressList $histlist]" grid $expgui(histFrame).top -column 1 -row 0 -sticky nsew set expgui(bkglbl) "Globally Edit Background" } else { grid forget $expgui(histFrame).top set expgui(bkglbl) "Edit Background" } # diffractometer constants foreach var {lam1 lam2 kratio pola ipola ddamp zero \ wref pref dcref daref ratref ttref zref } { set entrycmd($var) "histinfo [list $histlist] $var" set entryvar($var) [histinfo [lindex $histlist 0] $var] } eval destroy [grid slaves $expgui(diffBox)] if {$expgui(globalmode) == 0} { if {[string range $expmap(htype_$hist) 2 2] == "T"} { #------ # TOF | #------ grid [ label $expgui(diffBox).lDCrc -text "Refine DIFC" ] \ -column 1 -row 1 grid [ checkbutton $expgui(diffBox).rfDCrc -variable entryvar(dcref) ] \ -column 2 -row 1 grid [ label $expgui(diffBox).lDCdifc -text DIFC ] \ -column 3 -row 1 -sticky w grid [ entry $expgui(diffBox).eDCdifc -textvariable entryvar(lam1) \ -width 15 ] -column 4 -row 1 # grid [ label $expgui(diffBox).lDCra -text "Refine DIFA" ] \ -column 1 -row 2 grid [ checkbutton $expgui(diffBox).rfDCra -variable entryvar(daref) ] \ -column 2 -row 2 grid [ label $expgui(diffBox).lDCdifa -text DIFA ] \ -column 3 -row 2 grid [ entry $expgui(diffBox).eDCdifa -textvariable entryvar(lam2) \ -width 15 ] -column 4 -row 2 # grid [ label $expgui(diffBox).lDCzero -text "Zero"] \ -column 3 -row 3 grid [ entry $expgui(diffBox).eDCzero -textvariable entryvar(zero) \ -width 15 ] -column 4 -row 3 grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCzref \ -variable entryvar(zref) ] -column 2 -row 3 } elseif {[string range $expmap(htype_$hist) 1 2] == "NC"} { #--------------- # CW - neutron | #--------------- grid [ label $expgui(diffBox).lDC1 -text "Refine wave" ] \ -column 1 -row 1 grid [ checkbutton $expgui(diffBox).rfDC1 -variable entryvar(wref) ] \ -column 2 -row 1 grid [ label $expgui(diffBox).lDCdifc -text wave ] \ -column 3 -row 1 -sticky w grid [ entry $expgui(diffBox).eDCdifc -textvariable entryvar(lam1) \ -width 15 ] -column 4 -row 1 # grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCzref \ -variable entryvar(zref) ] -column 2 -row 3 grid [ label $expgui(diffBox).lDCzero -text "Zero"] \ -column 3 -row 3 grid [ entry $expgui(diffBox).eDCzero -textvariable entryvar(zero) \ -width 15 ] -column 4 -row 3 } elseif {[string range $expmap(htype_$hist) 1 2] == "XC" && \ [histinfo $hist lam2] == 0.0} { #-------------------------- # CW - x-ray 1 wavelength | #-------------------------- grid [ label $expgui(diffBox).lDC1 -text "Refine wave" ] \ -column 1 -row 1 grid [ checkbutton $expgui(diffBox).rfDC1 -variable entryvar(wref) ] \ -column 2 -row 1 grid [ label $expgui(diffBox).lDCdifc -text wave ] \ -column 3 -row 1 -sticky w grid [ entry $expgui(diffBox).eDCdifc -textvariable entryvar(lam1) \ -width 15 ] -column 4 -row 1 # grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCzref \ -variable entryvar(zref) ] -column 2 -row 3 grid [ label $expgui(diffBox).lDCzero -text "Zero"] \ -column 3 -row 3 grid [ entry $expgui(diffBox).eDCzero -textvariable entryvar(zero) \ -width 15 ] -column 4 -row 3 # grid [ label $expgui(diffBox).lDCpref -text "Refine POLA" ] \ -column 1 -row 4 -sticky w grid [ checkbutton $expgui(diffBox).rfDCpref \ -variable entryvar(pref) ] -column 2 -row 4 grid [ label $expgui(diffBox).lDCpola -text POLA ] \ -column 3 -row 4 grid [ entry $expgui(diffBox).eDCpola \ -textvariable entryvar(pola) -width 15 ] -column 4 -row 4 grid [ label $expgui(diffBox).lDCipola -text "IPOLA" ] \ -column 5 -row 4 grid [ entry $expgui(diffBox).eDCipola -width 2 \ -textvariable entryvar(ipola)] -column 6 -row 4 } elseif {[string range $expmap(htype_$hist) 1 2] == "XC"} { #--------------------------- # CW - x-ray 2 wavelengths | #--------------------------- grid [ label $expgui(diffBox).lDCdifc -text wavelengths ] \ -column 3 -row 1 -sticky w grid [ entry $expgui(diffBox).eDCdifc -textvariable entryvar(lam1) \ -width 15 ] -column 4 -row 1 grid [ entry $expgui(diffBox).eDCdifa -textvariable entryvar(lam2) \ -width 15 ] -column 5 -row 1 # grid [ label $expgui(diffBox).lDCrref -text "Refine ratio" ] \ -column 1 -row 2 -sticky w grid [ checkbutton $expgui(diffBox).rfDCrref \ -variable entryvar(ratref) ] -column 2 -row 2 grid [ label $expgui(diffBox).lDCratio -text Ratio ] \ -column 3 -row 2 grid [ entry $expgui(diffBox).eDCkratio \ -textvariable entryvar(kratio) \ -width 15 ] -column 4 -row 2 # grid [ label $expgui(diffBox).lDCzero -text "Zero"] \ -column 3 -row 3 grid [ entry $expgui(diffBox).eDCzero -textvariable entryvar(zero) \ -width 15 ] -column 4 -row 3 grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCzref \ -variable entryvar(zref) ] -column 2 -row 3 grid [ label $expgui(diffBox).lDCpref -text "Refine POLA" ] \ -column 1 -row 4 -sticky w grid [ checkbutton $expgui(diffBox).rfDCpref \ -variable entryvar(pref) ] -column 2 -row 4 grid [ label $expgui(diffBox).lDCpola -text POLA ] \ -column 3 -row 4 grid [ entry $expgui(diffBox).eDCpola \ -textvariable entryvar(pola) -width 15 ] -column 4 -row 4 grid [ label $expgui(diffBox).lDCipola -text "IPOLA" ] \ -column 5 -row 4 grid [ entry $expgui(diffBox).eDCipola -width 2 \ -textvariable entryvar(ipola)] -column 6 -row 4 -variable entryvar(zref) ] -column 2 -row 3 } elseif {[string range $expmap(htype_$hist) 1 2] == "XE"} { #------------- # ED - x-ray | #------------- grid [ label $expgui(diffBox).lDC1 -text "Refine 2theta" ] \ -column 1 -row 1 grid [ checkbutton $expgui(diffBox).rfDC1 -variable entryvar(ttref) ] \ -column 2 -row 1 grid [ label $expgui(diffBox).lDCdifc -text 2Theta ] \ -column 3 -row 1 -sticky w grid [ entry $expgui(diffBox).eDCdifc -textvariable entryvar(lam1) \ -width 15 ] -column 4 -row 1 # grid [ label $expgui(diffBox).lDCpref -text "Refine POLA" ] \ -column 1 -row 4 -sticky w grid [ checkbutton $expgui(diffBox).rfDCpref \ -variable entryvar(pref) ] -column 2 -row 4 grid [ label $expgui(diffBox).lDCpola -text POLA ] \ -column 3 -row 4 grid [ entry $expgui(diffBox).eDCpola \ -textvariable entryvar(pola) -width 15 ] -column 4 -row 4 grid [ label $expgui(diffBox).lDCipola -text "IPOLA" ] \ -column 5 -row 4 grid [ entry $expgui(diffBox).eDCipola -width 2 \ -textvariable entryvar(ipola)] -column 6 -row 4 } } elseif {$expgui(globalmode) == 1} { #------------- # Global TOF | #------------- grid [ label $expgui(diffBox).lDCrc -text "Refine DIFC" ] \ -column 1 -row 1 grid [ checkbutton $expgui(diffBox).rfDCrc -variable entryvar(dcref) ] \ -column 2 -row 1 grid [button $expgui(diffBox).bDCdifc -text "Set DIFC Globally" \ -command "editglobalparm histinfo difc {DIFC}"] -column 3 -row 1 # grid [ label $expgui(diffBox).lDCra -text "Refine DIFA" ] \ -column 1 -row 2 grid [ checkbutton $expgui(diffBox).rfDCra -variable entryvar(daref) ] \ -column 2 -row 2 grid [ button $expgui(diffBox).bDCdifa -text "Set DIFA Globally" \ -command "editglobalparm histinfo difa {DIFA}"] -column 3 -row 2 # grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCzref \ -variable entryvar(zref) ] -column 2 -row 3 grid [ button $expgui(diffBox).bDCzero -text "Set ZERO Globally" \ -command "editglobalparm histinfo zero {Zero}"] -column 3 -row 3 } elseif {$expgui(globalmode) == 2} { #-------------------- # Global CW neutron | #-------------------- grid [ label $expgui(diffBox).lDC1 -text "Refine wave" ] \ -column 1 -row 1 grid [ checkbutton $expgui(diffBox).rfDC1 -variable entryvar(wref) ] \ -column 2 -row 1 grid [button $expgui(diffBox).bDCdifc -text "Set Wave Globally" \ -command "editglobalparm histinfo lam1 Wavelength"] \ -column 3 -row 1 # grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCzref \ -variable entryvar(zref) ] -column 2 -row 3 grid [button $expgui(diffBox).bDCzero -text "Set Zero Globally" \ -command "editglobalparm histinfo zero Zero"] -column 3 -row 3 } elseif {$expgui(globalmode) == 4} { #---------------------- # Global CW mono xray | #---------------------- grid [ label $expgui(diffBox).lDC1 -text "Refine wave" ] \ -column 1 -row 1 grid [ checkbutton $expgui(diffBox).rfDC1 -variable entryvar(wref) ] \ -column 2 -row 1 grid [button $expgui(diffBox).bDCdifc -text "Set Wave Globally" \ -command "editglobalparm histinfo lam1 Wavelength"] \ -column 3 -row 1 # grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCzref \ -variable entryvar(zref) ] -column 2 -row 3 grid [button $expgui(diffBox).bDCzero -text "Set Zero Globally" \ -command "editglobalparm histinfo zero Zero"] -column 3 -row 3 # grid [ label $expgui(diffBox).lDCpref -text "Refine POLA" ] \ -column 1 -row 4 -sticky w grid [ checkbutton $expgui(diffBox).rfDCpref \ -variable entryvar(pref) ] -column 2 -row 4 grid [button $expgui(diffBox).bDCpola -text "Set POLA Globally" \ -command "editglobalparm histinfo pola POLA"] -column 3 -row 4 grid [button $expgui(diffBox).bDCipola -text "Set IPOLA Globally" \ -command "editglobalparm histinfo ipola IPOLA"] -column 4 -row 4 } elseif {$expgui(globalmode) == 3} { #------------------------ # Global alpha 1,2 xray | #------------------------ grid [button $expgui(diffBox).bDCl1 -text "Set Wave1 Globally" \ -command "editglobalparm histinfo lam1 {Wavelength 1}"] \ -column 3 -row 1 grid [button $expgui(diffBox).bDCl2 -text "Set Wave2 Globally" \ -command "editglobalparm histinfo lam2 {Wavelength 2}"] \ -column 4 -row 1 # grid [ label $expgui(diffBox).lDCratref -text "Refine Ratio" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCratref \ -variable entryvar(ratref) ] -column 2 -row 3 grid [button $expgui(diffBox).bDCrrat -text "Set Ratio Globally" \ -command "editglobalparm histinfo ratio {Wavelength Ratio}"] \ -column 3 -row 3 # grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \ -column 1 -row 3 -sticky w grid [ checkbutton $expgui(diffBox).rfDCzref \ -variable entryvar(zref) ] -column 2 -row 3 grid [button $expgui(diffBox).bDCzero -text "Set Zero Globally" \ -command "editglobalparm histinfo zero Zero"] -column 3 -row 3 # grid [ label $expgui(diffBox).lDCpref -text "Refine POLA" ] \ -column 1 -row 4 -sticky w grid [ checkbutton $expgui(diffBox).rfDCpref \ -variable entryvar(pref) ] -column 2 -row 4 grid [button $expgui(diffBox).bDCpola -text "Set POLA Globally" \ -command "editglobalparm histinfo pola POLA"] -column 3 -row 4 grid [button $expgui(diffBox).bDCipola -text "Set IPOLA Globally" \ -command "editglobalparm histinfo ipola IPOLA"] -column 4 -row 4 } elseif {$expgui(globalmode) == 5} { #----------------- # Global ED xray | #----------------- grid [ label $expgui(diffBox).lDC1 -text "Refine 2theta" ] \ -column 1 -row 1 grid [ checkbutton $expgui(diffBox).rfDC1 -variable entryvar(ttref) ] \ -column 2 -row 1 grid [button $expgui(diffBox).bDCdifc -text "Set 2Theta Globally" \ -command "editglobalparm histinfo ratio {Fixed 2Theta}"] \ -column 3 -row 1 # grid [ label $expgui(diffBox).lDCpref -text "Refine POLA" ] \ -column 1 -row 4 -sticky w grid [ checkbutton $expgui(diffBox).rfDCpref \ -variable entryvar(pref) ] -column 2 -row 4 grid [button $expgui(diffBox).bDCpola -text "Set POLA Globally" \ -command "editglobalparm histinfo pola POLA"] -column 3 -row 4 grid [button $expgui(diffBox).bDCipola -text "Set IPOLA Globally" \ -command "editglobalparm histinfo ipola IPOLA"] -column 4 -row 4 } if {$expgui(globalmode) == 0} { grid [frame $expgui(diffBox).d] -column 5 -row 5 \ -columnspan 2 -sticky e } else { grid [frame $expgui(diffBox).d] -column 4 -row 5 \ -columnspan 2 -sticky e } grid [label $expgui(diffBox).d.lDamp -text "Damping "] \ -column 1 -row 1 tk_optionMenu $expgui(diffBox).d.om entryvar(ddamp) 0 1 2 3 4 5 6 7 8 9 grid $expgui(diffBox).d.om -column 2 -row 1 grid columnconfigure $expgui(diffBox) 9 -weight 1 grid columnconfigure $expgui(diffBox) 0 -weight 1 update idletasks # enable traces on entryvar now set entrycmd(trace) 1 } #----------------------------------------------------------------------- # populate the Scaling page #----------------------------------------------------------------------- proc DisplayFrac {} { global expgui entrycmd entryvar expmap # display the selected histograms $expgui(fracFrame).hs.lbox selection clear 0 end foreach h $expgui(curhist) { $expgui(fracFrame).hs.lbox selection set $h } # disable traces on entryvar set entrycmd(trace) 0 # get histogram list set histlist {} foreach item $expgui(curhist) { lappend histlist [lindex $expmap(powderlist) $item] } # must have at least one histogram selected here if {[llength $histlist] == 0} { foreach var {scale sref sdamp} { set entrycmd($var) "" set entryvar($var) "" } set parm [grid info $expgui(scaleBox).but1] if {$parm != ""} { grid forget $expgui(scaleBox).but1 eval grid $expgui(scaleBox).ent1 $parm } # destroy the contents of the frame set phaseFractf1 $expgui(FracBox).f eval destroy [grid slaves $phaseFractf1] # reenable traces on entryvar set entrycmd(trace) 1 return } #-------------- # Scale factor #-------------- if {$expgui(globalmode) != 0} { foreach var {scale sref sdamp} { set entrycmd($var) "histinfo [list $histlist] $var" set entryvar($var) [histinfo [lindex $histlist 0] $var] } set parm [grid info $expgui(scaleBox).ent1] if {$parm != ""} { grid forget $expgui(scaleBox).ent1 eval grid $expgui(scaleBox).but1 $parm } } else { set hist $histlist foreach var {scale sref sdamp} { set entrycmd($var) "histinfo $hist $var" set entryvar($var) [eval $entrycmd($var)] } set parm [grid info $expgui(scaleBox).but1] if {$parm != ""} { grid forget $expgui(scaleBox).but1 eval grid $expgui(scaleBox).ent1 $parm } } #---------------- # Phase Fractions #---------------- set phaseFractf1 $expgui(FracBox).f # destroy the contents of the frame eval destroy [grid slaves $phaseFractf1] if {$expgui(globalmode) != 0} { grid [label $phaseFractf1.txt -anchor center \ -text "Phase Fractions for Histograms: [CompressList $histlist]"] \ -column 0 -row 0 -sticky news } else { grid [label $phaseFractf1.txt -anchor center \ -text "Phase Fractions"] -column 0 -row 0 -sticky news } # Create the frame inside the canvas, One frame for each Phase. foreach i {1 2 3 4 5 6 7 8 9} {set phasehistlist($i) ""} foreach hist $histlist { foreach i $expmap(phaselist_$hist) { lappend phasehistlist($i) $hist } } foreach i {1 2 3 4 5 6 7 8 9} { if {[llength $phasehistlist($i)] == 0} continue set framePF [frame $phaseFractf1.pF$i -relief groove -bd 4] grid $framePF -column 0 -row $i -sticky ew # Label Heading for each phase. if {$expgui(globalmode) != 0} { grid [label $framePF.l1 \ -text "Phase $i Hist: [CompressList $phasehistlist($i)] Fraction"] \ -column 0 -row 0 -sticky nws grid [button $framePF.but1 -text "Set Globally" \ -command "editglobalparm hapinfo frac \"Phase $i Fraction\" \ [list $phasehistlist($i)] $i" \ ] -column 1 -row 0 } else { grid [label $framePF.l1 -text "Phase $i fraction"] \ -column 0 -row 0 -sticky nws grid [entry $framePF.ent -textvariable entryvar(frac$i) -width 15]\ -column 1 -row 0 } set entrycmd(frac$i) "hapinfo $hist $i frac" set entryvar(frac$i) [hapinfo $hist $i frac] grid [label $framePF.l2 -text " Refine"] \ -column 2 -row 0 -sticky nws grid [checkbutton $framePF.cb -variable entryvar(frref$i)] \ -column 3 -row 0 -sticky nws set entrycmd(frref$i) "hapinfo $hist $i frref" set entryvar(frref$i) [hapinfo $hist $i frref] grid [label $framePF.l3 -text " Damping"] \ -column 4 -row 0 -sticky nws tk_optionMenu $framePF.tkOptDamp entryvar(frdamp$i) \ 0 1 2 3 4 5 6 7 8 9 set entrycmd(frdamp$i) "hapinfo $hist $i frdamp" set entryvar(frdamp$i) [hapinfo $hist $i frdamp] grid $framePF.tkOptDamp -row 0 -sticky nsw -column 5 } # resize the scroll window to match the actual update idletasks $expgui(FracBox) config -scrollregion [grid bbox $expgui(FracBox).f] $expgui(FracBox) config -width [lindex [grid bbox $expgui(FracBox).f] 2] update idletasks # enable traces on entryvar now set entrycmd(trace) 1 } #----------------------------------------------------------------------- # display the profile page #----------------------------------------------------------------------- proc DisplayProfile {} { global expgui entrycmd entryvar expmap $expgui(profFrame).hs.lbox selection clear 0 end foreach h $expgui(curhist) { $expgui(profFrame).hs.lbox selection set $h } # destroy the contents of the frame eval destroy [grid slaves $expgui(ProfileBox).f] if {$expgui(globalmode) == 0} { # must have at least one histogram selected here if {[llength $expgui(curhist)] == 0} return # disable traces on entryvar for right now set entrycmd(trace) 0 set hist [lindex $expmap(powderlist) $expgui(curhist)] # Create one frame for each Phase. set ind -1 set htype [string range $expmap(htype_$hist) 2 2] foreach i $expmap(phaselist_$hist) { incr ind grid [frame $expgui(ProfileBox).f.$i -relief groove -bd 4] \ -column 0 -row $ind -sticky ew grid [frame $expgui(ProfileBox).f.$i.1] \ -column 0 -row 0 -columnspan 10 -sticky ew # Label Heading for each phase. set ptype [string trim [hapinfo $hist $i proftype]] pack [label $expgui(ProfileBox).f.$i.1.l \ -text "Phase $i -- type $ptype Damping"]\ -side left tk_optionMenu $expgui(ProfileBox).f.$i.1.tkOptDamp entryvar(pdamp_$i) \ 0 1 2 3 4 5 6 7 8 9 set entrycmd(pdamp_$i) "hapinfo $hist $i pdamp" set entryvar(pdamp_$i) [hapinfo $hist $i pdamp] pack $expgui(ProfileBox).f.$i.1.tkOptDamp -side left pack [label $expgui(ProfileBox).f.$i.1.l1 \ -text " Peak cutoff"]\ -side left pack [entry $expgui(ProfileBox).f.$i.1.e1 \ -width 10 -textvariable entryvar(pcut_$i)]\ -side left set entrycmd(pcut_$i) "hapinfo $hist $i pcut" set entryvar(pcut_$i) [hapinfo $hist $i pcut] set col -1 set row 1 set nterms [hapinfo $hist $i profterms] set lbls $expgui(prof-$htype-$ptype) # for type 4, add extra terms depending on the cell type if {$ptype == 4} {set lbls [type4lbls $lbls $nterms $i]} for { set num 1 } { $num <= $nterms } { incr num } { set term {} catch {set term [lindex $lbls $num]} if {$term == ""} {set term $num} incr col grid [label $expgui(ProfileBox).f.$i.l${num}_${i} -text "$term"] \ -row $row -column $col incr col grid [checkbutton $expgui(ProfileBox).f.$i.ref${num}_${i} \ -variable entryvar(pref${num}_$i)] -row $row -column $col set entrycmd(pref${num}_$i) "hapinfo $hist $i pref$num" set entryvar(pref${num}_$i) [hapinfo $hist $i pref$num] incr col grid [entry $expgui(ProfileBox).f.$i.ent${num}_${i} \ -textvariable entryvar(pterm${num}_$i)\ -width 12] -row $row -column $col set entrycmd(pterm${num}_$i) "hapinfo $hist $i pterm$num" set entryvar(pterm${num}_$i) [hapinfo $hist $i pterm$num] if {$col > 6} {set col -1; incr row} } } grid columnconfigure $expgui(ProfileBox).f 0 -weight 1 } else { # get histogram list set histlist {} foreach item $expgui(curhist) { lappend histlist [lindex $expmap(powderlist) $item] } # must have at least one histogram selected here if {[llength $histlist] == 0} return # disable traces on entryvar for right now set entrycmd(trace) 0 # loop through histograms & phases, set up an array by type catch {unset ptypearray histarray phasearray} foreach hist $histlist { foreach i $expmap(phaselist_$hist) { set ptype [string trim [hapinfo $hist $i proftype]] lappend ptypearray(${ptype}_$i) $hist lappend histarray($ptype) $hist lappend phasearray($ptype) $i } } set ptype "" set title "" set ind -1 foreach key "[lsort [array names ptypearray]] 0_0" { # split key scan $key %d_%d type p # 1st time through if {$ptype == ""} {set ptype $type} if {$ptype == $type} { # we've seen this one before if {$title != ""} {append title "\n"} append title "Phase $p, hist [CompressList $ptypearray($key)]" } else { set hist [lindex $histarray($ptype) 0] set phase [lindex $phasearray($ptype) 0] set nterms [hapinfo $hist $phase profterms] set htype [string range $expmap(htype_$hist) 2 2] set lbls $expgui(prof-$htype-$ptype) set i $ptype # Create one frame for this type incr ind grid [frame $expgui(ProfileBox).f.$i -relief groove -bd 4] \ -column 0 -row $ind -sticky ew grid [frame $expgui(ProfileBox).f.$i.0] \ -column 0 -row 0 -columnspan 20 -sticky ew grid [label $expgui(ProfileBox).f.$i.0.0 \ -text "Profile Type $ptype "] -row 0 -column 0 grid [label $expgui(ProfileBox).f.$i.0.1 \ -text $title -anchor w] -row 0 -column 1 grid [frame $expgui(ProfileBox).f.$i.1] \ -column 0 -row 1 -columnspan 20 -sticky ew grid [label $expgui(ProfileBox).f.$i.1.2 \ -text "Damping"] -row 0 -column 2 tk_optionMenu $expgui(ProfileBox).f.$i.1.tkOptDamp \ entryvar(pdamp_$ptype) 0 1 2 3 4 5 6 7 8 9 set entrycmd(pdamp_$ptype) "hapinfo \ [list $histarray($ptype)] \ [list $phasearray($ptype)] pdamp" set entryvar(pdamp_$ptype) [hapinfo $hist $phase pdamp] grid $expgui(ProfileBox).f.$i.1.tkOptDamp -row 0 -column 3 grid [button $expgui(ProfileBox).f.$i.1.edit \ -text "Global Edit" \ -command "EditProfile [list $title] \ [list $histarray($ptype)] [list $phasearray($ptype)] " \ ] -row 0 -column 4 -sticky w # for type 4, add extra terms depending on the cell type if {$ptype == 4} {set lbls [type4lbls $lbls $nterms $phase]} set col -1 set row 2 for { set num 1 } { $num <= $nterms } { incr num } { set term {} catch {set term [lindex $lbls $num]} if {$term == ""} {set term $num} incr col grid [label $expgui(ProfileBox).f.$i.l${num}_${i} -text "$term"] \ -row $row -column $col incr col grid [checkbutton $expgui(ProfileBox).f.$i.ref${num}_${i} \ -variable entryvar(pref${num}_$i)] \ -row $row -column $col set entrycmd(pref${num}_$i) "hapinfo \ [list $histarray($ptype)] \ [list $phasearray($ptype)] pref$num" set entryvar(pref${num}_$i) [hapinfo $hist $phase pref$num] if {$col > 10} {set col -1; incr row} } grid columnconfigure $expgui(ProfileBox).f 0 -weight 1 set ptype "" } } } # resize the scroll window to match the actual update idletasks $expgui(ProfileBox) config -scrollregion [grid bbox $expgui(ProfileBox).f] $expgui(ProfileBox) config -width [lindex [grid bbox $expgui(ProfileBox).f] 2] update idletasks # enable traces on entryvar now set entrycmd(trace) 1 } # profile labels for type 4 profile proc type4lbls {lbls nterms phase} { if {$nterms == 14} { # cubic lappend lbls S400 S220 } elseif {$nterms == 15} { # hexagonal lappend lbls S400 S004 S202 } elseif {$nterms == 16} { # tetragonal or rhombohedral if {[phaseinfo $phase a] == [phaseinfo $phase c]} { # rhombohedral lappend lbls S400 S220 S310 S211 } else { lappend lbls S400 S004 S220 S202 } } elseif {$nterms == 18} { # orthorhombic lappend lbls S400 S040 S004 S220 S202 S022 } elseif {$nterms == 21} { # monoclinic lappend lbls S400 S040 S004 S220 S202 S022 S301 S103 S121 } elseif {$nterms == 25} { # triclinic lappend lbls S400 S040 S004 S220 S202 S022 S310 S103 S031 \ S130 S301 S013 S211 S121 S112 } return $lbls } # process the bit settings in the print options # bitnum -- the number of the bit to be tested/set starting at 0 for the LSBit proc printsetting {bitnum "action get" "value {}"} { global entryvar expgui if {$action == "get"} { return [expr ([expinfo print] & int(pow(2,$bitnum))) != 0] } elseif $value { set newval [expr ([expinfo print] | int(pow(2,$bitnum)))] } else { set newval [expr ([expinfo print] & ~int(pow(2,$bitnum)))] } expinfo print set $newval set expgui(printopt) "Print Options ([expinfo print])" } # need to respond to mouse presses -- control variable associated with extract Fobs # and set the LeBail extraction flags proc SetupExtractHist {} { global expgui entrycmd entryvar expmap # display the selected histograms $expgui(lsFrame).hs.lbox selection clear 0 end foreach h $expgui(curhist) { $expgui(lsFrame).hs.lbox selection set $h } # get histogram list set histlist {} foreach item $expgui(curhist) { set hist [lindex $expmap(powderlist) $item] if {$hist != ""} {lappend histlist $hist} } set entrycmd(fobsextract) "histinfo [list $histlist] foextract" if {[llength $histlist] == 0 || [string trim $histlist] == ""} { foreach phase {1 2 3 4 5 6 7 8 9} { $expgui(lsFrame).f1.a.l$phase config -fg grey set expgui(Fextract$phase) {} foreach item $expgui(ExtractSettingsRadiobuttons) { ${item}$phase config -state disabled -bd 1 } } } elseif {[llength $histlist] == 1} { # disable traces on entryvar set entrycmd(trace) 0 set entryvar(fobsextract) [histinfo $histlist foextract] foreach phase {1 2 3 4 5 6 7 8 9} { # is the phase present? if {[lsearch -exact $expmap(phaselist_$histlist) $phase] == -1} { $expgui(lsFrame).f1.a.l$phase config -fg grey set expgui(Fextract$phase) {} foreach item $expgui(ExtractSettingsRadiobuttons) { ${item}$phase config -state disabled -bd 1 } } else { $expgui(lsFrame).f1.a.l$phase config -fg black foreach item $expgui(ExtractSettingsRadiobuttons) { ${item}$phase config -state normal -bd 2 } set expgui(Fextract$phase) [hapinfo $histlist $phase extmeth] } } } elseif {[llength $histlist] > 1} { # disable traces on entryvar set entrycmd(trace) 0 # multiple histograms need phases in any histogram foreach phase {1 2 3 4 5 6 7 8 9} { set gotphase($phase) 0 } foreach hist $histlist { foreach phase $expmap(phaselist_$hist) { set gotphase($phase) 1 } } foreach phase {1 2 3 4 5 6 7 8 9} { set expgui(Fextract$phase) {} if $gotphase($phase) { $expgui(lsFrame).f1.a.l$phase config -fg black foreach item $expgui(ExtractSettingsRadiobuttons) { ${item}$phase config -state normal -bd 2 } } else { $expgui(lsFrame).f1.a.l$phase config -fg grey foreach item $expgui(ExtractSettingsRadiobuttons) { ${item}$phase config -state disabled -bd 1 } } } } # reenable traces set entrycmd(trace) 1 } # respond to a change in the fobs extraction method for a phase # force the main extraction flag on, if fobs extraction is selected for any phase proc HistExtractSet {phase} { global expgui entryvar expmap foreach item $expgui(curhist) { lappend histlist [lindex $expmap(powderlist) $item] } hapinfo $histlist $phase extmeth set $expgui(Fextract$phase) incr expgui(changed) if {$expgui(Fextract$phase) != 0} {set entryvar(fobsextract) 1} } #---------------------------- Global Edit Functions ------------------------ proc editbackground {} { global expgui expmap entrycmd set histlist {} foreach n $expgui(curhist) { lappend histlist [lindex $expmap(powderlist) $n] } if {[llength $histlist] == 0} return set w .back catch {destroy $w} toplevel $w -bg beige if {$expgui(globalmode) != 0} { wm title $w "Edit Background" } else { wm title $w "Global Edit Background" } pack [frame $w.0 -bd 6 -relief groove -bg beige \ ] -side top -expand yes -fill both if {[llength $histlist] > 1} { grid [label $w.0.a \ -text "Setting background terms for histograms [CompressList $histlist]" \ -bg beige] -row 0 -column 0 -columnspan 10 } else { grid [label $w.0.a \ -text "Setting background terms for histogram $histlist" \ -bg beige] -row 0 -column 0 -columnspan 10 } set hist [lindex $histlist 0] grid [label $w.0.b -text "Function type" -bg beige] -row 1 -column 0 # disable traces on expgui(backtype) & expgui(backterms) now set entrycmd(trace) 0 # number of terms set expgui(backtype) [histinfo $hist backtype] set expgui(orig_backtype) $expgui(backtype) set expgui(prev_backtype) $expgui(backtype) eval tk_optionMenu $w.0.type expgui(backtype) {1 2 3 4 5 6} grid $w.0.type -row 1 -column 1 grid [label $w.0.c -text " Number of terms" -bg beige] -row 1 -column 2 # function type set expgui(backterms) [histinfo $hist backterms] set expgui(orig_backterms) $expgui(backterms) set list {}; for {set i 1} {$i <= 36} {incr i} {lappend list $i} eval tk_optionMenu $w.0.terms expgui(backterms) $list grid $w.0.terms -row 1 -column 3 # enable traces on expgui(backtype) & expgui(backterms) now set entrycmd(trace) 1 #set background terms for {set num 1 } { $num <= 36 } { incr num } { set var "bterm$num" set expgui($var) {} set expgui(orig_$var) {} } if {[llength $histlist] == 1} { for {set num 1 } { $num <= $expgui(backterms) } { incr num } { set var "bterm$num" set expgui($var) [histinfo $histlist $var] set expgui(orig_$var) $expgui($var) } } pack [frame $w.1 -bd 6 -relief groove -bg beige] -side top \ -expand yes -fill both ShowBackTerms $w.1 set expgui(temp) {} pack [frame $w.b] -side top pack [button $w.b.2 -text Set -command "destroy $w"] -side left pack [button $w.b.3 -text Quit \ -command "QuitEditBackground $w"] -side left # force the window to stay on top wm transient $w [winfo toplevel [winfo parent $w]] bind $w "destroy $w" wm withdraw $w update idletasks # center the new window in the middle of the parent set x [expr [winfo x [winfo parent $w]] + [winfo width .]/2 - \ [winfo reqwidth $w]/2 - [winfo vrootx [winfo parent $w]]] set y [expr [winfo y [winfo parent $w]] + [winfo height .]/2 - \ [winfo reqheight $w]/2 - [winfo vrooty [winfo parent $w]]] wm geom $w +$x+$y wm deiconify $w set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } grab $w focus $w.b.2 tkwait window $w catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } if {$expgui(temp) != ""} return if {$expgui(orig_backtype) != $expgui(backtype)} { histinfo $histlist backtype set $expgui(backtype) incr expgui(changed) } if {$expgui(orig_backterms) != $expgui(backterms)} { histinfo $histlist backterms set $expgui(backterms) incr expgui(changed) } for {set num 1 } { $num <= $expgui(backterms) } { incr num } { set var "bterm$num" if {$expgui(orig_$var) != $expgui($var)} { histinfo $histlist $var set $expgui($var) incr expgui(changed) } } if {$expgui(globalmode) == 0} { set expgui(backtypelbl) "Function type [histinfo $hist backtype]" set expgui(backtermlbl) "([histinfo $hist backterms] terms)" } } trace variable expgui(backterms) w ChangeBackTerms proc ChangeBackTerms {a b c} { global entrycmd expgui if !$entrycmd(trace) return ShowBackTerms .back.1 } trace variable expgui(backtype) w ChangeBackType # reset the terms to 1, 0, 0... when the number of terms increase proc ChangeBackType {a b c} { global entrycmd expgui if !$entrycmd(trace) return if {$expgui(prev_backtype) == $expgui(backtype)} return set expgui(prev_backtype) $expgui(backtype) for {set num 1 } { $num <= $expgui(backterms) } { incr num } { set var "bterm$num" if {$num == 1} { set expgui($var) 1.0 } else { set expgui($var) 0.0 } } } proc ShowBackTerms {w } { global expgui expmap # destroy the contents of the frame eval destroy [grid slaves $w] set histlist {} foreach n $expgui(curhist) { lappend histlist [lindex $expmap(powderlist) $n] } set widgetsPerRow 4 for {set rows 2; set num 1 } { $num <= $expgui(backterms) } { incr rows } { for {set cols 0} { (2*$widgetsPerRow > $cols) && ($num <= $expgui(backterms)) } { incr num } { set var "bterm$num" grid [label $w.l$num -text $num -bg beige] \ -row $rows -column $cols -sticky nes incr cols grid [entry $w.e$num -width 15 -textvariable expgui($var) \ ] -row $rows -column $cols -sticky news incr cols } } } proc QuitEditBackground {w} { global expgui # lets find out if anything changed set changed 0 if {$expgui(orig_backtype) != $expgui(backtype)} { set changed 1 } if {$expgui(orig_backterms) != $expgui(backterms)} { set changed 1 } for {set num 1 } { $num <= $expgui(backterms) } { incr num } { set var "bterm$num" if {$expgui(orig_$var) != $expgui($var)} { set changed 1 break } } if $changed { set decision [tk_dialog .changes "Abandon Changes" \ "You have made changes to the background. Ok to abandon changes?" \ warning 0 Abandon Keep] if !$decision { set expgui(temp) "Quit" destroy $w } } else { set expgui(temp) "Quit" destroy $w } } # this probably needs work proc editglobalparm {cmd variable title "histlist {}" "phase {}"} { global expgui expmap set w .global catch {destroy $w} toplevel $w -bg beige wm title $w "Edit Global Parameter" set expgui(temp) {} if {[llength $histlist] == 0} { set hist {} foreach n $expgui(curhist) { lappend hist [lindex $expmap(powderlist) $n] } } else { set hist $histlist } pack [frame $w.0 -bd 6 -relief groove -bg beige] \ -side top -expand yes -fill both grid [label $w.0.a -text "Setting $title for histograms [CompressList $hist]"\ -bg beige] \ -row 0 -column 0 -columnspan 10 grid [entry $w.0.b -textvariable expgui(temp)] \ -row 1 -column 0 pack [frame $w.b] -side top pack [button $w.b.2 -text Set -command "destroy $w"] -side left pack [button $w.b.3 -text Quit -command "set expgui(temp) {}; destroy $w"] -side left # force the window to stay on top wm transient $w [winfo toplevel [winfo parent $w]] bind $w "destroy $w" wm withdraw $w update idletasks # center the new window in the middle of the parent set x [expr [winfo x [winfo parent $w]] + [winfo width .]/2 - \ [winfo reqwidth $w]/2 - [winfo vrootx [winfo parent $w]]] set y [expr [winfo y [winfo parent $w]] + [winfo height .]/2 - \ [winfo reqheight $w]/2 - [winfo vrooty [winfo parent $w]]] wm geom $w +$x+$y wm deiconify $w set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } grab $w focus $w.b.2 tkwait window $w if {$expgui(temp) != ""} { foreach h $hist { if {$cmd == "histinfo"} { histinfo $h $variable set $expgui(temp) incr expgui(changed) if $expgui(debug) { puts "histinfo $h $variable set $expgui(temp)" } } elseif {$cmd == "hapinfo"} { hapinfo $h $phase $variable set $expgui(temp) incr expgui(changed) if $expgui(debug) { puts "hapinfo $phase $h $variable set $expgui(temp)" } } else { error "$cmd unimplemented" } } } catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } } proc EditProfile {title histlist phaselist} { global expgui expmap entrycmd set w .back catch {destroy $w} toplevel $w -bg beige wm title $w "Global Edit Profile" set hist [lindex $histlist 0] set phase [lindex $phaselist 0] set ptype [string trim [hapinfo $hist $phase proftype]] set htype [string range $expmap(htype_$hist) 2 2] set nterms [hapinfo $hist $phase profterms] pack [frame $w.0 -bd 6 -relief groove -bg beige \ ] -side top -expand yes -fill both grid [label $w.0.a \ -text "Setting profile terms: $title" \ -bg beige] -row 0 -column 0 -columnspan 10 grid [label $w.0.b -text "Function type $ptype" -bg beige] -row 1 -column 0 # number of terms # set expgui(backtype) [histinfo $hist backtype] # set expgui(orig_backtype) $expgui(backtype) # set expgui(prev_backtype) $expgui(backtype) # eval tk_optionMenu $w.0.type expgui(backtype) {1 2 3 4 5 6} # grid $w.0.type -row 1 -column 1 grid [label $w.0.c -text " Peak cutoff" -bg beige] -row 1 -column 3 grid [entry $w.0.d -width 10 ] -row 1 -column 4 set entrylist {} lappend entrylist "pcut $w.0.d" set col -1 set row 1 set lbls $expgui(prof-$htype-$ptype) # for type 4, add extra terms depending on the cell type if {$ptype == 4} {set lbls [type4lbls $lbls $nterms $i]} pack [frame $w.1 -bd 6 -relief groove -bg beige \ ] -side top -expand yes -fill both for { set num 1 } { $num <= $nterms } { incr num } { set term {} catch {set term [lindex $lbls $num]} if {$term == ""} {set term $num} incr col grid [label $w.1.l${num} -text "$term" -bg beige] \ -row $row -column $col incr col grid [entry $w.1.ent${num} \ -width 14] -row $row -column $col lappend entrylist "pterm$num $w.1.ent${num}" if {$col > 6} {set col -1; incr row} } pack [frame $w.b] -side top pack [button $w.b.2 -text Set \ -command "SetEditProfile [list $entrylist] [list $phaselist] \ [list $histlist] $w"] -side left pack [button $w.b.3 -text Quit \ -command "QuitEditProfile $w [list $entrylist]"] -side left # force the window to stay on top wm transient $w [winfo toplevel [winfo parent $w]] bind $w "destroy $w" wm withdraw $w update idletasks # center the new window in the middle of the parent set x [expr [winfo x [winfo parent $w]] + [winfo width .]/2 - \ [winfo reqwidth $w]/2 - [winfo vrootx [winfo parent $w]]] set y [expr [winfo y [winfo parent $w]] + [winfo height .]/2 - \ [winfo reqheight $w]/2 - [winfo vrooty [winfo parent $w]]] wm geom $w +$x+$y wm deiconify $w set oldFocus [focus] set oldGrab [grab current $w] if {$oldGrab != ""} { set grabStatus [grab status $oldGrab] } grab $w focus $w.b.2 tkwait window $w catch {focus $oldFocus} if {$oldGrab != ""} { if {$grabStatus == "global"} { grab -global $oldGrab } else { grab $oldGrab } } } proc SetEditProfile {entrylist phaselist histlist w} { global expgui foreach item $entrylist { set value [ [lindex $item 1] get ] if {$value != ""} { hapinfo $histlist $phaselist [lindex $item 0] set $value incr expgui(changed) if $expgui(debug) { puts "hapinfo [list $phaselist] [list $histlist] [lindex $item 0] set $value" } } } destroy $w } proc QuitEditProfile {w entrylist} { global expgui # lets find out if anything changed set changed 0 foreach item $entrylist { if {[ [lindex $item 1] get ] != ""} {set changed 1; break} } if $changed { set decision [tk_dialog .changes "Abandon Changes" \ "You have made changes to the Profile. Ok to abandon changes?" \ warning 0 Abandon Keep] if !$decision {destroy $w} } else { destroy $w } } ############################################################################## ## ############################################# ## END OF THE PROCEDURES SECTION ############################################# ## ############################################# ############################################################################## # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<< # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< BEGIN: GUI SECTION >>>>>>>>>>>>>>>>>>> # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # A frame for menu items at top of display set expgui(fm) [frame .fm -relief raised -borderwidth 2 -width 150 -height 40] # Pack the menu frame. pack $expgui(fm) -fill x -side top -anchor n # create a button bar pack [frame .bar -relief raised -bd 2 -bg beige] -fill x -side top -anchor n # Creating the notebook with 5 panes: Phase, Histogram, Scaling, Profile # & LS controls if $expgui(havetix) { pack [tixNoteBook .n] -expand yes -fill both .n add lsPane -label "LS Controls" -underline 0 .n pageconfigure lsPane -raisecmd \ "set expgui(pagenow) lsFrame; SetupExtractHist" lappend expgui(frameactionlist) "lsFrame SetupExtractHist" .n add phasePane -label "Phase" -underline 0 .n pageconfigure phasePane -raisecmd \ "set expgui(pagenow) phaseFrame; DisplayAllAtoms noreset" # lappend expgui(frameactionlist) "phaseFrame {DisplayAllAtoms noreset}" .n add histPane -label "Histogram" -underline 0 .n pageconfigure histPane -raisecmd \ "set expgui(pagenow) histFrame; DisplayHistogram" lappend expgui(frameactionlist) "histFrame DisplayHistogram" lappend expgui(GlobalModeAllDisable) "histFrame {.n pageconfigure histPane}" .n add fracPane -label "Scaling" -underline 6 .n pageconfigure fracPane -raisecmd \ "set expgui(pagenow) fracFrame; DisplayFrac" lappend expgui(frameactionlist) "fracFrame DisplayFrac" .n add profPane -label Profile -underline 1 .n pageconfigure profPane -raisecmd \ "set expgui(pagenow) profFrame; DisplayProfile" lappend expgui(frameactionlist) "profFrame DisplayProfile" lappend expgui(GlobalModeAllDisable) "profFrame {.n pageconfigure profPane}" # Finding the pathname to the subwidget frames. set expgui(phaseFrame) [.n subwidget phasePane] set expgui(histFrame) [.n subwidget histPane] set expgui(fracFrame) [.n subwidget fracPane] set expgui(profFrame) [.n subwidget profPane] set expgui(lsFrame) [.n subwidget lsPane] } else { pack [frame .frmbar] -side top -anchor w pack [frame .n] -anchor w -fill both -expand yes foreach item {lsFrame phaseFrame histFrame fracFrame profFrame} \ page {"LS Controls" Phase Histogram Scaling Profile } { pack [button .frmbar.$item -text $page -bd 2 \ -command "RaisePage $item"] -side left set expgui($item) [frame .n.$item -relief flat] } lappend expgui(frameactionlist) "lsFrame SetupExtractHist" lappend expgui(frameactionlist) "phaseFrame {DisplayAllAtoms noreset}" lappend expgui(frameactionlist) "histFrame DisplayHistogram" lappend expgui(frameactionlist) "fracFrame DisplayFrac" lappend expgui(frameactionlist) "profFrame DisplayProfile" lappend expgui(GlobalModeAllDisable) "histFrame {.frmbar.histFrame config}" lappend expgui(GlobalModeAllDisable) "profFrame {.frmbar.profFrame config}" } # this is used in the non-tix notebook to bring up the selected frame proc RaisePage {nextpage} { global expgui set expgui(pagenow) $nextpage foreach item {phaseFrame histFrame fracFrame profFrame lsFrame} { if {$item == $nextpage} { .frmbar.$item config -relief flat } else { .frmbar.$item config -relief raised } } # forget all other pages foreach child [pack slaves .n] { pack forget $child } pack .n.$nextpage -anchor w -fill both -expand yes foreach set $expgui(frameactionlist) { if {$expgui(pagenow) == [lindex $set 0]} [lindex $set 1] } } #---------------------------------------------------------------------------- #\/ \/ \/ \/ \/ \/ \/ BEGINNING OF PHASE PANE CODE \/ \/ \/ \/ \/ \/ \/ \/ \/ # Setup major frames here frame $expgui(phaseFrame).top set frameLatt [frame $expgui(phaseFrame).frameLatt] # This is a big frame in the Phase notebook pane to hold a list of CRS data. set fbig [frame $expgui(phaseFrame).fbig -width 180 -relief raised -borderwidth 4 -bg beige] # This is a frame just below the big frame: fbig to allow edit of CRS data, One record at a time. set frame3 [frame $expgui(phaseFrame).frame3 -width 100 -relief raised -borderwidth 4 -bg beige] grid $expgui(phaseFrame).top -sticky news -row 0 -column 0 grid $frameLatt -sticky news -row 2 -column 0 grid $fbig -sticky news -row 3 -column 0 # give extra space to the atoms box grid columnconfigure $expgui(phaseFrame) 0 -weight 1 grid rowconfigure $expgui(phaseFrame) 3 -weight 1 grid $frame3 -sticky news -row 4 -column 0 grid columnconfigure $expgui(phaseFrame) 0 -weight 1 grid rowconfigure $expgui(phaseFrame) 3 -weight 1 grid [frame $expgui(phaseFrame).top.ps] -column 0 -row 0 -sticky w # this is where the buttons will go pack [label $expgui(phaseFrame).top.ps.0 -text "Phases: "] -side left grid [label $expgui(phaseFrame).top.lA -text " Phase name:" \ -fg blue ] -column 1 -row 0 -sticky e grid [entry $expgui(phaseFrame).top.lB -textvariable entryvar(phasename) \ -fg blue -width 45] -column 2 -row 0 -sticky e grid columnconfigure $expgui(phaseFrame).top 1 -weight 1 # ------------- Lattice Parameter Box ------------------ set e1 [entry $frameLatt.e1 -textvariable entryvar(a) -width 10] set e2 [entry $frameLatt.e2 -textvariable entryvar(b) -width 10] set e3 [entry $frameLatt.e3 -textvariable entryvar(c) -width 10] set e4 [entry $frameLatt.e4 -textvariable entryvar(alpha) -width 10] set e5 [entry $frameLatt.e5 -textvariable entryvar(beta) -width 10] set e6 [entry $frameLatt.e6 -textvariable entryvar(gamma) -width 10] set l1 [label $frameLatt.l1 -text "a"] set l2 [label $frameLatt.l2 -text "b"] set l3 [label $frameLatt.l3 -text "c"] set l4 [label $frameLatt.l4 -text "alpha"] set l5 [label $frameLatt.l5 -text "beta"] set l6 [label $frameLatt.l6 -text "gamma"] grid $e1 -column 1 -row 0 -padx 5 grid $e2 -column 3 -row 0 -padx 5 grid $e3 -column 5 -row 0 -padx 5 grid $e4 -column 1 -row 1 -padx 5 grid $e5 -column 3 -row 1 -padx 5 grid $e6 -column 5 -row 1 -padx 5 grid $l1 -column 0 -row 0 -padx 5 -sticky e grid $l2 -column 2 -row 0 -padx 5 -sticky e grid $l3 -column 4 -row 0 -padx 5 -sticky e grid $l4 -column 0 -row 1 -padx 5 -sticky e grid $l5 -column 2 -row 1 -padx 5 -sticky e grid $l6 -column 4 -row 1 -padx 5 -sticky e grid [label $frameLatt.lr -text "Refine Cell"] -column 6 -row 0 -padx 5 -sticky e grid [label $frameLatt.ld -text "Cell damping"] -column 6 -row 1 -padx 5 -sticky e set cFlag [checkbutton $frameLatt.c -text "" -variable entryvar(cellref)] grid $cFlag -column 7 -row 0 -padx 5 -sticky e tk_optionMenu $frameLatt.om entryvar(celldamp) 0 1 2 3 4 5 6 7 8 9 grid $frameLatt.om -column 7 -row 1 -padx 5 -sticky e #-------------- Begin Atom Coordinates Box --------------------------------- grid [listbox $fbig.title -height 1 -relief flat] \ -row 0 -column 0 -sticky ew set expgui(atomtitle) $fbig.title $expgui(atomtitle) configure -font $expgui(coordfont) -selectmode extended grid [listbox $fbig.lbox -height 10 \ -xscrollcommand " $fbig.bscr set"\ -yscrollcommand " $fbig.rscr set"\ ] -row 1 -column 0 -sticky news set expgui(atomlistbox) $fbig.lbox $expgui(atomlistbox) configure -font $expgui(coordfont) -selectmode extended grid [scrollbar $fbig.bscr -orient horizontal \ -command "move2boxes \" $fbig.title $fbig.lbox \" " ] -row 2 -column 0 -sticky ew grid [scrollbar $fbig.rscr -command "$fbig.lbox yview" \ ] -row 1 -column 1 -sticky ns # give extra space to the atoms box grid columnconfigure $fbig 0 -weight 1 grid rowconfigure $fbig 1 -weight 1 proc move2boxes {boxlist args} { foreach listbox $boxlist { eval $listbox xview $args } } # BIND mouse in editbox bind $expgui(atomlistbox) editRecord bind $expgui(atomlistbox) SelectAllAtoms #-------------- End Atoms Section --------------------------------- # --------------------------- Begin Edit Box ------------------------------- grid [set expgui(EditingAtoms) [label $frame3.top -bg beige -fg blue]] \ -column 0 -row 0 -padx 2 -pady 3 -columnspan 12 -sticky w set f3l1 [label $frame3.l1 -text "Refinement Flags " -bg beige] grid $f3l1 -column 0 -row 1 -padx 2 -sticky nsw -pady 3 set f3cFlag1 [checkbutton $frame3.cf1 -text "X" -variable entryvar(xref) -bg beige] set f3cFlag2 [checkbutton $frame3.cf2 -text "U" -variable entryvar(uref) -bg beige] set f3cFlag3 [checkbutton $frame3.cf3 -text "F" -variable entryvar(fref) -bg beige] grid $f3cFlag1 -column 1 -row 1 -padx 2 -pady 3 -sticky w grid $f3cFlag2 -column 2 -row 1 -padx 2 -pady 3 -sticky w grid $f3cFlag3 -column 3 -row 1 -padx 2 -pady 3 -sticky w set f3l4 [label $frame3.l4 -text "Damping Factors " -bg beige] grid $f3l4 -column 4 -row 1 -padx 2 -sticky nsw -pady 3 tk_optionMenu $frame3.om2 entryvar(xdamp) 0 1 2 3 4 5 6 7 8 9 tk_optionMenu $frame3.om3 entryvar(udamp) 0 1 2 3 4 5 6 7 8 9 tk_optionMenu $frame3.om4 entryvar(fdamp) 0 1 2 3 4 5 6 7 8 9 grid [label $frame3.lom2 -text X -bg beige] -column 5 -row 1 -padx 2 -pady 3 -sticky w grid $frame3.om2 -column 6 -row 1 -padx 2 -pady 3 -sticky w grid [label $frame3.lom3 -text U -bg beige] -column 7 -row 1 -padx 2 -pady 3 -sticky w grid $frame3.om3 -column 8 -row 1 -padx 2 -pady 3 -sticky w grid [label $frame3.lom4 -text F -bg beige] -column 9 -row 1 -padx 2 -pady 3 -sticky w grid $frame3.om4 -column 10 -row 1 -padx 2 -pady 3 -sticky w set expgui(atomreflbl) "$frame3.l1 $frame3.l4 $frame3.lom2 $frame3.lom3 $frame3.lom4 " set expgui(atomref) "$frame3.cf1 $frame3.cf2 $frame3.cf3 $frame3.om2 $frame3.om3 $frame3.om4" set coords [frame $frame3.coords -width 100 -borderwidth 0 -bg beige] grid $coords -column 0 -row 6 -columnspan 12 -sticky nsew set f3l1 [label $frame3.coords.l1 -text "Label" -bg beige] set f3e1 [entry $frame3.coords.e1 -textvariable entryvar(label) -width 6] set f3l8 [label $frame3.coords.l8 -text "Coordinates" -bg beige] set f3e8 [entry $frame3.coords.e8 -textvariable entryvar(x) -width 10] set f3e9 [entry $frame3.coords.e9 -textvariable entryvar(y) -width 10] set f3e10 [entry $frame3.coords.e10 -textvariable entryvar(z) -width 10] set f3l11 [label $frame3.coords.l11 -text "Occupancy" -bg beige] set f3e11 [entry $frame3.coords.e11 -textvariable entryvar(frac) -width 10] set expgui(atomlabels) "$frame3.coords.l1 $frame3.coords.l8 $frame3.coords.l11" set expgui(atomentry) "$frame3.coords.e1 $frame3.coords.e8 $frame3.coords.e9 $frame3.coords.e10 $frame3.coords.e11" grid $f3l1 -column 0 -row 4 -padx 2 -sticky nsw -pady 3 grid $f3e1 -column 1 -row 4 -padx 2 -sticky nsw -pady 3 grid $f3l8 -column 2 -row 4 -padx 2 -sticky nsw -pady 3 grid $f3e8 -column 3 -row 4 -padx 2 -sticky nsw -pady 3 grid $f3e9 -column 4 -row 4 -padx 2 -sticky nsw -pady 3 grid $f3e10 -column 5 -row 4 -padx 2 -sticky nsw -pady 3 grid $f3l11 -column 6 -row 4 -padx 2 -sticky nsw -pady 3 grid $f3e11 -column 7 -row 4 -padx 2 -sticky nsw -pady 3 set f3f31 [frame $frame3.f3f31 -width 100 -borderwidth 0 -bg beige] grid $f3f31 -column 0 -row 7 -columnspan 12 set expgui(anisolabels) {} lappend expgui(anisolabels) [label $f3f31.l13 -text "Uiso" -bg beige] lappend expgui(anisolabels) [label $f3f31.l14 -text "U22" -bg beige] lappend expgui(anisolabels) [label $f3f31.l15 -text "U33" -bg beige] lappend expgui(anisolabels) [label $f3f31.l16 -text "U12" -bg beige] lappend expgui(anisolabels) [label $f3f31.l17 -text "U13" -bg beige] lappend expgui(anisolabels) [label $f3f31.l18 -text "U23" -bg beige] set expgui(anisoentry) {} lappend expgui(anisoentry) [entry $f3f31.e13 -textvariable entryvar(U11) -width 10] lappend expgui(anisoentry) [entry $f3f31.e14 -textvariable entryvar(U22) -width 10] lappend expgui(anisoentry) [entry $f3f31.e15 -textvariable entryvar(U33) -width 10] lappend expgui(anisoentry) [entry $f3f31.e16 -textvariable entryvar(U12) -width 10] lappend expgui(anisoentry) [entry $f3f31.e17 -textvariable entryvar(U13) -width 10] lappend expgui(anisoentry) [entry $f3f31.e18 -textvariable entryvar(U23) -width 10] set col 0 foreach item1 $expgui(anisolabels) item2 $expgui(anisoentry) { grid $item1 -column $col -row 0 -sticky nsw -pady 3 incr col grid $item2 -column $col -row 0 -sticky nsw -pady 3 incr col } # --------------------------- End Edit Box -------------------------------- #/\ /\ /\ /\ /\ /\ /\ END OF PHASE PANE CODE /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ #----------------------------------------------------------------------------- #v v v v v v v v v v BEGINNING OF HISTOGRAM PANE CODE v v v v v v v v v v v v grid [frame $expgui(histFrame).hs] \ -column 0 -row 0 -rowspan 10 -sticky nsew grid columnconfigure $expgui(histFrame) 0 -weight 1 grid rowconfigure $expgui(histFrame) 1 -weight 1 grid rowconfigure $expgui(histFrame) 2 -weight 1 grid rowconfigure $expgui(histFrame) 3 -weight 1 grid [listbox $expgui(histFrame).hs.title -height 1 -relief flat \ -font $expgui(histfont) ] -row 0 -column 0 -sticky ew grid [listbox $expgui(histFrame).hs.lbox -height 10 -width 25 \ -font $expgui(histfont) \ -xscrollcommand "$expgui(histFrame).hs.x set" \ -yscrollcommand "$expgui(histFrame).hs.y set" \ ] -row 1 -column 0 -sticky news lappend expgui(HistSelectList) $expgui(histFrame).hs grid [scrollbar $expgui(histFrame).hs.x -orient horizontal \ -command "move2boxes \" $expgui(histFrame).hs.title $expgui(histFrame).hs.lbox \" " ] -row 2 -column 0 -sticky ew grid [scrollbar $expgui(histFrame).hs.y \ -command "$expgui(histFrame).hs.lbox yview"] \ -row 1 -column 1 -sticky ns grid columnconfigure $expgui(histFrame).hs 0 -weight 1 grid rowconfigure $expgui(histFrame).hs 1 -weight 1 bind $expgui(histFrame).hs.lbox { set expgui(curhist) [$expgui(histFrame).hs.lbox curselection] DisplayHistogram } bind $expgui(histFrame).hs.lbox { if $expgui(globalmode) { $expgui(histFrame).hs.lbox selection set 0 end set expgui(curhist) [$expgui(histFrame).hs.lbox curselection] DisplayHistogram } } frame $expgui(histFrame).top -borderwidth 4 -relief groove grid [label $expgui(histFrame).top.txt] -row 0 -column 0 if $expgui(havetix) { foreach item {backBox diffBox} num {2 3} \ title {Background "Diffractometer Constants"} { tixLabelFrame $expgui(histFrame).$item \ -borderwidth 4 -width 600 -height 100 -label $title grid $expgui(histFrame).$item -column 1 -row $num -sticky nsew set expgui($item) [$expgui(histFrame).$item subwidget frame] } } else { foreach item {backBox diffBox} num {1 2} \ title {Background "Diffractometer Constants"} { frame $expgui(histFrame).$item -borderwidth 4 -relief groove grid $expgui(histFrame).$item -column 1 -row $num -sticky nsew set expgui($item) $expgui(histFrame).$item grid [label $expgui(histFrame).$item.title -text $title] \ -row 0 -column 0 -columnspan 10 -sticky nw } } # BACKGROUND information. # <<<<<<<<<<<<<<<<<<<<<<<<< BACKGROUND <<<<<<<<<<<<<<<<<<<<< grid [ frame $expgui(backBox).f ] -row 0 -column 0 -columnspan 11 grid [ label $expgui(backBox).f.lBGType -textvariable expgui(backtypelbl)] \ -row 1 -column 0 -sticky nws -padx 2 -pady 3 grid [ label $expgui(backBox).f.lBGTerms -textvariable expgui(backtermlbl)] \ -row 1 -column 1 -sticky nws -padx 2 -pady 3 grid [ button $expgui(backBox).f.edit -textvariable expgui(bkglbl) \ -command editbackground] \ -row 1 -column 2 -columnspan 3 -sticky w -padx 2 -pady 3 grid [ frame $expgui(backBox).f1 ] -row 1 -column 0 -columnspan 11 -sticky e grid [ label $expgui(backBox).f1.lfBG -text " Refine background" ] \ -row 2 -column 1 -sticky news -padx 4 -pady 3 grid [ checkbutton $expgui(backBox).f1.rfBG -text "" \ -variable entryvar(bref) ] \ -row 2 -column 2 -sticky news -padx 4 -pady 3 grid [ label $expgui(backBox).f1.lBGDamp -text Damping ] \ -row 2 -column 3 -sticky w -padx 2 -pady 3 tk_optionMenu $expgui(backBox).f1.om entryvar(bdamp) 0 1 2 3 4 5 6 7 8 9 grid $expgui(backBox).f1.om \ -row 2 -column 4 -sticky news -padx 4 -pady 3 -sticky e # DIFFRACTOMETER CONSTANTS SECTION #^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^END OF HISTOGRAM PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ############################################################################### #v v v v v v v v v v BEGINNING OF SCALING PANE CODE v v v v v v v v v v pack [frame $expgui(fracFrame).hs] -side left -expand y -fill both grid [listbox $expgui(fracFrame).hs.title -height 1 -relief flat \ -font $expgui(histfont) ] -row 0 -column 0 -sticky ew grid [listbox $expgui(fracFrame).hs.lbox -height 10 -width 25 \ -font $expgui(histfont) \ -xscrollcommand "$expgui(fracFrame).hs.x set" \ -yscrollcommand "$expgui(fracFrame).hs.y set" \ ] -row 1 -column 0 -sticky news lappend expgui(HistSelectList) $expgui(fracFrame).hs grid [scrollbar $expgui(fracFrame).hs.x -orient horizontal \ -command "move2boxes \" $expgui(fracFrame).hs.title $expgui(fracFrame).hs.lbox \" " ] -row 2 -column 0 -sticky ew grid [scrollbar $expgui(fracFrame).hs.y \ -command "$expgui(fracFrame).hs.lbox yview"] \ -row 1 -column 1 -sticky ns grid columnconfigure $expgui(fracFrame).hs 0 -weight 1 grid rowconfigure $expgui(fracFrame).hs 1 -weight 1 bind $expgui(fracFrame).hs.lbox { set expgui(curhist) [$expgui(fracFrame).hs.lbox curselection] DisplayFrac } bind $expgui(fracFrame).hs.lbox { if $expgui(globalmode) { $expgui(fracFrame).hs.lbox selection set 0 end set expgui(curhist) [$expgui(fracFrame).hs.lbox curselection] DisplayFrac } } pack [frame $expgui(fracFrame).f1] -fill both -expand true # Create a large canvas area containing a frame for each phase in the data set. # The canvas and vertical scrollbar are inside a frame called f1 if $expgui(havetix) { tixLabelFrame $expgui(fracFrame).f1.scaleBox \ -borderwidth 4 -width 600 -height 100 -label "Scale Factor" grid $expgui(fracFrame).f1.scaleBox -column 0 -row 0 -sticky nsew -columnspan 2 set expgui(scaleBox) [$expgui(fracFrame).f1.scaleBox subwidget frame] } else { frame $expgui(fracFrame).f1.scaleBox -borderwidth 4 -relief groove grid $expgui(fracFrame).f1.scaleBox -column 0 -row 0 -sticky nsew -columnspan 2 set expgui(scaleBox) $expgui(fracFrame).f1.scaleBox } grid [label $expgui(scaleBox).histSFLabel -text "Scale Factor"] \ -row 1 -column 0 -sticky nws -padx 2 -pady 3 grid [entry $expgui(scaleBox).ent1 -textvariable entryvar(scale) -width 15] \ -row 1 -column 1 -sticky ew -padx 4 -pady 3 button $expgui(scaleBox).but1 -text "Set Globally" \ -command "editglobalparm histinfo scale {Scale Factor}" grid [label $expgui(scaleBox).histSFRLabel -text " Refine"] \ -row 1 -column 2 -sticky nws -padx 2 -pady 3 grid [checkbutton $expgui(scaleBox).rf -variable entryvar(sref)] \ -row 1 -column 3 -sticky news -padx 4 -pady 3 grid [label $expgui(scaleBox).lD1 -text "Damping"] \ -row 1 -column 4 -sticky w -padx 2 -pady 3 tk_optionMenu $expgui(scaleBox).om entryvar(sdamp) 0 1 2 3 4 5 6 7 8 9 grid $expgui(scaleBox).om \ -row 1 -column 5 -sticky news -padx 4 -pady 3 grid columnconfigure $expgui(scaleBox) 6 -weight 1 grid [set expgui(FracBox) [canvas $expgui(fracFrame).f1.fracBox \ -scrollregion {0 0 5000 500} -width 500 -height 350 -bg lightgrey]] \ -sticky news -row 1 -column 0 grid [scrollbar $expgui(fracFrame).f1.yscroll -orient vertical] \ -sticky ns -row 1 -column 1 $expgui(FracBox) config -yscrollcommand "$expgui(fracFrame).f1.yscroll set" $expgui(fracFrame).f1.yscroll config -command { $expgui(FracBox) yview } grid columnconfigure $expgui(fracFrame).f1 0 -weight 1 grid rowconfigure $expgui(fracFrame).f1 0 -weight 1 frame $expgui(FracBox).f -bd 0 $expgui(FracBox) create window 0 0 -anchor nw -window $expgui(FracBox).f # the rest of the page is created in DisplayFrac # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ END OF SCALING PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ############################################################################### # v v v v v v v v v v BEGINNING OF PROFILE PANE CODE v v v v v v v v v v v v v pack [frame $expgui(profFrame).hs] -side left -expand y -fill both grid [listbox $expgui(profFrame).hs.title -height 1 -relief flat \ -font $expgui(histfont) ] -row 0 -column 0 -sticky ew grid [listbox $expgui(profFrame).hs.lbox -height 10 -width 25 \ -font $expgui(histfont) \ -xscrollcommand "$expgui(profFrame).hs.x set" \ -yscrollcommand "$expgui(profFrame).hs.y set" \ ] -row 1 -column 0 -sticky news lappend expgui(HistSelectList) $expgui(profFrame).hs grid [scrollbar $expgui(profFrame).hs.x -orient horizontal \ -command "move2boxes \" $expgui(profFrame).hs.title $expgui(profFrame).hs.lbox \" " ] -row 2 -column 0 -sticky ew grid [scrollbar $expgui(profFrame).hs.y \ -command "$expgui(profFrame).hs.lbox yview"] \ -row 1 -column 1 -sticky ns grid columnconfigure $expgui(profFrame).hs 0 -weight 1 grid rowconfigure $expgui(profFrame).hs 1 -weight 1 bind $expgui(profFrame).hs.lbox { set expgui(curhist) [$expgui(profFrame).hs.lbox curselection] DisplayProfile } bind $expgui(profFrame).hs.lbox { if $expgui(globalmode) { $expgui(profFrame).hs.lbox selection set 0 end set expgui(curhist) [$expgui(profFrame).hs.lbox curselection] DisplayProfile } } # Create a large canvas area containing a frame for each phase in the data set. # The canvas and vertical scrollbar are inside a frame called f1 pack [frame $expgui(profFrame).f1] -fill both -expand true grid [set expgui(ProfileBox) [canvas $expgui(profFrame).f1.profileBox \ -scrollregion {0 0 5000 500} -width 500 -height 350 -bg lightgrey]] \ -sticky news -row 0 -column 0 grid [scrollbar $expgui(profFrame).f1.yscroll -orient vertical] \ -sticky ns -row 0 -column 1 $expgui(ProfileBox) config -yscrollcommand "$expgui(profFrame).f1.yscroll set" $expgui(profFrame).f1.yscroll config -command { $expgui(ProfileBox) yview } grid columnconfigure $expgui(profFrame).f1 1 -weight 1 grid rowconfigure $expgui(profFrame).f1 0 -weight 1 frame $expgui(ProfileBox).f -bd 0 $expgui(ProfileBox) create window 0 0 -anchor nw -window $expgui(ProfileBox).f # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ END OF PROFILE PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ############################################################################## # v v v v v v v v v v BEGINNING OF LS PANE CODE v v v v v v v v v v v v v array set printopts { 0 "Print the reciprocal metric tensor changes" 1 "Print the correlation matrix" 2 "Print the Least-Squares matrices and vectors" 4 "Print the linear constraint matrices" 5 "Print the applied shifts and shift factors" 6 "Print the reciprocal metric tensor Var-Covar terms" 7 "Print all parameters for each cycle" 8 "Print summary shift/esd data after last cycle" 9 "Print zero/unit pole figure constraint terms" } pack [frame $expgui(lsFrame).hs] -side left -expand y -fill both grid [listbox $expgui(lsFrame).hs.title -height 1 -relief flat \ -font $expgui(histfont) ] -row 0 -column 0 -sticky ew grid [listbox $expgui(lsFrame).hs.lbox -height 10 -width 25 \ -font $expgui(histfont) \ -xscrollcommand "$expgui(lsFrame).hs.x set" \ -yscrollcommand "$expgui(lsFrame).hs.y set" \ ] -row 1 -column 0 -sticky news lappend expgui(HistSelectList) $expgui(lsFrame).hs grid [scrollbar $expgui(lsFrame).hs.x -orient horizontal \ -command "move2boxes \" $expgui(lsFrame).hs.title $expgui(lsFrame).hs.lbox \" " ] -row 2 -column 0 -sticky ew grid [scrollbar $expgui(lsFrame).hs.y \ -command "$expgui(lsFrame).hs.lbox yview"] \ -row 1 -column 1 -sticky ns grid columnconfigure $expgui(lsFrame).hs 0 -weight 1 grid rowconfigure $expgui(lsFrame).hs 1 -weight 1 bind $expgui(lsFrame).hs.lbox { set expgui(curhist) [$expgui(lsFrame).hs.lbox curselection] SetupExtractHist } bind $expgui(lsFrame).hs.lbox { if $expgui(globalmode) { $expgui(lsFrame).hs.lbox selection set 0 end set expgui(curhist) [$expgui(lsFrame).hs.lbox curselection] SetupExtractHist } } pack [frame $expgui(lsFrame).f1] -fill both -expand true grid rowconfigure $expgui(lsFrame).f1 4 -weight 1 set row 0 grid [label $expgui(lsFrame).f1.his1 -pady 6 -text "Last History:"] -row $row -column 0 grid [label $expgui(lsFrame).f1.his2 -relief sunken -bd 2 -pady 6 \ -textvariable expgui(last_History)] \ -row $row -column 1 -columnspan 5 -sticky w incr row grid [label $expgui(lsFrame).f1.tit1 -pady 6 -text "Title:"] -row $row -column 0 grid [entry $expgui(lsFrame).f1.tit2 \ -textvariable entryvar(title) -width 48] \ -row $row -column 1 -columnspan 5 -sticky w set entrycmd(title) "expinfo title" incr row grid [frame $expgui(lsFrame).f1.b -bd 4 -relief groove] \ -row $row -column 0 -columnspan 2 -pady 3 grid [label $expgui(lsFrame).f1.b.lcyc -text "Number of Cycles"] -row 0 -column 0 grid [entry $expgui(lsFrame).f1.b.ecyc -width 3 \ -textvariable entryvar(cycles)] -row 0 -column 1 grid [menubutton $expgui(lsFrame).f1.lprint -textvariable expgui(printopt) \ -menu $expgui(lsFrame).f1.lprint.menu -bd 4 -relief raised \ ] -row $row -column 2 menu $expgui(lsFrame).f1.lprint.menu foreach num [lsort [array names printopts]] { $expgui(lsFrame).f1.lprint.menu add checkbutton \ -label "$printopts($num) ([expr int(pow(2,$num))])"\ -variable entryvar(printopt$num) } grid [frame $expgui(lsFrame).f1.c -bd 4 -relief groove] -row $row -column 3 grid [label $expgui(lsFrame).f1.c.fol -text "Extract Fobs"] -row 0 -column 2 grid [checkbutton $expgui(lsFrame).f1.c.foc -variable entryvar(fobsextract)] -row 0 -column 3 incr row grid [frame $expgui(lsFrame).f1.a -bd 4 -relief groove] -row $row -column 0 -columnspan 6 foreach num {1 2 3 4 5 6 7 8 9} { grid [label $expgui(lsFrame).f1.a.l$num -text $num] -row 1 -column $num grid [radiobutton $expgui(lsFrame).f1.a.cc$num \ -command "HistExtractSet $num" \ -variable expgui(Fextract$num) -value 0] \ -row 2 -column $num grid [radiobutton $expgui(lsFrame).f1.a.ca$num \ -command "HistExtractSet $num" \ -variable expgui(Fextract$num) -value 1] \ -row 3 -column $num # grid [radiobutton $expgui(lsFrame).f1.a.cb$num \ # -command "HistExtractSet $num" \ # -variable expgui(Fextract$num) -value 2] \ # -row 4 -column $num } set expgui(ExtractSettingsRadiobuttons) $expgui(lsFrame).f1.a.cc lappend expgui(ExtractSettingsRadiobuttons) $expgui(lsFrame).f1.a.ca #lappend expgui(ExtractSettingsRadiobuttons) $expgui(lsFrame).f1.a.cb grid [label $expgui(lsFrame).f1.a.t -text "Intensity Extraction Method" -anchor c] \ -column 0 -columnspan 11 -row 0 grid [label $expgui(lsFrame).f1.a.t0 -text "Phase #" -anchor c] -column 0 -row 1 grid [label $expgui(lsFrame).f1.a.t1 -text "Rietveld" -anchor c] -column 0 -row 2 grid [label $expgui(lsFrame).f1.a.t2 -text "F(calc) Weighted" -anchor c] -column 0 -row 3 #grid [label $expgui(lsFrame).f1.a.t3 -text "Equally Weighted" -anchor c] -column 0 -row 4 grid [label $expgui(lsFrame).f1.a.t2a -text "(Model biased)" -anchor c] -column 10 -row 3 #grid [label $expgui(lsFrame).f1.a.t3a -text "(Le Bail method)" -anchor c] -column 10 -row 4 # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ END OF LS PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ #------------------------------------------------------------------------- #------------------------------------------------------------------------- #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv THE MENU BAR vvvvvvvvvvvvvvvvvvvvvv #---- file menu button menubutton $expgui(fm).file -text File -underline 0 -menu $expgui(fm).file.menu menu $expgui(fm).file.menu if $expgui(debug) { $expgui(fm).file.menu add command -label "Reset" -underline 0 \ -command "reset" } $expgui(fm).file.menu add command -label "expnam" -underline 0 \ -command readnewexp $expgui(fm).file.menu add command -label "Save" -underline 0 \ -command savearchiveexp $expgui(fm).file.menu add command -label "Save As" -underline 1 \ -command "SaveAsFile" $expgui(fm).file.menu add command -label "Reread .EXP file" -underline 0 \ -command {rereadexp $expgui(expfile)} #$expgui(fm).file.menu add command -label "Close" -underline 0 #---- help menu button menubutton $expgui(fm).help -text Help -underline 0 -menu $expgui(fm).help.menu menu $expgui(fm).help.menu $expgui(fm).help.menu add command -command showhelp -label "Help on Command" $expgui(fm).help.menu add command -label "About..." -underline 0 -command About #---- options menu button menubutton $expgui(fm).option -text Options -underline 0 \ -menu $expgui(fm).option.menu menu $expgui(fm).option.menu $expgui(fm).option.menu add checkbutton -label "Archive EXP" \ -variable expgui(archive) -underline 0 $expgui(fm).option.menu add cascade -menu $expgui(fm).option.menu.asort \ -label "Sort atoms by" set expgui(asorttype) number menu $expgui(fm).option.menu.asort $expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \ -label number -value number -variable expgui(asorttype) $expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \ -label type -value type -variable expgui(asorttype) $expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \ -label x -value x -variable expgui(asorttype) $expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \ -label y -value y -variable expgui(asorttype) $expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \ -label z -value z -variable expgui(asorttype) $expgui(fm).option.menu add cascade -menu $expgui(fm).option.menu.hsort \ -label "Sort histograms by" set expgui(hsorttype) number menu $expgui(fm).option.menu.hsort $expgui(fm).option.menu.hsort add radiobutton -command sethistlist \ -label number -value number -variable expgui(hsorttype) $expgui(fm).option.menu.hsort add radiobutton -command sethistlist \ -label "Histogram type" -value type -variable expgui(hsorttype) $expgui(fm).option.menu.hsort add radiobutton -command sethistlist \ -label "Bank #" -value bank -variable expgui(hsorttype) $expgui(fm).option.menu.hsort add radiobutton -command sethistlist \ -label "Angle/Wavelength" -value angle -variable expgui(hsorttype) #---- Global mode menu button $expgui(fm).option.menu add cascade -menu $expgui(fm).option.menu.editmode \ -label "Multiple hist. selection" menu $expgui(fm).option.menu.editmode $expgui(fm).option.menu.editmode add radiobutton -label "Off" \ -variable expgui(globalmode) -underline 0 -value 0\ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "All" \ -variable expgui(globalmode) -underline 0 -value 6 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "TOF" \ -variable expgui(globalmode) -underline 0 -value 1 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "CW Neutron" \ -variable expgui(globalmode) -underline 0 -value 2 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "Alpha12 Xray" \ -variable expgui(globalmode) -underline 0 -value 3 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "Monochromatic Xray" \ -variable expgui(globalmode) -underline 0 -value 4 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "Energy Disp Xray" \ -variable expgui(globalmode) -underline 0 -value 5 \ -command sethistlist set expgui(globalmode) 0 if {$tcl_platform(platform) != "windows"} { $expgui(fm).option.menu add checkbutton -label "Override backspace" \ -variable env(GSASBACKSPACE) } $expgui(fm).option.menu add command -label "Save Options" -underline 1 \ -command "SaveOptions" pack $expgui(fm).file $expgui(fm).option -side left -in $expgui(fm) foreach menu $expgui(menunames) { set m [string tolower $menu] pack [menubutton $expgui(fm).$m -text $menu -underline 0 \ -menu $expgui(fm).$m.menu] -side left menu $expgui(fm).$m.menu } pack $expgui(fm).help -side right -in $expgui(fm) # add the commands in expgui_menulist foreach menu [array names expgui_menulist ] { foreach cmd $expgui_menulist($menu) { set action {} catch {set action [lindex $expgui_cmdlist($cmd) 0]} if {$expgui(debug) && $action == ""} {puts "blank command for $cmd"} if {$action != "" && $action != "-"} { eval $expgui(fm).$menu.menu add command \ -label $cmd -command [list [subst $action]] } } } # setup command help foreach cmd [array names expgui_cmdlist] { set help {} catch {set help [lindex $expgui_cmdlist($cmd) 1]} if {$help == ""} { if {$expgui(debug)} {puts "no help for $cmd"} } else { # remove regsub -all \x09 $help " " help # preserve blank lines regsub -all \x0A\x0A $help "AAA1234567890AAA" help regsub -all \x0A $help " " help regsub -all "AAA1234567890AAA" $help \x0A\x0A help regsub -all " +" $help " " help set expgui_helplist($cmd) [string trim $help] } } # set up button bar foreach cmd $expgui(buttonlist) { set action {} catch {set action [lindex $expgui_cmdlist($cmd) 0]} if {$expgui(debug) && $action == ""} {puts "blank command for $cmd"} if {$action != ""} { pack [eval button .bar.$cmd -bg beige \ -text $cmd -command [list [subst $action]]] -side left } } $expgui(fm).file.menu add command -label "Exit" -underline 1 -command catchQuit #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF MENU DEFINITION ^^^^^^^^^^^^^^^^^^^ # handle indirect exits wm protocol . WM_DELETE_WINDOW catchQuit bind . catchQuit set expgui(curPhase) "" set expgui(pagenow) "" set expgui(curhist) {} set expgui(selectedatomlist) {} loadexp $expgui(expfile) # select the 1st phase SelectOnePhase [lindex $expmap(phaselist) 0] # select the first histogram in the list by default (if there are any) if {[llength $expmap(histlistboxcontents)] > 0} {set expgui(curhist) 0} if !$expgui(havetix) { RaisePage lsFrame } else { .n raise lsPane set expgui(pagenow) lsFrame }