Changeset 822
- Timestamp:
- Nov 29, 2007 5:17:31 PM (16 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/analyzer.tcl
r768 r822 466 466 _autoLabel $xmlobj output.$item "String" counters 467 467 } 468 curve* - field* {468 histogram* - curve* - field* { 469 469 _autoLabel $xmlobj output.$item "Plot" counters 470 470 } -
trunk/gui/scripts/histogram.tcl
r818 r822 67 67 itcl::delete object $_hist 68 68 # don't destroy the _xmlobj! we don't own it! 69 blt::vector destroy $_widths _$heights $_locations69 blt::vector destroy $_widths $_heights $_locations 70 70 } 71 71 … … 132 132 set max "" 133 133 switch -- $which { 134 x - xlin { set vname $_locations; set log 0; set axis xaxis } 135 xlog { set vname $_locations; set log 1; set axis xaxis } 136 y - ylin - v - vlin { set vname $_heights; set log 0; set axis yaxis } 137 ylog - vlog { set vname $_heights; set log 1; set axis yaxis } 134 x - xlin { 135 set vname $_locations; 136 set log 0; 137 set axis xaxis 138 } 139 xlog { 140 set vname $_locations; 141 set log 1; 142 set axis xaxis 143 } 144 y - ylin { 145 set vname $_heights; 146 set log 0; 147 set axis yaxis 148 } 149 ylog { 150 set vname $_heights; 151 set log 1; 152 set axis yaxis 153 } 138 154 default { 139 error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog" 140 } 141 } 142 143 $vname variable vec 144 155 error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog" 156 } 157 } 158 $vname dup tmp 159 $vname dup zero 145 160 if {$log} { 146 161 # on a log scale, use abs value and ignore 0's 147 $vname dup tmp148 $vname dup zero149 162 zero expr {tmp == 0} ;# find the 0's 150 163 tmp expr {abs(tmp)} ;# get the abs value … … 153 166 set vmax [blt::vector expr max(tmp)] 154 167 } else { 155 set vmin $vec(min)156 set vmax $vec(max)168 set vmin [blt::vector expr min($vname)] 169 set vmax [blt::vector expr max($vname)] 157 170 } 158 171 … … 277 290 set xhwdata [$_hist get component.xhw] 278 291 if {"" != $xhwdata} { 279 set _widths [blt::vector create x]280 set _heights [blt::vector create y]281 set _locations [blt::vector create w]292 set _widths [blt::vector create \#auto] 293 set _heights [blt::vector create \#auto] 294 set _locations [blt::vector create \#auto] 282 295 283 296 foreach line [split $xhwdata \n] { … … 299 312 } 300 313 } 301 302 314 # Creates lists of x and y marker data. 303 315 set _xmarkers {} 304 316 set _ymarkers {} 305 317 foreach cname [$_hist children -type "marker" xaxis] { 306 set at [$_hist get " $parent.$cname.at"]307 set label [$_hist get " $parent.$cname.label"]308 set styles [$_hist get " $parent.$cname.style"]318 set at [$_hist get "xaxis.$cname.at"] 319 set label [$_hist get "xaxis.$cname.label"] 320 set styles [$_hist get "xaxis.$cname.style"] 309 321 set data [list $at $label $styles] 310 322 lappend _xmarkers $data 311 323 } 312 324 foreach cname [$_hist children -type "marker" yaxis] { 313 set at [$_hist get " $parent.$cname.at"]314 set label [$_hist get " $parent.$cname.label"]315 set styles [$_hist get " $parent.$cname.style"]325 set at [$_hist get "yaxis.$cname.at"] 326 set label [$_hist get "yaxis.$cname.label"] 327 set styles [$_hist get "yaxis.$cname.style"] 316 328 set data [list $at $label $styles] 317 329 lappend _xmarkers $data -
trunk/gui/scripts/historesult.tcl
r818 r822 1 1 2 2 # ---------------------------------------------------------------------- 3 # COMPONENT: historesult - X/Y plot in a ResultSet3 # COMPONENT: HistoResult - X/Y plot in a ResultSet 4 4 # 5 5 # This widget is an X/Y plot, meant to view histograms produced … … 17 17 package require BLT 18 18 19 option add *Historesult.width 3i widgetDefault 20 option add *Historesult.height 3i widgetDefault 21 option add *Historesult.gridColor #d9d9d9 widgetDefault 22 option add *Historesult.activeColor blue widgetDefault 23 option add *Historesult.dimColor gray widgetDefault 24 option add *Historesult.controlBackground gray widgetDefault 25 option add *Historesult.font \ 19 option add *HistoResult*Element.borderWidth 1 widgetDefault 20 option add *HistoResult*Element.relief solid widgetDefault 21 option add *HistoResult*x.loose 1 widgetDefault 22 option add *HistoResult*y.loose 1 widgetDefault 23 option add *HistoResult*Element.relief solid widgetDefault 24 25 option add *HistoResult.width 3i widgetDefault 26 option add *HistoResult.height 3i widgetDefault 27 option add *HistoResult.gridColor #d9d9d9 widgetDefault 28 option add *HistoResult.activeColor blue widgetDefault 29 option add *HistoResult.dimColor gray widgetDefault 30 option add *HistoResult.controlBackground gray widgetDefault 31 option add *HistoResult.font \ 26 32 -*-helvetica-medium-r-normal-*-12-* widgetDefault 27 33 28 option add *Histo result.autoColors {34 option add *HistoResult.autoColors { 29 35 #0000ff #ff0000 #00cc00 30 36 #cc00cc #ff9900 #cccc00 … … 33 39 } widgetDefault 34 40 35 option add *Histo result*Balloon*Entry.background white widgetDefault36 37 itcl::class Rappture::Histo result {41 option add *HistoResult*Balloon*Entry.background white widgetDefault 42 43 itcl::class Rappture::HistoResult { 38 44 inherit itk::Widget 39 45 … … 59 65 protected method _axis {option args} 60 66 protected method _getAxes {xydata} 67 protected method _getLineMarkerOptions { style } 68 protected method _getTextMarkerOptions { style } 61 69 62 70 private variable _dispatcher "" ;# dispatcher for !events … … 77 85 private variable _axisPopup ;# info for axis being edited in popup 78 86 common _downloadPopup ;# download options from popup 87 79 88 } 80 89 81 itk::usual Histo result {90 itk::usual HistoResult { 82 91 keep -background -foreground -cursor -font 83 92 } … … 86 95 # CONSTRUCTOR 87 96 # ---------------------------------------------------------------------- 88 itcl::body Rappture::Histo result::constructor {args} {97 itcl::body Rappture::HistoResult::constructor {args} { 89 98 Rappture::dispatcher _dispatcher 90 99 $_dispatcher register !rebuild … … 122 131 itk_component add plot { 123 132 blt::barchart $itk_interior.plot \ 124 -highlightthickness 0 -plotpadx 0 -plotpady0 \133 -highlightthickness 0 -plotpadx 10 -plotpady 10 \ 125 134 -rightmargin 10 126 135 } { … … 129 138 pack $itk_component(plot) -expand yes -fill both 130 139 $itk_component(plot) pen configure activeBar \ 131 - linewidth 2 -color black140 -foreground red -borderwidth 0 132 141 133 142 # … … 176 185 grid $inner.format -row 4 -column 1 -sticky ew -pady 4 177 186 178 label $inner.scalel -text "Scale:" 179 frame $inner.scales 180 radiobutton $inner.scales.linear -text "Linear" \ 181 -variable [itcl::scope _axisPopup(scale)] -value "linear" 182 pack $inner.scales.linear -side left 183 radiobutton $inner.scales.log -text "Logarithmic" \ 184 -variable [itcl::scope _axisPopup(scale)] -value "log" 185 pack $inner.scales.log -side left 186 grid $inner.scalel -row 5 -column 0 -sticky e 187 grid $inner.scales -row 5 -column 1 -sticky ew -pady 4 187 # I've temporarily removed the scaling controls. Log scale isn't useful 188 # for the x-axis, but can be for the y-axis. I need to figure out how to 189 # provide different menus for each axis. 188 190 189 191 foreach axis {x y} { … … 205 207 # DESTRUCTOR 206 208 # ---------------------------------------------------------------------- 207 itcl::body Rappture::Histo result::destructor {} {209 itcl::body Rappture::HistoResult::destructor {} { 208 210 } 209 211 … … 215 217 # -brightness, -width, -linestyle and -raise. 216 218 # ---------------------------------------------------------------------- 217 itcl::body Rappture::Histo result::add {histogram {settings ""}} {219 itcl::body Rappture::HistoResult::add {histogram {settings ""}} { 218 220 array set params { 219 221 -color auto … … 291 293 # order from bottom to top of this result. 292 294 # ---------------------------------------------------------------------- 293 itcl::body Rappture::Histo result::get {} {295 itcl::body Rappture::HistoResult::get {} { 294 296 # put the dataobj list in order according to -raise options 295 297 set clist $_hlist … … 312 314 # are specified, then all histograms are deleted. 313 315 # ---------------------------------------------------------------------- 314 itcl::body Rappture::Histo result::delete {args} {316 itcl::body Rappture::HistoResult::delete {args} { 315 317 if {[llength $args] == 0} { 316 318 set args $_hlist … … 356 358 # the user scans through data in the ResultSet viewer. 357 359 # ---------------------------------------------------------------------- 358 itcl::body Rappture::Histo result::scale {args} {360 itcl::body Rappture::HistoResult::scale {args} { 359 361 set allx [$itk_component(plot) x2axis use] 360 362 lappend allx x ;# fix main x-axis too … … 380 382 set id $map($axis)$type 381 383 foreach {min max} [$xydata limits $axis$type] break 384 puts stderr "axis=$axis min=$min, max=$max" 382 385 if {"" != $min && "" != $max} { 383 386 if {![info exists _limits($id-min)]} { … … 413 416 # "string" is the data itself. 414 417 # ---------------------------------------------------------------------- 415 itcl::body Rappture::Histo result::download {option args} {418 itcl::body Rappture::HistoResult::download {option args} { 416 419 switch $option { 417 420 coming { … … 419 422 } 420 423 controls { 421 set popup . historesultdownload424 set popup .HistoResultdownload 422 425 if {![winfo exists .historesultdownload]} { 423 426 # if we haven't created the popup yet, do it now … … 427 430 pack $inner.summary -side top 428 431 radiobutton $inner.csv -text "Data as Comma-Separated Values" \ 429 -variable Rappture::Histo result::_downloadPopup(format) \432 -variable Rappture::HistoResult::_downloadPopup(format) \ 430 433 -value csv 431 434 pack $inner.csv -anchor w 432 435 radiobutton $inner.pdf -text "Image as PDF/PostScript" \ 433 -variable Rappture::Histo result::_downloadPopup(format) \436 -variable Rappture::HistoResult::_downloadPopup(format) \ 434 437 -value pdf 435 438 pack $inner.pdf -anchor w … … 475 478 476 479 append csvdata "[$dataobj hints xlabel], [$dataobj hints ylabel]\n" 477 set first 1 478 foreach comp [$dataobj components] { 479 if {!$first} { 480 # blank line between components 481 append csvdata "\n" 482 } 483 set xv [$dataobj locations] 484 set hv [$dataobj heights] 485 set wv [$dataobj widths] 486 if { $wv == "" } { 487 foreach x [$xv range 0 end] h [$hv range 0 end] { 480 set xv [$dataobj locations] 481 set hv [$dataobj heights] 482 set wv [$dataobj widths] 483 if { $wv == "" } { 484 foreach x [$xv range 0 end] h [$hv range 0 end] { 485 append csvdata \ 486 [format "%20.15g, %20.15g\n" $x $h] 487 } 488 } else { 489 foreach x [$xv range 0 end] \ 490 h [$hv range 0 end] \ 491 w [$wv range 0 end] { 488 492 append csvdata \ 489 [format "%20.15g, %20.15g \n" $x $h]493 [format "%20.15g, %20.15g, %20.15g\n" $x $h $w] 490 494 } 491 } else {492 foreach x [$xv range 0 end] \493 h [$hv range 0 end] \494 w [$wv range 0 end] {495 append csvdata [format \496 "%20.15g, %20.15g, %20.15g\n" $x $h $w]497 }498 }499 set first 0500 append csvdata "\n"501 495 } 496 append csvdata "\n" 502 497 } 503 498 return [list .txt $csvdata] … … 537 532 # widget to display new data. 538 533 # ---------------------------------------------------------------------- 539 itcl::body Rappture::Histo result::_rebuild {} {534 itcl::body Rappture::HistoResult::_rebuild {} { 540 535 set g $itk_component(plot) 541 536 542 537 # first clear out the widget 543 538 eval $g element delete [$g element names] 539 eval $g marker delete [$g marker names] 544 540 foreach axis [$g axis names] { 545 $g axis configure $axis -hide yes 541 $g axis configure $axis -hide yes 546 542 } 547 543 catch {unset _label2axis} 548 549 544 # 550 545 # Scan through all objects and create a list of all axes. … … 623 618 foreach {mapx mapy} [_getAxes $xydata] break 624 619 625 foreach comp [$xydata components] { 626 set xv [$xydata locations] 627 set yv [$xydata heights] 628 set zv [$xydata widths] 629 630 if {[info exists _histo2color($xydata)]} { 631 set color $_histo2color($xydata) 632 } else { 633 set color [$xydata hints color] 634 if {"" == $color} { 635 set color black 636 } 637 } 638 639 if {[info exists _histo2width($xydata)]} { 640 set lwidth $_histo2width($xydata) 641 } else { 642 set lwidth 2 643 } 644 645 if {[info exists _histo2dashes($xydata)]} { 646 set dashes $_histo2dashes($xydata) 647 } else { 648 set dashes "" 649 } 650 set elem "elem[incr count]" 651 set _elem2histo($elem) $xydata 652 $g element line $elem -x $xv -y $yv \ 653 -symbol $sym -pixels $pixels -linewidth $lwidth -label $label \ 654 -color $color -dashes $dashes -smooth natural \ 655 -mapx $mapx -mapy $mapy 656 657 # Compute default bar width for histogram elements. 658 set defwidth { [expr ($zv(max) - $zv(min)) / ([$xv length] - 1)] } 659 foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] { 660 if { $z == "" } { 661 set z $defwidth 662 } 620 set xv [$xydata locations] 621 set yv [$xydata heights] 622 set zv [$xydata widths] 623 624 if {[info exists _histo2color($xydata)]} { 625 set color $_histo2color($xydata) 626 } else { 627 set color [$xydata hints color] 628 if {"" == $color} { 629 set color black 630 } 631 } 632 633 if {[info exists _histo2width($xydata)]} { 634 set lwidth $_histo2width($xydata) 635 } else { 636 set lwidth 2 637 } 638 639 if {[info exists _histo2dashes($xydata)]} { 640 set dashes $_histo2dashes($xydata) 641 } else { 642 set dashes "" 643 } 644 if {([$xv length] <= 1) || ($lwidth == 0)} { 645 set sym square 646 set pixels 2 647 } else { 648 set sym "" 649 set pixels 6 650 } 651 if { 0 } { 652 set elem "elem[incr count]" 653 set _elem2histo($elem) $xydata 654 $g line create $elem -x $xv -y $yv \ 655 -symbol $sym -pixels $pixels -linewidth $lwidth -label $label \ 656 -color $color -dashes $dashes -smooth natural \ 657 -mapx $mapx -mapy $mapy 658 } 659 # Compute default bar width for histogram elements. 660 if { [$zv length] == [$xv length] } { 661 foreach x [$xv range 0 end] \ 662 y [$yv range 0 end] \ 663 z [$zv range 0 end] { 663 664 set elem "elem[incr count]" 664 665 set _elem2histo($elem) $xydata 665 666 $g element create $elem -x $x -y $y -barwidth $z \ 666 667 667 -label $label -foreground $color \ 668 -mapx $mapx -mapy $mapy 668 669 } 669 } 670 } else { 671 set r [blt::vector expr {max($xv) - min($xv)}] 672 set z [expr {$r / ([$xv length]-1)}] 673 foreach x [$xv range 0 end] y [$yv range 0 end] { 674 set elem "elem[incr count]" 675 set _elem2histo($elem) $xydata 676 $g element create $elem -x $x -y $y -barwidth $z \ 677 -label $label -foreground $color \ 678 -mapx $mapx -mapy $mapy 679 } 680 } 681 682 # 683 # Create text/line markers for each *axis.marker specified. 684 # 685 foreach m [$xydata xmarkers] { 686 foreach {at label style} $m break 687 set yv [$xydata heights] 688 set min [blt::vector expr min($yv)] 689 set max [blt::vector expr max($yv)] 690 set id [$g marker create line -coords [list $at $min $at $max]] 691 set options [_getLineMarkerOptions $style] 692 if { $options != "" } { 693 eval $g marker configure $id $options 694 } 695 if { $label != "" } { 696 set id [$g marker create text -anchor w -xoffset 5 \ 697 -text $label -coords [list $at $max]] 698 set options [_getTextMarkerOptions $style] 699 if { $options != "" } { 700 eval $g marker configure $id $options 701 } 702 } 703 } 704 foreach m [$xydata ymarkers] { 705 foreach {at label style} $m break 706 set xv [$xydata widths] 707 set min [blt::vector expr min($xv)] 708 set max [blt::vector expr max($xv)] 709 set id [$g marker create line -coords [list $min $at $max $at]] 710 set options [_getLineMarkerOptions $style] 711 if { $options != "" } { 712 eval $g marker configure $id $options 713 } 714 if { $label != "" } { 715 set id [$g marker create text -anchor se -yoffset 5 \ 716 -text $label -coords [list $max $at]] 717 set options [_getTextMarkerOptions $style] 718 if { $options != "" } { 719 eval $g marker configure $id $options 720 } 721 } 722 } 670 723 } 671 724 } … … 677 730 # current plot. 678 731 # ---------------------------------------------------------------------- 679 itcl::body Rappture::Histo result::_resetLimits {} {732 itcl::body Rappture::HistoResult::_resetLimits {} { 680 733 set g $itk_component(plot) 681 734 … … 753 806 # controls for this widget. Changes the zoom for the current view. 754 807 # ---------------------------------------------------------------------- 755 itcl::body Rappture::Histo result::_zoom {option args} {808 itcl::body Rappture::HistoResult::_zoom {option args} { 756 809 switch -- $option { 757 810 reset { … … 768 821 # pop up with element info. 769 822 # ---------------------------------------------------------------------- 770 itcl::body Rappture::Histo result::_hilite {state x y} {823 itcl::body Rappture::HistoResult::_hilite {state x y} { 771 824 set g $itk_component(plot) 772 825 set elem "" … … 978 1031 # changes from the panel. 979 1032 # ---------------------------------------------------------------------- 980 itcl::body Rappture::Histo result::_axis {option args} {1033 itcl::body Rappture::HistoResult::_axis {option args} { 981 1034 set inner [$itk_component(hull).axes component inner] 982 1035 … … 1149 1202 [itcl::code $this _axis changed $axis format] 1150 1203 1151 # fix scale control... 1152 if {[$itk_component(plot) axis cget $axis -logscale]} { 1153 set _axisPopup(scale) "log" 1154 $inner.format configure -state disabled 1155 } else { 1156 set _axisPopup(scale) "linear" 1157 $inner.format configure -state normal 1158 } 1159 $inner.scales.linear configure \ 1160 -command [itcl::code $this _axis changed $axis scale] 1161 $inner.scales.log configure \ 1162 -command [itcl::code $this _axis changed $axis scale] 1204 # I removed the code for fixing the axis menus scale controls. 1205 # This needs to be added back when different menus are available 1206 # for each axis. 1163 1207 1164 1208 # … … 1330 1374 1331 1375 # ---------------------------------------------------------------------- 1376 # USAGE: _getLineMarkerOptions <style> 1377 # 1378 # Used internally to create a list of configuration options specific to the 1379 # axis line marker. The input is a list of name value pairs. Options that 1380 # are not recognized are ignored. 1381 # ---------------------------------------------------------------------- 1382 itcl::body Rappture::HistoResult::_getLineMarkerOptions {style} { 1383 array set lineOptions { 1384 "-color" "-outline" 1385 "-dashes" "-dashes" 1386 "-linecolor" "-outline" 1387 "-linewidth" "-linewidth" 1388 } 1389 set options {} 1390 foreach {name value} $style { 1391 if { [info exists lineOptions($name)] } { 1392 lappend options $lineOptions($name) $value 1393 } 1394 } 1395 return $options 1396 } 1397 1398 # ---------------------------------------------------------------------- 1399 # USAGE: _getTextMarkerOptions <style> 1400 # 1401 # Used internally to create a list of configuration options specific to the 1402 # axis text marker. The input is a list of name value pairs. Options that 1403 # are not recognized are ignored. 1404 # ---------------------------------------------------------------------- 1405 itcl::body Rappture::HistoResult::_getTextMarkerOptions {style} { 1406 array set textOptions { 1407 "-color" "-outline" 1408 "-textcolor" "-outline" 1409 "-font" "-font" 1410 "-xoffset" "-xoffset" 1411 "-yoffset" "-yoffset" 1412 "-anchor" "-anchor" 1413 } 1414 set options {} 1415 foreach {name value} $style { 1416 if { [info exists textOptions($name)] } { 1417 lappend options $textOptions($name) $value 1418 } 1419 } 1420 return $options 1421 } 1422 1423 # ---------------------------------------------------------------------- 1332 1424 # USAGE: _getAxes <histoObj> 1333 1425 # … … 1336 1428 # x-axis name (x, x2, x3, etc.), and y is the y-axis name. 1337 1429 # ---------------------------------------------------------------------- 1338 itcl::body Rappture::Histo result::_getAxes {xydata} {1430 itcl::body Rappture::HistoResult::_getAxes {xydata} { 1339 1431 # rebuild if needed, so we know about the axes 1340 1432 if {[$_dispatcher ispending !rebuild]} { … … 1365 1457 # CONFIGURATION OPTION: -gridcolor 1366 1458 # ---------------------------------------------------------------------- 1367 itcl::configbody Rappture::Histo result::gridcolor {1459 itcl::configbody Rappture::HistoResult::gridcolor { 1368 1460 if {"" == $itk_option(-gridcolor)} { 1369 1461 $itk_component(plot) grid off … … 1377 1469 # CONFIGURATION OPTION: -autocolors 1378 1470 # ---------------------------------------------------------------------- 1379 itcl::configbody Rappture::Histo result::autocolors {1471 itcl::configbody Rappture::HistoResult::autocolors { 1380 1472 foreach c $itk_option(-autocolors) { 1381 1473 if {[catch {winfo rgb $itk_component(hull) $c}]} { -
trunk/gui/scripts/resultviewer.tcl
r766 r822 209 209 itcl::body Rappture::ResultViewer::_plotAdd {dataobj {settings ""}} { 210 210 switch -- [$dataobj info class] { 211 ::Rappture::Histogram { 212 set mode "histogram" 213 if {![info exists _mode2widget($mode)]} { 214 set w $itk_interior.xy 215 Rappture::HistoResult $w 216 set _mode2widget($mode) $w 217 } 218 } 211 219 ::Rappture::Curve { 212 220 set mode "xy" … … 404 412 return [Rappture::Curve ::#auto $xmlobj $path] 405 413 } 414 histogram { 415 return [Rappture::Histogram ::#auto $xmlobj $path] 416 } 406 417 field { 407 418 return [Rappture::Field ::#auto $xmlobj $path] -
trunk/gui/scripts/sequence.tcl
r644 r822 62 62 curve { 63 63 set obj [Rappture::Curve ::#auto $xmlobj $path.$name.$cname] 64 } 65 histogram { 66 set obj [Rappture::Histogram ::#auto $xmlobj $path.$name.$cname] 64 67 } 65 68 field {
Note: See TracChangeset
for help on using the changeset viewer.