Changeset 1636 for trunk


Ignore:
Timestamp:
Jan 11, 2010, 10:52:45 PM (15 years ago)
Author:
gah
Message:

fix to xyprint

Location:
trunk/gui/scripts
Files:
4 edited

Legend:

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

    r1588 r1636  
    179179# ----------------------------------------------------------------------
    180180itcl::body Rappture::Combobox::current {} {
    181     return [translate [$itk_component(entry) get]]
     181    set raw [$itk_component(entry) get]
     182    set value [translate $raw]
     183    if { $value != "" } {
     184        return $value
     185    }
     186    return $raw
    182187}
    183188
  • trunk/gui/scripts/nanovisviewer.tcl

    r1632 r1636  
    665665            # here?
    666666            continue
     667        }
     668        if { ![info exists _vol2style($vol)] } {
     669            puts stderr "unknown volume $vol"
     670            continue;                   # How does this happen?
    667671        }
    668672        set tf $_vol2style($vol)
  • trunk/gui/scripts/xylegend.tcl

    r1342 r1636  
    293293    }
    294294    foreach node $nodes {
    295         set node [$itk_component(legend) index $node]
    296295        set elem [$tree_ label $node]
    297296        if { ![$graph_ element exists $elem] } {
  • trunk/gui/scripts/xyprint.tcl

    r1622 r1636  
    2323option add *XyPrint*Entry*background "white" widgetDefault
    2424
    25 array set Rappture::axistypes {
    26     x x
    27     y y
    28     x2 x
    29     y2 y
    30 }
    31 
    3225itcl::class Rappture::XyPrint {
    3326    inherit itk::Widget
     
    4134    private variable _savedSettings;    # Array of settings.
    4235
    43     private common _settingsFile "~/.rpsettings"
     36    private common _oldSettingsFile "~/.rpsettings"
     37    private common _settingsFile "~/.rp_settings"
    4438
    4539    public method print { graph toolName plotName }
     
    6256    private method InitClone {}
    6357    private method Pixels2Inches { pixels }
    64     private method Inches2Pixels { inches }
     58    private method Inches2Pixels { inches {defValue ""}}
    6559    private method Color2RGB { color }
    6660
     
    7872    private method GetOutput {}
    7973    private method Done { state }
     74    private method SetLayoutOption { option }
     75    private method GetAxisType { axis }
    8076    private method restore { toolName plotName data }
    8177    private common _settings
     
    286282itcl::body Rappture::XyPrint::CloneGraph { orig } {
    287283    set top $itk_interior
     284    if { [winfo exists $top.graph] } {
     285        destroy $top.graph
     286    }
    288287    set clone [blt::graph $top.graph]
    289288    CopyOptions "configure" $orig $clone
     
    399398        puts stderr "$err: $errorInfo"
    400399        set _settings($this-graph-$opt) $old
     400        $_clone configure -$opt $old
    401401    }
    402402}
     
    411411        puts stderr "$err: $errorInfo"
    412412        set _settings($this-$comp-$opt) $old
     413        $_clone $comp configure -$opt $old
    413414    }
    414415}
     
    423424        puts stderr "$err: $errorInfo"
    424425        set _settings($this-$comp-$opt) $old
     426        $_clone $comp configure $name -$opt $old
    425427    }
    426428}
     
    429431    update
    430432    set img [image create photo]
    431     set w [Inches2Pixels $_settings($this-layout-width)]
    432     set h [Inches2Pixels $_settings($this-layout-height)]
     433    set w [Inches2Pixels $_settings($this-layout-width) 3.4]
     434    set h [Inches2Pixels $_settings($this-layout-height) 3.4]
    433435    set pixelsPerInch [winfo pixels . 1i]
    434436    set sx [expr 2.5*$pixelsPerInch/$w]
     
    461463}
    462464
    463 itcl::body Rappture::XyPrint::Inches2Pixels { inches } {
     465itcl::body Rappture::XyPrint::Inches2Pixels { inches {defValue ""}} {
     466    set n [scan $inches %g dummy]
     467    if { n != 1  && $defValue != "" } {
     468        set inches $defValue
     469    }
    464470    return  [winfo pixels . ${inches}i]
    465471}
     
    474480}
    475481
     482itcl::body Rappture::XyPrint::GetAxisType { axis } {
     483    foreach type { x y x2 y2 } {
     484        set axes [$_clone ${type}axis use]
     485        if { [lsearch $axes $axis] >= 0 } {
     486            return [string range $type 0 0]
     487        }
     488    }
     489    return ""
     490}
    476491
    477492itcl::body Rappture::XyPrint::GetAxis {} {
     
    480495        set _settings($this-axis-$option) [$_clone axis cget $axis -$option]
    481496    }
    482     set type $Rappture::axistypes($axis)
     497    set type [GetAxisType $axis]
    483498    if { [$_clone grid cget -map${type}] == $axis } {
    484499        set _settings($this-axis-grid) 1
     
    493508itcl::body Rappture::XyPrint::GetElement { args } {
    494509    set index 1
     510    array unset _settings $this-element-*
    495511    foreach elem [$_clone element show] {
    496512        set _settings($this-element-$index) $elem
     
    10711087itcl::body Rappture::XyPrint::ApplyAxisSettings {} {
    10721088    set axis [$itk_component(axis_combo) current]
    1073     set type $Rappture::axistypes($axis)
     1089    set type [GetAxisType $axis]
    10741090    set page $itk_component(axis_page)
    10751091    if { $_settings($this-axis-grid) } {
     
    11111127}
    11121128
     1129itcl::body Rappture::XyPrint::SetLayoutOption { opt } {
     1130    set new [Inches2Pixels $_settings($this-layout-$opt)]
     1131    $_clone configure -$opt $new
     1132}
     1133
    11131134itcl::body Rappture::XyPrint::ApplyLayoutSettings {} {
    11141135    foreach opt { leftmargin rightmargin topmargin bottommargin } {
    1115         set new [Inches2Pixels $_settings($this-layout-$opt)]
    11161136        set old [$_clone cget -$opt]
    1117         set code [catch [list $_clone configure -$opt $new] err]
     1137        set code [catch { SetLayoutOption $opt } err]
    11181138        if { $code != 0 } {
    11191139            bell
     
    11211141            puts stderr "$err: $errorInfo"
    11221142            set _settings($this-layout-$opt) [Pixels2Inches $old]
     1143            $_clone configure -$opt [Pixels2Inches $old]
    11231144        }
    11241145    }
     
    11331154    set _settings($this-general-format) ps
    11341155    set _settings($this-general-style) ieee
    1135     set _settings($this-general-remember) 1
     1156    set _settings($this-general-remember) 0
    11361157    set page $itk_component(graph_page)
    11371158    $page.format value [$page.format label $_settings($this-general-format)]
     
    12221243    if { ![file readable $_settingsFile] } {
    12231244        return;                         # No file or not readable
     1245    }
     1246    if { [file exists $_oldSettingsFile] } {
     1247        file delete $_oldSettingsFile
    12241248    }
    12251249    # Read the file by sourcing it into a safe interpreter The only commands
     
    12711295        set plot [lindex $key 1]
    12721296        puts $f "xyprint \"$tool\" \"$plot\" \{"
    1273         puts $f "$_savedSettings($key)"
     1297        set settings [string trim $_savedSettings($key) \n]
     1298        puts $f "$settings"
    12741299        puts $f "\}\n"
    12751300    }
     
    12881313        array set info [font configure $font]
    12891314        foreach opt { -family -size -weight -slant } {
    1290             append out " $opt \"$info($opt)\""
     1315            set value [list $info($opt)]
     1316            append out " $opt $value"
    12911317        }
    12921318        append out "\n"
     
    12981324    foreach opt { -width -height -leftmargin -rightmargin -topmargin
    12991325        -bottommargin -plotpadx -plotpady } {
    1300         append out " $opt \"[$_clone cget $opt]\""
     1326        set value [list [$_clone cget $opt]]
     1327        append out " $opt $value"
    13011328    }
    13021329    append out "\n"
     
    13051332    append out "    preview legend configure"
    13061333    foreach opt { -position -anchor -borderwidth -hide } {
    1307         append out " $opt \"[$_clone legend cget $opt]\""
     1334        set value [list [$_clone legend cget $opt]]
     1335        append out " $opt $value"
    13081336    }
    13091337    append out " -font legend\n"
     
    13141342        append out "        preview element configure \"$elem\""
    13151343        foreach opt { -symbol -color -dashes -hide -label } {
    1316             append out " $opt \"[$_clone element cget $elem $opt]\""
     1344            set value [list [$_clone element cget $elem $opt]]
     1345            append out " $opt $value"
    13171346        }
    13181347        append out "    \}\n"
     
    13271356        append out "        preview axis configure \"$axis\""
    13281357        foreach opt { -hide -min -max -loose -title -stepsize -subdivisions } {
    1329             append out " $opt \"[$_clone axis cget $axis $opt]\""
     1358            set value [list [$_clone axis cget $axis $opt]]
     1359            append out " $opt $value"
    13301360        }
    13311361        append out " -tickfont \"$axis-ticks\""
     
    13421372    return $out
    13431373}
    1344 
Note: See TracChangeset for help on using the changeset viewer.