Changeset 14 for trunk/expgui


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

# on 1998/12/31 13:10:07, toby did:
move scale to "scaling" (prev phase frac) page
add scroll bar to phase fractions
rename archiveexp to savearchiveexp
move "set expgui(changed) 0" to savearchiveexp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expgui

    • Property rcs:date changed from 1998/12/28 02:33:30 to 1998/12/31 13:10:07
    • Property rcs:lines changed from +16 -9 to +122 -67
    • Property rcs:rev changed from 1.2 to 1.3
    r12 r14  
    77# start out blank with a "load from option"?
    88#
    9 # menu for least squares options
     9# access to GENLES & EXPEDT (merge in tkGSAS)
     10#
     11# look for external changes to the EXP file and warn/reload
     12#     add a mtime to loadexp and chain a routine to check the mtime for a new value
     13#     reset the mtime in SaveAsFile
     14#
    1015# idea:
    1116# a scroll list for all histogram refinement flags ; click on takes you to the
     
    179184                {} 0 "Save and reread" "Reread without Save" "Cancel reread command"]
    180185        switch $decision {
    181             0 { archiveexp $expfile }
    182             1 {                     }
    183             2 {              return }
     186            0 { savearchiveexp $expfile }
     187            1 {                         }
     188            2 {                  return }
    184189        }
    185190    }
     
    210215                {} 0 "Save and read" "Read without Save" "Cancel read command"]
    211216        switch $decision {
    212             0 { archiveexp $expfile }
    213             1 {                     }
    214             2 {              return }
     217            0 { savearchiveexp $expfile }
     218            1 {                         }
     219            2 {                  return }
    215220        }
    216221    }
     
    309314            {} 0 "Save and Exit" "Exit without Save" "Cancel exit command"]
    310315    switch $decision {
    311         0 { archiveexp $expfile;  return "Continue" }
    312         1 {               return "Continue" }
    313         2 {               return "Cancel"   }
    314     }
    315 }
    316 
    317 proc archiveexp {expfile} {
     316        0 { savearchiveexp $expfile;  return "Continue" }
     317        1 {                           return "Continue" }
     318        2 {                           return "Cancel"   }
     319    }
     320}
     321
     322# save and optionally archive the expfile
     323proc savearchiveexp {expfile} {
    318324    global expgui tcl_platform
    319325    if !$expgui(changed) return
     
    392398    # now save the file
    393399    expwrite $expfile
     400    set expgui(changed) 0
    394401}
    395402
     
    896903        set expgui(backtermlbl) ""
    897904        set expgui(backtypelbl) ""
    898         foreach var {scale sref sdamp bref bdamp} {
     905        foreach var {bref bdamp} {
    899906            set entrycmd($var) "histinfo [list $histlist] $var"
    900907            set entryvar($var) [histinfo [lindex $histlist 0] $var]
     
    905912        set expgui(backtermlbl) "($terms terms)"
    906913        set expgui(backtypelbl) "Function type [histinfo $hist backtype]"
    907         foreach var {scale sref sdamp bref bdamp} {
     914        foreach var {bref bdamp} {
    908915            set entrycmd($var) "histinfo $hist $var"
    909916            set entryvar($var) [eval $entrycmd($var)]
    910917        }
    911918    }
    912     # Scale factor box & Top box
     919    # Top box
    913920    if {$expgui(globalmode) != 0} {
    914921        $expgui(histFrame).top.txt config \
    915922                -text "Selected Histograms: [CompressList $histlist]"
    916923        grid $expgui(histFrame).top -column 1 -row 0 -sticky nsew       
    917         set parm [grid info $expgui(scaleBox).ent1]
    918         if {$parm != ""} {
    919             grid forget  $expgui(scaleBox).ent1
    920             eval grid $expgui(scaleBox).but1 $parm
    921         }
    922924        set expgui(bkglbl) "Globally Edit Background"
    923925    } else {
    924926        grid forget $expgui(histFrame).top
    925         set parm [grid info $expgui(scaleBox).but1]
    926         if {$parm != ""} {
    927             grid forget  $expgui(scaleBox).but1
    928             eval grid $expgui(scaleBox).ent1 $parm
    929         }
    930927        set expgui(bkglbl) "Edit Background"
    931928    }
     
    12371234
    12381235#-----------------------------------------------------------------------
    1239 # populate the Phase Fraction page
     1236# populate the Scaling page
    12401237#-----------------------------------------------------------------------
    12411238proc DisplayFrac {} {
     
    12571254    }
    12581255
    1259     set phaseFractf1 $expgui(fracFrame).f1
     1256    #--------------
     1257    # Scale factor
     1258    #--------------
     1259    if {$expgui(globalmode) != 0} {
     1260        foreach var {scale sref sdamp} {
     1261            set entrycmd($var) "histinfo [list $histlist] $var"
     1262            set entryvar($var) [histinfo [lindex $histlist 0] $var]
     1263        }
     1264        set parm [grid info $expgui(scaleBox).ent1]
     1265        if {$parm != ""} {
     1266            grid forget  $expgui(scaleBox).ent1
     1267            eval grid $expgui(scaleBox).but1 $parm
     1268        }
     1269    } else {
     1270        set hist $histlist
     1271        foreach var {scale sref sdamp} {
     1272            set entrycmd($var) "histinfo $hist $var"
     1273            set entryvar($var) [eval $entrycmd($var)]
     1274        }
     1275        set parm [grid info $expgui(scaleBox).but1]
     1276        if {$parm != ""} {
     1277            grid forget  $expgui(scaleBox).but1
     1278            eval grid $expgui(scaleBox).ent1 $parm
     1279        }
     1280    }
     1281
     1282    #----------------
     1283    # Phase Fractions
     1284    #----------------
     1285    set phaseFractf1 $expgui(FracBox).f
    12601286    # destroy the contents of the frame
    1261     eval destroy [pack slaves $phaseFractf1]
     1287    eval destroy [grid slaves $phaseFractf1]
    12621288    if {$expgui(globalmode) != 0} {
    1263         pack [frame $expgui(fracFrame).f1.top] \
    1264                 -side top -anchor center
    1265         pack [label $expgui(fracFrame).f1.top.txt \
    1266                 -text "Selected Histograms: [CompressList $histlist]"] -side left
     1289        grid [label $phaseFractf1.txt -anchor center \
     1290                -text "Phase Fractions for Histograms: [CompressList $histlist]"] \
     1291                -column 0 -row 0 -sticky news
     1292    } else {
     1293        grid [label $phaseFractf1.txt -anchor center \
     1294                -text "Phase Fractions"] -column 0 -row 0 -sticky news
    12671295    }
    12681296    # Create the frame inside the canvas, One frame for each Phase.
     
    12761304        if {[llength $phasehistlist($i)] == 0} continue
    12771305        set framePF [frame $phaseFractf1.pF$i -relief groove  -bd 4]
    1278         pack $framePF -pady 1 -side top -anchor w
    1279        
     1306        grid $framePF -column 0 -row $i -sticky ew
    12801307        # Label Heading for each phase.
    12811308        if {$expgui(globalmode) != 0} {
    12821309            grid [label $framePF.l1 \
    1283                     -text "Phase $i Hist: [CompressList $phasehistlist($i)]  Phase Fraction"] \
     1310                    -text "Phase $i Hist: [CompressList $phasehistlist($i)] Fraction"] \
    12841311                    -column 0 -row 0 -sticky nws
    12851312            grid [button $framePF.but1 -text "Set Globally" \
     
    12881315                    ] -column 1 -row 0
    12891316        } else {
    1290             grid [label $framePF.l1  -text "Phase $i    Phase fraction"] \
     1317            grid [label $framePF.l1  -text "Phase $i fraction"] \
    12911318                    -column 0 -row 0 -sticky nws
    12921319            grid [entry $framePF.ent -textvariable entryvar(frac$i) -width 15]\
     
    13091336        grid $framePF.tkOptDamp -row 0 -sticky nsw -column 5
    13101337    }
     1338    # resize the scroll window to match the actual
     1339    update idletasks
     1340    $expgui(FracBox) config -scrollregion [grid bbox $expgui(FracBox).f]
     1341    $expgui(FracBox) config -width [lindex [grid bbox $expgui(FracBox).f] 2]
    13111342    update idletasks
    13121343    # enable traces on entryvar now
     
    19461977pack $expgui(fm) -fill x -side top -anchor n
    19471978
    1948 # Creating the notebook with 5 panes: Phase, Histogram, Phase Fraction, Profile
     1979# Creating the notebook with 5 panes: Phase, Histogram, Scaling, Profile
    19491980# & LS controls
    19501981if $expgui(havetix) {
     
    19581989    lappend expgui(frameactionlist) "histFrame DisplayHistogram"
    19591990    lappend expgui(GlobalModeAllDisable) "histFrame {.n pageconfigure histPane}"
    1960     .n add fracPane -label "Phase Fraction" -underline 6
     1991    .n add fracPane -label "Scaling" -underline 6
    19611992    .n pageconfigure fracPane -raisecmd \
    19621993                "set expgui(pagenow) fracFrame; DisplayFrac"
     
    19812012    pack [frame .n] -anchor w -fill both -expand yes
    19822013    foreach item {phaseFrame histFrame fracFrame profFrame lsFrame} \
    1983             page {Phase Histogram "Phase Fraction" Profile "LS Controls"} {
     2014            page {Phase Histogram Scaling Profile "LS Controls"} {
    19842015        pack [button .bar.$item -text $page -bd 2 \
    19852016                    -command "RaisePage $item"] -side left
     
    22272258grid [label $expgui(histFrame).top.txt] -row 0 -column 0
    22282259if $expgui(havetix) {
    2229     foreach item {scaleBox backBox diffBox} num {1 2 3} \
    2230             title {"Scale Factor" Background "Diffractometer Constants"} {
     2260    foreach item {backBox diffBox} num {2 3} \
     2261            title {Background "Diffractometer Constants"} {
    22312262        tixLabelFrame $expgui(histFrame).$item  \
    22322263                -borderwidth 4 -width 600 -height 100 -label $title
     
    22352266    }
    22362267} else {
    2237     foreach item {scaleBox backBox diffBox} num {0 1 2} \
    2238             title {"" Background "Diffractometer Constants"} {
     2268    foreach item {backBox diffBox} num {1 2} \
     2269            title {Background "Diffractometer Constants"} {
    22392270        frame $expgui(histFrame).$item  -borderwidth 4 -relief groove
    22402271        grid $expgui(histFrame).$item -column 1 -row $num -sticky nsew
    22412272        set expgui($item)  $expgui(histFrame).$item
    2242         if {$title != ""} {
    2243             grid [label $expgui(histFrame).$item.title -text $title] \
    2244                     -row 0 -column 0 -columnspan 10 -sticky nw
    2245         }
    2246     }
    2247 }
    2248 grid [label $expgui(scaleBox).histSFLabel -text "Scale Factor"] \
    2249         -row 1 -column 6 -sticky nws  -padx 2 -pady 3
    2250 grid [entry $expgui(scaleBox).ent1 -textvariable entryvar(scale) -width 15] \
    2251         -row 1 -column 7 -sticky ew -padx 4 -pady 3
    2252 button $expgui(scaleBox).but1 -text "Set Globally" \
    2253         -command "editglobalparm histinfo scale {Scale Factor}"
    2254 
    2255 grid [label $expgui(scaleBox).histSFRLabel -text "  Refine scale"] \
    2256         -row 1 -column 2 -sticky nws  -padx 2 -pady 3
    2257 grid [checkbutton $expgui(scaleBox).rf -variable entryvar(sref)] \
    2258         -row 1 -column 3 -sticky news -padx 4 -pady 3
    2259 grid [label $expgui(scaleBox).lD1 -text "Damping"] \
    2260         -row 1 -column 4 -sticky w    -padx 2 -pady 3
    2261 tk_optionMenu $expgui(scaleBox).om entryvar(sdamp) 0 1 2 3 4 5 6 7 8 9
    2262 grid $expgui(scaleBox).om \
    2263         -row 1 -column 5 -sticky news -padx 4 -pady 3
    2264 grid columnconfigure $expgui(scaleBox) 6  -weight 1
     2273        grid [label $expgui(histFrame).$item.title -text $title] \
     2274                -row 0 -column 0 -columnspan 10 -sticky nw
     2275    }
     2276}
    22652277
    22662278# BACKGROUND information.
     
    22902302#^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^END OF HISTOGRAM PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
    22912303###############################################################################
    2292 #v v v v v v v v v v  BEGINNING OF PHASE FRACTION PANE CODE v v v v v v v v v v
     2304#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
    22932305
    22942306pack [frame $expgui(fracFrame).hs] -side left -expand y -fill both
     
    23212333}
    23222334pack [frame $expgui(fracFrame).f1] -fill both -expand true
     2335# Create a large canvas area containing a frame for each phase in the data set.
     2336# The canvas and vertical scrollbar are inside a frame called f1
     2337if $expgui(havetix) {
     2338    tixLabelFrame $expgui(fracFrame).f1.scaleBox \
     2339            -borderwidth 4 -width 600 -height 100 -label "Scale Factor"
     2340    grid $expgui(fracFrame).f1.scaleBox -column 0 -row 0 -sticky nsew -columnspan 2
     2341    set expgui(scaleBox)  [$expgui(fracFrame).f1.scaleBox subwidget frame]
     2342} else {
     2343    frame $expgui(fracFrame).f1.scaleBox  -borderwidth 4 -relief groove
     2344        grid $expgui(fracFrame).f1.scaleBox -column 0 -row 0 -sticky nsew -columnspan 2
     2345        set expgui(scaleBox)  $expgui(fracFrame).f1.scaleBox
     2346}
     2347grid [label $expgui(scaleBox).histSFLabel -text "Scale Factor"] \
     2348        -row 1 -column 0 -sticky nws  -padx 2 -pady 3
     2349grid [entry $expgui(scaleBox).ent1 -textvariable entryvar(scale) -width 15] \
     2350        -row 1 -column 1 -sticky ew -padx 4 -pady 3
     2351button $expgui(scaleBox).but1 -text "Set Globally" \
     2352        -command "editglobalparm histinfo scale {Scale Factor}"
     2353
     2354grid [label $expgui(scaleBox).histSFRLabel -text " Refine"] \
     2355        -row 1 -column 2 -sticky nws  -padx 2 -pady 3
     2356grid [checkbutton $expgui(scaleBox).rf -variable entryvar(sref)] \
     2357        -row 1 -column 3 -sticky news -padx 4 -pady 3
     2358grid [label $expgui(scaleBox).lD1 -text "Damping"] \
     2359        -row 1 -column 4 -sticky w    -padx 2 -pady 3
     2360tk_optionMenu $expgui(scaleBox).om entryvar(sdamp) 0 1 2 3 4 5 6 7 8 9
     2361grid $expgui(scaleBox).om \
     2362        -row 1 -column 5 -sticky news -padx 4 -pady 3
     2363grid columnconfigure $expgui(scaleBox) 6  -weight 1
     2364
     2365grid [set expgui(FracBox) [canvas $expgui(fracFrame).f1.fracBox \
     2366        -scrollregion {0 0 5000 500} -width 500 -height 350 -bg lightgrey]] \
     2367        -sticky  news -row 1 -column 0
     2368grid [scrollbar $expgui(fracFrame).f1.yscroll -orient vertical] \
     2369        -sticky ns -row 1 -column 1
     2370
     2371$expgui(FracBox) config -yscrollcommand "$expgui(fracFrame).f1.yscroll set"
     2372$expgui(fracFrame).f1.yscroll config -command { $expgui(FracBox) yview }
     2373
     2374grid columnconfigure $expgui(fracFrame).f1 0 -weight 1
     2375grid rowconfigure $expgui(fracFrame).f1 0 -weight 1
     2376frame $expgui(FracBox).f -bd 0
     2377$expgui(FracBox) create window 0 0 -anchor nw  -window $expgui(FracBox).f
    23232378
    23242379# the rest of the page is created in DisplayFrac
    2325 # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ END OF PHASE FRACTION PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
     2380# ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ END OF SCALING PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
    23262381###############################################################################
    23272382# v v v v v v v v v v BEGINNING OF PROFILE PANE CODE v v v v v v v v v v v v v
     
    25472602$expgui(fm).file.menu add checkbutton  -label "Archive EXP" -variable expgui(archive) -underline 0
    25482603$expgui(fm).file.menu add command -label "Save" -underline 0 \
    2549         -command " archiveexp $expfile;  set expgui(changed) 0"
     2604        -command {savearchiveexp $expfile}
    25502605$expgui(fm).file.menu add command -label "Save As" -underline 1 \
    25512606        -command "SaveAsFile"
Note: See TracChangeset for help on using the changeset viewer.