Ignore:
Timestamp:
Jun 5, 2015, 10:16:12 AM (9 years ago)
Author:
ldelgass
Message:

Merge r5657:5659 from trunk (whitespace/style)

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/gui/scripts/xyprint.tcl

    r4946 r5661  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*-
    2 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    32# ----------------------------------------------------------------------
    43#  COMPONENT: xyprint - Print X-Y plot.
     
    3029    destructor {}
    3130
    32     private variable _graph "";         # Original graph. 
     31    private variable _graph "";         # Original graph.
    3332    private variable _clone "";         # Cloned graph.
    3433    private variable _preview "";       # Preview image.
     
    4140    public method reset {}
    4241
    43     private method CopyOptions { cmd orig clone {exclude {}}} 
     42    private method CopyOptions { cmd orig clone {exclude {}}}
    4443    private method CloneGraph { orig }
    4544
     
    5352    private method GetAxis {}
    5453    private method GetElement { args }
    55     private method RegeneratePreview {} 
    56     private method InitClone {} 
    57     private method Pixels2Inches { pixels } 
    58     private method Inches2Pixels { inches {defValue ""}} 
    59     private method Color2RGB { color } 
    60 
    61     private method ApplyGeneralSettings {} 
    62     private method ApplyLegendSettings {} 
    63     private method ApplyAxisSettings {} 
    64     private method ApplyElementSettings {} 
    65     private method ApplyLayoutSettings {} 
    66     private method InitializeSettings {} 
    67     private method CreateSettings { toolName plotName } 
    68     private method RestoreSettings { toolName plotName } 
    69     private method SaveSettings { toolName plotName } 
     54    private method RegeneratePreview {}
     55    private method InitClone {}
     56    private method Pixels2Inches { pixels }
     57    private method Inches2Pixels { inches {defValue ""}}
     58    private method Color2RGB { color }
     59
     60    private method ApplyGeneralSettings {}
     61    private method ApplyLegendSettings {}
     62    private method ApplyAxisSettings {}
     63    private method ApplyElementSettings {}
     64    private method ApplyLayoutSettings {}
     65    private method InitializeSettings {}
     66    private method CreateSettings { toolName plotName }
     67    private method RestoreSettings { toolName plotName }
     68    private method SaveSettings { toolName plotName }
    7069    private method DestroySettings {}
    71     private method ResetSettings { } 
     70    private method ResetSettings { }
    7271    private method GetOutput {}
    7372    private method SetWaitVariable { state }
    74     private method SetLayoutOption { option } 
    75     private method GetAxisType { axis } 
    76     private method restore { toolName plotName data } 
     73    private method SetLayoutOption { option }
     74    private method GetAxisType { axis }
     75    private method restore { toolName plotName data }
    7776
    7877    # Same dialog may be used for different graphs
     
    8887    $_dispatcher register !rebuild
    8988    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
    90    
     89
    9190    set w [winfo pixels . 2.5i]
    9291    set h [winfo pixels . 2i]
     
    127126        0,1 $itk_component(tabs) -fill both -cspan 2 \
    128127        1,2 $itk_component(cancel) -padx 2 -pady 2 -width .9i -fill y \
    129         1,1 $itk_component(ok) -padx 2 -pady 2 -width .9i -fill y 
     128        1,1 $itk_component(ok) -padx 2 -pady 2 -width .9i -fill y
    130129    blt::table $inner \
    131         0,0 $itk_component(preview) -fill both -padx 10 -pady 10 
     130        0,0 $itk_component(preview) -fill both -padx 10 -pady 10
    132131
    133132    #blt::table configure $itk_interior c1 c2 -resize none
     
    167166    CloneGraph $graph
    168167    InitClone
    169     RestoreSettings $toolName $plotName 
     168    RestoreSettings $toolName $plotName
    170169    InitializeSettings
    171170    SetWaitVariable 0
    172171    tkwait variable [itcl::scope _wait($this)]
    173     SaveSettings $toolName $plotName 
     172    SaveSettings $toolName $plotName
    174173    set output ""
    175174    if { $_wait($this) } {
    176175        set output [GetOutput]
    177176    }
    178     DestroySettings 
     177    DestroySettings
    179178    return $output
    180179}
     
    212211        -center yes \
    213212        -width $w -height $h
    214    
     213
    215214    set psdata [$_clone postscript output]
    216215
    217216    if 0 {
    218         set f [open "junk.raw" "w"] 
     217        set f [open "junk.raw" "w"]
    219218        puts -nonewline $f $psdata
    220219        close $f
    221220    }
    222     if { $format == "eps" } { 
     221    if { $format == "eps" } {
    223222        return [list .$format $psdata]
    224223    }
    225224
    226225    set cmd ""
    227     # | eps2eps << $psdata 
     226    # | eps2eps << $psdata
    228227    lappend cmd "|" "/usr/bin/gs" \
    229228        "-q" "-sDEVICE=epswrite" "-sstdout=%stderr" \
     
    231230        "-dDEVICEWIDTH=250000" "-dDEVICEHEIGHT=250000" "-" "<<" "$psdata"
    232231    if { $format == "pdf" } {
    233         # | eps2eps << $psdata | ps2pdf 
     232        # | eps2eps << $psdata | ps2pdf
    234233        lappend cmd "|" "/usr/bin/gs" \
    235234            "-q" "-sDEVICE=pdfwrite" "-sstdout=%stderr" \
     
    243242        close $f
    244243    } err ] != 0 } {
    245         global errorInfo 
     244        global errorInfo
    246245        puts stderr "failed to generate file: $err\n$errorInfo"
    247246        return ""
    248247    }
    249248    if 0 {
    250         set f [open "junk.$format" "w"] 
     249        set f [open "junk.$format" "w"]
    251250        fconfigure $f -translation binary -encoding binary
    252251        puts -nonewline $f $output
     
    320319    # Element component
    321320    foreach elem [$orig element names] {
    322         set oper [$orig element type $elem] 
     321        set oper [$orig element type $elem]
    323322        $_clone $oper create $elem
    324         CopyOptions [list $oper configure $elem] $orig $_clone -data 
     323        CopyOptions [list $oper configure $elem] $orig $_clone -data
    325324        if { [$_clone $oper cget $elem -hide] } {
    326             $_clone $oper configure $elem -label "" 
     325            $_clone $oper configure $elem -label ""
    327326        }
    328327    }
     
    346345
    347346itcl::body Rappture::XyPrint::InitClone {} {
    348    
     347
    349348    $_clone configure -width 3.4i -height 3.4i -background white \
    350349        -borderwidth 0 \
     
    353352        -topmargin 0 \
    354353        -bottommargin 0
    355    
     354
    356355    # Kill the title and create a border around the plot
    357356    $_clone configure \
     
    373372        -hide yes -borderwidth 0 -background white -relief solid \
    374373        -anchor nw -activeborderwidth 0
    375     # 
     374    #
    376375    set _settings($this-axis-ticks-fontfamily) helvetica
    377376    set _settings($this-axis-ticks-fontsize)   10
     
    412411        incr count
    413412        if { [$_clone element cget $elem -linewidth] > 1 } {
    414             $_clone element configure $elem -linewidth 1 -pixels 3 
     413            $_clone element configure $elem -linewidth 1 -pixels 3
    415414        }
    416415    }
    417416    if { $count == 0 } {
    418         # There are no "line" elements in the graph. 
     417        # There are no "line" elements in the graph.
    419418        # Remove the symbol and dashes controls.
    420419        set page $itk_component(legend_page)
    421420        # May have already been forgotten.
    422         catch { 
     421        catch {
    423422            blt::table forget $page.symbol_l
    424423            blt::table forget $page.symbol
    425424            blt::table forget $page.dashes_l
    426             blt::table forget $page.dashes 
     425            blt::table forget $page.dashes
    427426        }
    428427    }
     
    430429
    431430itcl::body Rappture::XyPrint::SetOption { opt } {
    432     set new $_settings($this$opt) 
     431    set new $_settings($this$opt)
    433432    set old [$_clone cget $opt]
    434433    set code [catch [list $_clone configure $opt $new] err]
     
    443442
    444443itcl::body Rappture::XyPrint::SetComponentOption { comp opt } {
    445     set new $_settings($this-$comp$opt) 
     444    set new $_settings($this-$comp$opt)
    446445    set old [$_clone $comp cget $opt]
    447446    set code [catch [list $_clone $comp configure $opt $new] err]
     
    456455
    457456itcl::body Rappture::XyPrint::SetNamedComponentOption { comp name opt } {
    458     set new $_settings($this-$comp$opt) 
     457    set new $_settings($this-$comp$opt)
    459458    set old [$_clone $comp cget $name $opt]
    460459    set code [catch [list $_clone $comp configure $name $opt $new] err]
     
    469468
    470469itcl::body Rappture::XyPrint::RegeneratePreview {} {
    471     update 
     470    update
    472471    set img [image create photo]
    473472    set w [Inches2Pixels $_settings($this-layout-width) 3.4]
     
    483482    set maxheight $rh
    484483    if { $maxwidth > $cw } {
    485         set maxwidth $cw 
     484        set maxwidth $cw
    486485    }
    487486    if { $maxheight > $ch } {
    488         set maxheight $ch 
     487        set maxheight $ch
    489488    }
    490489    set sx [expr double($maxwidth)/$w]
     
    494493    set pw [expr int(round($s * $w))]
    495494    set ph [expr int(round($s * $h))]
    496     $_preview configure -width $pw -height $ph 
     495    $_preview configure -width $pw -height $ph
    497496    blt::winop resample $img $_preview box
    498497    image delete $img
     
    592591itcl::body Rappture::XyPrint::BuildLayoutTab {} {
    593592    itk_component add layout_page {
    594         frame $itk_component(tabs).layout_page 
     593        frame $itk_component(tabs).layout_page
    595594    }
    596595    set page $itk_component(layout_page)
     
    598597        -text "Layout" -padx 2 -pady 2 -window $page -fill both
    599598
    600     label $page.width_l -text "width" 
     599    label $page.width_l -text "width"
    601600    entry $page.width -width 6 \
    602601        -textvariable [itcl::scope _settings($this-layout-width)]
     
    605604        "Set the width (inches) of the output image. Must be a positive number."
    606605
    607     label $page.height_l -text "height" 
     606    label $page.height_l -text "height"
    608607    entry $page.height -width 6 \
    609608        -textvariable [itcl::scope _settings($this-layout-height)]
     
    612611        "Set the height (inches) of the output image. Must be a positive number"
    613612
    614     label $page.margin_l -text "Margins" 
     613    label $page.margin_l -text "Margins"
    615614
    616615    label $page.left_l -text "left"
     
    621620        "Set the size (inches) of the left margin. If zero, the size is automatically determined."
    622621
    623     label $page.right_l -text "right" 
     622    label $page.right_l -text "right"
    624623    entry $page.right -width 6 \
    625624        -textvariable [itcl::scope _settings($this-layout-rightmargin)]
     
    660659        0,2 $page.map -fill both -rspan 7 -padx 2
    661660
    662     blt::table configure $page c0 r* -resize none 
     661    blt::table configure $page c0 r* -resize none
    663662    blt::table configure $page c1 r2 -resize both
    664663}
     
    667666itcl::body Rappture::XyPrint::BuildGeneralTab {} {
    668667    itk_component add graph_page {
    669         frame $itk_component(tabs).graph_page 
     668        frame $itk_component(tabs).graph_page
    670669    }
    671670    set page $itk_component(graph_page)
     
    680679        "eps" "EPS Encapsulated PostScript"  \
    681680        "jpg" "JPEG Joint Photographic Experts Group Format" \
    682         "png" "PNG Portable Network Graphics Format"         
     681        "png" "PNG Portable Network Graphics Format"
    683682
    684683    bind $page.format <<Value>> [itcl::code $this ApplyGeneralSettings]
     
    686685        "Set the format of the image."
    687686
    688     label $page.style_l -text "style" 
     687    label $page.style_l -text "style"
    689688    Rappture::Combobox $page.style -width 20 -editable no
    690689    $page.style choices insert end \
    691690        "ieee" "IEEE Journal"  \
    692         "gekco" "G Klimeck" 
     691        "gekco" "G Klimeck"
    693692    bind $page.style <<Value>> [itcl::code $this ApplyGeneralSettings]
    694693    Rappture::Tooltip::for $page.format \
     
    696695
    697696    checkbutton $page.remember -text "remember settings" \
    698         -variable [itcl::scope _settings($this-general-remember)] 
     697        -variable [itcl::scope _settings($this-general-remember)]
    699698    Rappture::Tooltip::for $page.remember \
    700699        "Remember the settings. They will be override the default settings."
     
    712711        3,1 $page.style -fill x -cspan 2 \
    713712        5,0 $page.remember -cspan 2 -anchor w \
    714         5,2 $page.revert -anchor e 
     713        5,2 $page.revert -anchor e
    715714    blt::table configure $page r* -resize none  -pady { 0 2 }
    716715    blt::table configure $page r4 -resize both
    717716
    718717}
    719    
     718
    720719itcl::body Rappture::XyPrint::ApplyLegendSettings {} {
    721720    set page $itk_component(legend_page)
     
    736735itcl::body Rappture::XyPrint::BuildLegendTab {} {
    737736    itk_component add legend_page {
    738         frame $itk_component(tabs).legend_page 
     737        frame $itk_component(tabs).legend_page
    739738    }
    740739    set page $itk_component(legend_page)
     
    745744        -offvalue 1 -onvalue 0 \
    746745        -variable [itcl::scope _settings($this-legend-hide)]  \
    747         -command [itcl::code $this ApplyLegendSettings] 
     746        -command [itcl::code $this ApplyLegendSettings]
    748747    Rappture::Tooltip::for $page.show \
    749748        "Display the legend."
     
    756755        "bottommargin" "bottom margin"  \
    757756        "topmargin" "top margin"  \
    758         "plotarea" "inside plot" 
     757        "plotarea" "inside plot"
    759758    bind $page.position <<Value>> [itcl::code $this ApplyLegendSettings]
    760759    Rappture::Tooltip::for $page.position \
     
    771770        "c" "center"  \
    772771        "e" "east"  \
    773         "w" "west" 
     772        "w" "west"
    774773    bind $page.anchor <<Value>> [itcl::code $this ApplyLegendSettings]
    775774    Rappture::Tooltip::for $page.anchor \
     
    788787            -orient horizontal -width 12 \
    789788            -command [itcl::code $this GetElement]
    790     } 
     789    }
    791790    Rappture::Tooltip::for $page.slider \
    792791        "Select the current entry."
    793792
    794     label $page.label_l -text "label" 
     793    label $page.label_l -text "label"
    795794    entry $page.label \
    796795        -background white \
     
    800799        "Set the label of the current entry in the legend."
    801800
    802     label $page.color_l -text "color " 
     801    label $page.color_l -text "color "
    803802    Rappture::Combobox $page.color -width 15 -editable no
    804803    $page.color choices insert end \
     
    820819        "#0000ff" "blue1" \
    821820        "#ff0000" "red1" \
    822         "#00ff00" "green1" 
     821        "#00ff00" "green1"
    823822    bind $page.color <<Value>> [itcl::code $this ApplyElementSettings]
    824823    Rappture::Tooltip::for $page.color \
    825824        "Set the color of the current entry."
    826825
    827     label $page.dashes_l -text "line style" 
     826    label $page.dashes_l -text "line style"
    828827    Rappture::Combobox $page.dashes -width 15 -editable no
    829828    $page.dashes choices insert end \
     
    837836        "Set the line style of the current entry."
    838837
    839     label $page.symbol_l -text "symbol" 
     838    label $page.symbol_l -text "symbol"
    840839    Rappture::Combobox $page.symbol -editable no
    841840    $page.symbol choices insert end \
     
    860859        "new*century*schoolbook"  "new century schoolbook" \
    861860        "symbol"  "symbol" \
    862         "times"  "times"         
     861        "times"  "times"
    863862    bind $page.fontfamily <<Value>> [itcl::code $this ApplyLegendSettings]
    864863    Rappture::Tooltip::for $page.fontfamily \
     
    875874        "17" "17" \
    876875        "18" "18" \
    877         "20" "20" 
     876        "20" "20"
    878877    bind  $page.fontsize <<Value>> [itcl::code $this ApplyLegendSettings]
    879878    Rappture::Tooltip::for $page.fontsize \
     
    928927itcl::body Rappture::XyPrint::BuildAxisTab {} {
    929928    itk_component add axis_page {
    930         frame $itk_component(tabs).axis_page 
     929        frame $itk_component(tabs).axis_page
    931930    }
    932931    set page $itk_component(axis_page)
    933932    $itk_component(tabs) insert end "axis" \
    934933        -text "Axis" -padx 2 -pady 2 -window $page -fill both
    935    
    936     label $page.axis_l -text "axis" 
     934
     935    label $page.axis_l -text "axis"
    937936    itk_component add axis_combo {
    938937        Rappture::Combobox $page.axis -width 20 -editable no
    939     } 
     938    }
    940939    bind $itk_component(axis_combo) <<Value>> [itcl::code $this GetAxis]
    941940    Rappture::Tooltip::for $page.axis \
    942941        "Select the current axis."
    943942
    944     label $page.title_l -text "title" 
     943    label $page.title_l -text "title"
    945944    entry $page.title \
    946945        -textvariable [itcl::scope _settings($this-axis-title)]
     
    985984        "Set major ticks outside of the limits for the current axis."
    986985
    987     label $page.plotpad_l -text "pad" 
     986    label $page.plotpad_l -text "pad"
    988987    entry $page.plotpad -width 6 \
    989988        -textvariable [itcl::scope _settings($this-axis-plotpad)]
     
    10121011        "new*century*schoolbook"  "new century schoolbook" \
    10131012        "symbol"  "symbol" \
    1014         "times"  "times"         
     1013        "times"  "times"
    10151014    bind $page.tickfontfamily <<Value>> [itcl::code $this ApplyAxisSettings]
    10161015    Rappture::Tooltip::for $page.tickfontfamily \
     
    10271026        "17" "17" \
    10281027        "18" "18" \
    1029         "20" "20" 
     1028        "20" "20"
    10301029    bind $page.tickfontsize <<Value>> [itcl::code $this ApplyAxisSettings]
    10311030    Rappture::Tooltip::for $page.tickfontsize \
     
    10571056        "new*century*schoolbook"  "new century schoolbook" \
    10581057        "symbol"  "symbol" \
    1059         "times"  "times"         
     1058        "times"  "times"
    10601059    bind $page.titlefontfamily <<Value>> [itcl::code $this ApplyAxisSettings]
    10611060    Rappture::Tooltip::for $page.titlefontfamily \
     
    10721071        "17" "17" \
    10731072        "18" "18" \
    1074         "20" "20" 
     1073        "20" "20"
    10751074    bind $page.titlefontsize <<Value>> [itcl::code $this ApplyAxisSettings]
    10761075    Rappture::Tooltip::for $page.titlefontsize \
     
    11221121        8,1 $page.zero -cspan 2 -anchor w \
    11231122        8,3 $page.plotpad_l -anchor e \
    1124         8,4 $page.plotpad -fill both -cspan 3 
     1123        8,4 $page.plotpad -fill both -cspan 3
    11251124
    11261125    blt::table configure $page  c0 c4 c5 c6 c7 c8 -resize none
     
    11351134    set _settings($this-legend-position)  [$page.position current]
    11361135    set _settings($this-legend-anchor)    [$page.anchor current]
    1137    
     1136
    11381137    foreach option { -hide -position -anchor -borderwidth } {
    11391138        SetComponentOption legend $option
     
    12121211
    12131212itcl::body Rappture::XyPrint::ApplyLayoutSettings {} {
    1214     foreach opt { -width -height -leftmargin -rightmargin -topmargin 
     1213    foreach opt { -width -height -leftmargin -rightmargin -topmargin
    12151214        -bottommargin } {
    12161215        set old [$_clone cget $opt]
     
    12551254
    12561255    set names [$_clone element show]
    1257     $itk_component(element_slider) configure -from 1 -to [llength $names] 
     1256    $itk_component(element_slider) configure -from 1 -to [llength $names]
    12581257    set state [expr  { ([llength $names] < 2) ? "disabled" : "normal" } ]
    12591258    $page.slider configure -state $state
     
    12791278    # Axis settings
    12801279    set page $itk_component(axis_page)
    1281     set names [lsort [$_clone axis names]] 
     1280    set names [lsort [$_clone axis names]]
    12821281    $itk_component(axis_combo) choices delete 0 end
    12831282    foreach axis $names {
     
    13031302    set axis [lindex $axisnames 0]
    13041303    $itk_component(axis_combo) value $axis
    1305     GetAxis 
     1304    GetAxis
    13061305    RegeneratePreview
    13071306}
     
    13161315    if { ![file readable $_settingsFile] } {
    13171316        return;                         # No file or not readable
    1318     } 
     1317    }
    13191318    if { [file exists $_oldSettingsFile] } {
    13201319        file delete $_oldSettingsFile
     
    13471346itcl::body Rappture::XyPrint::ResetSettings {} {
    13481347    set graph $_graph
    1349     DestroySettings 
     1348    DestroySettings
    13501349    set _graph $graph
    13511350    CloneGraph $graph
     
    13811380    # General settings
    13821381    set length [string length "${this}-"]
    1383     append out "    array set settings {\n" 
     1382    append out "    array set settings {\n"
    13841383    foreach item [array names _settings ${this}-*] {
    13851384        set field [string range $item $length end]
     
    13901389        append out "        [list $field] [list $value]\n"
    13911390    }
    1392     append out "    }\n" 
     1391    append out "    }\n"
    13931392    # Legend font
    13941393    lappend legendfont $_settings($this-legend-fontfamily)
     
    14091408
    14101409    # Layout settings
    1411     append out "    preview configure" 
    1412     foreach opt { -width -height -leftmargin -rightmargin -topmargin 
     1410    append out "    preview configure"
     1411    foreach opt { -width -height -leftmargin -rightmargin -topmargin
    14131412        -bottommargin -plotpadx -plotpady } {
    14141413        set value [$_clone cget $opt]
     
    14181417
    14191418    # Legend settings
    1420     append out "    preview legend configure" 
    1421     foreach opt { -position -anchor -borderwidth -hide } { 
     1419    append out "    preview legend configure"
     1420    foreach opt { -position -anchor -borderwidth -hide } {
    14221421        set value [$_clone legend cget $opt]
    14231422        append out " $opt [list $value]"
     
    14351434        append out "        preview element configure $label"
    14361435        if { [$_clone element type $elem] != "bar" } {
    1437             set options { -symbol -color -dashes -label } 
     1436            set options { -symbol -color -dashes -label }
    14381437        } else {
    1439             set options { -color -label } 
    1440         }
    1441         foreach opt $options { 
     1438            set options { -color -label }
     1439        }
     1440        foreach opt $options {
    14421441            set value [$_clone element cget $elem $opt]
    14431442            append out " $opt [list $value]"
     
    14451444        append out "    \}\n"
    14461445    }
    1447    
     1446
    14481447    # Axis settings
    14491448    foreach axis [$_clone axis names] {
     
    14631462        append out "        preview marker configure ${axis}-zero -hide $hide\n"
    14641463        append out "    \}\n"
    1465     }   
    1466 
    1467     append out "    preview grid configure" 
     1464    }
     1465
     1466    append out "    preview grid configure"
    14681467    append out " -hide \"[$_clone grid cget -hide]\""
    14691468    append out " -mapx \"[$_clone grid cget -mapx]\""
Note: See TracChangeset for help on using the changeset viewer.