Changeset 557


Ignore:
Timestamp:
Dec 4, 2009 5:08:10 PM (14 years ago)
Author:
toby
Message:

# on 2002/01/25 21:26:41, toby did:
Add absorption correction to histogram pane
move damping on histogram pane, to save space
bug fix: global ref. w/alpha1,2 the ratio param were in wrong spot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expgui

    • Property rcs:date changed from 2002/01/22 22:29:18 to 2002/01/25 21:26:41
    • Property rcs:lines changed from +340 -106 to +206 -12
    • Property rcs:rev changed from 1.54 to 1.55
    r539 r557  
    15971597        set expgui(backtermlbl) ""
    15981598        set expgui(backtypelbl) ""
    1599         foreach var {bref bdamp} {
     1599        foreach var {bref bdamp absref absdamp} {
    16001600            set entrycmd($var) ""
    16011601            set entryvar($var) ""
     
    16041604        grid $expgui(histFrame).top -column 1 -row 0 -sticky nsew       
    16051605        set expgui(bkglbl) ""
     1606        set expgui(abslbl) ""
    16061607        eval destroy [winfo children $expgui(diffBox)]
    16071608        set entrycmd(trace) 1
     
    16121613        set expgui(backtermlbl) ""
    16131614        set expgui(backtypelbl) ""
    1614         foreach var {bref bdamp} {
     1615        foreach var {bref bdamp absref absdamp} {
    16151616            set entrycmd($var) "histinfo [list $histlist] $var"
    16161617            set entryvar($var) [histinfo [lindex $histlist 0] $var]
     
    16211622        set expgui(backtermlbl) "($terms terms)"
    16221623        set expgui(backtypelbl) "Function type [histinfo $hist backtype]"
    1623         foreach var {bref bdamp} {
     1624        foreach var {bref bdamp absref absdamp} {
    16241625            set entrycmd($var) "histinfo $hist $var"
    16251626            set entryvar($var) [eval $entrycmd($var)]
     
    16351636        grid $expgui(histFrame).top -column 1 -row 0 -sticky nsew       
    16361637        set expgui(bkglbl) "Globally Edit Background"
     1638        set expgui(abslbl) "Globally Edit Absorption"
    16371639    } else {
    16381640        grid forget $expgui(histFrame).top
    16391641        set expgui(bkglbl) "Edit Background"
     1642        set expgui(abslbl) "Edit Abs./Refl."
    16401643        if {$expgui(haveBW) && [llength $expmap(phaselist)] > 1} {
    16411644            TitleFrame $expgui(histFrame).pflag  \
     
    19191922        #
    19201923        grid [ label $expgui(diffBox).lDCratref -text "Refine Ratio" ] \
    1921                 -column 1 -row 3 -sticky w
     1924                -column 1 -row 2 -sticky w
    19221925        grid [ checkbutton $expgui(diffBox).rfDCratref \
    1923                 -variable entryvar(ratref) ] -column 2 -row 3
     1926                -variable entryvar(ratref) ] -column 2 -row 2
    19241927        grid [button $expgui(diffBox).bDCrrat -text "Set Ratio Globally" \
    19251928                -command "editglobalparm histinfo ratio {Wavelength Ratio}"] \
    1926                 -column 3 -row 3
     1929                -column 3 -row 2
    19271930        #
    19281931        grid [ label $expgui(diffBox).lDCzref -text "Refine zero" ] \
     
    19631966    }
    19641967    if {$expgui(globalmode) == 0} {
    1965         grid [frame $expgui(diffBox).d] -column 5 -row 5 \
     1968        grid [frame $expgui(diffBox).d] -column 5 -row 1 -rowspan 3 \
    19661969                -columnspan 2 -sticky e
    19671970    } else {
    1968         grid [frame $expgui(diffBox).d] -column 4 -row 5 \
     1971        grid [frame $expgui(diffBox).d] -column 4 -row 2 -rowspan 2 \
    19691972                -columnspan 2 -sticky e
    19701973    }
     
    28402843}
    28412844
     2845# this is called to change the absorption correction mode and to
     2846# change the absorption correction model.
     2847proc editabsorption {} {
     2848    global expgui expmap
     2849    set histlist {}
     2850    foreach n $expgui(curhist) {
     2851        lappend histlist [lindex $expmap(powderlist) $n]
     2852    }
     2853    if {[llength $histlist] == 0} return
     2854
     2855    set w .abs
     2856    catch {destroy $w}
     2857    toplevel $w -bg beige
     2858    if {$expgui(globalmode) != 0} {
     2859        wm title $w "Global Edit Absorption/Reflectivity"
     2860    } else {
     2861        wm title $w "Edit Absorption/Reflectivity"
     2862    }
     2863   
     2864    pack [frame $w.0 -bd 6 -relief groove  -bg beige \
     2865            ] -side top -expand yes -fill both
     2866    if {[llength $histlist] > 1} {
     2867        grid [label $w.0.a \
     2868            -text "Changing settings for histograms [CompressList $histlist]" \
     2869            -bg beige] -row 0 -column 0 -columnspan 10
     2870    } else {
     2871        grid [label $w.0.a \
     2872            -text "Changing settings for histogram $histlist" \
     2873            -bg beige] -row 0 -column 0 -columnspan 4
     2874        #grid columnconfig $w.0 4 -weight 1
     2875    }
     2876    grid rowconfig $w.0 1 -min 10
     2877    set hist [lindex $histlist 0]
     2878
     2879    grid [label $w.0.lb1 -text "Absorption Coefficient(s)" -bg beige] \
     2880            -row 2 -column 1  -columnspan 2
     2881    grid [label $w.0.lb1a -text "1" -bg beige] -row 3 -column 1
     2882    set expgui(abs2box1) $w.0.lb2a
     2883    grid [label $w.0.lb2a -text "2" -bg beige] -row 3 -column 2
     2884    grid [label $w.0.lb3 -text Absorption\nFunction -bg beige] \
     2885            -row 2 -column 6 -rowspan 2 -columnspan 2
     2886    grid [entry $w.0.ent1 -textvariable expgui(abscor1) -width 15] \
     2887            -row 4 -column 1
     2888    set expgui(abs2box2) $w.0.ent2
     2889    grid [entry $w.0.ent2 -textvariable expgui(abscor2) -width 15] \
     2890            -row 4 -column 2
     2891    trace vdelete expgui(abstype) w AbsSetoptmsg
     2892    eval tk_optionMenu $w.0.m1 expgui(abstype) 0 1 2 3 4
     2893    trace variable expgui(abstype) w AbsSetoptmsg
     2894    grid $w.0.m1 -row 4 -column 6 -columnspan 2
     2895    grid [label $w.0.lb8 -textvariable expgui(opttxt) -bg beige \
     2896          -wrap 300 -justify left] -row 5 -column 1  -sticky ne -columnspan 7
     2897    grid rowconfig $w.0 5 -min 100
     2898    # set the values, note the trace on abstype
     2899    foreach var {abscor1 abscor2 abstype} {
     2900        set expgui($var) [histinfo $hist $var]
     2901    }
     2902
     2903    pack [frame $w.b -bg beige] -fill x -expand yes -side top
     2904    grid [button $w.b.2 -text Set -command "AbsSaveEdit $w [list $histlist]"] \
     2905            -row 0 -column 1
     2906    grid [button $w.b.3 -text Quit \
     2907            -command "destroy $w"] -row 0 -column 2
     2908    grid [button $w.b.help -text Help -bg yellow \
     2909            -command "MakeWWWHelp expgui3.html EditAbsorption"] \
     2910            -row 0 -column 4
     2911    grid columnconfig $w.b 0 -weight 1
     2912    grid columnconfig $w.b 3 -weight 1
     2913    bind $w <Key-F1> "MakeWWWHelp expgui3.html EditAbsorption"
     2914    bind $w <Return> "destroy $w"
     2915
     2916    # force the window to stay on top
     2917    putontop $w
     2918
     2919    focus $w.b.2
     2920    tkwait window $w
     2921    afterputontop
     2922}
     2923
     2924proc AbsSetoptmsg {args} {
     2925    global expgui
     2926    array set opttxt {
     2927        0 "Correction for cylindrical samples [Lobanov & Alte da Veiga]. OK for all data types, but not for Bragg-Brentano flat-plate geometry. Set term 1 to mu*R/lambda (TOF: mu*R for lambda=1). For CW x-ray/neutron, do not refine!"
     2928        1 "Wavelength-dependent correction for container penetration. Use with TOF & Energy Disp x-ray only."
     2929        2 "Surface roughness correction [Pitschke, Hermann & Muttern]. Use with flat-plate reflection geometry (usually Bragg-Brentano) only."
     2930        3 "Surface roughness correction, [Suortti]. Use with flat-plate reflection geometry (usually Bragg-Brentano) only."
     2931        4 "Flat plate samples in transmission mode. OK for all data types, but not Bragg-Brentano geometry. Term 2 is angle w/r to beam (usually 0). For CW, do not refine."
     2932    }
     2933    set expgui(opttxt) ""
     2934    catch {set expgui(opttxt) [set opttxt($expgui(abstype))]}
     2935    switch $expgui(abstype) {
     2936        0 -
     2937        1 {
     2938            $expgui(abs2box1) config -fg gray
     2939            $expgui(abs2box2) config -state disabled -fg gray
     2940        }
     2941        2 -
     2942        3 -
     2943        4 {
     2944            $expgui(abs2box1) config -fg black
     2945            $expgui(abs2box2) config -state normal -fg black
     2946        }
     2947        default {
     2948            set expgui(opttxt) "Please select an absorption function"
     2949        }
     2950    }
     2951}
     2952proc AbsSaveEdit {top histlist} {
     2953    global expgui expmap
     2954    # sanity check: look at the histogram type
     2955    set h [lindex $histlist 0]
     2956    if {[string range $expmap(htype_$h) 2 2] == "T"} {set flag 1}
     2957    if {[string range $expmap(htype_$h) 1 2] == "NC"} {set flag 2}
     2958    if {[string range $expmap(htype_$h) 1 2] == "XC" && \
     2959            [histinfo $h lam2] != 0.0} {set flag 3}
     2960    if {[string range $expmap(htype_$h) 1 2] == "XC" && \
     2961            [histinfo $h lam2] == 0.0} {set flag 4}
     2962    if {[string range $expmap(htype_$h) 1 2] == "XE"} {set flag 5}
     2963
     2964    set msg {}
     2965    if {$expgui(abstype) == 0 && ($flag == 3 || $flag == 4)} {
     2966        set msg "Mode 0 is appropriate for cylindrical (Debye-Scherrer) geometry only"
     2967    } elseif {$expgui(abstype) == 1 && ($flag != 1 && $flag != 5)} {
     2968        set msg "Mode 1 is appropriate for wavelength-dispersive (TOF/E.D. X-ray) data only"
     2969    } elseif {($expgui(abstype) == 2 || $expgui(abstype) == 3) \
     2970            && $flag != 3 && $flag != 4} {
     2971        set msg "Mode 1 is appropriate for reflection geometry flat-plate (typically Bragg-Brentano) data only"
     2972    } elseif {$expgui(abstype) == 4 && $flag <= 3} {
     2973        set msg "Mode 4 is appropriate for flat-plate samples in transmission"
     2974    }
     2975    if {$msg != ""} {
     2976        set result [\
     2977                MyMessageBox -parent $top -title "Sanity check" \
     2978                -type okcancel -default cancel \
     2979                -icon warning -helplink "expgui3.html AbsorptionSanity" \
     2980                -message "$msg  -- are you sure you want to do this?"]
     2981        if {$result == "cancel"} return
     2982    }
     2983
     2984    # validate abscor1 & abscor2 (if needed)
     2985    set msg {}
     2986    if {![validreal expgui(abscor1) 15 8]} {
     2987        set msg "Term 1 is invalid"
     2988    }
     2989    if {$expgui(abstype) > 1} {
     2990        if {![validreal expgui(abscor2) 15 8]} {
     2991            if {$msg != ""} {append msg "\n"}
     2992            append msg "Term 2 is invalid"
     2993        }
     2994    }
     2995    if {$msg != ""} {
     2996        MyMessageBox -parent $top -title "Entry error" \
     2997                -type ok -default ok \
     2998                -icon warning -helplink "" \
     2999                -message "Invalid data entered. Please correct.\n$msg"
     3000        return
     3001    }
     3002   
     3003    histinfo $histlist abstype set $expgui(abstype)
     3004    histinfo $histlist abscor1 set $expgui(abscor1)
     3005    if {$expgui(abstype) > 1} {
     3006        histinfo $histlist abscor2 set $expgui(abscor2)
     3007    } else {
     3008        histinfo $histlist abscor2 set 0.
     3009    }
     3010    # turn off refinement, just in case they didn't read
     3011    if {($expgui(abstype) == 0 || $expgui(abstype) == 1 || $expgui(abstype) == 4) \
     3012            && ($flag != 1 && $flag != 5)} {
     3013        histinfo $histlist absref set 0
     3014    }
     3015    incr expgui(changed)
     3016    destroy $top
     3017}
     3018
    28423019##############################################################################
    28433020##                               #############################################
     
    32073384    grid [label $expgui(histFrame).top.txt] -row 0 -column 0
    32083385    if $expgui(haveBW) {
    3209         foreach item {backBox diffBox} num {2 3} \
    3210                 title {Background "Diffractometer Constants"} {
     3386        foreach item {backBox diffBox absBox} num {2 3 4} \
     3387                title {Background "Diffractometer Constants" \
     3388                "Absorption/Reflectivity Correction"} {
    32113389            TitleFrame $expgui(histFrame).$item  \
    32123390                    -borderwidth 4 -side left -relief groove -text $title
     
    32163394        }
    32173395    } else {
    3218         foreach item {backBox diffBox} num {1 2} \
    3219                 title {Background "Diffractometer Constants"} {
     3396        foreach item {backBox diffBox absBox} num {1 2 3} \
     3397                title {Background "Diffractometer Constants" \
     3398                "Absorp./Reflect. Corr"} {
    32203399            frame $expgui(histFrame).$item  -borderwidth 4 -relief groove
    32213400            grid $expgui(histFrame).$item -column 1 -row $num -sticky nsew
     
    32643443    grid $expgui(backBox).frm2.om \
    32653444            -row 2 -column 4 -sticky news -padx 4 -pady 3 -sticky e
     3445    # Absorption information.
     3446    grid [label $expgui(absBox).rf1 -text "  Refine Abs./Refl." ] \
     3447            -row 2 -column 1 -sticky news -padx 4 -pady 3
     3448    grid [checkbutton $expgui(absBox).rf2 -text "" \
     3449            -variable  entryvar(absref) ] \
     3450            -row 2 -column 2 -sticky news -padx 4 -pady 3
     3451    grid [label $expgui(absBox).d1 -text Damping ] \
     3452            -row 2 -column 3 -sticky w    -padx 2 -pady 3
     3453    tk_optionMenu $expgui(absBox).d2  entryvar(absdamp) 0 1 2 3 4 5 6 7 8 9
     3454    grid $expgui(absBox).d2 \
     3455            -row 2 -column 4 -sticky news -padx 4 -pady 3 -sticky e
     3456    grid [button $expgui(absBox).edit -textvariable expgui(abslbl) \
     3457            -command editabsorption] \
     3458            -row 2 -column 5 -sticky w -padx 2 -pady 3
     3459
    32663460    #^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^END OF HISTOGRAM PANE CODE ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
    32673461    # insert the histograms & resize in case the pane needs more space   
Note: See TracChangeset for help on using the changeset viewer.