Changeset 4000
- Timestamp:
- Oct 9, 2013, 8:10:24 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/curve.tcl
r3330 r4000 32 32 33 33 public method components {{pattern *}} 34 public method mesh { {what -overall}}35 public method values { {what -overall}}34 public method mesh {cname } 35 public method values { cname } 36 36 public method limits {which} 37 37 public method hints {{key ""}} 38 38 public method xmarkers {} 39 39 public method ymarkers {} 40 public method xErrorValues { cname } 41 public method yErrorValues { cname} 40 42 41 43 protected method _build {} 42 44 43 private variable _xmlobj "" ; # ref to lib obj with curve data44 private variable _curve "" ; # lib obj representing this curve45 private variable _comp2xy ; # maps component name => x,y vectors46 private variable _hints ; # cache of hints stored in XML47 48 private variable _xmarkers ""; # list of {x,label,options} triplets.49 private variable _ymarkers ""; # list of {y,label,options} triplets.50 private common _counter 0 ; # counter for unique vector names45 private variable _xmlobj "" ; # ref to lib obj with curve data 46 private variable _curve "" ; # lib obj representing this curve 47 private variable _comp2xy ; # maps component name => x,y vectors 48 private variable _hints ; # cache of hints stored in XML 49 50 private variable _xmarkers ""; # list of {x,label,options} triplets. 51 private variable _ymarkers ""; # list of {y,label,options} triplets. 52 private common _counter 0 ; # counter for unique vector names 51 53 } 52 54 … … 60 62 set _xmlobj $xmlobj 61 63 set _curve [$xmlobj element -as object $path] 62 63 64 # build up vectors for various components of the curve 64 65 _build … … 101 102 # overall curve (sum of all components). 102 103 # ---------------------------------------------------------------------- 103 itcl::body Rappture::Curve::mesh { {what -overall}} {104 if {[info exists _comp2xy($ what)]} {105 return [lindex $_comp2xy($ what) 0] ;# return xv106 } 107 error "bad option \"$what\": should be[join [lsort [array names _comp2xy]] {, }]"104 itcl::body Rappture::Curve::mesh {cname} { 105 if {[info exists _comp2xy($cname)]} { 106 return [lindex $_comp2xy($cname) 0] ;# return xv 107 } 108 error "bad component \"$cname\": should be one of [join [lsort [array names _comp2xy]] {, }]" 108 109 } 109 110 … … 115 116 # overall curve (sum of all components). 116 117 # ---------------------------------------------------------------------- 117 itcl::body Rappture::Curve::values {{what -overall}} { 118 if {[info exists _comp2xy($what)]} { 119 return [lindex $_comp2xy($what) 1] ;# return yv 120 } 121 error "bad option \"$what\": should be [join [lsort [array names _comp2xy]] {, }]" 118 itcl::body Rappture::Curve::values {cname} { 119 if {[info exists _comp2xy($cname)]} { 120 return [lindex $_comp2xy($cname) 1] ;# return yv 121 } 122 error "bad component \"$cname\": should be one of [join [lsort [array names _comp2xy]] {, }]" 123 } 124 125 # ---------------------------------------------------------------------- 126 # USAGE: xErrorValues <name> 127 # 128 # Returns the xvec for the specified curve component <name>. 129 # If the name is not specified, then it returns the vectors for the 130 # overall curve (sum of all components). 131 # ---------------------------------------------------------------------- 132 itcl::body Rappture::Curve::xErrorValues { cname } { 133 if {[info exists _comp2xy($cname)]} { 134 return [lindex $_comp2xy($cname) 2] ;# return xev 135 } 136 error "unknown component \"$cname\": should be one of [join [lsort [array names _comp2xy]] {, }]" 137 } 138 139 # ---------------------------------------------------------------------- 140 # USAGE: yErrorValues <name> 141 # 142 # Returns the xvec for the specified curve component <name>. 143 # If the name is not specified, then it returns the vectors for the 144 # overall curve (sum of all components). 145 # ---------------------------------------------------------------------- 146 itcl::body Rappture::Curve::yErrorValues { cname } { 147 if {[info exists _comp2xy($cname)]} { 148 return [lindex $_comp2xy($cname) 3] ;# return yev 149 } 150 error "unknown component \"$cname\": should be one of [join [lsort [array names _comp2xy]] {, }]" 122 151 } 123 152 … … 272 301 set xv [blt::vector create \#auto] 273 302 set yv [blt::vector create \#auto] 303 set xev [blt::vector create \#auto] 304 set yev [blt::vector create \#auto] 274 305 275 306 set xydata [$_curve get $cname.xy] … … 283 314 $yv set [$_curve get $cname.yvector] 284 315 } 285 if { (([$xv length] == 0) && ([$yv length] == 0)) 286 ||([$xv length] != [$yv length]) } {316 if { (([$xv length] == 0) && ([$yv length] == 0)) || 317 ([$xv length] != [$yv length]) } { 287 318 # FIXME: need to show an error about improper data. 288 319 blt::vector destroy $xv $yv 289 320 set xv ""; set yv "" 290 } else { 291 set _comp2xy($cname) [list $xv $yv] 292 incr _counter 293 } 294 } 321 continue; 322 } 323 $xev set [$_curve get "$cname.xerrorbars"] 324 $yev set [$_curve get "$cname.yerrorbars"] 325 set _comp2xy($cname) [list $xv $yv $xev $yev] 326 incr _counter 327 } 328 295 329 # Creates lists of x and y marker data. 296 330 set _xmarkers {}
Note: See TracChangeset
for help on using the changeset viewer.