Ignore:
Timestamp:
Dec 27, 2011, 2:45:13 PM (13 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

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

    r2388 r2744  
    4242    private variable _widths     ;# array of vectors of bin widths
    4343    private variable _yvalues    ;# array of vectors of bin heights along
    44                                 ;# y-axis.
     44                                ;# y-axis.
    4545    private variable _xvalues    ;# array of vectors of bin locations along
    46                                 ;# x-axis.
     46                                ;# x-axis.
    4747    private variable _xlabels    ;# array of labels
    4848    private variable _hints      ;# cache of hints stored in XML
     
    8484itcl::body Rappture::Histogram::mesh { comp } {
    8585    if { [info exists _xvalues($comp)] } {
    86         return $_xvalues($comp)
     86        return $_xvalues($comp)
    8787    }
    8888    return ""
     
    9696itcl::body Rappture::Histogram::values { comp } {
    9797    if { [info exists _yvalues($comp)] } {
    98         return $_yvalues($comp)
     98        return $_yvalues($comp)
    9999    }
    100100    return ""
     
    110110itcl::body Rappture::Histogram::widths { comp } {
    111111    if { [info exists _widths($comp)] } {
    112         return $_widths($comp)
     112        return $_widths($comp)
    113113    }
    114114    return ""
     
    124124itcl::body Rappture::Histogram::xlabels { comp } {
    125125    if { [info exists _xlabels($comp)] } {
    126         return $_xlabels($comp)
     126        return $_xlabels($comp)
    127127    }
    128128    return ""
     
    314314    #
    315315    foreach cname [$_hist children -type component] {
    316         ParseData $cname
     316        ParseData $cname
    317317    }
    318318    # Creates lists of x and y marker data.
     
    338338# ParseData --
    339339#
    340 #       Parse the components data representations.  The following
    341 #       elements may be used <xy>, <xhw>, <namevalue>, <xvector>,
    342 #       <yvector>.  Only one element is used for data. 
     340#       Parse the components data representations.  The following
     341#       elements may be used <xy>, <xhw>, <namevalue>, <xvector>,
     342#       <yvector>.  Only one element is used for data. 
    343343#
    344344itcl::body Rappture::Histogram::ParseData { comp } {
     
    351351    set xydata [$_hist get ${comp}.xy]
    352352    if { $xydata != "" } {
    353         set count 0
     353        set count 0
    354354        foreach line [split $xydata \n] {
    355             foreach {name value} $line break
    356             $_yvalues($comp) append $value
    357             $_xvalues($comp) append $count
    358             lappend _xlabels($comp) $name
    359             incr count
    360         }          
    361         set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
    362         return
     355            foreach {name value} $line break
     356            $_yvalues($comp) append $value
     357            $_xvalues($comp) append $count
     358            lappend _xlabels($comp) $name
     359            incr count
     360        }          
     361        set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
     362        return
    363363    }
    364364    set xhwdata [$_hist get ${comp}.xhw]
    365365    if { $xhwdata != "" } {
    366         set count 0
     366        set count 0
    367367        foreach line [split $xhwdata \n] {
    368368            set n [scan $line {%s %s %s} name h w]
    369             lappend _xlabels($comp) $name
    370             $_xvalues($comp) append $count
    371             $_yvalues($comp) append $h
     369            lappend _xlabels($comp) $name
     370            $_xvalues($comp) append $count
     371            $_yvalues($comp) append $h
    372372            if { $n == 3 } {
    373373                $_widths($comp) append $w
    374374            }
    375             incr count
    376         }          
    377         set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
    378         return
     375            incr count
     376        }          
     377        set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
     378        return
    379379
    380380        # FIXME:  There must be a width specified for each bin location.
    381         #         If this isn't true, we default to uniform widths
    382         #         (zero-length _widths vector == uniform).
     381        #         If this isn't true, we default to uniform widths
     382        #         (zero-length _widths vector == uniform).
    383383        if { [$_xvalues($comp) length] != [$_widths($comp) length] } {
    384384            $_widths($comp) set {}
    385385        }
    386         set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
    387         return
     386        set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
     387        return
    388388    }
    389389    set xv [$_hist get $comp.xvector]
    390390    set yv [$_hist get $comp.yvector]
    391391    if { $xv != "" && $yv != "" } {
    392         $_yvalues($comp) set $yv
    393         $_xvalues($comp) seq 0 [$yv length]
    394         set _xlabels($comp)
     392        $_yvalues($comp) set $yv
     393        $_xvalues($comp) seq 0 [$yv length]
     394        set _xlabels($comp)
    395395    }
    396396    set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
     
    399399itcl::body Rappture::Histogram::Clear { {comp ""} } {
    400400    if { $comp == "" } {
    401         foreach name [array names _widths] {
    402             blt::vector destroy $_widths($name)
    403         }
    404         array unset _widths
    405         foreach name [array names _yvalues] {
    406             blt::vector destroy $_yvalues($name)
    407         }
    408         array unset _yvalues
    409         foreach name [array names _xvalues] {
    410             blt::vector destroy $_xvalues($name)
    411         }
    412         array unset _xvalues
    413         array unset _xlabels
    414         array unset _comp2hist
    415         return
     401        foreach name [array names _widths] {
     402            blt::vector destroy $_widths($name)
     403        }
     404        array unset _widths
     405        foreach name [array names _yvalues] {
     406            blt::vector destroy $_yvalues($name)
     407        }
     408        array unset _yvalues
     409        foreach name [array names _xvalues] {
     410            blt::vector destroy $_xvalues($name)
     411        }
     412        array unset _xvalues
     413        array unset _xlabels
     414        array unset _comp2hist
     415        return
    416416    }
    417417    if { [info exists _widths($comp)] } {
    418         blt::vector destroy $_widths($comp)
     418        blt::vector destroy $_widths($comp)
    419419    }
    420420    if { [info exists _yvalues($comp)] } {
    421         blt::vector destroy $_yvalues($comp)
     421        blt::vector destroy $_yvalues($comp)
    422422    }
    423423    if { [info exists _xvalues($comp)] } {
    424         blt::vector destroy $_xvalues($comp)
     424        blt::vector destroy $_xvalues($comp)
    425425    }
    426426    array unset _xvalues $comp
Note: See TracChangeset for help on using the changeset viewer.