Changeset 2744 for trunk/gui/scripts/histogram.tcl
- Timestamp:
- Dec 27, 2011, 2:45:13 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/histogram.tcl
r2388 r2744 42 42 private variable _widths ;# array of vectors of bin widths 43 43 private variable _yvalues ;# array of vectors of bin heights along 44 44 ;# y-axis. 45 45 private variable _xvalues ;# array of vectors of bin locations along 46 46 ;# x-axis. 47 47 private variable _xlabels ;# array of labels 48 48 private variable _hints ;# cache of hints stored in XML … … 84 84 itcl::body Rappture::Histogram::mesh { comp } { 85 85 if { [info exists _xvalues($comp)] } { 86 86 return $_xvalues($comp) 87 87 } 88 88 return "" … … 96 96 itcl::body Rappture::Histogram::values { comp } { 97 97 if { [info exists _yvalues($comp)] } { 98 98 return $_yvalues($comp) 99 99 } 100 100 return "" … … 110 110 itcl::body Rappture::Histogram::widths { comp } { 111 111 if { [info exists _widths($comp)] } { 112 112 return $_widths($comp) 113 113 } 114 114 return "" … … 124 124 itcl::body Rappture::Histogram::xlabels { comp } { 125 125 if { [info exists _xlabels($comp)] } { 126 126 return $_xlabels($comp) 127 127 } 128 128 return "" … … 314 314 # 315 315 foreach cname [$_hist children -type component] { 316 316 ParseData $cname 317 317 } 318 318 # Creates lists of x and y marker data. … … 338 338 # ParseData -- 339 339 # 340 # 341 # 342 # 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. 343 343 # 344 344 itcl::body Rappture::Histogram::ParseData { comp } { … … 351 351 set xydata [$_hist get ${comp}.xy] 352 352 if { $xydata != "" } { 353 353 set count 0 354 354 foreach line [split $xydata \n] { 355 356 357 358 359 360 }361 362 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 363 363 } 364 364 set xhwdata [$_hist get ${comp}.xhw] 365 365 if { $xhwdata != "" } { 366 366 set count 0 367 367 foreach line [split $xhwdata \n] { 368 368 set n [scan $line {%s %s %s} name h w] 369 370 371 369 lappend _xlabels($comp) $name 370 $_xvalues($comp) append $count 371 $_yvalues($comp) append $h 372 372 if { $n == 3 } { 373 373 $_widths($comp) append $w 374 374 } 375 376 }377 378 375 incr count 376 } 377 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)] 378 return 379 379 380 380 # FIXME: There must be a width specified for each bin location. 381 # 382 # 381 # If this isn't true, we default to uniform widths 382 # (zero-length _widths vector == uniform). 383 383 if { [$_xvalues($comp) length] != [$_widths($comp) length] } { 384 384 $_widths($comp) set {} 385 385 } 386 387 386 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)] 387 return 388 388 } 389 389 set xv [$_hist get $comp.xvector] 390 390 set yv [$_hist get $comp.yvector] 391 391 if { $xv != "" && $yv != "" } { 392 393 394 392 $_yvalues($comp) set $yv 393 $_xvalues($comp) seq 0 [$yv length] 394 set _xlabels($comp) 395 395 } 396 396 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)] … … 399 399 itcl::body Rappture::Histogram::Clear { {comp ""} } { 400 400 if { $comp == "" } { 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 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 416 416 } 417 417 if { [info exists _widths($comp)] } { 418 418 blt::vector destroy $_widths($comp) 419 419 } 420 420 if { [info exists _yvalues($comp)] } { 421 421 blt::vector destroy $_yvalues($comp) 422 422 } 423 423 if { [info exists _xvalues($comp)] } { 424 424 blt::vector destroy $_xvalues($comp) 425 425 } 426 426 array unset _xvalues $comp
Note: See TracChangeset
for help on using the changeset viewer.