source: trunk/liveplot @ 75

Last change on this file since 75 was 75, checked in by toby, 11 years ago

# on 1999/04/05 18:14:24, toby did:
fix BLT element -show/-hide option
add timing debug option

  • Property rcs:author set to toby
  • Property rcs:date set to 1999/04/05 18:14:24
  • Property rcs:lines set to +22 -7
  • Property rcs:rev set to 1.6
  • Property rcs:state set to Exp
  • Property svn:keywords set to Author Date Revision Id
File size: 20.6 KB
Line 
1#!/usr/local/bin/wish
2set Revision {$Revision: 75 $ $Date: 2009-12-04 22:59:59 +0000 (Fri, 04 Dec 2009) $}
3
4bind all <Control-KeyPress-c> {destroy .}
5# process command line arguments
6set exitstat 0
7set expnam [lindex $argv 0]
8if {$expnam == ""} {puts "error -- no experiment name"; set exitstat 1}
9if $exitstat {
10    puts "usage: $argv0 expnam \[hist #\] \[legend\]"
11    destroy .
12}
13if {[lindex $argv 1] == ""} {
14    set hst 1
15} else {
16    set hst [lindex $argv 1]
17}
18if {[lindex $argv 2] == ""} {
19    set graph(legend) 1
20} else {
21    set graph(legend) [lindex $argv 2]
22}
23
24
25if {$tcl_platform(platform) == "windows"} {
26    set graph(printout) 1
27    set expgui(tcldump) tcldump.exe
28} else {
29    set graph(printout) 0
30    set expgui(tcldump) tcldump
31}
32
33# default values
34set graph(outname) out.ps
35set graph(outcmd) lpr
36set xunits {}
37set yunits {}
38set graph(xunits) 0
39set graph(yunits) 0
40set expgui(debug) 0
41catch {if $env(DEBUG) {set expgui(debug) 1}}
42#set expgui(debug) 1
43
44if [catch {package require BLT} errmsg] {
45    tk_dialog .err "BLT Error" "Error -- Unable to load the BLT package" \
46            error 0 Quit
47    destroy .
48}
49# handle Tcl/Tk v8+ where BLT is in a namespace
50#  use the command so that it is loaded
51catch {blt::graph}
52catch {
53    namespace import blt::graph
54    namespace import blt::vector
55}
56# old versions of blt don't report a version number
57if [catch {set blt_version}] {set blt_version 0}
58# option for coloring markers: note that GH keeps changing how to do this!
59# also element -mapped => -show
60if {$blt_version < 2.3 || $blt_version >= 8.0} {
61    # version 8.0 is ~same as 2.3
62    set graph(MarkerColorOpt) -fg
63    # mapped is needed in 8.0, both are OK in 2.3
64    set graph(ElementShowOption) "-mapped 1"
65    set graph(ElementHideOption) "-mapped 0"
66} elseif {$blt_version >= 2.4} {
67    set graph(MarkerColorOpt) -outline
68    set graph(ElementShowOption) "-hide 0"
69    set graph(ElementHideOption) "-hide 1"
70} else {
71    set graph(MarkerColorOpt) -color
72    set graph(ElementShowOption) "-mapped 1"
73    set graph(ElementHideOption) "-mapped 0"
74}
75
76proc waitmsg {message} {
77    set w .wait
78    # kill any window/frame with this name
79    catch {destroy $w}
80    pack [frame $w]
81    frame $w.bot -relief raised -bd 1
82    pack $w.bot -side bottom -fill both
83    frame $w.top -relief raised -bd 1
84    pack $w.top -side top -fill both -expand 1
85    label $w.msg -justify left -text $message -wrap 3i
86    catch {$w.msg configure -font \
87                -Adobe-Times-Medium-R-Normal--*-180-*-*-*-*-*-*
88    }
89    pack $w.msg -in $w.top -side right -expand 1 -fill both -padx 3m -pady 3m
90    label $w.bitmap -bitmap info
91    pack $w.bitmap -in $w.top -side left -padx 3m -pady 3m
92    update
93}
94
95proc donewait {} {
96    catch {destroy .wait}
97    update
98}
99
100waitmsg "Loading histogram, Please wait"
101
102#--------------------------------------------------------------
103# define constants
104array set peakinfo {
105    color1 magenta
106    color2 cyan
107    color3 yellow
108    color4 sienna
109    color5 orange
110    color6 DarkViolet
111    color7 HotPink
112    color8 salmon
113    color9 LimeGreen
114}
115set cycle -1
116set modtime 0
117
118#----------------------------------------------------------------
119# where are we?
120set expgui(script) [info script]
121# translate links -- go six levels deep
122foreach i {1 2 3 4 5 6} {
123    if {[file type $expgui(script)] == "link"} {
124        set link [file readlink $expgui(script)]
125        if { [file  pathtype  $link] == "absolute" } {
126            set expgui(script) $link
127        } {
128            set expgui(script) [file dirname $expgui(script)]/$link
129        }
130    } else {
131        break
132    }
133}
134
135# fixup relative paths
136if {[file pathtype $expgui(script)] == "relative"} {
137    set expgui(script) [file join [pwd] $expgui(script)]
138}
139set expgui(scriptdir) [file dirname $expgui(script) ]
140set expgui(gsasdir) [file dirname $expgui(scriptdir)]
141set expgui(gsasexe) [file join $expgui(gsasdir) exe]
142
143proc readdata {box} {
144    global expgui
145    if [catch {
146        set loadtime [time {
147            if {$expgui(tcldump) == ""} {
148                readdata_hst $box
149            } else {
150                readdata_tcl $box
151            }
152        }]
153        if $expgui(debug) {
154            tk_dialog .time "Timing info" \
155                    "Histogram loading took $loadtime" "" 0 OK
156        }
157    } errmsg] {
158        if $expgui(debug) {
159            catch {console show}
160            error $errmsg
161        }
162        $box config -title "Read error: $errmsg"
163        puts "error message: $errmsg"
164        update
165    }
166}
167   
168proc readdata_hst {box} {
169    global expgui expnam reflns
170    global lasthst
171    global hst peakinfo xunits
172    $box config -title "(Histogram update in progress)"
173    update
174    # parse the output of a file
175        set lasthst $hst
176###########################################################################
177#       set input [open histdump.inp w]
178#       puts $input "$hst"
179#       close $input
180#       set input [open "| $expgui(gsasexe)/hstdump $expnam  < histdump.inp" w+]
181###########################################################################
182        # use histdump for right now
183        set input [open histdump$hst.inp w]
184        puts $input "$expnam"
185        puts $input "L"
186        puts $input "$hst"
187        puts $input "0"
188        close $input
189        # use hstdmp without an experiment name so that output
190        # is not sent to the .LST file
191        set input [open "| $expgui(gsasexe)/hstdmp < histdump$hst.inp" r]
192       
193        # initalize arrays
194        set num -1
195        set xlist {}
196        set obslist {}
197        set calclist {}
198        set bcklist {}
199        set xunits {}
200        # define a list of reflection positions for each phase
201        for {set i 1} {$i < 10} {incr i} {
202            set reflns($i) {}
203        }
204        set i 0
205        while {[gets $input line] >= 0} {
206            incr i
207            # run update every 50th line
208            if {$i > 50} {set i 0; update}
209            if [scan $line %d num] {
210                if {$num > 0} {
211                    set Ispec 0
212                    set X -999
213                    scan [string range $line 8 end] %e%e%e%e%e%e \
214                            X Iobs Icalc Ispec fixB fitB
215                    #puts $line
216                    # eliminate excluded points
217                    if {$Ispec > 0.0 && $X >= 0} {
218                        lappend xlist $X
219                        lappend obslist $Iobs
220                        lappend calclist $Icalc
221                        lappend bcklist [expr $fixB + $fitB]
222                    }
223                    # add peaks to peak lists
224                    #    puts "[string range $line 6 6]"
225                    # is this 6 or 7; 6 on win & 7 on SGI
226                    if [regexp {[1-9]} [string range $line 6 7] ph] {
227                        lappend reflns($ph) $X
228                    }
229                }
230            } else {
231                regexp {Time|Theta|keV} $line xunits
232            }
233        }
234        if {$xunits == "Theta"} {set xunits "2-Theta"}
235        close $input
236        catch {file delete histdump$hst.inp}
237        xvec set $xlist
238        obsvec set $obslist
239        calcvec set $calclist
240        bckvec set $bcklist
241        diffvec set [obsvec - calcvec]
242        global obsvec calcvec diffvec
243        set maxdiff  [set diffvec(max)]
244        set ymin1 [expr [set calcvec(min)] - 1.1*$maxdiff]
245        set ymin2 [expr [set obsvec(min)] - 1.1*$maxdiff]
246        if {$ymin1 < $ymin2} {
247            diffvec set [diffvec + $ymin1]
248        } {
249            diffvec set [diffvec + $ymin2]
250        }
251        plotdata $box
252}
253
254proc readdata_tcl {box} {
255    global expgui expnam reflns
256    global lasthst graph
257    global hst peakinfo xunits yunits
258    $box config -title "(Histogram update in progress)"
259    update
260    # parse the output of a file
261    set lasthst $hst
262    # use tcldump
263    set input [open histdump$hst.inp w]
264    puts $input "$hst"
265    # x units -- native
266    puts $input "$graph(xunits)"
267    # y units  -- native
268    puts $input "$graph(yunits)"
269    # format (if implemented someday)
270    puts $input "0"
271    close $input
272    # initalize arrays
273    set X {}
274    set OBS {}
275    set CALC {}
276    set BKG {}
277    set refpos {}
278    global refhkllist refphaselist
279    set refhkllist {}
280    set refphaselist {}
281    for {set i 1} {$i < 10} {incr i} {
282        set reflns($i) {}
283    }
284    eval [exec $expgui(tcldump) $expnam < histdump$hst.inp]
285    catch {file delete histdump$hst.inp}
286    if {$X == ""} {
287        $box config -title "(Error reading Histogram $hst)"
288        foreach elem [$box element show] {
289           eval $box element config $elem $graph(ElementHideOption)
290        }
291        return
292    }
293    foreach elem [$box element names] {
294        eval $box element config $elem $graph(ElementShowOption)
295    }
296    xvec set $X
297    obsvec set $OBS
298    calcvec set $CALC
299    bckvec set $BKG
300    refposvec set $refpos
301    diffvec set [obsvec - calcvec]
302    global obsvec calcvec diffvec
303    set maxdiff  [set diffvec(max)]
304    set ymin1 [expr [set calcvec(min)] - 1.1*$maxdiff]
305    set ymin2 [expr [set obsvec(min)] - 1.1*$maxdiff]
306    if {$ymin1 < $ymin2} {
307        diffvec set [diffvec + $ymin1]
308    } {
309        diffvec set [diffvec + $ymin2]
310    }
311    plotdata $box
312}
313
314proc lblhkl {plot x} {
315    global cellparm command blt_version refhkllist refphaselist peakinfo
316    # look for peaks within pixelregion pixels
317    set pixelregion 5
318    set xmin [$plot xaxis invtransform [expr $x - $pixelregion]]
319    set xmax [$plot xaxis invtransform [expr $x + $pixelregion]]
320    set peaknums [refposvec search $xmin $xmax]
321    set peaklist {}
322    set xcen 0
323    # select by displayed phases
324    set lbls 0
325#    puts ""
326    foreach peak $peaknums {
327#       puts "hkl [lindex $refhkllist $peak] phase [lindex $refphaselist $peak]"
328        if [set peakinfo(flag[lindex $refphaselist $peak])] {
329            set xcen [expr $xcen + [refposvec range $peak $peak]]
330            lappend peaklist [lindex $refhkllist $peak]
331            incr lbls
332        }
333    }
334    if {$peaklist == ""} return
335    set xcen [expr $xcen / $lbls]
336    # avoid bug in BLT 2.3 where Inf does not work for text markers
337    if {$blt_version == 2.3} {
338        set ycen [lindex [$plot yaxis limits] 1]
339    } else  {
340        set ycen Inf
341    }
342    set mark [$plot marker create text -coords "$xcen $ycen" \
343            -rotate 90 -text $peaklist -anchor n -bg ""]
344    after 10000 "$plot marker delete $mark"
345}
346
347proc plotdata {box} {
348    global expnam hst peakinfo xunits yunits cycle reflns modtime
349    global lasthst graph
350
351    # is there a new histogram to load?
352    if {$hst != $lasthst} {
353        xvec set {}
354        xvec notify now
355        set cycle -1
356        set modtime 0
357        $box config -title "Please wait: loading histogram $hst"
358        update
359        return
360    }
361    xvec notify now
362    obsvec notify now
363    calcvec notify now
364    bckvec notify now
365    diffvec notify now
366    $box config -title "$expnam cycle $cycle Hist $hst"
367    $box xaxis config -title $xunits
368    $box yaxis config -title $yunits
369    setlegend $box $graph(legend)
370    # now deal with peaks
371    set j 0
372    for {set i 1} {$i < 10} {incr i} {
373        if [set peakinfo(flag$i)] {
374            foreach X $reflns($i) {
375                incr j
376                catch {
377                    $box marker create line -name peaks${i}_$j
378                }
379                $box marker config peaks${i}_$j  -under 1 \
380                        -coords "$X $peakinfo(min$i) $X $peakinfo(max$i)"
381                $box marker config peaks${i}_$j \
382                        $graph(MarkerColorOpt) $peakinfo(color$i)
383                if $peakinfo(dashes$i) {
384                    catch {
385                        $box marker config peaks${i}_$j -dashes "5 5"
386                    }
387                }
388            }
389            # $box element config phase$i -mapped  1
390            catch {$box element create phase$i}
391            catch {
392                $box element config phase$i -color $peakinfo(color$i)
393            }
394        } else {
395            eval $box marker delete [$box marker names peaks${i}_*]
396            eval $box element delete [$box element names phase$i]
397        }
398    }
399    # force an update of the plot as BLT may not
400    $box config -title [$box cget -title]
401    update
402}
403
404proc setlegend {box legend} {
405    global blt_version
406    if {$blt_version >= 2.3 && $blt_version < 8.0} {
407        if $legend {
408            $box legend config -hide no
409        } else {
410            $box legend config -hide yes
411        }
412    } else {
413        if $legend {
414            $box legend config -mapped yes
415        } else {
416            $box legend config -mapped no
417        }
418    }
419}
420
421proc minioptionsbox {num} {
422    set bx .opt$num
423    catch {destroy $bx}
424    toplevel $bx
425    wm iconname $bx "Phase $num options"
426    wm title $bx "Phase $num options"
427
428    set i $num
429        pack [label $bx.0 -text "Phase $i reflns" ] -side top
430        pack [checkbutton $bx.1 -text "Show reflections" \
431                -variable peakinfo(flag$i)] -side top
432        pack [checkbutton $bx.2 -text "Use dashed line" \
433                -variable peakinfo(dashes$i)] -side top
434        pack [frame $bx.p$i -bd 2 -relief groove] -side top
435#       pack [checkbutton $bx.p$i.0 -text "Show phase $i reflns" \
436#               -variable peakinfo(flag$i)] -side left -anchor w
437        pack [label $bx.p$i.1 -text "  Y min:"] -side left
438        pack [entry $bx.p$i.2 -textvariable peakinfo(min$i) -width 5] \
439                -side left
440        pack [label $bx.p$i.3 -text "  Y max:"] -side left
441        pack [entry $bx.p$i.4 -textvariable peakinfo(max$i) -width 5] \
442                -side left
443        pack [frame $bx.c$i -bd 2 -relief groove] -side top
444
445        pack [label $bx.c$i.5 -text " color:"] -side left
446        pack [entry $bx.c$i.6 -textvariable peakinfo(color$i) -width 12] \
447                -side left
448        pack [button $bx.c$i.1 -text "Color menu" \
449                -command "setcolor $i"] -side left
450
451    pack [frame $bx.b] -side top
452    pack [button $bx.b.1 -command {plotdata $box} -text "Update Plot"] \
453            -side left
454    pack [button $bx.b.4 -command "destroy $bx" -text Close ] -side right
455}
456
457proc setcolor {num} {
458    global peakinfo
459    set color [tk_chooseColor -initialcolor $peakinfo(color$num) -title "Choose color"]
460    if {$color == ""} return
461    set peakinfo(color$num) $color
462}
463proc makepostscriptout {} {
464    global graph box
465    if !$graph(printout) {
466        set out [open "| $graph(outcmd) >& liveplot.msg" w]
467        catch {
468            puts $out [$box postscript output -landscape 1 \
469                -decorations no -height 7.i -width 9.5i]
470            close $out
471        } msg
472        catch {
473            set out [open liveplot.msg r]
474            if {$msg != ""} {append msg "\n"}
475            append msg [read $out]
476            close $out
477            catch {file delete liveplot.msg}
478        }
479        if {$msg != ""} {
480            tk_dialog .msg "file created" \
481                    "Postscript file processed with command \
482                    $graph(outcmd). Result: $msg" "" 0 OK
483        } else {
484            tk_dialog .msg "file created" \
485                    "Postscript file processed with command \
486                    $graph(outcmd)" "" 0 OK
487        }
488    } else {
489        $box postscript output $graph(outname) -landscape 1 \
490                -decorations no -height 7.i -width 9.5i   
491        tk_dialog .msg "file created" \
492                "Postscript file $graph(outname) created" "" 0 OK
493    }
494}
495
496proc setprintopt {page} {
497    global graph
498    if $graph(printout) {
499        $page.4.1 config -fg black
500        $page.4.2 config -fg black -state normal
501        $page.6.1 config -fg #888
502        $page.6.2 config -fg #888 -state disabled
503    } else {
504        $page.4.1 config -fg #888
505        $page.4.2 config -fg #888 -state disabled
506        $page.6.1 config -fg black
507        $page.6.2 config -fg black -state normal
508    }
509}
510
511proc setpostscriptout {} {
512    global graph tcl_platform
513    set box .out
514    catch {destroy $box}
515    toplevel $box
516    focus $box
517    pack [frame $box.4] -side top -anchor w -fill x
518    pack [checkbutton $box.4.a -text "Write PostScript files" \
519            -variable graph(printout) -offvalue 0 -onvalue 1 \
520            -command "setprintopt $box"] -side left -anchor w
521    pack [entry $box.4.2 -textvariable graph(outname)] -side right -anchor w
522    pack [label $box.4.1 -text "PostScript file name:"] -side right -anchor w
523    pack [frame $box.6] -side top -anchor w -fill x
524    pack [checkbutton $box.6.a -text "Print PostScript files" \
525            -variable graph(printout) -offvalue 1 -onvalue 0 \
526            -command "setprintopt $box" ] -side left -anchor w
527    pack [entry $box.6.2 -textvariable graph(outcmd)] -side right -anchor w
528    pack [label $box.6.1 -text "Command to print files:"] -side right -anchor w
529
530    pack [button $box.a -text "Close" -command "destroy $box"] -side top
531    if {$tcl_platform(platform) == "windows"} {
532        set graph(printout) 1
533        $box.4.a config -state disabled
534        $box.6.a config -fg #888 -state disabled
535    }
536    setprintopt $box
537}
538
539# save some of the global options in ~/.gsas_config
540proc SaveOptions {} {
541    global graph
542    set fp [open [file join ~ .gsas_config] a]
543    puts $fp "set graph(legend) $graph(legend)"
544    puts $fp "set graph(printout) $graph(printout)"
545    puts $fp "set graph(outname) $graph(outname)"
546    puts $fp "set graph(outcmd) $graph(outcmd)"
547    close $fp
548}
549
550proc aboutliveplot {} {
551    global Revision
552    tk_dialog .warn About "
553GSAS\n\
554A. C. Larson and\n R. B. Von Dreele,\n LANSCE, Los Alamos\n\n\
555LIVEPLOT\nB. Toby, NIST\nNot subject to copyright\n\n\
556$Revision\n\
557" {} 0 OK
558}
559
560proc getcycle {} {
561    global expnam
562    set cycle -1
563    catch {
564        set fp [open $expnam.EXP r]
565        set text [read $fp]
566        close $fp
567        regexp {GNLS  RUN.*Total cycles run *([0-9]*) } $text x cycle
568    }
569    return $cycle
570}
571
572proc updateifnew {} {
573    global cycle modtime expnam
574    if {[file mtime $expnam.EXP] != $modtime} {
575        set modtime [file mtime $expnam.EXP]
576        set newcycle [getcycle]
577        if {$newcycle != $cycle} {
578            set cycle $newcycle
579            # delay one second
580            # after 1000
581            readdata .g
582        }
583    }
584    # check every second
585#    after 10000 updateifnew
586    after 1000 updateifnew
587}
588
589# fetch EXP file processing routines
590source [file join $expgui(scriptdir) readexp.tcl]
591
592set fl [file join $expgui(scriptdir) icddcmd.tcl]
593if [file exists $fl] {source $fl}
594set fl [file join $expgui(scriptdir) cellgen.tcl]
595if [file exists $fl] {source $fl}
596
597# override options with locally defined values
598if [file exists [file join $expgui(scriptdir) localconfig]] {
599    source [file join $expgui(scriptdir) localconfig]
600}
601if [file exists [file join ~ .gsas_config]] {
602    source [file join ~ .gsas_config]
603}
604
605if [file executable [file join $expgui(gsasexe) $expgui(tcldump)]] {
606    set expgui(tcldump) [file join $expgui(gsasexe) $expgui(tcldump)]
607#    puts "got tcldump"
608} else {
609    set expgui(tcldump) {}
610#    puts "no tcldump"
611}
612
613# vectors
614vector xvec
615xvec notify never
616vector obsvec
617obsvec notify never
618vector calcvec
619calcvec notify never
620vector bckvec
621bckvec notify never
622vector diffvec
623diffvec notify never
624vector refposvec
625refposvec notify never
626# create the graph
627set box [graph .g]
628Blt_ZoomStack $box
629$box element create obs -color black -symbol scross -linewidth 0
630$box element create calc -color red  -symbol none 
631$box element create diff -color blue  -symbol none 
632$box element config obs -xdata xvec -ydata obsvec
633$box element config calc -xdata xvec -ydata calcvec
634$box element config diff -xdata xvec -ydata diffvec
635if {$expgui(tcldump) != ""} {
636    $box element create bckg -color green  -symbol none 
637    $box element config bckg -xdata xvec -ydata bckvec
638    bind $box <Shift-Button-1> "lblhkl %W %x"
639}
640$box yaxis config -title {}
641setlegend $box $graph(legend)
642# create a set of markers for each phase
643for {set i 1} {$i < 10} {incr i} {
644    set peakinfo(flag$i) 0
645    set peakinfo(max$i) Inf
646    set peakinfo(min$i) -Inf
647    set peakinfo(dashes$i) 1
648}
649
650updateifnew
651frame .a -bd 3 -relief groove
652pack [menubutton .a.file -text File -underline 0 -menu .a.file.menu] -side left
653menu .a.file.menu
654.a.file.menu add cascade -label "Histogram" -menu .a.file.menu.hist
655menu .a.file.menu.hist
656for {set num 1} {$num < 99} {incr num 10} {
657    .a.file.menu.hist add cascade -label "$num-[expr $num+9]" \
658            -menu .a.file.menu.hist.$num
659    menu .a.file.menu.hist.$num
660    for {set num1 $num} {$num1 < 10+$num} {incr num1} {
661        .a.file.menu.hist.$num add radiobutton -label $num1 -value $num1 \
662                -variable hst \
663                -command {set cycle [getcycle];readdata .g}
664    }
665}
666.a.file.menu add cascade -label Tickmarks -menu .a.file.menu.tick
667menu .a.file.menu.tick
668foreach num {1 2 3 4 5 6 7 8 9} {
669    .a.file.menu.tick add checkbutton -label "Phase $num" \
670            -variable  peakinfo(flag$num) \
671            -command {plotdata $box}
672}
673.a.file.menu add command -label "Update Plot" \
674        -command {set cycle [getcycle];readdata .g}
675.a.file.menu add command -label "Make PostScript" -command makepostscriptout
676.a.file.menu add command -label Quit -command "destroy ."
677
678pack [menubutton .a.options -text Options -underline 0 -menu .a.options.menu] \
679        -side left   
680menu .a.options.menu
681.a.options.menu add cascade -label "Configure Tickmarks" -menu .a.options.menu.tick
682menu .a.options.menu.tick
683foreach num {1 2 3 4 5 6 7 8 9} {
684    .a.options.menu.tick add command -label "Phase $num" \
685            -command "minioptionsbox $num"
686}
687if {$expgui(tcldump) != ""} {
688    .a.options.menu add cascade -label "X units" -menu .a.options.menu.xunits
689    menu .a.options.menu.xunits
690    .a.options.menu.xunits add radiobutton -label "As collected" \
691            -variable graph(xunits) -value 0 \
692            -command {set cycle [getcycle];readdata .g}
693    .a.options.menu.xunits add radiobutton -label "d-space" \
694            -variable graph(xunits) -value 1 \
695            -command {set cycle [getcycle];readdata .g}
696    .a.options.menu.xunits add radiobutton -label "Q" \
697            -variable graph(xunits) -value 2 \
698            -command {set cycle [getcycle];readdata .g}
699    .a.options.menu add cascade -label "Y units" -menu .a.options.menu.yunits
700    menu .a.options.menu.yunits
701    .a.options.menu.yunits add radiobutton -label "As collected" \
702            -variable graph(yunits) -value 0 \
703            -command {set cycle [getcycle];readdata .g}
704    .a.options.menu.yunits add radiobutton -label "Normalized" \
705            -variable graph(yunits) -value 1 \
706            -command {set cycle [getcycle];readdata .g}
707}
708   
709.a.options.menu add checkbutton -label "Include legend" \
710        -variable graph(legend) \
711        -command {setlegend $box $graph(legend)}
712.a.options.menu add command -label "Set PS output" -command setpostscriptout
713.a.options.menu add command -label "Save Options" -underline 1 \
714        -command "SaveOptions"
715
716pack [menubutton .a.help -text Help -underline 0 -menu .a.help.menu] -side right
717menu .a.help.menu -tearoff 0
718.a.help.menu add command -command aboutliveplot -label About
719
720pack .a -side top -fill both
721pack $box -fill both -expand yes
722donewait
Note: See TracBrowser for help on using the repository browser.