Changeset 1166 for trunk/liveplot


Ignore:
Timestamp:
Aug 17, 2011 6:17:04 PM (9 years ago)
Author:
toby
Message:

bring sandbox changes over to main release

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/liveplot

    r993 r1166  
    1414# process command line arguments
    1515set exitstat 0
    16 set expnam [lindex $argv 0]
     16set expnam [file root [lindex $argv 0]]
    1717if {$expnam == ""} {catch {puts "error -- no experiment name"}; set exitstat 1}
    1818if $exitstat {
     
    2020    exit
    2121}
    22 
     22# work in .EXP directory (in case files will be exported).
     23catch {
     24    cd [file dirname $expnam]
     25}
    2326# get name of script
    2427set expgui(script) [info script]
     
    4245    set graph(legend) [lindex $argv 2]
    4346}
     47set plot_title "(None)"
    4448
    4549set graph(backsub) 0
     
    7983set expgui(fadetime) 10
    8084set expgui(hklbox) 1
    81 set expgui(autotick) 0
     85set expgui(autotick) 1
    8286set expgui(phaselabel) 0
    8387set expgui(pixelregion) 5
     
    174178source [file join $expgui(scriptdir) readexp.tcl]
    175179source [file join $expgui(scriptdir) opts.tcl]
     180#----------------------------------------------------------------
     181# use EXPGUI directory for packages
     182lappend auto_path $expgui(scriptdir)
    176183
    177184if {$program == "bkgedit"}  {
     
    357364        catch {$vec variable $vec}
    358365    }
    359     set maxdiff  [set diffvec(max)]
    360     set cmin [set calcvec(min)]
    361     set omin [set obsvec(min)]
    362     set cmax [set calcvec(max)]
    363     set omax [set obsvec(max)]
    364     set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}]
    365     set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}]
    366     set ymin1 [expr {$cmin - 1.1*$maxdiff}]
    367     set ymin2 [expr {$omin - 1.1*$maxdiff}]
    368     if {$ymin1 < $ymin2} {
    369         diffvec set [diffvec + $ymin1]
    370     } {
    371         diffvec set [diffvec + $ymin2]
    372     }
     366    ApplyMag
    373367    plotdata
    374368}
     
    441435        wifdvec set $sumlist
    442436        wifdvec set [wifdvec / [wifdvec length]]
    443     }
    444     if {$graph(OmCoS)} {
     437    } elseif {$graph(OmCoS)} {
    445438        wifdvec set $WGT
    446439        wifdvec expr sqrt(wifdvec)
    447440        wifdvec set [wifdvec * diffvec]
     441    } else {
     442        wifdvec length 0
    448443    }
    449444    if $graph(backsub) {
     
    451446        calcvec set [calcvec - bckvec]
    452447    }
    453     global obsvec calcvec diffvec
    454     set maxdiff  [set diffvec(max)]
    455     set cmin [set calcvec(min)]
    456     set omin [set obsvec(min)]
    457     set cmax [set calcvec(max)]
    458     set omax [set obsvec(max)]
    459     set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}]
    460     set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}]
    461     set ymin1 [expr {$cmin - 1.1*$maxdiff}]
    462     set ymin2 [expr {$omin - 1.1*$maxdiff}]
    463     if {$ymin1 < $ymin2} {
    464         diffvec set [diffvec + $ymin1]
    465     } {
    466         diffvec set [diffvec + $ymin2]
    467     }
    468    
     448    ApplyMag
     449    plotdata
     450}
     451
     452proc SetTitle {} {
     453    set bx .title
     454    toplevel $bx
     455    wm title $bx "Edit plot title"
     456    wm iconname $bx "Edit plot title"
     457    grid [label $bx.txt -text "Enter plot title below"] -row 1 -column 1
     458    grid [entry $bx.title -width 70] -row 2 -column 1
     459    grid [frame $bx.a] -row 3 -column 1
     460    grid [button $bx.a.save -text "Save" \
     461              -command "set plot_title \"\[$bx.title get\]\"; destroy $bx" \
     462             ] -row 1 -column 1
     463    grid [button $bx.a.quit -text "Quit" \
     464              -command "destroy $bx" \
     465             ] -row 1 -column 2
     466    putontop $bx
     467    tkwait window $bx
     468    afterputontop
    469469    plotdata
    470470}
     
    572572    global expnam hst peakinfo xunits yunits cycle reflns modtime
    573573    global lasthst graph expgui box
     574    global obsvec calcvec diffvec
     575
     576    if {$graph(yunits) == 2} {
     577        set yunits {Intensity/sigma(I)}
     578        wifdvec set $::weightlist
     579        wifdvec expr sqrt(wifdvec)
     580        obsvec set [obsvec * wifdvec]
     581        calcvec set [calcvec * wifdvec]
     582        bckvec set {}
     583        diffvec set [obsvec - calcvec]
     584        wifdvec set {}
     585        $box element config 1 -label {} -line 0 -hide 1
     586    } else {
     587        $box element config 1 -label bckgr -line 1 -hide 0
     588    }
     589
     590    set cmin [set calcvec(min)]
     591    set omin [set obsvec(min)]
     592    set cmax [set calcvec(max)]
     593    set omax [set obsvec(max)]
     594    set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}]
     595    set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}]
    574596
    575597    foreach p $::expmap(phaselist) {
     
    592614        return
    593615    }
    594     $box config -title "$expnam cycle $cycle Hist $hst"
     616    if {$::plot_title == "(None)"} {
     617        $box config -title "$expnam cycle $cycle Hist $hst"
     618    } else {
     619        $box config -title $::plot_title
     620    }
    595621    $box xaxis config -title $xunits
    596622    $box yaxis config -title $yunits
     
    622648    calcvec notify now
    623649    bckvec notify now
    624     diffvec notify now
    625650    wifdvec notify now
    626651    # now deal with peaks
    627     for {set i 1} {$i < 10} {incr i} {
    628         if {$expgui(autotick)} {
    629             set div [expr {( $expgui(max) - $expgui(min) )/40.}]
    630             set ymin [expr {$expgui(min) - ($i+1) * $div}]
    631             set ymax [expr {$expgui(min) - $i * $div}]
    632         } else {
    633             set ymin $peakinfo(min$i)
    634             set ymax $peakinfo(max$i)
    635         }
    636         set j 0
    637         if [set peakinfo(flag$i)] {
    638             foreach X $reflns($i) {
    639                 incr j
    640                 catch {
    641                     $box marker create line -name peaks${i}_$j
    642                 }
    643                 $box marker config peaks${i}_$j  -under 1 \
    644                         -coords "$X $ymin $X $ymax"
    645                 catch {
    646                     $box marker config peaks${i}_$j \
    647                             $graph(MarkerColorOpt) [list $peakinfo(color$i)]
    648                     if {$peakinfo(dashes$i) && ! $expgui(autotick)} {
    649                         $box marker config peaks${i}_$j -dashes "5 5"
    650                     }
    651                 }
     652    #for {set i 1} {$i < 10} {incr i}
     653    set k 0
     654    set cmin $expgui(min)
     655    foreach i $::expmap(phaselist) {
     656        if {[set peakinfo(flag$i)]} {
     657            incr k
     658            if {$expgui(autotick)} {
     659                set div [expr {( $expgui(max) - $expgui(min) )/40.}]
     660                set ymin [expr {$expgui(min) - ($k+1) * $div}]
     661                set ymax [expr {$expgui(min) - $k * $div}]
     662                if {$cmin > $ymin} {set cmin $ymin}
     663            } else {
     664                set ymin $peakinfo(min$i)
     665                set ymax $peakinfo(max$i)
     666            }
     667            set j 0
     668            foreach X $reflns($i) {
     669                incr j
     670                catch {
     671                    $box marker create line -name peaks${i}_$j
     672                }
     673                $box marker config peaks${i}_$j  -under 1 \
     674                    -coords "$X $ymin $X $ymax"
     675                catch {
     676                    $box marker config peaks${i}_$j \
     677                        $graph(MarkerColorOpt) [list $peakinfo(color$i)]
     678                    if {$peakinfo(dashes$i) && ! $expgui(autotick)} {
     679                        $box marker config peaks${i}_$j -dashes "5 5"
     680                    }
     681                }
    652682            }
    653683            catch {$box element create phase$i}
    654684            catch {
    655685                $box element config phase$i -color $peakinfo(color$i) \
    656                         -label $graph(label$i)
     686                    -label $graph(label$i)
    657687            }
    658688        } else {
     
    661691        }
    662692    }
     693    # offset the difference pattern
     694    set maxdiff  [set diffvec(max)]
     695    if {$expgui(autotick)} {
     696        diffvec set [diffvec + [expr {$cmin - $maxdiff}]]
     697    } else {
     698        diffvec set [diffvec + [expr {$cmin - 1.1*$maxdiff}]]
     699    }
     700    diffvec notify now
     701
    663702    # force an update of the plot as BLT may not
    664703    $box config -title [$box cget -title]
     
    11221161        eval $box y2axis config $graph(ElementHideOption)
    11231162        $box element config 0 -label ""
     1163        # clear the vector
     1164        wifdvec set {}
     1165        wifdvec notify now
    11241166    }
    11251167}
     
    20462088setlegend $box $graph(legend)
    20472089
     2090set ps2pdfcmd {}
     2091set gnuplotpath {}
     2092# find gnuplot
     2093if {$::tcl_platform(platform) == "windows"} {
     2094    set gnuplotpath [file join $::expgui(gsasexe) "gnuplot/gnuplot.exe"]
     2095    if {![file exists $gnuplotpath]} {
     2096        set gnuplotpath [auto_execok gnuplot.exe]
     2097    }
     2098} else {
     2099    set ::env(PATH) "${::expgui(gsasexe)}:${::env(PATH)}"
     2100    auto_reset
     2101    set gnuplotpath [auto_execok gnuplot]
     2102}
     2103# find postscript conversion routine
     2104if {$::tcl_platform(platform) == "windows"} {
     2105    set gspath [file join $::expgui(gsasexe) "gs/bin/gswin32c.exe"]
     2106    if {![file exists $gspath]} {
     2107        set gspath [auto_execok gswin32c.exe]
     2108    }
     2109    if {[file exists $gspath]} {
     2110        set ps2pdfcmd "$gspath -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=\$pdfoutname -c save pop -f \$psoutname"
     2111    }
     2112} else {
     2113    # look for ghostscript
     2114    set gspath [auto_execok gs]
     2115    if {[file exists $gspath]} {
     2116        set ps2pdfcmd "$gspath -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=\$pdfoutname -c save pop -f \$psoutname"
     2117    } else {
     2118        set gspath [auto_execok pstopdf]; # this is on Mac only
     2119        if {[file exists $gspath]} {
     2120            set ps2pdfcmd "$gspath \$psoutname -o \$pdfoutname"
     2121        }
     2122    }
     2123}
     2124set gnuplotexport {}
     2125catch {
     2126    source [file join $expgui(scriptdir) gnuplot.tcl]
     2127}
     2128
     2129#======================================================================
     2130# make menus
    20482131frame .a -bd 3 -relief groove
    20492132pack [menubutton .a.file -text File -underline 0 -menu .a.file.menu] -side left
     
    20542137.a.file.menu add command -label "Update Plot" \
    20552138        -command {set cycle [getcycle];readdata .g}
     2139.a.file.menu add command -label "Set Plot Title" \
     2140        -command SetTitle
    20562141.a.file.menu add cascade -label "Export plot" -menu .a.file.menu.export
    20572142menu .a.file.menu.export
     
    20622147    .a.file.menu.export add command -label "to Grace" -command exportgrace
    20632148}
     2149if {$gnuplotpath == {}} {
     2150    .a.file.menu.export add cascade -label "gnuplot program not found"
     2151} elseif {$gnuplotexport == ""} {
     2152    .a.file.menu.export add cascade -label "file gnuplot.tcl not found"
     2153} elseif {$ps2pdfcmd == ""} {
     2154    .a.file.menu.export add cascade -label "gs or pstopdf program not found"
     2155} else {
     2156    .a.file.menu.export add command -label "to PDF" -command ExportPDF
     2157}
     2158
    20642159.a.file.menu add command -label Quit -command "destroy ."
    20652160.a.file.menu.export add command -label "as .csv file" \
     
    20892184.a.options.menu.tick add separator
    20902185
     2186pack [menubutton .a.mag -text Magnification -underline 0 -menu .a.mag.menu] \
     2187        -side left
     2188menu .a.mag.menu
     2189set maglist {}
     2190set mag0 1.0
     2191# display magnification routines
     2192proc ShowMag {} {
     2193    global blt_version tcl_platform peakinfo expgui
     2194    set bx .opt
     2195    catch {destroy $bx}
     2196    toplevel $bx
     2197    putontop $bx
     2198    wm iconname $bx "Mag Regs"
     2199    wm title $bx "Plot Magnification Regions"
     2200    pack [label $bx.0 -text "Magnification Regions:"] -side top
     2201    if {[llength $::maglist] == 0} {
     2202        set lbl "None"
     2203    } else {
     2204        set lbl ""
     2205        set xm $::xvec(min)
     2206        set ym $::mag0
     2207        set ::maglist [lsort -real -index 0 $::maglist]
     2208        foreach pair $::maglist {
     2209            foreach {xh ymh} $pair {}
     2210            append lbl "\tfrom $xm to $xh: times $ym\n"
     2211            set xm $xh
     2212            set ym $ymh
     2213        }
     2214        set xh $::xvec(max)
     2215        append lbl "\tfrom $xm to $xh: times $ym"
     2216    }
     2217    pack [label $bx.1 -text $lbl -justify left] -side top
     2218    pack [button $bx.2 -text "Close" -command "destroy $bx"] -side top
     2219    tkwait window $bx
     2220    afterputontop
     2221}
     2222
     2223# edit magnification regions
     2224proc EditMag {} {
     2225    set ::multrow 1
     2226    set bx .opt
     2227    catch {destroy $bx}
     2228    toplevel $bx
     2229    putontop $bx
     2230    wm iconname $bx "Mag Regs"
     2231    wm title $bx "Edit Magnification Regions"
     2232    pack [label $bx.0 -text "Vertical Magnification Regions:"] -side top
     2233    if {[llength $::maglist] == 0} {
     2234        set lbl "None"
     2235        pack [label $bx.1 -text $lbl -justify left] -side top
     2236        pack [button $bx.2 -text "Close" -command "destroy $bx"] -side top
     2237        tkwait window $bx
     2238        afterputontop
     2239        return
     2240    } else {
     2241        pack [frame $bx.1] -side top
     2242        set ::maglist [lsort -real -index 0 $::maglist]
     2243        set row 0
     2244        foreach pair $::maglist {
     2245            foreach {xh ymh} $pair {}
     2246            set row1 [expr {$row + 1}]
     2247            set ::xmag($row1) $xh
     2248            set ::mag($row1) $ymh
     2249            if {$row == 0} {
     2250                grid [label $bx.1.a$row -text "From "] -column 1 -row $row
     2251                grid [label $bx.1.b$row -text $::xvec(min)] -column 2 -row $row
     2252                grid [label $bx.1.c$row -text " to "] -column 3 -row $row
     2253                grid [entry $bx.1.d$row -textvariable xmag(1) -width 6] -column 4 -row $row
     2254                grid [label $bx.1.e$row -text " times "] -column 5 -row $row
     2255                grid [entry $bx.1.f$row -textvariable mag0 -width 4] -column 6 -row $row
     2256            } else {
     2257                grid [label $bx.1.a$row -text "From "] -column 1 -row $row
     2258                grid [entry $bx.1.b$row -textvariable xmag($row) -width 6] -column 2 -row $row
     2259                grid [label $bx.1.c$row -text " to "] -column 3 -row $row
     2260                grid [entry $bx.1.d$row -textvariable xmag($row1) -width 6] -column 4 -row $row
     2261                grid [label $bx.1.e$row -text " times "] -column 5 -row $row
     2262                grid [entry $bx.1.f$row -textvariable mag($row) -width 4] -column 6 -row $row
     2263            }
     2264            incr row
     2265        }
     2266        grid [label $bx.1.a$row -text "From "] -column 1 -row $row
     2267        grid [entry $bx.1.b$row -textvariable xmag($row) -width 6] -column 2 -row $row
     2268        grid [label $bx.1.c$row -text " to "] -column 3 -row $row
     2269        grid [label $bx.1.d$row -text $::xvec(max)] -column 4 -row $row
     2270        grid [label $bx.1.e$row -text " times "] -column 5 -row $row
     2271        grid [entry $bx.1.f$row -textvariable mag($row) -width 4] -column 6 -row $row
     2272        set ::multrow $row
     2273    }
     2274    pack [label $bx.l -text "\nSet the multiplier to zero to delete a region"] -side top
     2275    pack [frame $bx.2] -side top
     2276    pack [button $bx.2.a -text "Edit" -command "destroy $bx"] -side left
     2277    pack [button $bx.2.b -text "Cancel" -command "set multrow 0; destroy $bx"] -side left
     2278    tkwait window $bx
     2279    afterputontop
     2280    if {$::multrow == 0} return
     2281    set newmaglist {}
     2282    set xp $::xvec(min)
     2283    for {set i 1} {$i <= $::multrow} {incr i} {
     2284        if {$::mag($i) > 0} {
     2285            lappend newmaglist [list $::xmag($i) $::mag($i)]
     2286        }
     2287        set xp $::xmag($i)
     2288    }
     2289    set ::maglist $newmaglist
     2290    readdata .g
     2291}
     2292
     2293# show a menu to add a magnification region
     2294proc AddMag {} {
     2295    set bx .opt
     2296    catch {destroy $bx}
     2297    toplevel $bx
     2298    putontop $bx
     2299    wm iconname $bx "Add Regs"
     2300    wm title $bx "Add Plot Magnification Region"
     2301    pack [frame $bx.0] -side top
     2302    pack [label $bx.0.a -text "Magnify from "] -side left
     2303    pack [entry $bx.0.b -textvariable xmin -width 6] -side left
     2304    pack [label $bx.0.c -text " to next region. Multiply by "] -side left
     2305    pack [entry $bx.0.d -textvariable mult -width 4] -side left
     2306    pack [frame $bx.2] -side top
     2307    pack [button $bx.2.a -text "Add" -command "destroy $bx"] -side left
     2308    pack [button $bx.2.b -text "Cancel" -command "set mult {}; destroy $bx"] -side left
     2309    if {[catch {expr $::mult}]} {set ::mult 1.0}
     2310    if {$::mult <= 0} {set ::mult 1.0}
     2311    tkwait window $bx
     2312    afterputontop
     2313    catch {
     2314        if {$::xmin < $::xvec(min)} {set ::xmin $::xvec(min)}
     2315        if {$::xmin > $::xvec(max)} {set ::xmin $::xvec(max)}
     2316        if {$::mult > 0} {
     2317            lappend ::maglist [list $::xmin $::mult]
     2318            readdata .g
     2319        } else {
     2320            MyMessageBox -parent . -title "Invalid" \
     2321                -message "Invalid input, try again" \
     2322                -icon error -type Continue -default continue
     2323        }
     2324    }
     2325}
     2326proc AddCursorMag {p m} {
     2327    set x [.g xaxis invtransform $p]
     2328    if {$x < $::xvec(min) || $x > $::xvec(max) } {
     2329        bell
     2330        return
     2331    }
     2332    lappend ::maglist [list $x $m]
     2333    readdata .g
     2334}
     2335
     2336# scale the data with magnification regions
     2337proc ApplyMag {} {
     2338    foreach mrk [.g marker names mag*] {
     2339        .g marker delete $mrk
     2340    }
     2341    if {[llength $::maglist] == 0} return
     2342    global xvec
     2343    vector create ymult([xvec length])
     2344    set xl $xvec(min)
     2345    set ym $::mag0
     2346    set i 0
     2347    set ::maglist [lsort -real -index 0 $::maglist]
     2348    foreach pair $::maglist {
     2349        foreach {xh ymh} $pair {}
     2350        set xr [xvec search $xl $xh]
     2351        #puts "$xl $xh [lindex $xr 0]:[lindex $xr end] $ym"
     2352        if {[lindex $xr 0] != [lindex $xr end]} {
     2353            set ymult([lindex $xr 0]:[lindex $xr end]) $ym
     2354            if {$xl != $xvec(min)} {
     2355                .g marker create line -coords "$xl -Inf $xl Inf" -name mag[incr i]
     2356            }
     2357            .g marker create text -coords "$xl Inf" -name mag[incr i] -text "x$ym" -anchor w
     2358        }
     2359        set xl $xh
     2360        set ym $ymh
     2361    }
     2362    set xh $xvec(max)
     2363    set xr [xvec search $xl $xh]
     2364    set ymult([lindex $xr 0]:[lindex $xr end]) $ym
     2365    #puts "$xl $xh [lindex $xr 0]:[lindex $xr end] $ym"
     2366    .g marker create line -coords "$xl -Inf $xl Inf" -name mag[incr i]
     2367    .g marker create text -coords "$xl Inf" -name mag[incr i] -text "x$ym" -anchor w
     2368    foreach vec {obsvec calcvec bckvec diffvec} {
     2369        global $vec
     2370        $vec expr {$vec * ymult}
     2371    }
     2372}
     2373
     2374# create a PDF using GNUPLOT & GhostScript
     2375proc ExportPDF {} {
     2376    set msg {}
     2377    if {$::gnuplotpath == {}} {
     2378        append msg "\n\tThe gnuplot program was not found"
     2379    }
     2380    if {$::gnuplotexport == ""} {
     2381        append msg "\n\tfile gnuplot.tcl not found in $::expgui(scriptdir)"
     2382    }
     2383    if {$::ps2pdfcmd == ""} {
     2384        append msg "\n\tNo PDF conversion routine (ghostscript or pstopdf on Mac was found"
     2385    }
     2386    if {$msg != ""} {
     2387        MyMessageBox -parent . -title "Gnuplot/GS Error" \
     2388                -message $msg \
     2389                -icon error -type OK -default OK
     2390        return 0
     2391    }
     2392
     2393    set pdfoutname [tk_getSaveFile -title "Select output file" -parent . \
     2394                        -defaultextension ".pdf" \
     2395                        -initialdir [pwd] \
     2396                        -initialfile "[file rootname $::expnam].pdf"]
     2397    if { $pdfoutname == "" } { return }
     2398    cd [file dirname $pdfoutname]
     2399    set pdfoutname [regsub -all " " [file tail $pdfoutname] "_"]
     2400    set rootname [file root $pdfoutname]
     2401    set csvoutname "$rootname.csv"
     2402    set gplotname "$rootname.gplot"
     2403    set psoutname "$rootname.ps"
     2404    foreach filename [list $pdfoutname $csvoutname $gplotname $psoutname] {
     2405        catch {file -force delete $filename}
     2406    }
     2407    waitmsg "running gnuplot, Please wait"
     2408    Graph2Gnuplot .g $gplotname $psoutname $csvoutname
     2409    if {![file exists $gplotname]} {
     2410        set msg "\n  Output file for gnuplot not created! ($gplotname)"
     2411    }
     2412    if {![file exists $csvoutname]} {
     2413        append msg "\n   Output file for gnuplot not created! ($csvoutname)"
     2414    }
     2415    if {$msg == ""} {
     2416        if {[catch { exec $::gnuplotpath $gplotname } err]} {
     2417            if {[string first "Warning" $err] == -1} {
     2418                append msg "Error in running gnuplot: $err"
     2419            }
     2420        }
     2421        if {![file exists $psoutname]} {
     2422            append msg "\n   Output file from gnuplot not created! ($psoutname)"
     2423        }
     2424    }
     2425    if {$msg == ""} {
     2426        if {[catch { eval exec [subst $::ps2pdfcmd]} err]} {
     2427            append msg "Error in PDF conversion: $err"
     2428        }
     2429        if {![file exists $pdfoutname]} {
     2430            append msg "\n   PDF file not created! ($pdfoutname)"
     2431        }
     2432    }
     2433    donewaitmsg
     2434    if {$msg == ""} {
     2435        # clean up
     2436        foreach filename [list $csvoutname $gplotname $psoutname] {
     2437            catch {file -force delete $filename}
     2438        }
     2439        MyMessageBox -parent . -title "PDF created" \
     2440            -message "Success: PDF file created ($pdfoutname)" \
     2441            -type OK -default OK
     2442        return 1
     2443    } else {
     2444        # something failed
     2445        MyMessageBox -parent . -title "Gnuplot/GS Error" \
     2446                -message "Error: $msg" \
     2447                -icon error -type OK -default OK
     2448        return 0
     2449    }
     2450}
     2451
     2452# resize graph font only
     2453proc ResizeGraphFont {graph font} {
     2454    foreach w {legend xaxis yaxis xaxis yaxis \
     2455                   x2axis y2axis x2axis y2axis} \
     2456        o {-font -tickfont -tickfont -titlefont -titlefont \
     2457               -tickfont -tickfont -titlefont -titlefont} {
     2458                   catch {
     2459                       $graph $w configure $o $font
     2460                   }
     2461               }
     2462    catch {
     2463        set curfont [$graph cget -font]
     2464        if {[string tolower [lindex $curfont 0]] == "symbol"} {
     2465            $graph configure -font "Symbol [lrange $font 1 end]"
     2466        } else {
     2467            $graph configure -font $font
     2468        }
     2469    }
     2470}
     2471
    20912472if {$program == "liveplot"} {
     2473    .a.mag.menu add command -label "Add region" -command "AddMag"
     2474    .a.mag.menu add command -label "Edit Regions" -command "EditMag"
     2475    .a.mag.menu add separator
     2476    .a.mag.menu add command -label "Clear" \
     2477        -command "set maglist {}; readdata .g"
    20922478    .a.options.menu add command -label "Obs symbol" -command getsymopts
     2479    foreach i {1 2 3 4 5 6 7 8 9} {
     2480        bind . <Control-Key-$i> "AddCursorMag %x $i"
     2481    }
    20932482} else {
    20942483    .a.options.menu add cascade -label "Symbol Type" -menu .a.options.menu.sym
     
    21312520            -variable graph(yunits) -value 1 \
    21322521            -command {set cycle [getcycle];readdata .g}
     2522    .a.options.menu.yunits add radiobutton -label "I/Sigma(I)" \
     2523            -variable graph(yunits) -value 2 \
     2524            -command {set cycle [getcycle];readdata .g}
    21332525    .a.options.menu add command -label "HKL labeling" -command setlblopts
    21342526    .a.options.menu add checkbutton -label "Subtract background" \
     
    21552547}
    21562548if {$program == "liveplot"} {
     2549    .a.options.menu add cascade -menu  .a.options.menu.gfont \
     2550        -label "Graph font"
     2551    menu .a.options.menu.gfont
     2552    foreach f {12 14 16 18 20 22 24 26 28 32 36 40} {
     2553        .a.options.menu.gfont add radiobutton \
     2554            -command "ResizeGraphFont .g \[list Helvetica -$f\]" \
     2555            -label $f -font "Helvetica -$f"
     2556    }
    21572557    .a.options.menu add checkbutton -label "Raise on update" \
    21582558            -variable graph(autoraise)
     
    23142714expload $expnam.EXP
    23152715mapexp
    2316 
     2716if {$expgui(autotick)} {
     2717    foreach i $::expmap(phaselist) {
     2718        set peakinfo(flag$i) 1
     2719    }
     2720}
     2721       
    23172722# fill the histogram menu
    23182723if {[llength $expmap(powderlist)] > 15} {
Note: See TracChangeset for help on using the changeset viewer.