Changeset 426 for trunk/liveplot


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

# on 2001/09/04 22:53:53, toby did:
set colors/symbols
adjust fonts
cleanup save opts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/liveplot

    • Property rcs:date changed from 2001/09/04 22:09:40 to 2001/09/04 22:53:53
    • Property rcs:lines changed from +4 -0 to +107 -52
    • Property rcs:rev changed from 1.17 to 1.18
    r420 r426  
    4545set graph(yunits) 0
    4646set graph(autoraise) 1
     47set graph(color_diff) blue
     48set graph(color_chi2) magenta
     49set graph(color_bkg) green
     50set graph(color_calc) red
     51set graph(color_obs) black
     52set graph(color_input) magenta
     53set graph(color_fit) blue
    4754set expgui(debug) 0
    4855catch {if $env(DEBUG) {set expgui(debug) 1}}
    4956#set expgui(debug) 1
     57set expgui(font) 14
    5058set expgui(lblfontsize) 15
    5159set expgui(fadetime) 10
     
    5765set peakinfo(obssym) scross
    5866set peakinfo(obssize) 1.0
     67set peakinfo(inpsym) triangle
     68set peakinfo(inpsize) 1.0
    5969# create a set of markers for each phase
    6070for {set i 1} {$i < 10} {incr i} {
     
    299309        diffvec set [diffvec + $ymin2]
    300310    }
    301     plotdata $box
     311    plotdata
    302312}
    303313
     
    385395    }
    386396   
    387     plotdata $box
     397    plotdata
    388398}
    389399
     
    463473}
    464474
    465 proc plotdata {box} {
     475proc plotdata {} {
    466476    global expnam hst peakinfo xunits yunits cycle reflns modtime
    467     global lasthst graph expgui
     477    global lasthst graph expgui box
    468478
    469479    # is there a new histogram to load?
     
    477487        return
    478488    }
     489    $box config -title "$expnam cycle $cycle Hist $hst"
     490    $box xaxis config -title $xunits
     491    $box yaxis config -title $yunits
     492    setlegend $box $graph(legend)
     493    # reconfigure the data
     494    $box element configure 3 \
     495            -symbol $peakinfo(obssym) -color $graph(color_obs) \
     496            -pixels [expr 0.125 * $peakinfo(obssize)]i
     497    $box element config 0 -color $graph(color_chi2)
     498    $box element config 1 -color $graph(color_bkg)
     499    $box element config 2 -color $graph(color_calc)
     500    $box element config 4 -color $graph(color_diff)
     501    global program
     502    if {$program == "bkgedit"}  {
     503        $box element config 12 -color $graph(color_input) \
     504                -pixels [expr 0.125 * $peakinfo(inpsize)]i \
     505                -symbol $peakinfo(inpsym)
     506        $box element config 11 -color $graph(color_fit)
     507    }
    479508    xvec notify now
    480509    obsvec notify now
     
    483512    diffvec notify now
    484513    wifdvec notify now
    485     $box config -title "$expnam cycle $cycle Hist $hst"
    486     $box xaxis config -title $xunits
    487     $box yaxis config -title $yunits
    488     setlegend $box $graph(legend)
    489     # reconfigure the obs data
    490     $box element configure 3 \
    491             -symbol $peakinfo(obssym) \
    492             -pixels [expr 0.125 * $peakinfo(obssize)]i
    493514    # now deal with peaks
    494515    for {set i 1} {$i < 10} {incr i} {
     
    586607            -command "setcolor $i"] -side left
    587608    pack [frame $bx.b] -side top
    588     #pack [button $bx.b.1 -command {plotdata $box} -text "Update Plot"] \
     609    #pack [button $bx.b.1 -command plotdata -text "Update Plot"] \
    589610            #    -side left
    590611    pack [button $bx.b.4 -command "destroy $bx" -text Close ] -side right
     
    707728}
    708729
    709 proc setsymopts {} {
     730proc getsymopts {"sym obs"} {
    710731    global expgui peakinfo
    711732    set box .out
     
    713734    toplevel $box
    714735    focus $box
     736    wm title .out "set $sym symbol"
    715737    pack [frame $box.d] -side left -anchor n
    716738    pack [label $box.d.t -text "Symbol type"] -side top
    717     set expgui(obssym) $peakinfo(obssym)
    718     set expgui(obssize) $peakinfo(obssize)
    719     foreach symbol {square circle diamond plus cross \
     739    set expgui(sym) $peakinfo(${sym}sym)
     740    set expgui(size) $peakinfo(${sym}size)
     741    foreach symbol {square circle diamond triangle plus cross \
    720742            splus scross} \
    721             symbol_name {square circle diamond plus cross \
     743            symbol_name {square circle diamond triangle plus cross \
    722744            thin-plus thin-cross} {
    723745        pack [radiobutton $box.d.$symbol \
    724                 -text $symbol_name -variable expgui(obssym) \
     746                -text $symbol_name -variable expgui(sym) \
    725747                -value $symbol] -side top -anchor w
    726748    }
    727749    pack [frame $box.e] -side left -anchor n -fill y
    728750    pack [label $box.e.l -text "Symbol Size"] -side top
    729     pack [scale $box.e.s -variable expgui(obssize) \
     751    pack [scale $box.e.s -variable expgui(size) \
    730752            -from .1 -to 3 -resolution 0.05] -side top
    731753    pack [frame $box.a] -side bottom
    732     pack [button $box.a.1 -text "Apply" -command { \
    733             if {$peakinfo(obssym) != $expgui(obssym)} {set peakinfo(obssym) $expgui(obssym)}; \
    734             if {$peakinfo(obssize) != $expgui(obssize)} {set peakinfo(obssize) $expgui(obssize)} \
    735         } ] -side left
     754    pack [button $box.a.1 -text "Apply" -command "setsymopts $sym"] -side left
    736755    pack [button $box.a.2 -text "Close" -command "destroy $box"] -side left
     756}
     757proc setsymopts {sym} {
     758    global peakinfo expgui
     759    if {$peakinfo(${sym}sym) != $expgui(sym)} {set peakinfo(${sym}sym) $expgui(sym)}
     760    if {$peakinfo(${sym}size) != $expgui(size)} {set peakinfo(${sym}size) $expgui(size)}
    737761}
    738762
     
    741765    global graph expgui peakinfo
    742766    set fp [open [file join ~ .gsas_config] a]
    743     puts $fp "set graph(legend) $graph(legend)"
    744     puts $fp "set graph(chi2) $graph(chi2)"
    745     puts $fp "set graph(printout) $graph(printout)"
    746     puts $fp "set graph(outname) $graph(outname)"
    747     puts $fp "set graph(outcmd) $graph(outcmd)"
    748     puts $fp "set graph(autoraise) $graph(autoraise)"
    749     puts $fp "set expgui(lblfontsize) $expgui(lblfontsize)"
    750     puts $fp "set expgui(fadetime) $expgui(fadetime)"
    751     puts $fp "set expgui(hklbox) $expgui(hklbox)"
    752     puts $fp "set peakinfo(obssym) $peakinfo(obssym)"
    753     puts $fp "set peakinfo(obssize) $peakinfo(obssize)"
    754     puts $fp "set expgui(pixelregion) $expgui(pixelregion)"
    755     puts $fp "set expgui(autotick) $expgui(autotick)"
     767    foreach v {printout legend outname outcmd autoraise chi2} {
     768        puts $fp "set graph($v) $graph($v)"
     769    }
     770    foreach v {diff chi2 bkg calc obs input fit} {
     771        puts $fp "set graph(color_$v) $graph(color_$v)"
     772    }
     773    foreach v {font lblfontsize fadetime hklbox pixelregion autotick} {
     774        puts $fp "set expgui($v) $expgui($v)"
     775    }
     776    foreach v {obssym obssize inpsym inpsize} {
     777        puts $fp "set peakinfo($v) $peakinfo($v)"
     778    }
    756779    close $fp
    757780}
     
    834857    }
    835858    waitmsg {Updating}
    836     plotdata $box
     859    plotdata
    837860    donewaitmsg
    838861}
     
    13361359source [file join $expgui(scriptdir) gsascmds.tcl]
    13371360source [file join $expgui(scriptdir) readexp.tcl]
     1361source [file join $expgui(scriptdir) opts.tcl]
    13381362
    13391363# override options with locally defined values
     
    13441368    source [file join ~ .gsas_config]
    13451369}
     1370SetTkDefaultOptions $expgui(font)
    13461371
    13471372if [file executable [file join $expgui(gsasexe) $expgui(tcldump)]] {
     
    13601385# create the graph
    13611386if [catch {
    1362     set box [graph .g]
     1387    set box [graph .g -plotbackground white]
    13631388} errmsg] {
    13641389    tk_dialog .err "BLT Error" \
     
    13841409}
    13851410
    1386 $box element create 0 -xdata xvec -ydata wifdvec -color magenta \
     1411$box element create 0 -xdata xvec -ydata wifdvec -color $graph(color_chi2) \
    13871412        -line 3 -symbol none -label "Chi2" -mapy y2
    1388 $box element create 1 -label bckgr -color green  -symbol none 
    1389 $box element config 1 -xdata xvec -ydata bckvec
    1390 $box element create 3 -color black -linewidth 0 -label Obs \
     1413$box element create 1 -label bckgr -symbol none 
     1414$box element config 1 -xdata xvec -ydata bckvec -color $graph(color_bkg)
     1415$box element create 3 -color $graph(color_obs) -linewidth 0 -label Obs \
    13911416        -symbol $peakinfo(obssym) \
    13921417        -pixels [expr 0.125 * $peakinfo(obssize)]i
    1393 $box element create 2 -label Calc -color red -symbol none 
    1394 $box element create 4 -label diff -color blue -symbol none 
     1418$box element create 2 -label Calc -color $graph(color_calc) -symbol none 
     1419$box element create 4 -label diff -color $graph(color_diff) -symbol none 
    13951420
    13961421if {$program == "liveplot"} {
     
    14061431    $box element create 11
    14071432    $box element create 12
    1408     $box element configure 12  -color magenta  -pixels 12 \
    1409             -line 0 -symbol triangle -label "bkg pts"
    1410     $box element configure 11 -color blue \
     1433    $box element configure 12  -color $graph(color_input) \
     1434            -pixels [expr 0.125 * $peakinfo(inpsize)]i \
     1435            -line 0 -symbol $peakinfo(inpsym) -label "bkg pts"
     1436    $box element configure 11 -color $graph(color_fit) \
    14111437            -symbol none -label "Cheb fit" -dashes 5 -line 2
    14121438    $box element show "3 2 11 12"
     
    14421468    .a.file.menu.tick add checkbutton -label "Phase $num" \
    14431469            -variable  peakinfo(flag$num) \
    1444             -command {plotdata $box}
     1470            -command plotdata
    14451471}
    14461472.a.file.menu add cascade -label "Histogram" -menu .a.file.menu.hist
     
    14671493menu .a.options.menu.tick
    14681494.a.options.menu.tick add radiobutton -label "Manual Placement" \
    1469         -value 0 -variable expgui(autotick) -command "plotdata $box"
     1495        -value 0 -variable expgui(autotick) -command plotdata
    14701496.a.options.menu.tick add radiobutton -label "Auto locate" \
    1471         -value 1 -variable expgui(autotick) -command "plotdata $box"
     1497        -value 1 -variable expgui(autotick) -command plotdata
    14721498.a.options.menu.tick add separator
    14731499foreach num {1 2 3 4 5 6 7 8 9} {
     
    14751501            -command "minioptionsbox $num"
    14761502}
    1477 .a.options.menu add command -label "Obs symbol" -command setsymopts
     1503if {$program == "liveplot"} {
     1504    .a.options.menu add command -label "Obs symbol" -command getsymopts
     1505} else {
     1506    .a.options.menu add cascade -label "Symbol Type" -menu .a.options.menu.sym
     1507    menu .a.options.menu.sym
     1508    foreach var {obs inp} lbl {Observed "Input bkg"} {
     1509        .a.options.menu.sym add command -label $lbl -command "getsymopts $var"
     1510    }
     1511}
     1512.a.options.menu add cascade -label "Symbol color" -menu .a.options.menu.color
     1513menu .a.options.menu.color
     1514set l1 {obs calc diff bkg chi2}
     1515set l2 {Observed Calculated Obs-Calc Background Cumulative-Chi2}
     1516if {$program != "liveplot"} {
     1517    lappend l1 input fit
     1518    lappend l2 "Input points" "Cheb. fit"
     1519}
     1520   
     1521foreach var $l1 lbl $l2 {
     1522    .a.options.menu.color add command -label $lbl \
     1523        -command "set graph(color_$var) \[tk_chooseColor -initialcolor \$graph(color_$var) -title \"Choose \$lbl color\"]; plotdata"
     1524}
    14781525if {$expgui(tcldump) != "" && $program == "liveplot"} {
    14791526    .a.options.menu add cascade -label "X units" -menu .a.options.menu.xunits
     
    15081555        -command {setlegend $box $graph(legend)}
    15091556.a.options.menu add command -label "Set PS output" -command setpostscriptout
     1557.a.options.menu add cascade -menu  .a.options.menu.font \
     1558        -label "Screen font"
     1559menu .a.options.menu.font
     1560foreach f {10 11 12 13 14 16 18 20 22} {
     1561    .a.options.menu.font add radiobutton \
     1562            -command {SetTkDefaultOptions $expgui(font); ResizeFont .} \
     1563        -label $f -value $f -variable expgui(font) -font "Helvetica -$f"
     1564}
    15101565if {$program == "liveplot"} {
    15111566    .a.options.menu add checkbutton -label "Raise on update" \
Note: See TracChangeset for help on using the changeset viewer.