Changeset 907 for trunk/excledt.tcl


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

# on 2008/04/15 17:12:02, toby did:
fix child window parentage
record macros

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/excledt.tcl

    • Property rcs:date changed from 2004/10/04 20:28:29 to 2008/04/15 17:12:02
    • Property rcs:lines changed from +12 -18 to +125 -82
    • Property rcs:rev changed from 1.14 to 1.15
    r825 r907  
    33# create the main Excluded Region window
    44proc ExclReaddata {box} {
    5     global expgui
     5    global expgui graph
    66#    if [catch {
    77        set loadtime [time {
     
    99#       }]
    1010        if $expgui(debug) {
    11             tk_dialog .time "Timing info" \
     11            tk_dialog $graph(exclbox).time "Timing info" \
    1212                    "Histogram loading took $loadtime" "" 0 OK
    1313        }
     
    217217# show tickmark options
    218218proc minioptionsbox {num} {
    219     global blt_version tcl_platform peakinfo expgui
    220     set bx .opt$num
     219    global blt_version tcl_platform peakinfo expgui graph
     220    set bx $graph(exclbox).opt$num
    221221    catch {destroy $bx}
    222222    toplevel $bx
     
    263263}
    264264
    265 proc makepostscriptout {} {
     265proc MakePostscriptOut {{parent {}}} {
    266266    global graph
    267267    if !$graph(printout) {
     
    280280        }
    281281        if {$msg != ""} {
    282             tk_dialog .msg "file created" \
     282            tk_dialog $parent.msg "file created" \
    283283                    "Postscript file processed with command \
    284284                    $graph(outcmd). Result: $msg" "" 0 OK
    285285        } else {
    286             tk_dialog .msg "file created" \
     286            tk_dialog $parent.msg "file created" \
    287287                    "Postscript file processed with command \
    288288                    $graph(outcmd)" "" 0 OK
     
    291291        $graph(plot) postscript output $graph(outname) -landscape 1 \
    292292                -decorations no -height 7.i -width 9.5i   
    293         tk_dialog .msg "file created" \
     293        tk_dialog $parent.msg "file created" \
    294294                "Postscript file $graph(outname) created" "" 0 OK
    295295    }
     
    311311}
    312312
    313 proc setpostscriptout {} {
     313proc SetPostscriptOut {{parent ""}} {
    314314    global graph tcl_platform
    315     set box .out
     315    set box ${parent}.out
    316316    catch {destroy $box}
    317317    toplevel $box
     
    340340}
    341341
    342 proc getsymopts {"sym obs"} {
     342proc GetSymbolOpts {"sym obs" {parent ""} {
    343343    global expgui peakinfo
    344     set box .out
     344    set box $parent.out
    345345    catch {destroy $box}
    346346    toplevel $box
    347347    focus $box
    348     wm title .out "Set $sym symbol"
     348    wm title $box "Set $sym symbol"
    349349    pack [frame $box.d] -side left -anchor n
    350350    pack [label $box.d.t -text "Symbol type"] -side top
     
    362362    pack [label $box.e.l -text "Symbol Size"] -side top
    363363    pack [scale $box.e.s -variable expgui(size) \
    364             -from .1 -to 3 -resolution 0.05] -side top
     364            -from 0.1 -to 3 -resolution 0.05] -side top
    365365    pack [frame $box.a] -side bottom
    366366    pack [button $box.a.1 -text "Apply" -command "setsymopts $sym"] -side left
     
    518518            global graph
    519519            if {$graph(exclPrompt)} {
    520                 set ans [MyMessageBox -parent . -message $msg \
     520                set ans [MyMessageBox -parent $graph(exclbox) -message $msg \
    521521                        -helplink "expguierr.html ExcludeRegion" \
    522522                        -title "Delete region" -type okcancel]
     
    535535    } else {
    536536        histinfo $hst excl set $newlist
     537        RecordMacroEntry "histinfo $hst excl set [list $newlist]" 0
     538        RecordMacroEntry "incr expgui(changed)" 0
    537539        updateplot
    538540    }
     
    623625    global graph
    624626    if {$graph(exclPrompt)} {
    625         set ans [MyMessageBox -parent . -message $msg -title "Exclude?"\
     627        set ans [MyMessageBox -parent $graph(exclbox) -message $msg -title "Exclude?"\
    626628                -type okcancel -helplink "expguierr.html ExcludeRegion"]
    627629    } else {
     
    690692    }
    691693    histinfo $graph(hst) excl set $exclist
     694    RecordMacroEntry "histinfo $graph(hst) excl set [list $exclist]" 0
     695    RecordMacroEntry "incr expgui(changed)" 0
    692696}
    693697
     
    696700    global expmap graph expgui
    697701    set hst $graph(hst)
     702    set box $graph(exclbox).limit
    698703    if {[string trim [string range $expmap(htype_$hst) 3 3]] == "D"} {
    699704        if {[string range $expmap(htype_$hst) 2 2] == "T"} {
     
    711716        return
    712717    }
    713     set box .limit
    714718    toplevel $box
    715719    wm title $box "Set usable range"
     
    830834        if {$oldtmin != $tmin} {
    831835            # edited minimum time -- reset d-min & set CHANS -- use EXPEDT
    832             SetTminTOF $tmin [winfo parent $graph(plot)]
     836            SetTminTOF $tmin $hst [winfo parent $graph(plot)]
    833837            # Qmax got bigger. Show the new data?
    834838            if {$tmin < $oldtmin} {QmaxIncreased}
     
    839843            # edited 2theta or Energy max -- reset d-min
    840844            histinfo $hst dmin set [tod $tmax $hst]
     845            RecordMacroEntry "histinfo $hst dmin set [tod $tmax $hst]" 0
     846            RecordMacroEntry "incr expgui(changed)" 0
    841847            if {$tmax > $oldtmax} {QmaxIncreased}
    842848        }
     
    852858    append msg "to see the full range of data displayed. Do you want to "
    853859    append msg "run POWPREF (& possibly GENLES with zero cycles)?"
    854     set ans [MyMessageBox -parent . -message $msg -title "Process limits?"\
     860    set ans [MyMessageBox -parent $graph(exclbox) -message $msg -title "Process limits?"\
    855861            -helplink "expguierr.html ProcessRegions" \
    856862            -type {Skip {Run POWPREF} {Run POWPREF & GENLES}}]
     
    912918        }
    913919        append msg "OK to make this change?"
    914         set ans [MyMessageBox -parent . -message $msg -title "Reset limits?"\
     920        set ans [MyMessageBox -parent $graph(exclbox) -message $msg -title "Reset limits?"\
    915921                -helplink "expguierr.html RegionTooBig" \
    916922                -type {OK Cancel}]
     
    920926            set exclist [lreplace $exclist end end $item]
    921927            histinfo $hst excl set $exclist
     928            RecordMacroEntry "histinfo $hst excl set [list $exclist]" 0
    922929            histinfo $hst dmin set [tod $max $hst]
     930            RecordMacroEntry "histinfo $hst dmin set [tod $max $hst]" 0
     931            RecordMacroEntry "incr expgui(changed)" 0
    923932            updateplot
    924933            return
     
    952961    set i [expr {$reg -1}]
    953962    set range [lindex $exclist $i]
    954     toplevel [set box .edit]
     963    toplevel [set box $graph(exclbox).edit]
    955964    wm title $box "Edit excluded region"
    956965    set beg minimum
     
    10171026        set $v $graph($v)
    10181027    }
    1019     bind $box <Return> "destroy .edit"
     1028    bind $box <Return> "destroy $box"
    10201029    grid [frame $box.c] -column 1 -row 99 -columnspan 99
    1021     grid [button $box.c.1 -text "OK" -command "destroy .edit"] \
     1030    grid [button $box.c.1 -text "OK" -command "destroy $box"] \
    10221031            -column 1 -row 1
    10231032    grid [button $box.c.2 -text "Cancel" \
    1024             -command "set graph(tmin) $tmin; set graph(tmax) $tmax;destroy .edit"] \
     1033            -command "set graph(tmin) $tmin; set graph(tmax) $tmax;destroy $box"] \
    10251034            -column 2 -row 1
    10261035    putontop $box
     
    12061215
    12071216# manual zoom option
    1208 proc BLTmanualZoom {} {
     1217proc BLTplotManualZoom {} {
    12091218    global graph
    1210     catch {toplevel .zoom}
    1211     wm title .zoom "Manual zoom"
    1212     eval destroy [grid slaves .zoom]
    1213     raise .zoom
    1214     wm title .zoom {Manual Scaling}
    1215     grid [label .zoom.l1 -text minimum] -row 1 -column 2
    1216     grid [label .zoom.l2 -text maximum] -row 1 -column 3
    1217     grid [label .zoom.l3 -text x] -row 2 -column 1
    1218     grid [label .zoom.l4 -text y] -row 3 -column 1
    1219     grid [entry .zoom.xmin -textvariable graph(xmin) -width 10] -row 2 -column 2
    1220     grid [entry .zoom.xmax -textvariable graph(xmax) -width 10] -row 2 -column 3
    1221     grid [entry .zoom.ymin -textvariable graph(ymin) -width 10] -row 3 -column 2
    1222     grid [entry .zoom.ymax -textvariable graph(ymax) -width 10] -row 3 -column 3
    1223     grid [frame .zoom.b] -row 4 -column 1 -columnspan 3
    1224     grid [button .zoom.b.1 -text "Set Scaling" \
     1219    set parent [winfo parent graph(plot)]
     1220    if {$parent == "."} {set parent ""}
     1221    set box ${parent}.zoom
     1222    catch {toplevel $box}
     1223    wm title $box "Manual zoom"
     1224    eval destroy [grid slaves $box]
     1225    raise $box
     1226    wm title $box {Manual Scaling}
     1227    grid [label $box.l1 -text minimum] -row 1 -column 2
     1228    grid [label $box.l2 -text maximum] -row 1 -column 3
     1229    grid [label $box.l3 -text x] -row 2 -column 1
     1230    grid [label $box.l4 -text y] -row 3 -column 1
     1231    grid [entry $box.xmin -textvariable graph(xmin) -width 10] -row 2 -column 2
     1232    grid [entry $box.xmax -textvariable graph(xmax) -width 10] -row 2 -column 3
     1233    grid [entry $box.ymin -textvariable graph(ymin) -width 10] -row 3 -column 2
     1234    grid [entry $box.ymax -textvariable graph(ymax) -width 10] -row 3 -column 3
     1235    grid [frame $box.b] -row 4 -column 1 -columnspan 3
     1236    grid [button $box.b.1 -text "Set Scaling" \
    12251237             -command "SetManualZoom set"]  -row 4 -column 1 -columnspan 2
    1226     grid [button .zoom.b.2 -text Reset \
     1238    grid [button $box.b.2 -text Reset \
    12271239            -command "SetManualZoom clear"] -row 4 -column 3
    1228     grid [button .zoom.b.3 -text Close -command "destroy .zoom"] -row 4 -column 4
    1229     grid rowconfigure .zoom 1 -weight 1 -pad 5
    1230     grid rowconfigure .zoom 2 -weight 1 -pad 5
    1231     grid rowconfigure .zoom 3 -weight 1 -pad 5
    1232     grid rowconfigure .zoom 4 -weight 0 -pad 5
    1233     grid columnconfigure .zoom 1 -weight 1 -pad 20
    1234     grid columnconfigure .zoom 1 -weight 1
    1235     grid columnconfigure .zoom 3 -weight 1 -pad 10
     1240    grid [button $box.b.3 -text Close -command "destroy $box"] -row 4 -column 4
     1241    grid rowconfigure $box 1 -weight 1 -pad 5
     1242    grid rowconfigure $box 2 -weight 1 -pad 5
     1243    grid rowconfigure $box 3 -weight 1 -pad 5
     1244    grid rowconfigure $box 4 -weight 0 -pad 5
     1245    grid columnconfigure $box 1 -weight 1 -pad 20
     1246    grid columnconfigure $box 1 -weight 1
     1247    grid columnconfigure $box 3 -weight 1 -pad 10
    12361248    foreach item {min min max max} \
    12371249            format {3   2   3   2} \
     
    12411253        catch {set graph(${axis}${item}) [format %.${format}f $val]}
    12421254    }
    1243     putontop .zoom
    1244     tkwait window .zoom
     1255    putontop $box
     1256    tkwait window $box
    12451257    afterputontop   
    12461258}
     
    13041316        set graph(plot) [graph $graph(exclbox).g -plotbackground white]
    13051317    } errmsg] {
    1306         MyMessageBox -parent . -title "BLT Error" \
     1318        MyMessageBox -parent $graph(exclbox) -title "BLT Error" \
    13071319                -message "BLT Setup Error: could not create a graph \
    13081320(error msg: $errmsg). \
     
    13171329        Blt_ZoomStack $graph(plot)
    13181330    } errmsg] {
    1319         MyMessageBox -parent . -title "BLT Error" \
     1331        MyMessageBox -parent $graph(exclbox) -title "BLT Error" \
    13201332                -message "BLT Setup Error: could not access a Blt_ routine \
    13211333(msg: $errmsg). \
     
    13581370            -label "Update Plot" -command "CheckChanges $startchanges;updateplot"
    13591371    $graph(exclmenu).file.menu add command \
    1360             -label "Make PostScript" -command makepostscriptout
     1372            -label "Make PostScript" -command "MakePostscriptOut $graph(exclbox)"
    13611373    $graph(exclmenu).file.menu add command \
    13621374            -label Finish -command "CheckChanges $startchanges;destroy $graph(exclbox)"
     
    13821394    foreach var {excl obs} lbl {Excluded Observed} {
    13831395        $graph(exclmenu).options.menu.sym add command -label $lbl \
    1384                 -command "getsymopts $var"
     1396                -command "GetSymbolOpts $var $graph(exclbox)"
    13851397    }
    13861398
     
    14121424            -variable graph(exclPrompt)
    14131425    $graph(exclmenu).options.menu add command -label "Set PS output" \
    1414             -command setpostscriptout
     1426            -command "SetPostscriptOut $graph(exclbox)"
    14151427    # phase options
    14161428    set box $graph(plot)
     
    14241436                -command "minioptionsbox $num"
    14251437    }
    1426     bind $win <Key-Up> "ScanZoom $box %K .1"
    1427     bind $win <Key-Left> "ScanZoom $box %K .1"
    1428     bind $win <Key-Right> "ScanZoom $box %K .1"
    1429     bind $win <Key-Down> "ScanZoom $box %K .1"
     1438    bind $win <Key-Up> "ScanZoom $box %K 0.1"
     1439    bind $win <Key-Left> "ScanZoom $box %K 0.1"
     1440    bind $win <Key-Right> "ScanZoom $box %K 0.1"
     1441    bind $win <Key-Down> "ScanZoom $box %K 0.1"
    14301442    bind $win <Control-Key-Up> "ScanZoom $box %K 1.0"
    14311443    bind $win <Control-Key-Left> "ScanZoom $box %K 1.0"
     
    15351547        set cycle [getcycle];readdata .g
    15361548    }
    1537     bind $graph(exclbox) <Key-z> {BLTmanualZoom}
    1538     bind $graph(exclbox) <Key-Z> {BLTmanualZoom}
     1549    bind $graph(exclbox) <Key-z> {BLTplotManualZoom}
     1550    bind $graph(exclbox) <Key-Z> {BLTplotManualZoom}
    15391551    updateplot
    15401552    trace variable peakinfo w plotExclData
     
    15611573
    15621574proc SetDummyRangeBox {hst tmin tmax tstep} {
    1563     global newhist expmap
     1575    global newhist expmap graph
    15641576    if {[histinfo $hst dtype] != "CONST"} {
    1565         MyMessageBox -parent $np -title  "Change Range Error" \
     1577        MyMessageBox -parent $graph(exclbox) -title  "Change Range Error" \
    15661578                -message "This histogram (#$hst) does not have constant steps. The range must be changed in EXPEDT." \
    15671579                -icon error -type ok -default ok \
     
    15691581        return
    15701582    }
    1571     catch {toplevel [set np ".dummy"]}
     1583    catch {toplevel [set np "$graph(exclbox).dummy"]}
    15721584    wm title $np "Dummy Histogram Range"
    15731585    eval destroy [winfo children $np]
     
    17651777        histinfo $hst dstep   set [expr {$newhist(tstep)*1000.}]
    17661778        histinfo $hst dmin set [tod $newhist(tmin) $hst]
     1779        RecordMacroEntry "histinfo $hst excl set [list $exclist]" 0
     1780        RecordMacroEntry "histinfo $hst dpoints set $pnts" 0
     1781        RecordMacroEntry "histinfo $hst dstart  set [expr {$newhist(tmin)*1000.}]" 0
     1782        RecordMacroEntry "histinfo $hst dstep   set [expr {$newhist(tstep)*1000.}]" 0
     1783        RecordMacroEntry "histinfo $hst dmin set [tod $newhist(tmin) $hst]" 0
    17671784    } elseif {[string range $expmap(htype_$hst) 2 2] == "C"} {
    17681785        lappend exclist "0 [expr {$newhist(tmin)-$newhist(tstep)}]" \
     
    17731790        histinfo $hst dstep   set [expr {$newhist(tstep)*100.}]
    17741791        histinfo $hst dmin set [tod $newhist(tmax) $hst]
     1792        RecordMacroEntry "histinfo $hst excl set [list $exclist]" 0
     1793        RecordMacroEntry "histinfo $hst dpoints set $pnts" 0
     1794        RecordMacroEntry "histinfo $hst dstart  set [expr {$newhist(tmin)*100.}]" 0
     1795        RecordMacroEntry "histinfo $hst dstep   set [expr {$newhist(tstep)*100.}]" 0
     1796        RecordMacroEntry "histinfo $hst dmin set [tod $newhist(tmin) $hst]" 0
    17751797    } else {
    17761798        lappend exclist "0 [expr {$newhist(tmin)-$newhist(tstep)}]" \
     
    17811803        histinfo $hst dstep   set $newhist(tstep)
    17821804        histinfo $hst dmin set [tod $newhist(tmax) $hst]
     1805        RecordMacroEntry "histinfo $hst excl set [list $exclist]" 0
     1806        RecordMacroEntry "histinfo $hst dpoints set $pnts" 0
     1807        RecordMacroEntry "histinfo $hst dstart  set $newhist(tmin)" 0
     1808        RecordMacroEntry "histinfo $hst dstep   set $newhist(tstep)" 0
     1809        RecordMacroEntry "histinfo $hst dmin set [tod $newhist(tmin) $hst]" 0
    17831810    }
    17841811    global expgui
    17851812    incr expgui(changed) 5
     1813    RecordMacroEntry "incr expgui(changed)" 0
    17861814    destroy $np
    17871815    updateplot
     
    17891817
    17901818# set the minimum tof/d-space using the EXPEDT program
    1791 proc SetTminTOF {tmin parent} {
    1792     global expgui reflns graph tcl_platform
    1793     set hst $graph(hst)
     1819proc SetTminTOF {tmin hst parent} {
     1820    global expgui
     1821
     1822    set errmsg [runSetTminTOF $tmin $hst]
     1823    # save call to Macro file
     1824    RecordMacroEntry "runSetTminTOF $tmin $hst" 0
     1825    RecordMacroEntry "incr expgui(changed)" 0
     1826
     1827    if {$expgui(showexptool) || $errmsg != ""} {
     1828        if {$errmsg != ""} {
     1829            set err 1
     1830            append errmsg "\n" $expgui(exptoolout)
     1831        } else {
     1832            set err 0
     1833            set errmsg $expgui(exptoolout)
     1834        }
     1835        set msg "Please review the result from listing the phase."
     1836        if {$errmsg != ""} {append msg "\nIt appears an error occurred!"}
     1837        ShowBigMessage $parent.msg $msg $errmsg OK "" $err
     1838    }
     1839}
     1840proc runSetTminTOF {tmin hst} {
     1841    global expgui tcl_platform
    17941842    set input [open excl$hst.inp w]
    17951843    puts $input "Y"
     
    18131861        }
    18141862    } errmsg]
     1863    set fp [open excl$hst.out r]
     1864    set expgui(exptoolout) [read $fp]
     1865    close $fp
    18151866    loadexp $expgui(expfile)
    1816     catch {file delete excl$hst.inp}
    1817     if {$expgui(showexptool) || $err} {
    1818         set fp [open excl$hst.out r]
    1819         set out [read $fp]
    1820         close $fp
    1821         if {$errmsg != ""} {
    1822             append errmsg "\n" $out
    1823         } else {
    1824             set errmsg $out
    1825         }
    1826         set msg "Please review the result from changing the TOF minimum."
    1827         if {$err} {append msg "\nIt appears an error occurred!"}
    1828         ShowBigMessage $parent.msg $msg $errmsg OK "" $err
    1829     }
    1830 }
     1867    catch {file delete excl$hst.inp excl$hst.out}
     1868    if {$err} {
     1869        return $errmsg
     1870    } else {
     1871        return ""
     1872    }
     1873}
Note: See TracChangeset for help on using the changeset viewer.