Ignore:
Timestamp:
Oct 26, 2009 11:20:33 AM (15 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/xyprint.tcl

    r1592 r1593  
    1313package require BLT
    1414
    15 #option add *XyResult.width 3i widgetDefault
    16 #option add *XyResult.height 3i widgetDefault
    17 option add *XyResult.gridColor #d9d9d9 widgetDefault
     15#option add *XyPrint.width 3i widgetDefault
     16#option add *XyPrint.height 3i widgetDefault
     17option add *XyPrint.gridColor #d9d9d9 widgetDefault
    1818option add *XyPrint.activeColor blue widgetDefault
    1919option add *XyPrint.dimColor gray widgetDefault
     
    4646    private method CloneGraph { orig }
    4747
    48     private method BuildGraphTab {}
     48    private method BuildGeneralTab {}
    4949    private method BuildLayoutTab {}
    5050    private method BuildLegendTab {}
     
    6060    private method Inches2Pixels { inches }
    6161
    62     private method BuildLayoutTab {}
    63     private method BuildGeneralTab {}
    64     private method ApplyLegendSettings {}
    65     private method BuildLegendTab {}
    66     private method BuildAxisTab {}
    67 
    6862    private method ApplyGeneralSettings {}
    6963    private method ApplyLegendSettings {}
     
    7367    private method InitializeSettings {}
    7468    private method RestoreSettings { file }
     69    private method ResetSettings { }
    7570    private method SaveSettings { file }
     71    private method GetOutput {}
    7672    private method Done { state }
    7773    private method DestroySettings {}
     
    132128    blt::table configure $itk_interior r1 -resize both
    133129
    134     BuildGraphTab
     130    BuildGeneralTab
    135131    BuildAxisTab
    136132    BuildLegendTab
     
    142138# DESTRUCTOR
    143139# ----------------------------------------------------------------------
    144 itcl::body Rappture::XyResult::destructor {} {
     140itcl::body Rappture::XyPrint::destructor {} {
    145141    destroy $_clone
    146142    image delete $_preview
     
    148144}
    149145
    150 itcl::body Rappture::XyResult::DestroySettings {} {
     146itcl::body Rappture::XyPrint::DestroySettings {} {
    151147    destroy $_clone
    152148    array unset _settings $this-*
     
    167163    set _wait($this) 0
    168164    tkwait variable [itcl::scope _wait($this)]
    169     if { _wait($this) } {
    170         return [GetOutput]
    171     }
    172     SaveSettings
    173     # DestroySettings
    174     return ""
     165    set output ""
     166    if { $_wait($this) } {
     167        set output [GetOutput]
     168    }
     169    SaveSettings dummy
     170    DestroySettings
     171    return $output
    175172}
    176173
     
    228225        return ""
    229226    }
    230     set f [open "junk.$format" "w"]
    231     fconfigure $f -translation binary -encoding binary
    232     puts -nonewline $f $output
    233     close $f
     227    if 0 {
     228        set f [open "junk.$format" "w"]
     229        fconfigure $f -translation binary -encoding binary
     230        puts -nonewline $f $output
     231        close $f
     232    }
    234233    return [list .$format $output]
    235234}
     
    344343    # Create markers representing lines at zero for the x and y axis.
    345344    $_clone marker create line -name x-zero \
    346         -coords "0 -Inf 0 Inf" -dashes dot -hide yes
     345        -coords "0 -Inf 0 Inf" -dashes 1 -hide yes
    347346    $_clone marker create line -name y-zero \
    348         -coords "-Inf 0 Inf 0" -dashes dot -hide yes
     347        -coords "-Inf 0 Inf 0" -dashes 1 -hide yes
    349348}
    350349
     
    391390    set w [Inches2Pixels $_settings($this-layout-width)]
    392391    set h [Inches2Pixels $_settings($this-layout-height)]
    393 puts stderr "w=$w h=$h"
    394392    set pixelsPerInch [winfo pixels . 1i]
    395393    set sx [expr 2.5*$pixelsPerInch/$w]
    396394    set sy [expr 2.0*$pixelsPerInch/$h]
    397 puts stderr "sx=$sx sy=$sy"
    398395    set s [expr min($sx,$sy)]
    399396    $_clone snap $img -width $w -height $h
     
    615612
    616613    label $page.slider_l -text "legend\nentry"  -font "Arial 10" -justify right
    617     set names [$_clone element show]
    618614    itk_component add element_slider {
    619         ::scale $page.slider -from 1 -to [llength $names] \
     615        ::scale $page.slider -from 1 -to 1 \
    620616            -orient horizontal -width 12 \
    621617            -command [itcl::code $this GetElement]
    622618    }
    623     if { [llength $names] < 2 } {
    624         $page.slider configure -state disabled
    625         $page.slider_l configure -state disabled
    626     }
    627619    checkbutton $page.hide -text "hide" \
    628620        -font "Arial 10"  \
     
    715707        Rappture::Combobox $page.axis -width 20 -editable no
    716708    }
    717     set names [lsort [$_clone axis names]]
    718     foreach axis $names {
    719         if { ![$_clone axis cget $axis -hide] } {
    720             $itk_component(axis_combo) choices insert end $axis $axis
    721         }
    722     }
    723709    bind $itk_component(axis_combo) <<Value>> [itcl::code $this GetAxis]
    724710
     
    756742    label $page.plotpadx_l -text "pad x-axis" 
    757743    entry $page.plotpadx -width 6 \
    758         -textvariable [itcl::scope _settings($this-axis-plotpadx)]
     744        -textvariable [itcl::scope _settings($this-graph-plotpadx)]
    759745    bind  $page.plotpadx <KeyPress-Return> [itcl::code $this ApplyAxisSettings]
    760746
    761747    label $page.plotpady_l -text "pad y-axis"
    762748    entry $page.plotpady -width 6 \
    763         -textvariable [itcl::scope _settings($this-axis-plotpady)]
     749        -textvariable [itcl::scope _settings($this-graph-plotpady)]
    764750    bind  $page.plotpady <KeyPress-Return> [itcl::code $this ApplyAxisSettings]
    765751
     
    812798
    813799itcl::body Rappture::XyPrint::ApplyAxisSettings {} {
    814     set plotpadx [Inches2Pixels $_settings($this-axis-plotpadx)]
    815     set plotpady [Inches2Pixels $_settings($this-axis-plotpady)]
     800    set plotpadx [Inches2Pixels $_settings($this-graph-plotpadx)]
     801    set plotpady [Inches2Pixels $_settings($this-graph-plotpady)]
    816802    SetOption plotpadx
    817803    SetOption plotpady
     
    827813    }
    828814    $_clone marker configure ${type}-zero -hide $_settings($this-axis-zero)
    829     puts stderr "$axis: [$_clone axis configure $axis]"
    830815    GetAxis
    831816    RegeneratePreview
     
    889874    set names [$_clone element show]
    890875    $itk_component(element_slider) configure -from 1 -to [llength $names]
    891     if { [llength $names] < 2 } {
    892         $page.slider configure -state disabled
    893         $page.slider_l configure -state disabled
    894     }
     876    set state [expr  { ([llength $names] < 2) ? "disabled" : "normal" } ]
     877    $page.slider configure -state $state
     878    $page.slider_l configure -state $state
    895879    # Always initialize the slider to the first entry in the element list.
    896880    $itk_component(element_slider) set 1
     
    923907    blt::table configure $page r* -resize none
    924908    blt::table configure $page r9 -resize both
    925     set _settings($this-axis-plotpadx) [Pixels2Inches [$_clone cget -plotpadx]]
    926     set _settings($this-axis-plotpady) [Pixels2Inches [$_clone cget -plotpady]]
     909    set _settings($this-graph-plotpadx) [Pixels2Inches [$_clone cget -plotpadx]]
     910    set _settings($this-graph-plotpady) [Pixels2Inches [$_clone cget -plotpady]]
    927911    GetAxis
    928912}
     
    933917n}
    934918
    935 itcl::body Rappture::XyPrint::ResetSettings { file } {
     919itcl::body Rappture::XyPrint::ResetSettings {} {
    936920    # Revert the widget back to the original graph's settings
    937921    destroy $_clone
     
    984968   
    985969    foreach axis [$_clone axis names] {
     970        if { [$_clone axis cget $axis -hide] } {
     971            continue
     972        }
    986973        append out "if \{ \[\$graph axis names \"$axis\"\] == \"$axis\" \} \{\n"
    987974        set cmd {}
    988975        lappend cmd {$graph} "axis" "configure" $axis
    989         foreach opt {-hide -min -max -dashes -title -stepsize -subdivisions} {
     976        foreach opt {-hide -min -max -title -stepsize -loose -subdivisions} {
    990977            lappend cmd $opt [$_clone axis cget $axis $opt]
    991978        }
    992979        append out "$cmd\n"
    993         append out "\}\n"
    994980        set hide [$_clone marker cget ${axis}-zero -hide]
    995981        append out "\$graph marker configure ${axis}-zero -hide $hide\n"
     982        append out "\}\n"
    996983    }   
    997984    set cmd {}
     
    1003990    append out "\}\n"
    1004991    # Write the settings out
    1005     puts stderr $out
    1006 }
     992    puts stderr "savesettings=$out"
     993}
Note: See TracChangeset for help on using the changeset viewer.