#!/usr/local/bin/wish # $Id: expgui 306 2009-12-04 23:03:51Z toby $ set expgui(Revision) {$Revision: 306 $ $Date: 2009-12-04 23:03:51 +0000 (Fri, 04 Dec 2009) $} # to do: # # need to change heading and button label depending on where getExpFileName # is called from? # # 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. # # idea: # change cell parameters to labels and have a edit cell button # that enforces metric symmetry # # 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) # # idea: load more than one bank from a multi-bank .RAW file # if {$tcl_version < 8.0} { tk_dialog .expFileErrorMsg "Version Error" \ "The program requires Tcl/Tk version 8.0 or higher" error 0 "Exit" exit } # the shell variable tells expgui to act as a shell for GSAS # as well as edit the EXP file. In no-shell mode, it can # only be used to edit the .EXP file as a callable program set expgui(shell) 1 catch {if $env(EXPGUI_NOSHELL) {set expgui(shell) 0}} if {$argv != ""} { if {[string match *noshell* [string tolower $argv]]} { puts noshell set expgui(shell) 0 set expgui(expfile) [lindex $argv 1] } else { set expgui(expfile) [lindex $argv 0] } if {[string toupper [file extension $expgui(expfile)]] != ".EXP"} { append expgui(expfile) ".EXP" } } else { set expgui(expfile) {} } set expgui(curhist) {} set expmap(powderlist) {} set expgui(bkgcolor1) #fdf set expgui(debug) 0 catch {if $env(DEBUG) {set expgui(debug) 1}} #set expgui(debug) 1 # default for archive mode = on set expgui(archive) 1 # default for autoexec load = off set expgui(autoexpload) 0 # save the name of the wish executable set wishshell [info nameofexecutable] # misc constants set txtvw(font) "Courier" 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 set expgui(initstring) {} # use a separate window for DISAGL (default) set expgui(disaglSeparateBox) 1 set expgui(DefaultPeakType) 0 # default: keep current atoms when replacing a phase set expgui(DeleteAllAtoms) 0 #============================================================================= #---------------------------------------------------------------- # 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] #---------------------------------------------------------------- lappend auto_path $expgui(scriptdir) set expgui(havetix) 0 set expgui(haveBW) 1 # for debugging non-BWidget version set environment variable NOBWIDGET catch {if $env(NOBWIDGET) {set expgui(haveBW) 0}} if $expgui(haveBW) { if [catch {package require BWidget}] {set expgui(haveBW) 0} } # get the notebook widget if not using BWidgets if {!$expgui(haveBW)} {source [file join $expgui(scriptdir) notebook.tcl]} #---------------------------------------------------------------- if [file exists [file join $expgui(scriptdir) opts.tcl]] { source [file join $expgui(scriptdir) opts.tcl] } # 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] # commands for adding phases, histograms & atoms source [file join $expgui(scriptdir) addcmds.tcl] # commands for preferred orientation source [file join $expgui(scriptdir) orient.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 {$tcl_platform(platform) == "windows"} { set expgui(exptool) [file join $expgui(gsasexe) exptool.exe] } else { set expgui(exptool) [file join $expgui(gsasexe) exptool] } #--------------------------------------------------------------------------- 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) == ""} { # center the parent window because the getExpFileName window # will be centered above it. wm withdraw . set x [expr [winfo screenwidth .]/2 - [winfo reqwidth .]/2 ] set y [expr [winfo screenheight .]/2 - [winfo reqheight .]/2] wm geom . +$x+$y wm deiconify . # windows needed this update before when using tk_getOpenFile. # I am not sure it is still needed. 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 tcl_platform set exploadtime [time {set fmt [expload $expfile]}] if $expgui(debug) {puts "expload $exploadtime"} # if the file was not in the correct format, force a rewrite before use if {$fmt < 0} { # read error return } elseif {$fmt == 0 && $tcl_platform(platform) == "windows"} { set expgui(changed) 1 } elseif {$fmt == 1 && $tcl_platform(platform) == "unix"} { set expgui(changed) 1 } else { set expgui(changed) 0 } # force exp files to be upper case, force save if name changes set filetail [file tail $expfile] set filetailcaps [string toupper $filetail] if {$tcl_platform(platform) == "unix" && $filetail != $filetailcaps} { set expgui(changed) 1 } if {[file dirname $expfile] == "."} { set expgui(expfile) $filetailcaps } else { set expgui(expfile) [file join \ [file dirname $expfile] $filetailcaps] } mapexp set expgui(expModifiedLast) 0 catch { 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 $expfile] # set the number of phases on the phase page setphases # disable the "global options" that don't make sense based on # which histograms present foreach num {1 2 3 4 5} { set flag($num) 0 } # save a list of the allowed modes, too set expgui(AllowedHistSelectModes) {0 6} 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 lappend expgui(AllowedHistSelectModes) $num } else { $expgui(fm).option.menu.editmode entryconfigure $lbl -state disabled } } # disable traces on entryvar until we are ready set entrycmd(trace) 0 trace vdelete entryvar w entvartrace # 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 trace variable entryvar w entvartrace # set fo extraction on LS page SetupExtractHist # update the histogram list & update the page sethistlist # start checking for external changes afterawhile } # called to reread the .EXP 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 SaveAsFile {} { global expgui set newexpfile [getExpFileName new] if {$newexpfile == ""} return expwrite $newexpfile set expgui(expfile) $newexpfile catch {cd [string trim [file dirname $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 # switch to the 1st page RaisePage lsFrame if ![file exists $newexpfile] { # you've been warned this .EXP does not exist! # 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)]]} set expgui(globalmode) 0 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 } else { set expgui(curhist) {} } if {[CountHistory] > 100} { DeleteHistoryRecords "This .EXP file has [CountHistory] history records\nErasing most will speed EXPGUI" } } #------------- set up data read/write layer ---------------------- # trace routine on entryvar proc entvartrace {array elem action} { global expgui entrycmd entryvar entrybox 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 { set result [eval $entrycmd($elem) set [list $entryvar($elem)]] if {!$result} { if $expgui(debug) {puts "error with $entrycmd($elem)"} catch {$entrybox($elem) config -fg red} } else { catch {$entrybox($elem) config -fg black} } if {[lindex $entrycmd($elem) 0] == "atominfo"} { after idle {DisplayAllAtoms noreset} } } errmsg] {error $errmsg} } } # disable traces on entryvar until we are ready set entrycmd(trace) 0 trace variable entryvar w entvartrace # # # ############################################################################## ##### ##################################################### ##### PROCEDURES SECTION ##################################################### ##### ##################################################### ############################################################################## # save some of the global options in ~/.gsas_config proc SaveOptions {} { global expgui env tcl_platform set fp [open [file join ~ .gsas_config] a] foreach item {archive asorttype hsorttype filesort disaglSeparateBox} { puts $fp "set expgui($item) $expgui($item)" } if {$tcl_platform(platform) != "windows"} { puts $fp "set env(GSASBACKSPACE) $env(GSASBACKSPACE)" puts $fp "set expgui(autoexpload) $expgui(autoexpload)" } 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\ 2000, 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 } # This is called every 2 seconds to check for changes to the .EXP file proc whenidle {} { global expgui if $expgui(titleunchanged) { if {$expgui(changed) != 0} { wm title . "$expgui(expfile) (modified)" set expgui(titleunchanged) 0 } } if {$expgui(expModifiedLast) == 0} { after 2000 afterawhile return } if {[file mtime $expgui(expfile)] != $expgui(expModifiedLast)} { set ans [ReloadExpMsg [file tail $expgui(expfile)] $expgui(changed)] 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 } # place a message about changes over the main window proc ReloadExpMsg {file changes} { global expgui tcl_platform set msg "File $file has been modified by another program" if {$changes == 1} { append msg " and you have made a change to this version.\n" } elseif {$changes > 0} { append msg " and you have made $changes changes to this version.\n" } else { append msg ".\n" } append msg "Do you want to use the newer (modified) version or continue with the older (previous) version of the file?" set w .ask catch {destroy $w} toplevel $w -class Dialog wm title $w "Reload?" wm iconname $w "Reload?" wm protocol $w WM_DELETE_WINDOW { } wm transient $w . frame $w.bot pack $w.bot -side bottom frame $w.top pack $w.top -side top -fill both -expand 1 label $w.top.msg -justify left \ -wraplength 5i -font {Times 18} \ -text $msg if {$tcl_platform(platform) == "windows"} { $w.top.msg config -font {Times 14} } pack $w.top.msg -side right -expand 1 -fill both -padx 3m -pady 3m pack [button $w.bot.1 -text "Load new" \ -default active -command "set expgui(dialogbutton) 0" \ ] -side left -expand 1 -padx 3m -pady 2m pack [button $w.bot.2 -text "Continue with old" \ -command "set expgui(dialogbutton) 1"] \ -side left -expand 1 -padx 3m -pady 2m if {$changes > 0} { pack [button $w.bot.3 -text "Save edited version" \ -command "set expgui(dialogbutton) 2"] \ -side left -expand 1 -padx 3m -pady 2m } # Create a binding for on the dialog bind $w "tkButtonInvoke $w.bot.1" wm withdraw $w update idletasks # for windows put the box in the upper left, for # unix center it over the parent (in unix it appears later) #if {$tcl_platform(platform) == "windows"} { #wm geom $w +0+0 #} else { # for now, always center the message over the main window # center the new window in the middle of the parent set x [expr [winfo x .] + [winfo width .]/2 - \ [winfo reqwidth $w]/2 - [winfo vrootx .]] set y [expr [winfo y .] + [winfo height .]/2 - \ [winfo reqheight $w]/2 - [winfo vrooty .]] wm geom $w +$x+$y #} wm deiconify $w # Grab the focus set oldFocus [focus] set oldGrab [grab current $w] if {[string compare $oldGrab ""]} { set grabStatus [grab status $oldGrab] } grab $w focus $w.bot.1 # for windows rearrange window stacking if {$tcl_platform(platform) == "windows"} { lower . raise $w . } update idletasks tkwait variable expgui(dialogbutton) catch {focus $oldFocus} destroy $w if {[string compare $oldGrab ""]} { if {![string compare $grabStatus "global"]} { grab -global $oldGrab } else { grab $oldGrab } } # for windows rearrange window stacking if {$tcl_platform(platform) == "windows"} { raise . } return $expgui(dialogbutton) } # -------- 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 # is there a file to archive if {![file exists $expgui(expfile)]} return catch { set expnam [file rootname $expgui(expfile)] if {$tcl_platform(platform) == "windows"} { set version -1 catch {source $expnam.version} incr version if ![file executable [file join $expgui(scriptdir) pkzip.exe]] { # archive w/o pkzip set file $expnam![format "%3.3d" $version].EXP file copy -force $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 file $sexp.[format "%3.3d" $version] file copy -force $expnam.EXP $file exec [file join $expgui(scriptdir) pkzip.exe] -m $sexp $file > zip.out & 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 } set fp [open $expnam.version w] puts $fp "set version $version" 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] } file copy $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 } # setup buttons for each phase on the phase page proc setphases {} { global expgui expmap eval destroy [winfo children $expgui(phaseFrame).top.ps] pack [label $expgui(phaseFrame).top.ps.0 -text Phase:] -side left foreach num $expmap(phaselist) type $expmap(phasetype) { pack [button $expgui(phaseFrame).top.ps.$num -text $num \ -command "SelectOnePhase $num" -padx 1.5m] -side left if {$type > 3} { $expgui(phaseFrame).top.ps.$num config -state disabled } } if {[file executable $expgui(exptool)] && \ [llength $expmap(phaselist)]} { pack [button $expgui(phaseFrame).top.ps.10 -text "Add Phase" \ -padx 1.5m -command MakeAddPhaseBox] -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 entrybox expmap expgui set crsPhase {} $expgui(atomxform) config -text "Xform Atoms" -state disabled foreach n $expmap(phaselist) type $expmap(phasetype) { if {$n == $num && $type <= 3} { catch {$expgui(phaseFrame).top.ps.$num config -relief sunken} set crsPhase $num if {$type == 3} { set expgui(phasetype) "Magnetic\nOnly" } elseif {$type == 2} { set expgui(phasetype) "Magnetic\n& Nuclear" } elseif {$type == 4} { # this is not used at present set expgui(phasetype) "Macromolecular" } else { set expgui(phasetype) "" } } else { catch {$expgui(phaseFrame).top.ps.$n config -relief raised} } } # no phase is selected if {$crsPhase == "" || [llength $expmap(phaselist)] == 0} { # 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) "" } set expgui(curPhase) {} # enable traces on entryvar set entrycmd(trace) 1 $expgui(EditingAtoms) config -text "" DisplayAtom 0 0 DisplayU 0 0 DisplayRefFlags 0 0 $expgui(atomlistbox) delete 0 end 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] # reset item to black catch {$entrybox($ent) config -fg black} } #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 {} set typehead "type " set namehead " name " set multhead "Mult" set coordhead " " set frachead "Occupancy" if {$expgui(asorttype) == "type"} { # sort on atom type set typehead "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 set namehead "* name " foreach atom $expmap(atomlist_$phase) { lappend atomlist "$atom $atom $phase" } set expmap(atomlistboxcontents) [lsort -integer -index 1 $atomlist] } elseif {$expgui(asorttype) == "mult"} { # sort on atom number set multhead "Mlt*" foreach atom $expmap(atomlist_$phase) { lappend atomlist "$atom [atominfo $phase $atom mult] $phase" } set expmap(atomlistboxcontents) [lsort -integer -decreasing -index 1 $atomlist] } elseif {$expgui(asorttype) == "occupancy"} { # sort on atom number set frachead " Occup* " foreach atom $expmap(atomlist_$phase) { lappend atomlist "$atom [atominfo $phase $atom frac] $phase" } set expmap(atomlistboxcontents) [lsort -real -decreasing -index 1 $atomlist] } elseif {$expgui(asorttype) == "x"} { # sort on x set coordhead "(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 set coordhead "(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 set coordhead "(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%4d%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 mult] \ [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%29s %9s %s" \ $namehead $typehead "ref/damp " \ "fractional coordinates$coordhead" \ "$multhead $frachead" \ " Uiso/Uij "] } else { $expgui(atomtitle) insert end [format "%10s %6s %8s%29s %9s %s" \ $namehead $typehead "ref/damp " \ "fractional coordinates$coordhead" \ "$multhead $frachead" \ " 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} { if $expgui(debug) {error "Attempt display non-existent atoms"} } 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]" $expgui(atomxform) config -text "Xform Atom" -state normal } # 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 $expgui(atomxform) config -text "Xform Atoms" -state normal } # 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 if [catch {set sortlist [lsort -integer $numberList]}] {return $numberList} foreach num $sortlist { 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 $expgui(bkgcolor1) } foreach item [lrange $expgui(anisoentry) 1 end] \ var {U22 U33 U12 U13 U23} { set entrycmd($var) "" set entryvar($var) "" $item config -fg $expgui(bkgcolor1) -bg $expgui(bkgcolor1) \ -state disabled } if { $iOrA == "disable"} { set entrycmd($var) "" set entryvar($var) "" [lindex $expgui(anisoentry) 0] config \ -fg $expgui(bkgcolor1) -bg $expgui(bkgcolor1) \ -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 $expgui(bkgcolor1) } foreach entry $expgui(atomref) { $entry config -state disabled \ -fg $expgui(bkgcolor1) -bg $expgui(bkgcolor1) # turn off checkbuttons catch {$entry deselect} } return } foreach label $expgui(atomreflbl) { $label config -fg black } foreach entry $expgui(atomref) { $entry config -state normal -fg black -bg $expgui(bkgcolor1) } 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 $expgui(bkgcolor1) } foreach entry $expgui(atomentry) { $entry config -state disabled \ -fg $expgui(bkgcolor1) -bg $expgui(bkgcolor1) } 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)] } } # make a histogram box; used in MakeHistPane, proc MakeHistBox {frm} { global expgui grid [label $frm.mode -text "Select a Histogram" \ -bg beige -anchor center] \ -row 0 -column 0 -columnspan 2 -sticky ew bind $frm.mode { set i [lsearch $expgui(AllowedHistSelectModes) $expgui(globalmode)] set expgui(globalmode) [lindex \ "$expgui(AllowedHistSelectModes) \ $expgui(AllowedHistSelectModes)" [incr i]] sethistlist } bind $frm.mode {set expgui(globalmode) 0; sethistlist} grid [listbox $frm.title -height 1 -relief flat \ -exportselection 0 \ -font $expgui(histfont) ] -row 1 -column 0 -sticky ew grid [listbox $frm.lbox -height 10 -width 25 \ -exportselection 0 \ -font $expgui(histfont) \ -xscrollcommand "$frm.x set" \ -yscrollcommand "$frm.y set" \ ] -row 2 -column 0 -sticky news lappend expgui(HistSelectList) $frm grid [scrollbar $frm.x -orient horizontal \ -command "move2boxes \" $frm.title $frm.lbox \" " ] -row 3 -column 0 -sticky ew grid [scrollbar $frm.y \ -command "$frm.lbox yview"] \ -row 2 -column 1 -sticky ns grid columnconfigure $frm 0 -weight 1 grid rowconfigure $frm 2 -weight 1 } # update the histogram list # to do: show histogram ref flags? proc sethistlist {} { global expgui expmap array set lbl { 1 "Select 1 or more\nTOF Histograms" 2 "Select 1 or more\nCW Neutron Histograms" 3 "Select 1 or more\nAlpha 1,2 X-ray Histograms" 4 "Select 1 or more\nmonochromatic X-ray Histograms" 5 "Select 1 or more Energy\nDisperive X-ray Histograms" 6 "Select 1 or more of\n any type Histograms" } foreach lbox $expgui(HistSelectList) { $lbox.title delete 0 end $lbox.lbox delete 0 end if {$expgui(globalmode) != 0} { $lbox.lbox config -selectmode extended $lbox.mode config -text $lbl($expgui(globalmode)) -bg yellow } else { $lbox.lbox config -selectmode browse $lbox.mode config -text "Select a histogram" -bg beige } } # disable the unallowed pages in all mode if {$expgui(globalmode) == 6} { foreach pair $expgui(GlobalModeAllDisable) { if {$expgui(pagenow) == [lindex $pair 0]} { RaisePage 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] \ ] } } UpdateCurrentPage } proc UpdateCurrentPage {} { global expgui foreach set $expgui(frameactionlist) { if {$expgui(pagenow) == [lindex $set 0]} {catch [lindex $set 1]} } } #----------------------------------------------------------------------- # ----------- draw Histogram page #----------------------------------------------------------------------- proc DisplayHistogram {} { global expgui entrycmd entryvar entrybox expmap # trap if more than one histogram is selected unless global mode if {$expgui(globalmode) == 0 && [llength $expgui(curhist)] > 1} { set expgui(curhist) [lindex $expgui(curhist) 0] } # 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 [winfo children $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(haveBW) { catch {destroy $expgui(histFrame).pflag} } 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" if {$expgui(haveBW) && [llength $expmap(phaselist)] > 1} { TitleFrame $expgui(histFrame).pflag \ -borderwidth 4 -side left -relief groove \ -text "Phase Flags" set expgui(pflag) [$expgui(histFrame).pflag getframe] grid $expgui(histFrame).pflag -column 1 -row 1 -sticky nsew grid rowconfigure $expgui(histFrame) 2 -minsize 35 foreach p $expmap(phaselist) { pack [checkbutton $expgui(pflag).$p \ -command "GetPhaseFlags $hist" \ -variable expgui(pflag$p) -text $p] -side left if {[lsearch $expmap(phaselist_$hist) $p] == -1} { set expgui(pflag$p) 0 } else { set expgui(pflag$p) 1 } } } } # 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 [winfo children $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 set entrybox(lam1) $expgui(diffBox).eDCdifc # 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 set entrybox(lam2) $expgui(diffBox).eDCdifa # 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 set entrybox(zero) $expgui(diffBox).eDCzero 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 set entrybox(lam1) $expgui(diffBox).eDCdifc # 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 set entrybox(zero) $expgui(diffBox).eDCzero } 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 set entrybox(lam1) $expgui(diffBox).eDCdifc # 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 set entrybox(zero) $expgui(diffBox).eDCzero # 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 set entrybox(pola) $expgui(diffBox).eDCpola 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 set entrybox(ipola) $expgui(diffBox).eDCipola } 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 set entrybox(lam1) $expgui(diffBox).eDCdifc grid [ entry $expgui(diffBox).eDCdifa -textvariable entryvar(lam2) \ -width 15 ] -column 5 -row 1 set entrybox(lam2) $expgui(diffBox).eDCdifa # 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 set entrybox(kratio) $expgui(diffBox).eDCkratio # 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 set entrybox(zero) $expgui(diffBox).eDCzero 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 set entrybox(pola) $expgui(diffBox).eDCpola 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 set entrybox(ipola) $expgui(diffBox).eDCipola } 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 set entrybox(lam1) $expgui(diffBox).eDCdifc # 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 set entrybox(pola) $expgui(diffBox).eDCpola 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 set entrybox(ipola) $expgui(diffBox).eDCipola } } 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 } # this gets the phase flags as set in the expgui(pflag*) elements # (linked to phase flag checkbuttons) and the sets the "HST xx NPHAS" flags # accordingly using SetPhaseFlag proc GetPhaseFlags {hist} { global expmap expgui set plist {} foreach p $expmap(phaselist) { if {$expgui(pflag$p)} {lappend plist $p} } SetPhaseFlag $hist $plist incr expgui(changed) mapexp } #----------------------------------------------------------------------- # populate the Scaling page #----------------------------------------------------------------------- proc DisplayFrac {} { global expgui entrycmd entryvar entrybox expmap # trap if more than one histogram is selected unless global mode if {$expgui(globalmode) == 0 && [llength $expgui(curhist)] > 1} { set expgui(curhist) [lindex $expgui(curhist) 0] } # 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 [winfo children $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] } # reset scale to black catch {$entrybox(scale) config -fg black} 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)] } # reset scale to black catch {$entrybox(scale) config -fg black} 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 [winfo children $phaseFractf1] if {$expgui(globalmode) != 0} { set txt "Phase Fractions for Histograms: [CompressList $histlist]" } else { set txt "Phase Fractions" } if $expgui(haveBW) { $expgui(fracFrame).f1.phaseFrac configure -text $txt } else { grid [label $phaseFractf1.txt -anchor center -text $txt] \ -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)]"] \ -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"] \ -column 0 -row 0 -sticky nws grid [entry $framePF.ent -textvariable entryvar(frac$i) -width 15]\ -column 1 -row 0 set entrybox(frac$i) $framePF.ent } 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 entrybox expmap # trap if more than one histogram is selected unless global mode if {$expgui(globalmode) == 0 && [llength $expgui(curhist)] > 1} { set expgui(curhist) [lindex $expgui(curhist) 0] } # display the selected histograms $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 [winfo children $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)] # no defined histograms? if {$hist == ""} return # 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 # Label Heading for each phase. set ptype [string trim [hapinfo $hist $i proftype]] if {$expgui(haveBW)} { grid [TitleFrame $expgui(ProfileBox).f.$i \ -text "Hist $hist -- Phase $i (type $ptype)" \ -relief groove -bd 2] \ -column 0 -row $ind -sticky ew set ProfileFrame [$expgui(ProfileBox).f.$i getframe] grid [frame $ProfileFrame.1] \ -column 0 -row 0 -columnspan 10 pack [label $ProfileFrame.1.l \ -text Damping]\ -side left } else { grid [frame $expgui(ProfileBox).f.$i -relief groove -bd 4] \ -column 0 -row $ind -sticky ew set ProfileFrame $expgui(ProfileBox).f.$i grid [frame $ProfileFrame.1] \ -column 0 -row 0 -columnspan 10 -sticky ew pack [label $ProfileFrame.1.l \ -text "Phase $i (type $ptype) Damping"]\ -side left } tk_optionMenu $ProfileFrame.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 $ProfileFrame.1.tkOptDamp -side left pack [label $ProfileFrame.1.l1 \ -text " Peak cutoff"]\ -side left pack [entry $ProfileFrame.1.e1 \ -width 10 -textvariable entryvar(pcut_$i)]\ -side left set entrybox(pcut_$i) $ProfileFrame.1.e1 set entrycmd(pcut_$i) "hapinfo $hist $i pcut" set entryvar(pcut_$i) [hapinfo $hist $i pcut] pack [button $ProfileFrame.1.b1 \ -text "Change Type" \ -command "ChangeProfileType $hist $i"]\ -side left set col -1 set row 1 set nterms [hapinfo $hist $i profterms] set lbls "dummy [GetProfileTerms $i $hist $ptype]" 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 $ProfileFrame.l${num}_${i} -text "$term"] \ -row $row -column $col incr col grid [checkbutton $ProfileFrame.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 $ProfileFrame.ent${num}_${i} \ -textvariable entryvar(pterm${num}_$i)\ -width 12] -row $row -column $col set entrybox(pterm${num}_$i) $ProfileFrame.ent${num}_${i} 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 phase & profile type catch {unset prtyparray histarray phasearray} foreach hist $histlist { foreach phase $expmap(phaselist_$hist) { set prtyp [string trim [hapinfo $hist $phase proftype]] set key ${prtyp}_$phase lappend prtyparray($key) $hist lappend histarray($key) $hist lappend phasearray($key) $phase } } set ptype "" set i -1 # loop over all combined phases and profile types, sorted 1st by profile number foreach key [lsort [array names prtyparray]] { # split key scan $key %d_%d prftyp p if {$ptype != $prftyp || !$expgui(globalphasemode)} { set ptype $prftyp set curhistlist $histarray($key) set curphaslist $phasearray($key) set hist1 [lindex $curhistlist 0] set phase1 [lindex $curphaslist 0] set nterms [hapinfo $hist1 $phase1 profterms] set htype [string range $expmap(htype_$hist1) 2 2] set lbls "dummy [GetProfileTerms $phase1 $hist1 $ptype]" # Create a frame for this type incr i set boxtitle "Phase $p, hist [CompressList $histarray($key)]" if {$expgui(haveBW)} { grid [TitleFrame $expgui(ProfileBox).f.$i \ -text "(type $ptype)" \ -relief groove -bd 2] \ -column 0 -row $i -sticky ew set ProfileFrame [$expgui(ProfileBox).f.$i getframe] grid [frame $ProfileFrame.0] \ -column 0 -row 0 -columnspan 20 -sticky ew } else { grid [frame $expgui(ProfileBox).f.$i \ -relief groove -bd 4] \ -column 0 -row $i -sticky ew set ProfileFrame $expgui(ProfileBox).f.$i grid [frame $ProfileFrame.0] \ -column 0 -row 0 -columnspan 20 -sticky ew grid [label $ProfileFrame.0.0 \ -text "Profile Type $ptype "] -row 0 -column 0 } grid [label $ProfileFrame.0.1 \ -anchor w] -row 0 -column 1 grid [frame $ProfileFrame.1] \ -column 0 -row 1 -columnspan 20 -sticky ew grid [label $ProfileFrame.1.2 \ -text "Damping"] -row 0 -column 2 tk_optionMenu $ProfileFrame.1.tkOptDamp \ entryvar(pdamp_$i) 0 1 2 3 4 5 6 7 8 9 grid $ProfileFrame.1.tkOptDamp -row 0 -column 3 grid [button $ProfileFrame.1.edit \ -text "Global Edit"] -row 0 -column 4 -sticky w set entryvar(pdamp_$i) [hapinfo $hist $phase pdamp] grid [button $ProfileFrame.1.b1 -text "Change Type"] \ -row 0 -column 5 -sticky w 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 $ProfileFrame.l${num}_${i} \ -text "$term"] -row $row -column $col incr col grid [checkbutton $ProfileFrame.ref${num}_${i} \ -variable entryvar(pref${num}_$i)] \ -row $row -column $col 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 } else { # add to the current entry eval lappend curhistlist $histarray($key) eval lappend curphaslist $phasearray($key) append boxtitle "\nPhase $p, hist [CompressList $histarray($key)]" } $ProfileFrame.0.1 config -text $boxtitle $ProfileFrame.1.edit config -command "\ EditProfile \"\n$boxtitle\" \ [list $curhistlist] \ [list $curphaslist]" $ProfileFrame.1.b1 config -command "ChangeProfileType \ [list $curhistlist] [list $curphaslist]" set entrycmd(pdamp_$i) "hapinfo \ [list $curhistlist] \ [list $curphaslist] pdamp" for { set num 1 } { $num <= $nterms } { incr num } { set entrycmd(pref${num}_$i) "hapinfo \ [list $curhistlist] \ [list $curphaslist] pref$num" } } } # 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 ResizeNotebook # enable traces on entryvar now set entrycmd(trace) 1 } # 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(FobsExtractFrame).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(FobsExtractFrame).l$phase config -fg grey set expgui(Fextract$phase) {} foreach item $expgui(ExtractSettingsRadiobuttons) { ${item}$phase config -state disabled -bd 1 } } else { $expgui(FobsExtractFrame).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(FobsExtractFrame).l$phase config -fg black foreach item $expgui(ExtractSettingsRadiobuttons) { ${item}$phase config -state normal -bd 2 } } else { $expgui(FobsExtractFrame).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 "Global Edit Background" } else { wm title $w "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) set typemenu [tk_optionMenu $w.0.type expgui(backtype) null] $typemenu delete 0 end foreach item { "1 - Shifted Chebyshev" "2 - Cosine Fourier series" "3 - Radial distribution peaks" "4 - Power series in Q**2n/n!" "5 - Power series in n!/Q**2n" "6 - Power series in Q**2n/n! and n!/Q**2n" "7 - Linear interpolation function" "8 - Reciprocal interpolation function" } { set val [lindex $item 0] $typemenu insert end radiobutton -variable expgui(backtype) \ -label $item -value $val } 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 bind $w "destroy $w" # force the window to stay on top putontop $w focus $w.b.2 tkwait window $w afterputontop 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 [winfo children $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 bind $w "destroy $w" # force the window to stay on top putontop $w focus $w.b.2 tkwait window $w afterputontop 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" } } } } 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 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 "dummy [GetProfileTerms $phase $hist $ptype]" 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 bind $w "destroy $w" # force the window to stay on top putontop $w focus $w.b.2 tkwait window $w afterputontop } 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 # 0 name, # 1 title # 2 create command # 3 raise command # 4 disable page in global mode (0/1) if $expgui(haveBW) { pack [NoteBook .n -bd 2] -expand yes -fill both # create an array element describing each notebook page # element 0 -- pane name # 1 -- Label on frame # 2 -- initialization command # 3 -- update command # 4 -- 0/1 Use 1 if pane should be disabled in when all histograms # are selected in global mode, 0 otherwise set expgui(notebookpagelist) { {lsFrame "LS Controls" \ "" \ SetupExtractHist \ 0} {phaseFrame Phase \ "" \ "SelectOnePhase \$expgui(curPhase); DisplayAllAtoms noreset" \ 0} {histFrame Histogram \ MakeHistPane \ DisplayHistogram \ 1} {fracFrame Scaling \ MakeScalingPane \ DisplayFrac \ 0} {profFrame Profile \ MakeProfilePane \ DisplayProfile \ 1} {consFrame Constraints \ "source [file join $expgui(scriptdir) atomcons.tcl]; MakeConstraintsPane" \ DisplayConstraintsPane \ 0} {orientFrame "MD Pref Orient" \ MakeOrientPane \ DisplayOrient \ 0} {odfFrame "SH Pref Orient" \ "source [file join $expgui(scriptdir) odf.tcl]; MakeODFPane" \ DisplayODFPane \ 0} } foreach item $expgui(notebookpagelist) { set frm [lindex $item 0] set expgui($frm) [\ .n insert end $frm -text [lindex $item 1] \ -createcmd [lindex $item 2] \ -raisecmd "set expgui(pagenow) $frm; [lindex $item 3]"] # at this time expgui(frameactionlist) is generated # from expgui(notebookpagelist), but in the future it might # make sense to use expgui(notebookpagelist) directly lappend expgui(frameactionlist) "$frm [list [lindex $item 3]]" # panes to disable in global "all" mode if {[lindex $item 4]} { lappend expgui(GlobalModeAllDisable) \ "$frm \{.n itemconfigure $frm\}" } } } else { Notebook:create .n \ -pages {lsFrame phaseFrame histFrame fracFrame profFrame} pack .n -anchor w -fill both -expand yes foreach item {lsFrame phaseFrame histFrame fracFrame profFrame \ orientFrame} \ page {"LS Controls" Phase Histogram Scaling Profile \ "MD Pref Orient"} { set expgui($item) [Notebook:frame .n $item] Notebook:pageconfig .n $item -command "InitPage $item" -title $page } 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(frameactionlist) "orientFrame DisplayOrient" set expgui(GlobalModeAllDisable) {} lappend expgui(GlobalModeAllDisable) "histFrame {Notebook:pageconfig .n histFrame}" lappend expgui(GlobalModeAllDisable) "profFrame {Notebook:pageconfig .n profFrame}" } # this is used to bring up the selected frame proc RaisePage {nextpage} { global expgui if $expgui(haveBW) { .n see $nextpage .n raise $nextpage set expgui(pagenow) $nextpage } else { Notebook:raise .n $nextpage InitPage $nextpage } } # this is only called when BWidget is not in use proc InitPage {nextpage} { global expgui set expgui(pagenow) $nextpage UpdateCurrentPage } # resize the notebook to fit all the tabs and the largest page proc ResizeNotebook {} { global expgui if {$expgui(haveBW)} { .n compute_size } else { Notebook:resize .n } } #---------------------------------------------------------------------------- proc MakePhasePane {} { #\/ \/ \/ \/ \/ \/ \/ BEGINNING OF PHASE PANE CODE \/ \/ \/ \/ \/ \/ \/ global expgui entryvar entrybox entrycmd frame $expgui(phaseFrame).top set frameLatt [frame $expgui(phaseFrame).frameLatt] # This is a big frame in the Phase notebook pane to hold atomic data. set fbig [frame $expgui(phaseFrame).fbig -width 180 \ -relief raised -borderwidth 4] # This is a frame just below the big frame: for edits set frame3 [frame $expgui(phaseFrame).frame3 -width 100 \ -relief raised -borderwidth 4 -bg $expgui(bkgcolor1)] 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 "No Phases"] -side left grid [label $expgui(phaseFrame).top.lA -text title: \ -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 row 0 foreach col {2 4 6} var {a b c} lbl {a b c} { grid [label $frameLatt.l$var -text $lbl] \ -column $col -row $row -padx 5 -sticky e incr col grid [entry $frameLatt.e$var -textvariable entryvar($var) -width 10] \ -column $col -row $row -padx 5 set entrybox($var) $frameLatt.e$var } incr row foreach col {2 4 6} var {alpha beta gamma} lbl {a b g} { grid [label $frameLatt.l$var -text $lbl -font symbol] \ -column $col -row $row -padx 5 -sticky e incr col grid [entry $frameLatt.e$var -textvariable entryvar($var) -width 10] \ -column $col -row $row -padx 5 set entrybox($var) $frameLatt.e$var } grid [label $frameLatt.lr -text "Refine Cell"] -column 8 -row 0 -padx 5 -sticky e grid [label $frameLatt.ld -text "Cell damping"] -column 8 -row 1 -padx 5 -sticky e set cFlag [checkbutton $frameLatt.c -text "" -variable entryvar(cellref)] grid $cFlag -column 9 -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 9 -row 1 -padx 5 -sticky e grid [label $frameLatt.phasetype -textvariable expgui(phasetype) -fg blue] \ -column 1 -row 0 -rowspan 2 if [file executable $expgui(exptool)] { grid [button $frameLatt.newp -text Replace\nPhase \ -command MakeReplacePhaseBox] \ -column 0 -row 0 -rowspan 2 -sticky w } grid columnconfig $frameLatt 1 -weight 1 grid columnconfig $frameLatt 0 -weight 1 #-------------- Begin Atom Coordinates Box ------------------------------ grid [listbox $fbig.title -height 1 -relief flat \ -exportselection 0 -bg lightgrey -fg black \ -selectforeground black -selectbackground lightgrey] \ -row 0 -column 0 -sticky ew set expgui(atomtitle) $fbig.title bind $expgui(atomtitle) { set i [lsearch {number type mult x y z occupancy} $expgui(asorttype)] incr i set expgui(asorttype) [lindex {number type mult x y z occupancy number} $i] DisplayAllAtoms } bind $expgui(atomtitle) {set expgui(asorttype) number; DisplayAllAtoms} $expgui(atomtitle) configure -font $expgui(coordfont) -selectmode extended grid [listbox $fbig.lbox -height 10 \ -exportselection 0 \ -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 # 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 $expgui(bkgcolor1) -fg blue]] \ -column 0 -row 0 -padx 2 -pady 3 -columnspan 10 -sticky w if [file executable $expgui(exptool)] { button $frame3.newa -text "Add New Atoms" \ -bg $expgui(bkgcolor1) -highlightthickness 0 \ -command {MakeAddAtomsBox $expgui(curPhase)} grid $frame3.newa -column 11 -row 0 } button [set expgui(atomxform) $frame3.xa] \ -bg $expgui(bkgcolor1) -highlightthickness 0 \ -command {MakeXformAtomsBox $expgui(curPhase)} grid $expgui(atomxform) -column 11 -row 1 -sticky ew set f3l1 [label $frame3.l1 -text "Refinement Flags:" -bg $expgui(bkgcolor1)] grid $f3l1 -column 0 -row 1 -padx 2 -sticky nsw -pady 3 foreach lbl {X U F} var {xref uref fref} col {1 2 3} { grid [checkbutton $frame3.cf$col \ -text $lbl -variable entryvar($var) \ -bg $expgui(bkgcolor1) -highlightthickness 0 \ -activebackground $expgui(bkgcolor1)] \ -column $col -row 1 -padx 4 -pady 3 -sticky w } set f3l4 [label $frame3.l4 -text " Damping:" -bg $expgui(bkgcolor1)] grid $f3l4 -column 4 -row 1 -padx 2 -sticky nsw -pady 3 set col 4 foreach var {xdamp udamp fdamp} num {2 3 4} lbl {X U F} { grid [label $frame3.lom$num -text $lbl \ -bg $expgui(bkgcolor1)] \ -column [incr col] -row 1 -padx 2 -pady 3 -sticky w tk_optionMenu $frame3.om$num entryvar($var) 0 1 2 3 4 5 6 7 8 9 $frame3.om$num config -highlightthickness 0 grid $frame3.om$num -column [incr col] -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 $expgui(bkgcolor1)] grid $coords -column 0 -row 6 -columnspan 12 -sticky nsew set f3l1 [label $frame3.coords.l1 -text "Label" -bg $expgui(bkgcolor1)] grid $f3l1 -column 0 -row 4 -padx 2 -sticky nsw -pady 3 set expgui(atomlabels) $f3l1 set f3e1 [entry $frame3.coords.e1 -textvariable entryvar(label) -width 6] grid $f3e1 -column 1 -row 4 -padx 2 -sticky nsw -pady 3 set expgui(atomentry) $f3e1 set f3l8 [label $frame3.coords.l8 -text "Coordinates" -bg $expgui(bkgcolor1)] grid $f3l8 -column 2 -row 4 -padx 2 -sticky nsw -pady 3 lappend expgui(atomlabels) $f3l8 set f3l11 [label $frame3.coords.l11 -text "Occupancy" -bg $expgui(bkgcolor1)] grid $f3l11 -column 6 -row 4 -padx 2 -sticky nsw -pady 3 lappend expgui(atomlabels) $f3l11 foreach var {x y z frac} col {3 4 5 7} { set entrybox($var) [entry $frame3.coords.e$var \ -textvariable entryvar($var) -width 10] grid $entrybox($var) -column $col -row 4 -padx 2 -sticky nsw -pady 3 lappend expgui(atomentry) $entrybox($var) } set f3f31 [frame $frame3.f3f31 -width 100 -borderwidth 0 -bg $expgui(bkgcolor1)] grid $f3f31 -column 0 -row 7 -columnspan 12 set expgui(anisolabels) {} foreach lbl {13 14 15 16 17 18} txt {Uiso U22 U33 U12 U13 U23} { lappend expgui(anisolabels) [\ label $f3f31.l$lbl -text $txt -bg $expgui(bkgcolor1) ] } set expgui(anisoentry) {} foreach i {e13 e14 e15 e16 e17 e18} var {U11 U22 U33 U12 U13 U23} { lappend expgui(anisoentry) [\ entry $f3f31.$i -textvariable entryvar($var) \ -width 10] set entrybox($var) $f3f31.$i } 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 /\ /\ /\ /\ /\ /\ /\ /\ / # resize in case the pane needs more space ResizeNotebook } proc move2boxes {boxlist args} { foreach listbox $boxlist { eval $listbox xview $args } } #----------------------------------------------------------------------------- proc MakeHistPane {} { #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 global expgui 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 [frame $expgui(histFrame).hs] \ -column 0 -row 0 -rowspan 10 -sticky nsew MakeHistBox $expgui(histFrame).hs 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(haveBW) { foreach item {backBox diffBox} num {2 3} \ title {Background "Diffractometer Constants"} { TitleFrame $expgui(histFrame).$item \ -borderwidth 4 -side left -relief groove -text $title set expgui($item) [$expgui(histFrame).$item getframe] grid $expgui(histFrame).$item -column 1 -row $num -sticky nsew grid rowconfigure $expgui(histFrame) $num -minsize 100 } } 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 } } if [file executable $expgui(exptool)] { button $expgui(histFrame).newh -text "Add New Histogram" -command MakeAddHistBox grid $expgui(histFrame).newh -column 1 -row 6 } # BACKGROUND information. # <<<<<<<<<<<<<<<<<<<<<<<<< BACKGROUND <<<<<<<<<<<<<<<<<<<<< grid [frame $expgui(backBox).frm1 ] -row 0 -column 0 -columnspan 11 grid [label $expgui(backBox).frm1.lBGType \ -textvariable expgui(backtypelbl)] \ -row 1 -column 0 -sticky nws -padx 2 -pady 3 grid [label $expgui(backBox).frm1.lBGTerms \ -textvariable expgui(backtermlbl)] \ -row 1 -column 1 -sticky nws -padx 2 -pady 3 grid [button $expgui(backBox).frm1.edit -textvariable expgui(bkglbl) \ -command editbackground] \ -row 1 -column 2 -columnspan 3 -sticky w -padx 2 -pady 3 grid [frame $expgui(backBox).frm2 ] \ -row 1 -column 0 -columnspan 11 -sticky e grid [label $expgui(backBox).frm2.lfBG -text " Refine background" ] \ -row 2 -column 1 -sticky news -padx 4 -pady 3 grid [checkbutton $expgui(backBox).frm2.rfBG -text "" \ -variable entryvar(bref) ] \ -row 2 -column 2 -sticky news -padx 4 -pady 3 grid [label $expgui(backBox).frm2.lBGDamp -text Damping ] \ -row 2 -column 3 -sticky w -padx 2 -pady 3 tk_optionMenu $expgui(backBox).frm2.om entryvar(bdamp) 0 1 2 3 4 5 6 7 8 9 grid $expgui(backBox).frm2.om \ -row 2 -column 4 -sticky news -padx 4 -pady 3 -sticky e #^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^END OF HISTOGRAM PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ # insert the histograms & resize in case the pane needs more space sethistlist ResizeNotebook } ############################################################################### proc MakeScalingPane {} { #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 global expgui entryvar entrybox pack [frame $expgui(fracFrame).hs] -side left -expand y -fill both MakeHistBox $expgui(fracFrame).hs 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(haveBW) { TitleFrame $expgui(fracFrame).f1.scaleBox \ -borderwidth 4 -text "Scale Factor" # -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 getframe] grid [label $expgui(scaleBox).histSFLabel -text Scale] \ -row 1 -column 0 -sticky nws -padx 2 -pady 3 } 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 set entrybox(scale) $expgui(scaleBox).ent1 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 if $expgui(haveBW) { grid [TitleFrame $expgui(fracFrame).f1.phaseFrac -bd 4 \ -text "Phase Fractions" -relief groove] \ -sticky news -row 1 -column 0 -columnspan 2 set PhaseFractBox [$expgui(fracFrame).f1.phaseFrac getframe] } else { set PhaseFractBox $expgui(fracFrame).f1 } grid columnconfigure $expgui(fracFrame).f1 0 -weight 1 grid rowconfigure $expgui(fracFrame).f1 1 -weight 1 grid [set expgui(FracBox) [canvas $PhaseFractBox.fracBox \ -scrollregion {0 0 5000 500} \ -yscrollcommand "$PhaseFractBox.yscroll set" \ -width 500 -height 350 -bg lightgrey]] \ -sticky news -row 1 -column 0 grid [scrollbar $PhaseFractBox.yscroll \ -command "$expgui(FracBox) yview" \ -orient vertical] \ -sticky ns -row 1 -column 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 # insert the histograms & resize in case the pane needs more space sethistlist ResizeNotebook # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ END OF SCALING PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ } ############################################################################### proc MakeProfilePane {} { global expgui # 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 pack [frame $expgui(profFrame).hs] -side left -expand y -fill both MakeHistBox $expgui(profFrame).hs 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 # insert the histograms & resize in case the pane needs more space sethistlist ResizeNotebook # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 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 MakeHistBox $expgui(lsFrame).hs 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 raised -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 set entrybox(cycles) $expgui(lsFrame).f1.b.ecyc 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 if {$expgui(haveBW)} { grid [TitleFrame $expgui(lsFrame).f1.a -bd 4 -relief groove \ -text "Reflection Intensity Extraction" \ ] -row $row -column 0 -columnspan 6 set expgui(FobsExtractFrame) [$expgui(lsFrame).f1.a getframe] } else { grid [frame $expgui(lsFrame).f1.a -bd 4 -relief groove \ ] -row $row -column 0 -columnspan 6 set expgui(FobsExtractFrame) $expgui(lsFrame).f1.a } grid rowconfigure $expgui(lsFrame).f1 $row -pad 16 grid [frame $expgui(FobsExtractFrame).c -bd 4 -relief groove] \ -row 0 -column 8 -columnspan 3 -sticky e grid [label $expgui(FobsExtractFrame).c.fol -text "Extract Fobs"] \ -row 0 -column 2 grid [checkbutton $expgui(FobsExtractFrame).c.foc \ -variable entryvar(fobsextract)] -row 0 -column 3 foreach num {1 2 3 4 5 6 7 8 9} { grid [label $expgui(FobsExtractFrame).l$num -text $num] -row 1 -column $num grid [radiobutton $expgui(FobsExtractFrame).cc$num \ -command "HistExtractSet $num" \ -variable expgui(Fextract$num) -value 0] \ -row 2 -column $num grid [radiobutton $expgui(FobsExtractFrame).ca$num \ -command "HistExtractSet $num" \ -variable expgui(Fextract$num) -value 1] \ -row 3 -column $num grid [radiobutton $expgui(FobsExtractFrame).cb$num \ -command "HistExtractSet $num" \ -variable expgui(Fextract$num) -value 2] \ -row 4 -column $num } set expgui(ExtractSettingsRadiobuttons) $expgui(FobsExtractFrame).cc lappend expgui(ExtractSettingsRadiobuttons) $expgui(FobsExtractFrame).ca lappend expgui(ExtractSettingsRadiobuttons) $expgui(FobsExtractFrame).cb grid [label $expgui(FobsExtractFrame).t \ -text "Extraction\nMethod" -anchor c] \ -column 0 -row 0 -rowspan 2 -sticky s grid [label $expgui(FobsExtractFrame).t0 -text "Phase #" -anchor sw] \ -column 1 -row 0 -columnspan 7 -sticky sw grid [label $expgui(FobsExtractFrame).t1 -text "Rietveld" -anchor c] -column 0 -row 2 grid [label $expgui(FobsExtractFrame).t2 -text "F(calc) Weighted" -anchor c] -column 0 -row 3 grid [label $expgui(FobsExtractFrame).t3 -text "Equally Weighted" -anchor c] -column 0 -row 4 grid [label $expgui(FobsExtractFrame).t2a -text "(Model biased)" -anchor c] -column 10 -row 3 grid [label $expgui(FobsExtractFrame).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 -menu $expgui(fm).file.menu menu $expgui(fm).file.menu if $expgui(debug) { $expgui(fm).file.menu add command -label "Reset" -command "reset" } if {$expgui(shell)} { $expgui(fm).file.menu add command -label "expnam" -command readnewexp } $expgui(fm).file.menu add command -label "Save" -underline 0 \ -command savearchiveexp foreach c {s S} {bind . [list savearchiveexp]} $expgui(fm).file.menu add command -label "Save As" \ -command "SaveAsFile" $expgui(fm).file.menu add command -label "Reread .EXP file" \ -command {rereadexp $expgui(expfile)} #---- help menu button menubutton $expgui(fm).help -text Help -menu $expgui(fm).help.menu menu $expgui(fm).help.menu $expgui(fm).help.menu add command -command showhelp -underline 0 \ -label "Help on Command" foreach c {h H} {bind . [list showhelp]} $expgui(fm).help.menu add command -label "About..." -command About #---- options menu button menubutton $expgui(fm).option -text Options \ -menu $expgui(fm).option.menu menu $expgui(fm).option.menu if {$expgui(shell)} { $expgui(fm).option.menu add checkbutton -label "Archive EXP" \ -variable expgui(archive) $expgui(fm).option.menu add checkbutton -label "Use DISAGL window" \ -variable expgui(disaglSeparateBox) } $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 foreach opt {number type mult x y z occupancy} { $expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \ -label $opt -value $opt -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) -value 0 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "All" \ -variable expgui(globalmode) -value 6 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "TOF" \ -variable expgui(globalmode) -value 1 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "CW Neutron" \ -variable expgui(globalmode) -value 2 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "Alpha12 Xray" \ -variable expgui(globalmode) -value 3 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "Monochromatic Xray" \ -variable expgui(globalmode) -value 4 \ -command sethistlist $expgui(fm).option.menu.editmode add radiobutton -label "Energy Disp Xray" \ -variable expgui(globalmode) -value 5 \ -command sethistlist $expgui(fm).option.menu.editmode add separator $expgui(fm).option.menu.editmode add checkbutton \ -label "Group phases together" \ -variable expgui(globalphasemode) \ -command sethistlist set expgui(globalmode) 0 set expgui(globalphasemode) 1 if {$tcl_platform(platform) == "unix"} { $expgui(fm).option.menu add checkbutton -label "Override backspace" \ -variable env(GSASBACKSPACE) if {$expgui(shell)} { $expgui(fm).option.menu add checkbutton -label "Autoload EXP" \ -variable expgui(autoexpload) } } $expgui(fm).option.menu add command -label "Save Options" \ -command "SaveOptions" pack $expgui(fm).file $expgui(fm).option -side left -in $expgui(fm) if {$expgui(shell)} { foreach menu $expgui(menunames) { set m [string tolower $menu] pack [menubutton $expgui(fm).$m -text $menu \ -menu $expgui(fm).$m.menu] -side left menu $expgui(fm).$m.menu } } pack $expgui(fm).help -side right -in $expgui(fm) if {$expgui(shell)} { # add the commands in expgui_menulist foreach menu [array names expgui_menulist ] { foreach cmd $expgui_menulist($menu) { set action {} set opt {} catch {set action [lindex $expgui_cmdlist($cmd) 0]} catch {set opt [lindex $expgui_cmdlist($cmd) 2]} if {$expgui(debug) && $action == ""} {puts "blank command for $cmd"} if {$action != "" && $action != "-"} { eval $expgui(fm).$menu.menu add command \ -label $cmd $opt -command [list [subst $action]] if {[lindex $opt 0] == "-underline"} { catch { set num [lindex $opt 1] set key [string range $cmd $num $num] bind . [subst $action] bind . [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] } } if {$expgui(shell)} { # 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 -activebackground yellow \ -text $cmd -command [list [subst $action]]] -side left } } } $expgui(fm).file.menu add command -label "Exit" -underline 1 -command catchQuit foreach c {X x} {bind . [list catchQuit]} #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF MENU DEFINITION ^^^^^^^^^^^^^^^^^^^ # make the phase pane MakePhasePane # and the rest of the windows w/o BWidget if !$expgui(haveBW) { MakeHistPane MakeScalingPane MakeProfilePane } # 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 } else { set expgui(curhist) {} } # execute any local commands for final initialization eval $expgui(initstring) # resize the notebook to fit all the tabs and the largest page ResizeNotebook RaisePage lsFrame if {[CountHistory] > 100} { DeleteHistoryRecords "This .EXP file has [CountHistory] history records\nErasing most will speed EXPGUI" }