Changeset 16


Ignore:
Timestamp:
Dec 4, 2009 4:58:57 PM (11 years ago)
Author:
toby
Message:

# on 1999/01/01 18:34:49, toby did:
add tcl_version < 8.0 error
add history display & tracking
update title when modified
move lsPage to 1st page
change option menu name & merge in Global mode menu
add loop to flag external changes to current exp file (afterawhile & whenidle)
move Archive Exp to options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expgui

    • Property rcs:date changed from 1998/12/31 13:10:07 to 1999/01/01 18:34:49
    • Property rcs:lines changed from +122 -67 to +136 -65
    • Property rcs:rev changed from 1.3 to 1.4
    r14 r16  
    2525#   DisplayAllAtoms needs to loop over phases: expgui(curPhase)
    2626
     27if {$tcl_version < 8.0} {
     28    tk_dialog .expFileErrorMsg "Version Error" \
     29            "The program requires Tcl/Tk version 8.0 or higher" error 0 "Exit"
     30    exit
     31}
     32
    2733if {$argv != ""} {
    2834    set expfile [lindex $argv 0]
     
    114120    set expgui(changed) 0
    115121    mapexp
    116 
     122    set expgui(expModifiedLast) [file mtime $expfile]
     123    set expgui(last_History) [string trim [lindex [exphistory last] 1]]
    117124    # set the window/icon title
    118125    wm title . $expfile
     126    set expgui(titleunchanged) 1
    119127    wm iconname . [file tail $expfile]
    120128
     
    129137
    130138    if !$expgui(havetix) {
    131         RaisePage phaseFrame
     139        RaisePage lsFrame
    132140    } else {
    133         .n raise phasePane
    134         set expgui(pagenow) phaseFrame
     141        .n raise lsPane
     142        set expgui(pagenow) lsFrame
    135143    }
    136144    # select the 1st phase
     
    153161            "Energy Disp Xray"} {
    154162        if $flag($num) {
    155             $expgui(fm).edit.menu entryconfigure $lbl -state normal
     163            $expgui(fm).option.menu.editmode entryconfigure $lbl -state normal
    156164        } else {
    157             $expgui(fm).edit.menu entryconfigure $lbl -state disabled
     165            $expgui(fm).option.menu.editmode entryconfigure $lbl -state disabled
    158166        }
    159167    }
     
    173181    # enable traces on entryvar
    174182    set entrycmd(trace) 1
     183    # start checking for external changes
     184    afterawhile
    175185}
    176186
     
    202212    expwrite $expfile
    203213    set expgui(changed) 0
     214    set expgui(expModifiedLast) [file mtime $expfile]
     215    set expgui(last_History) [string trim [lindex [exphistory last] 1]]
    204216    # set the window/icon title
    205217    wm title . $expfile
     218    set expgui(titleunchanged) 1
    206219    wm iconname . [file tail $expfile]
    207220}
     
    298311}
    299312
     313# wait until idle
     314proc afterawhile {} {
     315    # cancel any other instances of this loop
     316    after cancel afterawhile
     317    after cancel whenidle
     318    after cancel whenidle
     319    after idle whenidle
     320}
     321
     322proc whenidle {} {
     323    global expgui expfile
     324    if $expgui(titleunchanged) {
     325        if {$expgui(changed) != 0} {
     326            wm title . "$expfile (modified)"
     327            set expgui(titleunchanged) 0
     328        }
     329    }
     330#puts whenidle
     331    if {[file mtime $expfile] != $expgui(expModifiedLast)} {
     332        if {$expgui(changed) == 0} {
     333            set ans [tk_dialog .expFileErrorMsg "Reload?" \
     334                    "File $expfile has been modified by another program. \
     335Do you want to load the newer version or loose the modifications \
     336by editing the current version?" \
     337                    warning 0 "Load new" "Continue editing"]
     338        } else {
     339            set ans [tk_dialog .expFileErrorMsg "Reload?" \
     340                    "File $expfile has been modified by another program \
     341and you have made $expgui(changed) changes to this version. \
     342Do you want to load the newer version or loose the modifications \
     343by continuing to edit the current version?" \
     344                    warning 0 "Load new" "Continue editing" "Save edited version"]
     345        }
     346        if {$ans == 0} {
     347            loadexp $expfile
     348        } elseif {$ans == 1} {
     349            # reset the time to the next version
     350            set expgui(expModifiedLast) [file mtime $expfile]
     351        } elseif {$ans == 2} {
     352            savearchiveexp $expfile
     353        }
     354    }
     355    after 2000 afterawhile
     356}
    300357# --------  called to confirm before exiting
    301358proc catchQuit {} {
     
    322379# save and optionally archive the expfile
    323380proc savearchiveexp {expfile} {
    324     global expgui tcl_platform
     381    global expgui tcl_platform expmap
    325382    if !$expgui(changed) return
    326383    if $expgui(archive) {
     
    396453        }
    397454    }
     455    # add a header
     456    exphistory add " EXPGUI [lindex $expgui(Revision) 1] [lindex $expmap(Revision) 1] ($expgui(changed) changes) -- [clock format [clock seconds]]"
    398457    # now save the file
    399458    expwrite $expfile
    400459    set expgui(changed) 0
     460    set expgui(expModifiedLast) [file mtime $expfile]
     461    set expgui(last_History) [string trim [lindex [exphistory last] 1]]
     462    wm title . $expfile
     463    set expgui(titleunchanged) 1
    401464}
    402465
     
    782845            if {$expgui(pagenow) == [lindex $pair 0]} {
    783846                if !$expgui(havetix) {
    784                     RaisePage phaseFrame
     847                    RaisePage lsFrame
    785848                } else {
    786                     .n raise phasePane
    787                     set expgui(pagenow) phaseFrame
     849                    .n raise lsPane
     850                    set expgui(pagenow) lsFrame
    788851                }
    789852            }
     
    19812044if $expgui(havetix) {
    19822045    pack [tixNoteBook .n] -expand yes -fill both
     2046    .n add lsPane -label "LS Controls" -underline 0
     2047    .n pageconfigure lsPane -raisecmd \
     2048                "set expgui(pagenow) lsFrame; SetupExtractHist"
     2049    lappend expgui(frameactionlist) "lsFrame SetupExtractHist"
    19832050    .n add phasePane -label "Phase" -underline 0
    19842051    .n pageconfigure phasePane -raisecmd \
     
    19982065    lappend expgui(frameactionlist) "profFrame DisplayProfile"
    19992066    lappend expgui(GlobalModeAllDisable) "profFrame {.n pageconfigure profPane}"
    2000     .n add lsPane -label "LS Controls" -underline 0
    2001     .n pageconfigure lsPane -raisecmd \
    2002                 "set expgui(pagenow) lsFrame; SetupExtractHist"
    2003     lappend expgui(frameactionlist) "lsFrame SetupExtractHist"
    20042067    # Finding the pathname to the subwidget frames.
    20052068    set expgui(phaseFrame) [.n subwidget phasePane]
     
    20112074    pack [frame .bar] -side top -anchor w
    20122075    pack [frame .n] -anchor w -fill both -expand yes
    2013     foreach item {phaseFrame histFrame fracFrame profFrame lsFrame} \
     2076    foreach item {lsFrame phaseFrame histFrame fracFrame profFrame} \
    20142077            page {Phase Histogram Scaling Profile "LS Controls"} {
    20152078        pack [button .bar.$item -text $page -bd 2 \
     
    20172080        set expgui($item) [frame .n.$item -relief flat]
    20182081    }
     2082    lappend expgui(frameactionlist) "lsFrame SetupExtractHist"
    20192083    lappend expgui(frameactionlist) "histFrame DisplayHistogram"
    20202084    lappend expgui(frameactionlist) "fracFrame DisplayFrac"
    20212085    lappend expgui(frameactionlist) "profFrame DisplayProfile"
    2022     lappend expgui(frameactionlist) "lsFrame SetupExtractHist"
    20232086    lappend expgui(GlobalModeAllDisable) "histFrame {.bar.histFrame config}"
    20242087    lappend expgui(GlobalModeAllDisable) "profFrame {.bar.profFrame config}"
     
    25492612pack [frame $expgui(lsFrame).f1] -fill both -expand true
    25502613grid rowconfigure $expgui(lsFrame).f1  4 -weight 1
    2551 grid [frame $expgui(lsFrame).f1.b -bd 4 -relief groove] -row 0 -column 0
     2614grid [label $expgui(lsFrame).f1.his1 -pady 6 -text "Last History:"] -row 0 -column 0
     2615grid [label $expgui(lsFrame).f1.his2 -relief sunken -bd 2 -pady 6 \
     2616        -textvariable expgui(last_History)] \
     2617        -row 0 -column 1 -columnspan 5 -sticky w
     2618grid [frame $expgui(lsFrame).f1.b -bd 4 -relief groove] \
     2619        -row 1 -column 0 -columnspan 2 -pady 3
    25522620grid [label $expgui(lsFrame).f1.b.lcyc -text "Number of Cycles"] -row 0 -column 0
    25532621grid [entry $expgui(lsFrame).f1.b.ecyc -width 3 \
     
    25552623grid [menubutton $expgui(lsFrame).f1.lprint -textvariable expgui(printopt) \
    25562624        -menu $expgui(lsFrame).f1.lprint.menu -bd 4 -relief raised \
    2557         ] -row 0 -column 1
     2625        ] -row 1 -column 2
    25582626menu $expgui(lsFrame).f1.lprint.menu
    25592627foreach num [lsort [array names printopts]] {
     
    25622630        -variable entryvar(printopt$num)
    25632631}
    2564 grid [frame $expgui(lsFrame).f1.c -bd 4 -relief groove] -row 0 -column 2
     2632grid [frame $expgui(lsFrame).f1.c -bd 4 -relief groove] -row 1 -column 3
    25652633grid [label $expgui(lsFrame).f1.c.fol -text "Extract Fobs"] -row 0 -column 2
    25662634grid [checkbutton $expgui(lsFrame).f1.c.foc -variable entryvar(fobsextract)] -row 0 -column 3
     
    26002668            -command "reset"
    26012669}
    2602 $expgui(fm).file.menu add checkbutton  -label "Archive EXP" -variable expgui(archive) -underline 0
    26032670$expgui(fm).file.menu add command -label "Save" -underline 0 \
    26042671        -command {savearchiveexp $expfile}
     
    26182685#$expgui(fm).help.menu add command -label "GSAStk" -underline 0 -command { GSAStkHelp }
    26192686
     2687#---- options menu button
     2688menubutton $expgui(fm).option -text Options -underline 0 \
     2689        -menu $expgui(fm).option.menu
     2690menu $expgui(fm).option.menu
     2691
     2692$expgui(fm).option.menu add checkbutton  -label "Archive EXP" \
     2693        -variable expgui(archive) -underline 0
     2694
     2695$expgui(fm).option.menu add cascade -menu  $expgui(fm).option.menu.asort \
     2696        -label "Sort atoms by"
     2697
     2698set expgui(asorttype) number
     2699menu $expgui(fm).option.menu.asort
     2700$expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \
     2701        -label number -value number -variable expgui(asorttype)
     2702$expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \
     2703        -label type -value type -variable expgui(asorttype)
     2704$expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \
     2705        -label x -value x -variable expgui(asorttype)
     2706$expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \
     2707        -label y -value y -variable expgui(asorttype)
     2708$expgui(fm).option.menu.asort add radiobutton -command DisplayAllAtoms \
     2709        -label z -value z -variable expgui(asorttype)
     2710
     2711
     2712$expgui(fm).option.menu add cascade -menu  $expgui(fm).option.menu.hsort \
     2713        -label "Sort histograms by"
     2714
     2715set expgui(hsorttype) number
     2716menu $expgui(fm).option.menu.hsort
     2717$expgui(fm).option.menu.hsort add radiobutton -command sethistlist \
     2718        -label number -value number -variable expgui(hsorttype)
     2719$expgui(fm).option.menu.hsort add radiobutton -command sethistlist \
     2720        -label "Histogram type" -value type -variable expgui(hsorttype)
     2721$expgui(fm).option.menu.hsort add radiobutton -command sethistlist \
     2722        -label "Bank #" -value bank -variable expgui(hsorttype)
     2723$expgui(fm).option.menu.hsort add radiobutton -command sethistlist \
     2724        -label "Angle/Wavelength" -value angle -variable expgui(hsorttype)
     2725
    26202726#---- Global mode menu button
    2621 menubutton $expgui(fm).edit -text "Global mode" -underline 0 \
    2622         -menu $expgui(fm).edit.menu
    2623 menu $expgui(fm).edit.menu
    2624 $expgui(fm).edit.menu add radiobutton  -label "Off" \
     2727$expgui(fm).option.menu add cascade -menu $expgui(fm).option.menu.editmode \
     2728        -label "Global mode"
     2729menu $expgui(fm).option.menu.editmode
     2730$expgui(fm).option.menu.editmode add radiobutton  -label "Off" \
    26252731        -variable expgui(globalmode) -underline 0 -value 0\
    26262732        -command sethistlist
    2627 $expgui(fm).edit.menu add radiobutton  -label "All" \
     2733$expgui(fm).option.menu.editmode add radiobutton  -label "All" \
    26282734        -variable expgui(globalmode) -underline 0 -value 6 \
    26292735        -command sethistlist
    2630 $expgui(fm).edit.menu add radiobutton  -label "TOF" \
     2736$expgui(fm).option.menu.editmode add radiobutton  -label "TOF" \
    26312737        -variable expgui(globalmode) -underline 0 -value 1 \
    26322738        -command sethistlist
    2633 $expgui(fm).edit.menu add radiobutton  -label "CW Neutron" \
     2739$expgui(fm).option.menu.editmode add radiobutton  -label "CW Neutron" \
    26342740        -variable expgui(globalmode) -underline 0 -value 2  \
    26352741        -command sethistlist
    2636 $expgui(fm).edit.menu add radiobutton  -label "Alpha12 Xray" \
     2742$expgui(fm).option.menu.editmode add radiobutton  -label "Alpha12 Xray" \
    26372743        -variable expgui(globalmode) -underline 0 -value 3 \
    26382744        -command sethistlist
    2639 $expgui(fm).edit.menu add radiobutton  -label "Monochromatic Xray" \
     2745$expgui(fm).option.menu.editmode add radiobutton  -label "Monochromatic Xray" \
    26402746        -variable expgui(globalmode) -underline 0 -value 4 \
    26412747        -command sethistlist
    2642 $expgui(fm).edit.menu add radiobutton  -label "Energy Disp Xray" \
     2748$expgui(fm).option.menu.editmode add radiobutton  -label "Energy Disp Xray" \
    26432749        -variable expgui(globalmode) -underline 0 -value 5 \
    26442750        -command sethistlist
    26452751set  expgui(globalmode) 0
    2646 #---- options menu button
    2647 menubutton $expgui(fm).atom -text Options -underline 0 \
    2648         -menu $expgui(fm).atom.menu
    2649 menu $expgui(fm).atom.menu
    2650 $expgui(fm).atom.menu add cascade -menu  $expgui(fm).atom.menu.asort \
    2651         -label "Sort atoms by"
    2652 
    2653 set expgui(asorttype) number
    2654 menu $expgui(fm).atom.menu.asort
    2655 $expgui(fm).atom.menu.asort add radiobutton -command DisplayAllAtoms \
    2656         -label number -value number -variable expgui(asorttype)
    2657 $expgui(fm).atom.menu.asort add radiobutton -command DisplayAllAtoms \
    2658         -label type -value type -variable expgui(asorttype)
    2659 $expgui(fm).atom.menu.asort add radiobutton -command DisplayAllAtoms \
    2660         -label x -value x -variable expgui(asorttype)
    2661 $expgui(fm).atom.menu.asort add radiobutton -command DisplayAllAtoms \
    2662         -label y -value y -variable expgui(asorttype)
    2663 $expgui(fm).atom.menu.asort add radiobutton -command DisplayAllAtoms \
    2664         -label z -value z -variable expgui(asorttype)
    2665 
    2666 
    2667 $expgui(fm).atom.menu add cascade -menu  $expgui(fm).atom.menu.hsort \
    2668         -label "Sort histograms by"
    2669 
    2670 set expgui(hsorttype) number
    2671 menu $expgui(fm).atom.menu.hsort
    2672 $expgui(fm).atom.menu.hsort add radiobutton -command sethistlist \
    2673         -label number -value number -variable expgui(hsorttype)
    2674 $expgui(fm).atom.menu.hsort add radiobutton -command sethistlist \
    2675         -label "Histogram type" -value type -variable expgui(hsorttype)
    2676 $expgui(fm).atom.menu.hsort add radiobutton -command sethistlist \
    2677         -label "Bank #" -value bank -variable expgui(hsorttype)
    2678 $expgui(fm).atom.menu.hsort add radiobutton -command sethistlist \
    2679         -label "Angle/Wavelength" -value angle -variable expgui(hsorttype)
    2680 
    2681 pack $expgui(fm).file $expgui(fm).edit $expgui(fm).atom \
    2682         -side left  -in $expgui(fm)
     2752
     2753pack $expgui(fm).file $expgui(fm).option -side left  -in $expgui(fm)
    26832754pack $expgui(fm).help  -side right -in $expgui(fm)
    26842755
Note: See TracChangeset for help on using the changeset viewer.