Changeset 2518 for branches/blt4/gui
- Timestamp:
- Sep 15, 2011, 4:23:27 PM (13 years ago)
- Location:
- branches/blt4/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/gui/scripts/histogram.tcl
r2300 r2518 351 351 set xydata [$_hist get ${comp}.xy] 352 352 if { $xydata != "" } { 353 # Fast way of parsing x/y pairs. Set a temporary vector using the354 # entire as a list of values (newlines treated as whitespace).355 # Then split the vector into the x and y vectors required.356 set tmp [blt::vector create \#auto]357 $tmp set $xydata358 $tmp split $_xvalues($comp) $_yvalues($comp)359 blt::vector destroy $tmp360 $_widths($comp) set {}361 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]362 return363 }364 set xhwdata [$_hist get ${comp}.xhw]365 if { $xhwdata != "" } {366 # Slow way of parsing x, h, and w values. The third value is367 # optional to can't simply load the values into a vector.368 foreach line [split $xhwdata \n] {369 set n [scan $line {%s %s %s} x h w]370 if { $n == 2 } {371 $_xvalues($comp) append $x372 $_yvalues($comp) append $h373 } elseif { $n == 3 } {374 $_xvalues($comp) append $x375 $_yvalues($comp) append $h376 $_widths($comp) append $w377 }378 }379 # FIXME: There must be a width specified for each bin location.380 # If this isn't true, we default to uniform widths381 # (zero-length _widths vector == uniform).382 if { [$_xvalues($comp) length] != [$_widths($comp) length] } {383 $_widths($comp) set {}384 }385 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]386 return387 }388 set nvdata [$_hist get ${comp}.namevalue]389 if { $nvdata != "" } {390 353 set count 0 391 foreach line [split $ nvdata \n] {354 foreach line [split $xydata \n] { 392 355 foreach {name value} $line break 393 356 $_yvalues($comp) append $value … … 399 362 return 400 363 } 364 set xhwdata [$_hist get ${comp}.xhw] 365 if { $xhwdata != "" } { 366 set count 0 367 foreach line [split $xhwdata \n] { 368 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 372 if { $n == 3 } { 373 $_widths($comp) append $w 374 } 375 incr count 376 } 377 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)] 378 return 379 380 # 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). 383 if { [$_xvalues($comp) length] != [$_widths($comp) length] } { 384 $_widths($comp) set {} 385 } 386 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)] 387 return 388 } 401 389 set xv [$_hist get $comp.xvector] 402 390 set yv [$_hist get $comp.yvector] 403 391 if { $xv != "" && $yv != "" } { 404 392 $_yvalues($comp) set $yv 405 $_xvalues($comp) set $xv 406 } 407 set _comp2hist($comp) [list $xv $yv] 393 $_xvalues($comp) seq 0 [$yv length] 394 set _xlabels($comp) 395 } 396 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)] 408 397 } 409 398 -
branches/blt4/gui/scripts/histogramresult.tcl
r2409 r2518 29 29 option add *HistogramResult.height 3i widgetDefault 30 30 option add *HistogramResult.gridColor #d9d9d9 widgetDefault 31 option add *HistogramResult.activeColor blue widgetDefault31 option add *HistogramResult.activeColor blue2 widgetDefault 32 32 option add *HistogramResult.dimColor gray widgetDefault 33 33 option add *HistogramResult.controlBackground gray widgetDefault 34 34 option add *HistogramResult.font \ 35 35 -*-helvetica-medium-r-normal-*-12-* widgetDefault 36 37 option add *HistogramResult.autoColors {38 #0000ff #ff0000 #00cc0039 #cc00cc #ff9900 #cccc0040 #000080 #800000 #00660041 #660066 #996600 #66660042 }43 set autocolors {44 #0000cd45 #cd000046 #00cd0047 #3a5fcd48 #cdcd0049 #cd107650 #009acd51 #00c5cd52 #a2b5cd53 #7ac5cd54 #66cdaa55 #a2cd5a56 #cd9b9b57 #cdba9658 #cd333359 #cd660060 #cd8c9561 #cd00cd62 #9a32cd63 #6ca6cd64 #9ac0cd65 #9bcd9b66 #00cd6667 #cdc67368 #cdad0069 #cd555570 #cd853f71 #cd705472 #cd5b4573 #cd688974 #cd69c975 #551a8b76 }77 78 option add *HistogramResult.autoColors $autocolors widgetDefault79 36 option add *HistogramResult*Balloon*Entry.background white widgetDefault 37 38 option add *HistogramResult*autoColors { 39 #3a5fcd 40 #cdcd00 41 #cd1076 42 #0000cd 43 #cd0000 44 #00cd00 45 #009acd 46 #00c5cd 47 #a2b5cd 48 #7ac5cd 49 #66cdaa 50 #a2cd5a 51 #cd9b9b 52 #cdba96 53 #cd3333 54 #cd6600 55 #cd8c95 56 #cd00cd 57 #9a32cd 58 #6ca6cd 59 #9ac0cd 60 #9bcd9b 61 #00cd66 62 #cdc673 63 #cdad00 64 #cd5555 65 #cd853f 66 #cd7054 67 #cd5b45 68 #cd6889 69 #cd69c9 70 #551a8b 71 } widgetDefault 80 72 81 73 itcl::class Rappture::HistogramResult { … … 86 78 itk_option define -dimcolor dimColor DimColor "" 87 79 itk_option define -autocolors autoColors AutoColors "" 80 88 81 constructor {args} { 89 82 # defined below … … 651 644 } 652 645 } 653 $g axis configure x646 654 647 # 655 648 # All of the extra axes get mapped to the x2/y2 (top/right) … … 670 663 } 671 664 } 672 665 673 666 foreach axis $all { 674 667 set _axisPopup(format-$axis) "%.6g" 675 676 668 $g axis bind $axis <Enter> \ 677 669 [itcl::code $this Axis hilite $axis on] … … 823 815 itcl::body Rappture::HistogramResult::ResetLimits {} { 824 816 set g $itk_component(plot) 817 825 818 # 826 819 # HACK ALERT! … … 920 913 } 921 914 set tip "" 915 set index "" 922 916 if {$state == "at"} { 923 917 set results [$g element closest $x $y -interpolate yes] … … 957 951 append tip "\n$yval$yunits" 958 952 set xval [Axis format x dummy $info(x)] 959 append tip " @ $xval $xunits"953 append tip " @ $xval" 960 954 set tip [string trim $tip] 955 set index $info(index) 961 956 } 962 957 set state 1 … … 968 963 # for dealing with xy scatter plot 969 964 set elem $info(name) 970 971 965 # Some elements are generated dynamically and therefore will 972 966 # not have a dataobj object associated with them. … … 976 970 foreach {mapx mapy} [GetAxes $_elem2dataobj($elem)] break 977 971 } 978 979 972 set tip "" 980 973 set x [$g axis transform $mapx $info(x)] 981 974 set y [$g axis transform $mapy $info(y)] 982 983 if {[info exists _elem2dataobj($elem)]} { 975 if { [$g cget -invertxy] } { 976 set tmp $x 977 set x $y 978 set y $tmp 979 } 980 if {[info exists _elem2dataobj($elem)]} { 984 981 set dataobj $_elem2dataobj($elem) 985 982 set yunits [$dataobj hints yunits] … … 993 990 append tip "\n$yval$yunits" 994 991 set xval [Axis format x dummy $info(x)] 995 append tip " @ $xval $xunits"992 append tip " @ $xval" 996 993 set tip [string trim $tip] 994 set index $info(index) 997 995 set state 1 998 996 } else { … … 1014 1012 Rappture::Tooltip::tooltip cancel 1015 1013 } 1016 $g element activate $elem 1014 if { $index != "" } { 1015 $g element activate $elem $index 1016 set _hilite(index) $index 1017 } 1017 1018 set _hilite(elem) $elem 1018 1019 … … 1056 1057 set tipx "-0" 1057 1058 } else { 1058 set tipx "-[expr {$x- 4}]" ;# move tooltip to the left1059 set tipx "-[expr {$x-20}]" ;# move tooltip to the left 1059 1060 } 1060 1061 } else { … … 1062 1063 set tipx "+0" 1063 1064 } else { 1064 set tipx "+[expr {$x+ 4}]" ;# move tooltip to the right1065 set tipx "+[expr {$x+20}]" ;# move tooltip to the right 1065 1066 } 1066 1067 } … … 1069 1070 set tipy "-0" 1070 1071 } else { 1071 set tipy "-[expr {$y- 4}]" ;# move tooltip to the top1072 set tipy "-[expr {$y-20}]" ;# move tooltip to the top 1072 1073 } 1073 1074 } else { … … 1075 1076 set tipy "+0" 1076 1077 } else { 1077 set tipy "+[expr {$y+ 4}]" ;# move tooltip to the bottom1078 set tipy "+[expr {$y+20}]" ;# move tooltip to the bottom 1078 1079 } 1079 1080 } … … 1166 1167 error "wrong # args: should be \"Axis click axis x y\"" 1167 1168 } 1168 set axis [lindex $args 0] 1169 set x [lindex $args 1] 1170 set y [lindex $args 2] 1169 foreach { axis x y } $args break 1171 1170 set g $itk_component(plot) 1171 if { [$g cget -invertxy] } { 1172 set tmp $x 1173 set x $y 1174 set y $tmp 1175 } 1172 1176 1173 1177 set _axis(moved) 0 … … 1186 1190 return ;# must have skipped click event -- ignore 1187 1191 } 1188 set axis [lindex $args 0] 1189 set x [lindex $args 1] 1190 set y [lindex $args 2] 1192 foreach { axis x y } $args break 1191 1193 set g $itk_component(plot) 1194 if { [$g cget -invertxy] } { 1195 set tmp $x 1196 set x $y 1197 set y $tmp 1198 } 1192 1199 1193 1200 if {[info exists _axis(click-x)] && [info exists _axis(click-y)]} { … … 1244 1251 return ;# must have skipped click event -- ignore 1245 1252 } 1246 set axis [lindex $args 0] 1247 set x [lindex $args 1] 1248 set y [lindex $args 2] 1253 foreach { axis x y } $args break 1254 set g $itk_component(plot) 1255 if { [$g cget -invertxy] } { 1256 set tmp $x 1257 set x $y 1258 set y $tmp 1259 } 1249 1260 1250 1261 if {!$_axis(moved)} { … … 1454 1465 set axis [lindex $args 0] 1455 1466 set value [lindex $args 2] 1456 1467 if { $axis == "x" } { 1468 return [FormatLabels $itk_component(plot) $value] 1469 } 1457 1470 if {[$itk_component(plot) axis cget $axis -logscale]} { 1458 1471 set fmt "%.6g" … … 1632 1645 return $_xlabels($index) 1633 1646 } 1634 puts stderr "value=$value index=$index" 1635 parray _xlabels 1636 return $value 1637 } 1647 return " " 1648 }
Note: See TracChangeset
for help on using the changeset viewer.