Changeset 413
- Timestamp:
- Apr 26, 2006 6:42:46 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/zoo/curve/tool.xml
r72 r413 26 26 <output> 27 27 <curve id="single"> 28 <about><label>Single curve</label></about> 28 <about> 29 <label>Single curve</label> 30 <description>This is an example of a single curve.</description> 31 </about> 29 32 <xaxis> 30 33 <label>Time</label> 34 <description>Time during the experiment.</description> 31 35 <units>s</units> 32 36 </xaxis> 33 37 <yaxis> 34 38 <label>Voltage v(11)</label> 39 <description>Output from the amplifier.</description> 35 40 <units>V</units> 36 41 </yaxis> … … 41 46 <group>Multiple curves</group> 42 47 <label>Factor a=1</label> 48 <description>This is an example of multiple curves on the same plot.</description> 43 49 </about> 44 50 <xaxis> 45 51 <label>Frequency</label> 52 <description>Frequency of the input source.</description> 46 53 <units>Hz</units> 47 54 <scale>log</scale> … … 49 56 <yaxis> 50 57 <label>Current</label> 58 <description>Current through the pull-down resistor.</description> 51 59 <units>uA</units> 52 60 <scale>log</scale> … … 58 66 <group>Multiple curves</group> 59 67 <label>Factor a=2</label> 68 <description>This is an example of multiple curves on the same plot.</description> 60 69 </about> 61 70 <xaxis> 62 71 <label>Frequency</label> 72 <description>Frequency of the input source.</description> 63 73 <units>Hz</units> 64 74 <scale>log</scale> … … 66 76 <yaxis> 67 77 <label>Current</label> 78 <description>Current through the pull-down resistor.</description> 68 79 <units>uA</units> 69 80 <scale>log</scale> -
trunk/gui/Makefile.in
r193 r413 339 339 $(TCLSH_PROG) $(srcdir)/cf/mkindex.tcl $(DESTDIR)$(pkglibdir)/scripts 340 340 $(mkinstalldirs) $(pkglibdir)/scripts/images 341 @for i in $(srcdir)/scripts/images/*.gif; do \ 341 @for i in $(srcdir)/scripts/images/*.gif \ 342 $(srcdir)/scripts/images/*.xbm; do \ 342 343 echo "Installing $$i" ; \ 343 344 $(INSTALL_DATA) $$i $(DESTDIR)$(pkglibdir)/scripts/images ; \ -
trunk/gui/apps/driver
r365 r413 50 50 option add *Switch.textBackground white 51 51 option add *Progress.barColor #ffffcc 52 option add *Balloon.titleBackground #6666cc 53 option add *Balloon.titleForeground white 54 option add *ResultSet.controlbarBackground #6666cc 55 option add *ResultSet.controlbarForeground white 56 option add *ResultSet.activeControlBackground #ccccff 57 option add *ResultSet.activeControlForeground black 58 option add *Radiodial.length 3i 52 59 53 60 switch $tcl_platform(platform) { … … 83 90 84 91 set tool [Rappture::Tool ::#auto $xmlobj $installdir] 92 93 # ---------------------------------------------------------------------- 94 # LOAD RESOURCE SETTINGS 95 # 96 # Try to load the $SESSIONDIR/resources file, which contains 97 # middleware settings, such as the application name and the 98 # filexfer settings. 99 # ---------------------------------------------------------------------- 100 Rappture::resources::load 85 101 86 102 # ---------------------------------------------------------------------- -
trunk/gui/scripts/analyzer.tcl
r216 r413 64 64 protected method _simState {state args} 65 65 protected method _simOutput {message} 66 protected method _resultTooltip {} 66 67 67 68 private variable _tool "" ;# belongs to this tool … … 70 71 private variable _pages 0 ;# number of pages for result sets 71 72 private variable _label2page ;# maps output label => result set 73 private variable _label2desc ;# maps output label => description 72 74 private variable _lastlabel "" ;# label of last example loaded 73 75 private variable _plotlist "" ;# items currently being plotted … … 75 77 private common job ;# array var used for blt::bgexec jobs 76 78 77 private common icons 78 set icons(download) [image create photo -data { 79 R0lGODlhFAAUAMYBAAAAAP///+js9vL1+4yhxrbD21h6sFp8slx+tV6Bt2CFumSIvmOHvWaLwGyS 80 yG6UynCRwWiOw2yUyXCZzm+XzG+Wy3Oc0XKaz3We1Hqk23mj2Xqk2nmi2ICex/T3+3Od0nqm3Hag 81 1Xun3Iat3ZK56JK03t7n8uzy+PX4+/f5+/T4+/L3+vn7/Pj7/Pf7/Pb6+/n9/fz///r9/fn8/Pz+ 82 /vv9/fr8/Pz9/UGMfluegZzRp6XYqwWXC67frwCZAAKaAgOaAgOaAwWbBQabBQicCA6fDg6eDw+f 83 Dw+fEA+eDxCfEF6/Xl+/X6TbpKbbpqzerK7frq3era/fr/z+/P3+/bXjsXjSbKrjotbw02bSVKvj 84 olnSQYPfcJbjh5/jk1TSOV7XQm3bVIvidprmiKjqmXTgV4DjZrPuo7TupNb1zo/qc5nsf8L0s8Hz 85 sar0j7L1mdD5wdH5wur+4eL91f///////////////////////////////////////////////yH5 86 BAEAAH8ALAIAAgAQABAAAAfYgAUlIiAbHCEYHxcTFRIdBX8jJJOUlZQQfyKam5ycDX8ZAaKjpKMM 87 fxoBLC0pHis7Rz5GOiYBCn8cATI2LC8oSFhVWEkCAQl/IQE3NTIzLj5aVlc+JwEIfxgBNDXLMD5e 88 WV4+AwEHfxbaNNs1Pl1bXT4qAQZ/FAExPUo++1xfXPs+eEh5IIpJGjJjxIQBE0bMGDJpljgQFQUI 89 GjNlMmY0c0bIEwIRGizAEYTNGjUo17QhkoPKn5cvnwSJ88bNGzhEmkyByfPJDzlz5AxxspMnTyix 90 ijxx+TIQADs= 91 }] 79 # resources file tells us the results directory 80 public common _resultdir "" 81 public proc setResultDir {path} { set _resultdir $path } 82 } 83 84 # must use this name -- plugs into Rappture::resources::load 85 proc analyzer_init_resources {} { 86 Rappture::resources::register \ 87 results_directory Rappture::Analyzer::setResultDir 92 88 } 93 89 … … 214 210 [itcl::code $this download coming] 215 211 212 Rappture::Tooltip::for $itk_component(resultselector) \ 213 "@[itcl::code $this _resultTooltip]" 214 216 215 if {[Rappture::filexfer::enabled]} { 217 216 $itk_component(resultselector) choices insert end \ … … 221 220 222 221 itk_component add download { 223 button $w.top.dl -image $icons(download)-anchor e \222 button $w.top.dl -image [Rappture::icon download] -anchor e \ 224 223 -borderwidth 1 -relief flat -overrelief raised \ 225 224 -command [itcl::code $this download now $w.top.dl] … … 235 234 236 235 itk_component add results { 237 Rappture::Panes $w.pane 236 Rappture::Panes $w.pane -sashwidth 1 -sashrelief solid -sashpadding {4 0} 238 237 } 239 238 pack $itk_component(results) -expand yes -fill both … … 254 253 pack $itk_component(resultset) -expand yes -fill both 255 254 bind $itk_component(resultset) <<Control>> [itcl::code $this _fixSize] 255 bind $itk_component(results) <Configure> [itcl::code $this _fixSize] 256 256 257 257 eval itk_initialize $args … … 360 360 set result "$msg\n$errorInfo" 361 361 } 362 363 # if there's a results_directory defined in the resources 364 # file, then move the run.xml file there for storage 365 if {"" != $_resultdir} { 366 file rename -force -- $file $_resultdir 367 } 362 368 } else { 363 369 set status 1 364 set result "Can't find result file in output :\n\n$result"370 set result "Can't find result file in output.\nDid you call Rappture::result in your simulator?" 365 371 } 366 372 } … … 465 471 # if there are any valid results, add them to the resultset 466 472 if {$haveresults} { 467 set size [$itk_component(resultset) size]468 473 set index [$itk_component(resultset) add $xmlobj] 469 474 … … 483 488 set page [$itk_component(resultpages) insert end $name] 484 489 set _label2page($label) $page 490 set _label2desc($label) \ 491 [$xmlobj get output.$item.about.description] 485 492 Rappture::ResultViewer $page.rviewer 486 493 pack $page.rviewer -expand yes -fill both -pady 4 … … 535 542 536 543 $itk_component(resultset) clear 537 $itk_component(results) fraction end 0.1 544 545 # reset the size of the controls area 546 set ht [winfo height $itk_component(results)] 547 set cntlht [$itk_component(resultset) size -controlarea] 548 set frac [expr {double($cntlht)/$ht}] 549 $itk_component(results) fraction end $frac 538 550 539 551 foreach label [array names _label2page] { … … 544 556 $itk_component(resultselector) choices delete 0 end 545 557 catch {unset _label2page} 558 catch {unset _label2desc} 546 559 set _plotlist "" 547 560 … … 775 788 # ---------------------------------------------------------------------- 776 789 itcl::body Rappture::Analyzer::_fixSize {} { 777 set f [$itk_component(results) fraction end] 778 if {$f < 0.4} { 779 $itk_component(results) fraction end [expr {$f+0.15}] 790 set ht [winfo height $itk_component(results)] 791 if {$ht <= 1} { set ht [winfo reqheight $itk_component(results)] } 792 set cntlht [$itk_component(resultset) size -controlarea] 793 set frac [expr {double($cntlht)/$ht}] 794 795 if {$frac < 0.4} { 796 $itk_component(results) fraction end $frac 780 797 } 781 798 _fixSimControl … … 937 954 938 955 # ---------------------------------------------------------------------- 956 # USAGE: _resultTooltip 957 # 958 # Used internally to build the tooltip string displayed for the 959 # result selector. If the current page has an associated description, 960 # then it is displayed beneath the result. 961 # 962 # Returns the string for the tooltip. 963 # ---------------------------------------------------------------------- 964 itcl::body Rappture::Analyzer::_resultTooltip {} { 965 set tip "" 966 set name [$itk_component(resultselector) value] 967 if {[info exists _label2desc($name)] && 968 [string length $_label2desc($name)] > 0} { 969 append tip "$_label2desc($name)\n\n" 970 } 971 if {[array size _label2page] > 1} { 972 append tip "Use this control to display other output results." 973 } 974 return $tip 975 } 976 977 # ---------------------------------------------------------------------- 939 978 # USAGE: _fixSimControl 940 979 # -
trunk/gui/scripts/balloon.tcl
r115 r413 19 19 namespace eval Rappture { # forward declaration } 20 20 21 option add *Balloon.dismissButton on widgetDefault 22 option add *Balloon.padX 4 widgetDefault 23 option add *Balloon.padY 4 widgetDefault 24 option add *Balloon.titleBackground #999999 widgetDefault 25 option add *Balloon.titleForeground white widgetDefault 26 option add *Balloon.relief raised widgetDefault 21 27 option add *Balloon.stemLength 16 widgetDefault 22 28 … … 24 30 inherit itk::Toplevel 25 31 32 itk_option define -deactivatecommand deactivateCommand DeactivateCommand "" 33 itk_option define -dismissbutton dismissButton DismissButton "on" 34 itk_option define -padx padX Pad 0 35 itk_option define -pady padY Pad 0 36 itk_option define -title title Title "" 37 itk_option define -titlebackground titleBackground Background "" 38 itk_option define -titleforeground titleForeground Foreground "" 26 39 itk_option define -stemlength stemLength StemLength 20 27 itk_option define -deactivatecommand deactivateCommand DeactivateCommand ""28 40 29 41 constructor {args} { # defined below } … … 53 65 wm overrideredirect $itk_component(hull) yes 54 66 wm withdraw $itk_component(hull) 55 component hull configure -borderwidth 1 -relief solid 67 component hull configure -borderwidth 1 -relief solid -padx 0 -pady 0 68 69 itk_component add border { 70 frame $itk_interior.border -borderwidth 2 71 } { 72 usual 73 keep -relief 74 } 75 pack $itk_component(border) -expand yes -fill both 76 77 itk_component add titlebar { 78 frame $itk_component(border).tbar 79 } { 80 usual 81 rename -background -titlebackground titleBackground Background 82 } 83 84 itk_component add title { 85 label $itk_component(titlebar).title -width 1 -anchor w 86 } { 87 usual 88 rename -background -titlebackground titleBackground Background 89 rename -foreground -titleforeground titleForeground Foreground 90 rename -highlightbackground -titlebackground titleBackground Background 91 rename -text -title title Title 92 } 93 pack $itk_component(title) -side left -expand yes -fill both -padx 2 94 95 itk_component add dismiss { 96 button $itk_component(titlebar).dismiss \ 97 -bitmap [Rappture::icon dismiss] \ 98 -relief flat -overrelief raised -command " 99 Rappture::Tooltip::cue hide 100 [list $itk_component(hull) deactivate] 101 " 102 } { 103 usual 104 rename -background -titlebackground titleBackground Background 105 rename -foreground -titleforeground titleForeground Foreground 106 rename -highlightbackground -titlebackground titleBackground Background 107 } 56 108 57 109 itk_component add inner { 58 frame $itk_ interior.inner -borderwidth 2 -relief raised110 frame $itk_component(border).inner 59 111 } 60 112 pack $itk_component(inner) -expand yes -fill both … … 85 137 set sh [image height $_fills($placement)] 86 138 set p $itk_component(hull) 139 set screenw [winfo screenwidth $p] 140 set screenh [winfo screenheight $p] 87 141 88 142 if {[winfo exists $where]} { … … 104 158 deactivate 105 159 160 set pw [winfo reqwidth $p] 161 if {$pw > $screenw} { set pw [expr {$screenw-10}] } 162 set ph [winfo reqheight $p] 163 if {$ph > $screenh} { set ph [expr {$screenh-10}] } 164 106 165 switch -- $placement { 107 166 left { 108 167 set sx [expr {$x-$sw+3}] 109 168 set sy [expr {$y-$sh/2}] 110 set px [expr {$sx-[winfo reqwidth $p]+3}] 111 set py [expr {$y-[winfo reqheight $p]/2}] 169 set px [expr {$sx-$pw+3}] 170 set py [expr {$y-$ph/2}] 171 172 # make sure that the panel doesn't go off-screen 173 if {$py < 0} { set py 0 } 174 if {$py+$ph > $screenh} { set py [expr {$screenh-$ph}] } 175 if {$px < 0} { set pw [expr {$pw+$px}]; set px 0 } 112 176 } 113 177 right { … … 115 179 set sy [expr {$y-$sh/2}] 116 180 set px [expr {$x+$sw-3}] 117 set py [expr {$y-[winfo reqheight $p]/2}] 181 set py [expr {$y-$ph/2}] 182 183 # make sure that the panel doesn't go off-screen 184 if {$py < 0} { set py 0 } 185 if {$py+$ph > $screenh} { set py [expr {$screenh-$ph}] } 186 if {$px+$pw > $screenw} { set pw [expr {$screenw-$px)}] } 118 187 } 119 188 above { 120 189 set sx [expr {$x-$sw/2}] 121 190 set sy [expr {$y-$sh+3}] 122 set px [expr {$x-[winfo reqwidth $p]/2}] 123 set py [expr {$sy-[winfo reqheight $p]+3}] 191 set px [expr {$x-$pw/2}] 192 set py [expr {$sy-$ph+3}] 193 194 # make sure that the panel doesn't go off-screen 195 if {$px < 0} { set px 0 } 196 if {$px+$pw > $screenw} { set px [expr {$screenw-$pw}] } 197 if {$py < 0} { set ph [expr {$ph+$py}]; set py 0 } 124 198 } 125 199 below { 126 200 set sx [expr {$x-$sw/2}] 127 201 set sy $y 128 set px [expr {$x- [winfo reqwidth $p]/2}]202 set px [expr {$x-$pw/2}] 129 203 set py [expr {$y+$sh-3}] 204 205 # make sure that the panel doesn't go off-screen 206 if {$px < 0} { set px 0 } 207 if {$px+$pw > $screenw} { set px [expr {$screenw-$pw}] } 208 if {$py+$ph > $screenh} { set ph [expr {$screenh-$py)}] } 130 209 } 131 210 } … … 134 213 } 135 214 136 wm geometry $p +$px+$py215 wm geometry $p ${pw}x${ph}+$px+$py 137 216 wm deiconify $p 138 217 raise $p … … 408 487 } 409 488 } 489 490 # ---------------------------------------------------------------------- 491 # CONFIGURATION OPTION: -dismissbutton 492 # ---------------------------------------------------------------------- 493 itcl::configbody Rappture::Balloon::dismissbutton { 494 if {![string is boolean $itk_option(-dismissbutton)]} { 495 error "bad value \"$itk_option(-dismissbutton)\": should be on/off, 1/0, true/false, yes/no" 496 } 497 if {$itk_option(-dismissbutton)} { 498 pack $itk_component(titlebar) -before $itk_component(inner) \ 499 -side top -fill x 500 pack $itk_component(dismiss) -side right -padx 4 501 } elseif {"" != $itk_option(-title)} { 502 pack $itk_component(titlebar) -before $itk_component(inner) \ 503 -side top -fill x 504 pack forget $itk_component(dismiss) 505 } else { 506 pack forget $itk_component(titlebar) 507 } 508 } 509 510 # ---------------------------------------------------------------------- 511 # CONFIGURATION OPTION: -padx 512 # ---------------------------------------------------------------------- 513 itcl::configbody Rappture::Balloon::padx { 514 pack $itk_component(inner) -padx $itk_option(-padx) 515 } 516 517 # ---------------------------------------------------------------------- 518 # CONFIGURATION OPTION: -pady 519 # ---------------------------------------------------------------------- 520 itcl::configbody Rappture::Balloon::pady { 521 pack $itk_component(inner) -pady $itk_option(-pady) 522 } 523 524 # ---------------------------------------------------------------------- 525 # CONFIGURATION OPTION: -title 526 # ---------------------------------------------------------------------- 527 itcl::configbody Rappture::Balloon::title { 528 if {"" != $itk_option(-title) || $itk_option(-dismissbutton)} { 529 pack $itk_component(titlebar) -before $itk_component(inner) \ 530 -side top -fill x 531 if {$itk_option(-dismissbutton)} { 532 pack $itk_component(dismiss) -side right -padx 4 533 } else { 534 pack forget $itk_component(dismiss) 535 } 536 } else { 537 pack forget $itk_component(titlebar) 538 } 539 } -
trunk/gui/scripts/contourresult.tcl
r220 r413 18 18 package require BLT 19 19 package require Img 20 21 blt::bitmap define ContourResult-reset {22 #define reset_width 1223 #define reset_height 1224 static unsigned char reset_bits[] = {25 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02,26 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};27 }28 29 blt::bitmap define ContourResult-zoomin {30 #define zoomin_width 1231 #define zoomin_height 1232 static unsigned char zoomin_bits[] = {33 0x7c, 0x00, 0x82, 0x00, 0x11, 0x01, 0x11, 0x01, 0x7d, 0x01, 0x11, 0x01,34 0x11, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};35 }36 37 blt::bitmap define ContourResult-zoomout {38 #define zoomout_width 1239 #define zoomout_height 1240 static unsigned char zoomout_bits[] = {41 0x7c, 0x00, 0x82, 0x00, 0x01, 0x01, 0x01, 0x01, 0x7d, 0x01, 0x01, 0x01,42 0x01, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};43 }44 45 blt::bitmap define ContourResult-xslice {46 #define x_width 1247 #define x_height 1248 static unsigned char x_bits[] = {49 0x00, 0x00, 0x00, 0x00, 0x9c, 0x03, 0x98, 0x01, 0xf0, 0x00, 0x60, 0x00,50 0x60, 0x00, 0xf0, 0x00, 0x98, 0x01, 0x9c, 0x03, 0x00, 0x00, 0x00, 0x00};51 }52 53 blt::bitmap define ContourResult-yslice {54 #define y_width 1255 #define y_height 1256 static unsigned char y_bits[] = {57 0x00, 0x00, 0x00, 0x00, 0x0e, 0x07, 0x0c, 0x03, 0x98, 0x01, 0xf0, 0x00,58 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00};59 }60 blt::bitmap define ContourResult-zslice {61 #define z_width 1262 #define z_height 1263 static unsigned char z_bits[] = {64 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x84, 0x03, 0xc0, 0x01, 0xe0, 0x00,65 0x70, 0x00, 0x38, 0x00, 0x1c, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};66 }67 20 68 21 option add *ContourResult.width 4i widgetDefault … … 157 110 button $itk_component(zoom).reset \ 158 111 -borderwidth 1 -padx 1 -pady 1 \ 159 -bitmap ContourResult-reset\112 -bitmap [Rappture::icon reset] \ 160 113 -command [itcl::code $this _zoom reset] 161 114 } { … … 170 123 button $itk_component(zoom).zin \ 171 124 -borderwidth 1 -padx 1 -pady 1 \ 172 -bitmap ContourResult-zoomin\125 -bitmap [Rappture::icon zoomin] \ 173 126 -command [itcl::code $this _zoom in] 174 127 } { … … 183 136 button $itk_component(zoom).zout \ 184 137 -borderwidth 1 -padx 1 -pady 1 \ 185 -bitmap ContourResult-zoomout\138 -bitmap [Rappture::icon zoomout] \ 186 139 -command [itcl::code $this _zoom out] 187 140 } { … … 211 164 label $itk_component(slicers).xslice \ 212 165 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 213 -bitmap ContourResult-xslice166 -bitmap [Rappture::icon x] 214 167 } { 215 168 usual … … 245 198 label $itk_component(slicers).yslice \ 246 199 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 247 -bitmap ContourResult-yslice200 -bitmap [Rappture::icon y] 248 201 } { 249 202 usual … … 279 232 label $itk_component(slicers).zslice \ 280 233 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 281 -bitmap ContourResult-zslice234 -bitmap [Rappture::icon z] 282 235 } { 283 236 usual -
trunk/gui/scripts/curve.tcl
r115 r413 194 194 style about.style 195 195 xlabel xaxis.label 196 xdesc xaxis.description 196 197 xunits xaxis.units 197 198 xscale xaxis.scale … … 199 200 xmax xaxis.max 200 201 ylabel yaxis.label 202 ydesc yaxis.description 201 203 yunits yaxis.units 202 204 yscale yaxis.scale -
trunk/gui/scripts/energyLevels.tcl
r226 r413 28 28 option add *EnergyLevels.font \ 29 29 -*-helvetica-medium-r-normal-*-*-120-* widgetDefault 30 31 blt::bitmap define EnergyLevels-reset {32 #define reset_width 1233 #define reset_height 1234 static unsigned char reset_bits[] = {35 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02,36 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};37 }38 39 blt::bitmap define EnergyLevels-zoomin {40 #define zoomin_width 1241 #define zoomin_height 1242 static unsigned char zoomin_bits[] = {43 0x7c, 0x00, 0x82, 0x00, 0x11, 0x01, 0x11, 0x01, 0x7d, 0x01, 0x11, 0x01,44 0x11, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};45 }46 47 blt::bitmap define EnergyLevels-zoomout {48 #define zoomout_width 1249 #define zoomout_height 1250 static unsigned char zoomout_bits[] = {51 0x7c, 0x00, 0x82, 0x00, 0x01, 0x01, 0x01, 0x01, 0x7d, 0x01, 0x01, 0x01,52 0x01, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};53 }54 55 blt::bitmap define EnergyLevels-rdiag {56 #define rdiag_width 857 #define rdiag_height 858 static unsigned char rdiag_bits[] = {59 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99, 0xcc};60 }61 62 30 63 31 itcl::class Rappture::EnergyLevels { … … 132 100 button $itk_component(controls).reset \ 133 101 -borderwidth 1 -padx 1 -pady 1 \ 134 -bitmap EnergyLevels-reset\102 -bitmap [Rappture::icon reset] \ 135 103 -command [itcl::code $this _zoom reset] 136 104 } { … … 144 112 button $itk_component(controls).zin \ 145 113 -borderwidth 1 -padx 1 -pady 1 \ 146 -bitmap EnergyLevels-zoomin\114 -bitmap [Rappture::icon zoomin] \ 147 115 -command [itcl::code $this _zoom in] 148 116 } { … … 157 125 button $itk_component(controls).zout \ 158 126 -borderwidth 1 -padx 1 -pady 1 \ 159 -bitmap EnergyLevels-zoomout\127 -bitmap [Rappture::icon zoomout] \ 160 128 -command [itcl::code $this _zoom out] 161 129 } { … … 508 476 set y [expr {($_ehomo-$_emin)*$e2y + $yzoom0}] 509 477 set id [$c create rectangle $xx0 $y $xx1 $y0 \ 510 -stipple EnergyLevels-rdiag\478 -stipple [Rappture::icon rdiag] \ 511 479 -outline "" -fill $itk_option(-shadecolor)] 512 480 $c lower $id … … 623 591 if {$yy0 < $y0} { 624 592 set id [$c create rectangle $xx2 $yy0 $xx3 $y0 \ 625 -stipple EnergyLevels-rdiag\593 -stipple [Rappture::icon rdiag] \ 626 594 -outline "" -fill $itk_option(-shadecolor) \ 627 595 -tags zlabels] -
trunk/gui/scripts/filexfer.tcl
r213 r413 27 27 namespace eval Rappture::filexfer { 28 28 variable enabled 0 ;# set to 1 when this is running 29 variable port 9001;# start server on this port29 variable port 0 ;# start server on this port 30 30 variable cookie "" ;# magic cookie for applet auth 31 31 variable restrictClientAddress "" ;# allow clients only from this addr … … 75 75 } 76 76 77 # 78 # Set up a safe interpreter for loading filexfer options... 79 # 80 variable optionParser [interp create -safe] 81 foreach cmd [$optionParser eval {info commands}] { 82 $optionParser hide $cmd 83 } 84 # this lets us ignore unrecognized commands in the file: 85 $optionParser invokehidden proc unknown {args} {} 86 87 $optionParser alias filexfer_port Rappture::filexfer::option_port 88 $optionParser alias filexfer_cookie Rappture::filexfer::option_cookie 89 $optionParser alias filexfer_sitelogo Rappture::filexfer::option_sitelogo 90 $optionParser alias filexfer_stylesheet Rappture::filexfer::option_stylesheet 77 } 78 79 # must use this name -- plugs into Rappture::resources::load 80 proc filexfer_init_resources {} { 81 Rappture::resources::register \ 82 filexfer_port Rappture::filexfer::option_port \ 83 filexfer_cookie Rappture::filexfer::option_cookie \ 84 filexfer_sitelogo Rappture::filexfer::option_sitelogo \ 85 filexfer_stylesheet Rappture::filexfer::option_stylesheet 91 86 } 92 87 … … 99 94 # ---------------------------------------------------------------------- 100 95 proc Rappture::filexfer::init {} { 101 global env102 variable optionParser103 96 variable enabled 104 97 variable port … … 109 102 110 103 # 111 # Look for a $SESSION variable and a file called 112 # ~/data/sessions/$SESSION/resources. If found, then 113 # load the settings from that file and start a server 114 # for filexfer. 115 # 116 if {[info exists env(SESSION)]} { 117 set file ~/data/sessions/$env(SESSION)/resources 118 if {![file exists $file]} { 119 return 0 120 } 121 if {[catch { 122 set fid [open $file r] 123 set info [read $fid] 124 close $fid 125 $optionParser eval $info 126 } result]} { 127 after 1 [list tk_messageBox -title Error -icon error -message "Error in resources file:\n$reslt"] 128 return 0 129 } 130 104 # The port setting should have been set properly in the 105 # "resources" file loaded at the beginning of the app. 106 # If it wasn't, then don't do any filexfer. 107 # 108 if {$port > 0} { 131 109 # 132 110 # If the prescribed port is busy, then exit with a special -
trunk/gui/scripts/imageresult.tcl
r193 r413 22 22 -*-helvetica-medium-r-normal-*-*-120-* widgetDefault 23 23 24 blt::bitmap define ImageResult-reset {25 #define reset_width 1226 #define reset_height 1227 static unsigned char reset_bits[] = {28 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02,29 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};30 }31 32 blt::bitmap define ImageResult-zoomin {33 #define zoomin_width 1234 #define zoomin_height 1235 static unsigned char zoomin_bits[] = {36 0x7c, 0x00, 0x82, 0x00, 0x11, 0x01, 0x11, 0x01, 0x7d, 0x01, 0x11, 0x01,37 0x11, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};38 }39 40 blt::bitmap define ImageResult-zoomout {41 #define zoomout_width 1242 #define zoomout_height 1243 static unsigned char zoomout_bits[] = {44 0x7c, 0x00, 0x82, 0x00, 0x01, 0x01, 0x01, 0x01, 0x7d, 0x01, 0x01, 0x01,45 0x01, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};46 }47 48 49 24 itcl::class Rappture::ImageResult { 50 25 inherit itk::Widget … … 105 80 button $itk_component(controls).reset \ 106 81 -borderwidth 1 -padx 1 -pady 1 \ 107 -bitmap ImageResult-reset\82 -bitmap [Rappture::icon reset] \ 108 83 -command [itcl::code $this _zoom reset] 109 84 } { … … 118 93 button $itk_component(controls).zin \ 119 94 -borderwidth 1 -padx 1 -pady 1 \ 120 -bitmap ImageResult-zoomin\95 -bitmap [Rappture::icon zoomin] \ 121 96 -command [itcl::code $this _zoom in] 122 97 } { … … 131 106 button $itk_component(controls).zout \ 132 107 -borderwidth 1 -padx 1 -pady 1 \ 133 -bitmap ImageResult-zoomout\108 -bitmap [Rappture::icon zoomout] \ 134 109 -command [itcl::code $this _zoom out] 135 110 } { -
trunk/gui/scripts/meshresult.tcl
r193 r413 22 22 option add *MeshResult.font \ 23 23 -*-helvetica-medium-r-normal-*-*-120-* widgetDefault 24 25 blt::bitmap define MeshResult-reset {26 #define reset_width 1227 #define reset_height 1228 static unsigned char reset_bits[] = {29 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02,30 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};31 }32 24 33 25 itcl::class Rappture::MeshResult { … … 85 77 button $itk_component(controls).reset \ 86 78 -borderwidth 1 -padx 1 -pady 1 \ 87 -bitmap MeshResult-reset\79 -bitmap [Rappture::icon reset] \ 88 80 -command [itcl::code $this _zoom reset] 89 81 } { -
trunk/gui/scripts/moleculeViewer.tcl
r220 r413 22 22 option add *MoleculeViewer.backdrop black widgetDefault 23 23 24 blt::bitmap define MoleculeViewer-reset {25 #define reset_width 1226 #define reset_height 1227 static unsigned char reset_bits[] = {28 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02,29 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};30 }31 32 blt::bitmap define MoleculeViewer-zoomin {33 #define zoomin_width 1234 #define zoomin_height 1235 static unsigned char zoomin_bits[] = {36 0x7c, 0x00, 0x82, 0x00, 0x11, 0x01, 0x11, 0x01, 0x7d, 0x01, 0x11, 0x01,37 0x11, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};38 }39 40 blt::bitmap define MoleculeViewer-zoomout {41 #define zoomout_width 1242 #define zoomout_height 1243 static unsigned char zoomout_bits[] = {44 0x7c, 0x00, 0x82, 0x00, 0x01, 0x01, 0x01, 0x01, 0x7d, 0x01, 0x01, 0x01,45 0x01, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};46 }47 48 blt::bitmap define MoleculeViewer-atoms {49 #define atoms_width 1250 #define atoms_height 1251 static unsigned char atoms_bits[] = {52 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x02, 0x4c, 0x02, 0xc8, 0x03,53 0x48, 0x02, 0x48, 0x02, 0x5c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};54 }55 56 24 itcl::class Rappture::MoleculeViewer { 57 25 inherit itk::Widget … … 138 106 button $itk_component(controls).reset \ 139 107 -borderwidth 1 -padx 1 -pady 1 \ 140 -bitmap MoleculeViewer-reset\108 -bitmap [Rappture::icon reset] \ 141 109 -command [itcl::code $this _zoom reset] 142 110 } { … … 151 119 button $itk_component(controls).zin \ 152 120 -borderwidth 1 -padx 1 -pady 1 \ 153 -bitmap MoleculeViewer-zoomin\121 -bitmap [Rappture::icon zoomin] \ 154 122 -command [itcl::code $this _zoom in] 155 123 } { … … 164 132 button $itk_component(controls).zout \ 165 133 -borderwidth 1 -padx 1 -pady 1 \ 166 -bitmap MoleculeViewer-zoomout\134 -bitmap [Rappture::icon zoomout] \ 167 135 -command [itcl::code $this _zoom out] 168 136 } { … … 177 145 label $itk_component(controls).labels \ 178 146 -borderwidth 1 -padx 1 -pady 1 \ 179 -bitmap MoleculeViewer-atoms147 -bitmap [Rappture::icon atoms] 180 148 } { 181 149 usual -
trunk/gui/scripts/panes.tcl
r115 r413 16 16 option add *Panes.width 3i widgetDefault 17 17 option add *Panes.height 3i widgetDefault 18 option add *Panes.sashRelief sunken widgetDefault 19 option add *Panes.sashWidth 2 widgetDefault 20 option add *Panes.sashPadding 4 widgetDefault 18 21 option add *Panes.sashCursor sb_v_double_arrow 19 22 … … 22 25 23 26 itk_option define -sashcursor sashCursor SashCursor "" 27 itk_option define -sashrelief sashRelief SashRelief "" 28 itk_option define -sashwidth sashWidth SashWidth 0 29 itk_option define -sashpadding sashPadding SashPadding 0 24 30 25 31 constructor {args} { # defined below } … … 33 39 protected method _drop {pane X Y} 34 40 protected method _fixLayout {args} 41 protected method _fixSashes {args} 35 42 36 43 private variable _dispatcher "" ;# dispatcher for !events … … 54 61 $_dispatcher register !layout 55 62 $_dispatcher dispatch $this !layout [itcl::code $this _fixLayout] 63 $_dispatcher register !sashes 64 $_dispatcher dispatch $this !sashes [itcl::code $this _fixSashes] 56 65 57 66 # fix the layout whenever the window size changes … … 94 103 95 104 itk_component add ${sash}ridge { 96 frame $itk_component($sash).ridge \ 97 -height 2 -borderwidth 1 -relief sunken 105 frame $itk_component($sash).ridge 98 106 } { 99 107 usual 100 108 rename -cursor -sashcursor sashCursor SashCursor 101 } 102 pack $itk_component(${sash}ridge) -fill x -pady 4 109 rename -relief -sashrelief sashRelief SashRelief 110 ignore -borderwidth 111 } 112 pack $itk_component(${sash}ridge) -fill x 103 113 104 114 foreach comp [list $sash ${sash}ridge] { … … 120 130 set f $params(-fraction) 121 131 set _frac [list [expr {1-$f}] $f] 132 133 # fix sash characteristics 134 $_dispatcher event -idle !sashes 122 135 123 136 # make sure we fix up the layout at some point … … 238 251 } 239 252 } 253 254 # ---------------------------------------------------------------------- 255 # USAGE: _fixSashes 256 # 257 # Used internally to fix the appearance of sashes whenever a new 258 # sash appears or the controlling configuration options change. 259 # ---------------------------------------------------------------------- 260 itcl::body Rappture::Panes::_fixSashes {args} { 261 set ht [winfo pixels $itk_component(hull) $itk_option(-sashwidth)] 262 set bd [expr {$ht/2}] 263 foreach pane $_panes { 264 set sash "${pane}sashridge" 265 if {[info exists itk_component($sash)]} { 266 $itk_component($sash) configure -height $ht -borderwidth $bd 267 if {$itk_option(-sashrelief) == "solid"} { 268 $itk_component($sash) configure -background black 269 } else { 270 $itk_component($sash) configure \ 271 -background $itk_option(-background) 272 } 273 pack $itk_component($sash) -pady $itk_option(-sashpadding) 274 } 275 } 276 } 277 278 # ---------------------------------------------------------------------- 279 # CONFIGURATION OPTION: -sashrelief 280 # ---------------------------------------------------------------------- 281 itcl::configbody Rappture::Panes::sashrelief { 282 $_dispatcher event -idle !sashes 283 } 284 285 # ---------------------------------------------------------------------- 286 # CONFIGURATION OPTION: -sashwidth 287 # ---------------------------------------------------------------------- 288 itcl::configbody Rappture::Panes::sashwidth { 289 $_dispatcher event -idle !sashes 290 } 291 292 # ---------------------------------------------------------------------- 293 # CONFIGURATION OPTION: -sashpadding 294 # ---------------------------------------------------------------------- 295 itcl::configbody Rappture::Panes::sashpadding { 296 $_dispatcher event -idle !sashes 297 } -
trunk/gui/scripts/postern.tcl
r171 r413 16 16 package require Itk 17 17 18 blt::bitmap define Postern-dismiss {19 #define dismiss_width 1020 #define dismiss_height 821 static unsigned char dismiss_bits[] = {22 0x87, 0x03, 0xce, 0x01, 0xfc, 0x00, 0x78, 0x00, 0x78, 0x00, 0xfc, 0x00,23 0xce, 0x01, 0x87, 0x03};24 }25 26 18 option add *Postern.size 2 widgetDefault 27 19 option add *Postern.activeColor gray widgetDefault … … 86 78 # 87 79 Rappture::Balloon $itk_component(hull).popup \ 80 -title "Secret Command Console" \ 88 81 -deactivatecommand [itcl::code $this activate off] 89 90 82 set inner [$itk_component(hull).popup component inner] 91 set inner [frame $inner.bd -borderwidth 4 -relief flat]92 pack $inner -expand yes -fill both93 94 button $inner.dismiss -bitmap Postern-dismiss \95 -relief flat -overrelief raised \96 -command [itcl::code $this close]97 pack $inner.dismiss -anchor e98 83 99 84 Rappture::Scroller $inner.area … … 203 188 $itk_component(hull) $itk_option(-popup) 204 189 205 set text [$itk_component(hull).popup component inner]. bd.area.text190 set text [$itk_component(hull).popup component inner].area.text 206 191 focus $text 207 192 … … 226 211 # ---------------------------------------------------------------------- 227 212 itcl::body Rappture::Postern::command {option} { 228 set text [$itk_component(hull).popup component inner]. bd.area.text213 set text [$itk_component(hull).popup component inner].area.text 229 214 230 215 switch -- $option { … … 331 316 } 332 317 333 set text [$itk_component(hull).popup component inner]. bd.area.text318 set text [$itk_component(hull).popup component inner].area.text 334 319 if {$channel == "stdout" || $channel == "stderr"} { 335 320 $text insert end $string $channel -
trunk/gui/scripts/radiodial.tcl
r115 r413 29 29 itk_option define -min min Min "" 30 30 itk_option define -max max Max "" 31 itk_option define -variable variable Variable "" 32 31 33 itk_option define -thickness thickness Thickness 0 32 34 itk_option define -length length Length 0 … … 50 52 public method color {value} 51 53 54 protected method _setCurrent {val} 52 55 protected method _redraw {} 53 56 protected method _click {x y} … … 55 58 protected method _limits {} 56 59 protected method _fixSize {} 60 protected method _fixValue {args} 57 61 58 62 private variable _values "" ;# list of all values on the dial 59 63 private variable _val2label ;# maps value => label 60 64 private variable _current "" ;# current value (where pointer is) 65 private variable _variable "" ;# variable associated with -variable 61 66 62 67 private variable _spectrum "" ;# width allocated for values … … 103 108 # ---------------------------------------------------------------------- 104 109 itcl::body Rappture::Radiodial::destructor {} { 110 configure -variable "" ;# remove variable trace 105 111 after cancel [itcl::code $this _redraw] 106 112 } … … 123 129 124 130 if {"" == $_current} { 125 set _current $value131 _setCurrent $value 126 132 } 127 133 … … 137 143 itcl::body Rappture::Radiodial::clear {} { 138 144 set _values "" 139 set _current ""145 _setCurrent "" 140 146 catch {unset _val2label} 141 147 … … 168 174 set ilist "" 169 175 for {set i 0} {$i < [llength $_values]} {incr i} { 170 append ilist $i176 lappend ilist $i 171 177 } 172 178 } elseif {"current" == $index} { … … 235 241 error "bad value \"$newval\"" 236 242 } 237 set _current $newval243 _setCurrent $newval 238 244 239 245 after cancel [itcl::code $this _redraw] … … 277 283 } 278 284 return $color 285 } 286 287 # ---------------------------------------------------------------------- 288 # USAGE: _setCurrent <value> 289 # 290 # Called automatically whenever the widget changes size to redraw 291 # all elements within it. 292 # ---------------------------------------------------------------------- 293 itcl::body Rappture::Radiodial::_setCurrent {value} { 294 set _current $value 295 if {"" != $_variable} { 296 upvar #0 $_variable var 297 if {[info exists _val2label($value)]} { 298 set var $_val2label($value) 299 } else { 300 set var $value 301 } 302 } 279 303 } 280 304 … … 389 413 390 414 if {$vnearest != $_current} { 391 set _current $vnearest415 _setCurrent $vnearest 392 416 _redraw 393 417 … … 417 441 set newval [lindex $_values $index] 418 442 if {$newval != $_current} { 419 set _current $newval443 _setCurrent $newval 420 444 _redraw 421 445 … … 482 506 483 507 # ---------------------------------------------------------------------- 508 # USAGE: _fixValue ?<name1> <name2> <op>? 509 # 510 # Invoked automatically whenever the -variable associated with this 511 # widget is modified. Copies the value to the current settings for 512 # the widget. 513 # ---------------------------------------------------------------------- 514 itcl::body Rappture::Radiodial::_fixValue {args} { 515 if {"" == $itk_option(-variable)} { 516 return 517 } 518 upvar #0 $itk_option(-variable) var 519 520 set newval $var 521 set found 0 522 foreach v $_values { 523 if {[string equal $_val2label($v) $newval]} { 524 set newval $v 525 set found 1 526 break 527 } 528 } 529 if {!$found && "" != $newval} { 530 error "bad value \"$newval\"" 531 } 532 set _current $newval ;# set current directly, so we don't trigger again 533 534 after cancel [itcl::code $this _redraw] 535 after idle [itcl::code $this _redraw] 536 event generate $itk_component(hull) <<Value>> 537 } 538 539 # ---------------------------------------------------------------------- 484 540 # CONFIGURE: -thickness 485 541 # ---------------------------------------------------------------------- … … 509 565 error "bad value \"$itk_option(-valuewidth)\": should be integer" 510 566 } 567 _fixSize 511 568 after cancel [itcl::code $this _redraw] 512 569 after idle [itcl::code $this _redraw] … … 554 611 after idle [itcl::code $this _redraw] 555 612 } 613 614 # ---------------------------------------------------------------------- 615 # CONFIGURE: -variable 616 # ---------------------------------------------------------------------- 617 itcl::configbody Rappture::Radiodial::variable { 618 if {"" != $_variable} { 619 upvar #0 $_variable var 620 trace remove variable var write [itcl::code $this _fixValue] 621 } 622 623 set _variable $itk_option(-variable) 624 625 if {"" != $_variable} { 626 upvar #0 $_variable var 627 trace add variable var write [itcl::code $this _fixValue] 628 629 # sync to the current value of this variable 630 if {[info exists var]} { 631 _fixValue 632 } 633 } 634 } -
trunk/gui/scripts/resultset.tcl
r170 r413 17 17 option add *ResultSet.height 4i widgetDefault 18 18 option add *ResultSet.missingData skip widgetDefault 19 option add *ResultSet.controlbarBackground gray widgetDefault 20 option add *ResultSet.controlbarForeground white widgetDefault 21 option add *ResultSet.activeControlBackground #ffffcc widgetDefault 22 option add *ResultSet.activeControlForeground black widgetDefault 23 option add *ResultSet.controlActiveForeground blue widgetDefault 19 24 option add *ResultSet.toggleBackground gray widgetDefault 20 25 option add *ResultSet.toggleForeground white widgetDefault … … 27 32 inherit itk::Widget 28 33 34 itk_option define -activecontrolbackground activeControlBackground Background "" 35 itk_option define -activecontrolforeground activeControlForeground Foreground "" 36 itk_option define -controlactiveforeground controlActiveForeground Foreground "" 29 37 itk_option define -togglebackground toggleBackground Background "" 30 38 itk_option define -toggleforeground toggleForeground Foreground "" 31 39 itk_option define -textfont textFont Font "" 32 40 itk_option define -boldfont boldFont Font "" 41 itk_option define -foreground foreground Foreground "" 33 42 itk_option define -missingdata missingData MissingData "" 34 43 itk_option define -clearcommand clearCommand ClearCommand "" … … 41 50 public method add {xmlobj} 42 51 public method clear {} 52 public method activate {column} 43 53 public method contains {xmlobj} 44 54 public method size {{what -results}} … … 46 56 protected method _doClear {} 47 57 protected method _doSettings {{cmd ""}} 58 protected method _doPrompt {state} 59 protected method _control {option args} 48 60 protected method _fixControls {args} 61 protected method _fixLayout {args} 49 62 protected method _fixSettings {args} 50 protected method _doPrompt {state} 51 protected method _toggleAll {path widget} 63 protected method _fixExplore {} 64 protected method _fixValue {column why} 65 protected method _drawValue {column widget wmax} 66 protected method _toggleAll {{column "current"}} 67 protected method _getTooltip {role column} 52 68 53 69 private variable _dispatcher "" ;# dispatchers for !events 54 70 private variable _results "" ;# tuple of known results 55 71 private variable _recent "" ;# most recent result in _results 56 private variable _plotall "" ;# column with "All" active 57 private variable _col2widget ;# maps column name => control widget 72 private variable _active "" ;# column with active control 73 private variable _plotall 0 ;# non-zero => plot all active results 74 private variable _layout ;# info used in _fixLayout 58 75 private variable _counter 0 ;# counter for unique control names 76 private variable _settings 0 ;# non-zero => _fixSettings in progress 77 private variable _explore 0 ;# non-zero => explore all parameters 78 79 private common _cntlInfo ;# maps column name => control info 59 80 } 60 81 … … 75 96 $_dispatcher dispatch $this !fixcntls \ 76 97 [itcl::code $this _fixControls] 98 $_dispatcher register !layout 99 $_dispatcher dispatch $this !layout \ 100 [itcl::code $this _fixLayout] 77 101 $_dispatcher register !settings 78 102 $_dispatcher dispatch $this !settings \ 79 103 [itcl::code $this _fixSettings] 80 104 105 # initialize controls info 106 set _cntlInfo($this-all) "" 107 108 # initialize layout info 109 set _layout(mode) "usual" 110 set _layout(active) "" 111 81 112 # create a list of tuples for data 82 113 set _results [Rappture::Tuples ::#auto] … … 86 117 itk_component add cntls { 87 118 frame $itk_interior.cntls 88 } 89 pack $itk_component(cntls) -fill x 119 } { 120 usual 121 rename -background -controlbarbackground controlbarBackground Background 122 rename -highlightbackground -controlbarbackground controlbarBackground Background 123 } 124 pack $itk_component(cntls) -fill x -pady {0 2} 90 125 91 126 itk_component add clear { 92 127 button $itk_component(cntls).clear -text "Clear" -state disabled \ 128 -padx 1 -pady 1 \ 93 129 -relief flat -overrelief raised \ 94 130 -command [itcl::code $this _doClear] 95 } 96 pack $itk_component(clear) -side right 131 } { 132 usual 133 rename -background -controlbarbackground controlbarBackground Background 134 rename -foreground -controlbarforeground controlbarForeground Foreground 135 rename -highlightbackground -controlbarbackground controlbarBackground Background 136 } 137 pack $itk_component(clear) -side right -padx 2 -pady 1 97 138 Rappture::Tooltip::for $itk_component(clear) \ 98 139 "Clears all results collected so far." 99 140 100 141 itk_component add status { 101 label $itk_component(cntls).status -anchor w -text "No results" 102 } 103 pack $itk_component(status) -side left -expand yes -fill x 104 105 itk_component add scroller { 106 Rappture::Scroller $itk_interior.scroller \ 107 -xscrollmode off -yscrollmode auto -height 1i 108 } 109 pack $itk_component(scroller) -expand yes -fill both 142 label $itk_component(cntls).status -anchor w \ 143 -text "No results" -padx 0 -pady 0 144 } { 145 usual 146 rename -background -controlbarbackground controlbarBackground Background 147 rename -foreground -controlbarforeground controlbarForeground Foreground 148 rename -highlightbackground -controlbarbackground controlbarBackground Background 149 } 150 pack $itk_component(status) -side left -padx 2 -pady {2 0} 151 152 itk_component add parameters { 153 button $itk_component(cntls).params -text "Parameters..." \ 154 -state disabled -padx 1 -pady 1 \ 155 -relief flat -overrelief raised \ 156 -command [list $itk_component(hull).popup activate $itk_component(cntls).params above] 157 } { 158 usual 159 rename -background -controlbarbackground controlbarBackground Background 160 rename -foreground -controlbarforeground controlbarForeground Foreground 161 rename -highlightbackground -controlbarbackground controlbarBackground Background 162 } 163 pack $itk_component(parameters) -side left -padx 8 -pady 1 164 Rappture::Tooltip::for $itk_component(parameters) \ 165 "Click to access all parameters." 166 167 itk_component add dials { 168 frame $itk_interior.dials 169 } 170 pack $itk_component(dials) -expand yes -fill both 171 bind $itk_component(dials) <Configure> \ 172 [list $_dispatcher event -after 10 !layout why resize] 173 174 # create the permanent controls in the "short list" area 175 set dials $itk_component(dials) 176 frame $dials.bg 177 Rappture::Radiodial $dials.dial -valuewidth 0 178 Rappture::Tooltip::for $dials.dial \ 179 "@[itcl::code $this _getTooltip dial active]" 180 181 set fn [option get $itk_component(hull) textFont Font] 182 label $dials.all -text "All" -padx 8 \ 183 -borderwidth 1 -relief raised -font $fn 184 Rappture::Tooltip::for $dials.all \ 185 "@[itcl::code $this _getTooltip all active]" 186 bind $dials.all <ButtonRelease> [itcl::code $this _toggleAll] 187 188 frame $dials.labelmore 189 label $dials.labelmore.arrow -bitmap [Rappture::icon empty] -borderwidth 0 190 pack $dials.labelmore.arrow -side left -fill y 191 _control bind $dials.labelmore.arrow @more 192 label $dials.labelmore.name -text "more parameters..." -font $fn \ 193 -borderwidth 0 -padx 0 -pady 1 194 pack $dials.labelmore.name -side left 195 label $dials.labelmore.value 196 pack $dials.labelmore.value -side left 197 _control bind $dials.labelmore.name @more 198 Rappture::Tooltip::for $dials.labelmore \ 199 "@[itcl::code $this _getTooltip more more]" 200 201 # use this pop-up for access to all controls 202 Rappture::Balloon $itk_component(hull).popup \ 203 -title "Change Parameters" -padx 0 -pady 0 204 set inner [$itk_component(hull).popup component inner] 205 206 frame $inner.cntls 207 pack $inner.cntls -side bottom -fill x 208 frame $inner.cntls.sep -height 2 -borderwidth 1 -relief sunken 209 pack $inner.cntls.sep -side top -fill x -padx 4 -pady 4 210 checkbutton $inner.cntls.explore -font $fn \ 211 -text "Explore combinations with no results" \ 212 -variable [itcl::scope _explore] \ 213 -command [itcl::code $this _fixExplore] 214 pack $inner.cntls.explore -side top -anchor w 215 Rappture::Tooltip::for $inner.cntls.explore \ 216 "When this option is turned on, you can set parameters to various combinations that have not yet been simulated. The Simulate button will light up, and you can simulate these missing combinations.\n\nWhen turned off, controls will avoid missing combinations, and automatically snap to the closest available dataset." 217 218 itk_component add options { 219 Rappture::Scroller $inner.scrl -xscrollmode auto -yscrollmode auto 220 } 221 pack $itk_component(options) -expand yes -fill both 222 223 set popup [$itk_component(options) contents frame] 224 frame $popup.bg 110 225 111 226 eval itk_initialize $args … … 143 258 $itk_component(status) configure -text "1 result" 144 259 $itk_component(clear) configure -state normal 260 if {[$_results size] >= 2} { 261 $itk_component(parameters) configure -state normal 262 } else { 263 $itk_component(parameters) configure -state disabled 264 } 145 265 return 0 146 266 } … … 204 324 } else { 205 325 $itk_component(status) configure -text "[$_results size] results" 326 $itk_component(parameters) configure -state normal 206 327 } 207 328 $itk_component(clear) configure -state normal … … 219 340 220 341 # delete all adjuster controls 221 set f [$itk_component(scroller) contents frame] 222 foreach w [winfo children $f] { 223 destroy $w 224 } 225 catch {unset _col2widget} 226 set _plotall "" 342 set popup [$itk_component(options) contents frame] 343 set shortlist $itk_component(dials) 344 foreach col $_cntlInfo($this-all) { 345 set id $_cntlInfo($this-$col-id) 346 destroy $popup.label$id $popup.dial$id $popup.all$id 347 destroy $shortlist.label$id 348 } 349 350 # clean up control info 351 foreach key [array names _cntlInfo $this-*] { 352 catch {unset _cntlInfo($key)} 353 } 354 set _cntlInfo($this-all) "" 227 355 set _counter 0 228 229 # don't need to scroll adjustor controls right now230 $itk_component(scroller) configure -yscrollmode off231 356 232 357 # clear out all results … … 234 359 eval $_results column delete [lrange [$_results column names] 1 end] 235 360 set _recent "" 361 set _active "" 362 363 set _plotall 0 364 $itk_component(dials).all configure -relief raised \ 365 -background $itk_option(-background) \ 366 -foreground $itk_option(-foreground) 236 367 237 368 # update status and Clear button 238 369 $itk_component(status) configure -text "No results" 370 $itk_component(parameters) configure -state disabled 239 371 $itk_component(clear) configure -state disabled 240 372 $_dispatcher event -idle !fixcntls 373 374 # let clients know that the number of controls has changed 375 event generate $itk_component(hull) <<Control>> 376 } 377 378 # ---------------------------------------------------------------------- 379 # USAGE: activate <column> 380 # 381 # Clients use this to activate a particular column in the set of 382 # controls. When a column is active, its label is bold and its 383 # value has a radiodial in the "short list" area. 384 # ---------------------------------------------------------------------- 385 itcl::body Rappture::ResultSet::activate {column} { 386 if {$column == "@more"} { 387 $itk_component(hull).popup activate \ 388 $itk_component(dials).labelmore.name above 389 return 390 } 391 392 set allowed [$_results column names] 393 if {[lsearch $allowed $column] < 0} { 394 error "bad value \"$column\": should be one of [join $allowed {, }]" 395 } 396 397 # column is now active 398 set _active $column 399 400 # keep track of usage, so we know which controls are popular 401 incr _cntlInfo($this-$column-usage) 402 403 # fix controls at next idle point 404 $_dispatcher event -idle !layout why data 405 $_dispatcher event -idle !settings column $_active 241 406 } 242 407 … … 310 475 311 476 # ---------------------------------------------------------------------- 312 # USAGE: size ?-results|-controls? 313 # 314 # Returns the number of results or the number of controls in this 315 # result set. 477 # USAGE: size ?-results|-controls|-controlarea? 478 # 479 # Returns various measures for the size of this area: 480 # -results ....... number of results loaded 481 # -controls ...... number of distinct control parameters 482 # -controlarea ... minimum size of usable control area, in pixels 316 483 # ---------------------------------------------------------------------- 317 484 itcl::body Rappture::ResultSet::size {{what -results}} { … … 321 488 } 322 489 -controls { 323 return [array size _col2widget] 490 return [llength $_cntlInfo($this-all)] 491 } 492 -controlarea { 493 set ht [winfo reqheight $itk_component(cntls)] 494 incr ht 2 ;# padding below controls 495 496 set normalLine [font metrics $itk_option(-textfont) -linespace] 497 incr normalLine 2 ;# padding 498 set boldLine [font metrics $itk_option(-boldfont) -linespace] 499 incr boldLine 2 ;# padding 500 501 set numcntls [llength $_cntlInfo($this-all)] 502 switch -- $numcntls { 503 0 - 1 { 504 # 0 = no controls (no data at all) 505 # 1 = run control, but only 1 run so far 506 # add nothing 507 } 508 default { 509 # non-active controls 510 incr ht [expr {($numcntls-1)*$normalLine}] 511 # active control 512 incr ht $boldLine 513 # dial for active control 514 incr ht [winfo reqheight $itk_component(dials).dial] 515 # padding around active control 516 incr ht 4 517 } 518 } 519 return $ht 324 520 } 325 521 default { 326 error "bad option \"$what\": should be -results or -controls"522 error "bad option \"$what\": should be -results, -controls, or -controlarea" 327 523 } 328 524 } … … 356 552 357 553 # ---------------------------------------------------------------------- 554 # USAGE: _doPrompt <state> 555 # 556 # Used internally whenever the current settings represent a point 557 # with no data. Invokes the -promptcommand with an explanation of 558 # the missing data, prompting the user to simulate it. 559 # ---------------------------------------------------------------------- 560 itcl::body Rappture::ResultSet::_doPrompt {state} { 561 if {[string length $itk_option(-promptcommand)] > 0} { 562 if {$state} { 563 set message "No data for these settings" 564 set settings "" 565 foreach col [lrange [$_results column names] 1 end] { 566 set val $_cntlInfo($this-$col-value) 567 lappend settings $col $val 568 } 569 uplevel #0 $itk_option(-promptcommand) [list on $message $settings] 570 } else { 571 uplevel #0 $itk_option(-promptcommand) off 572 } 573 } 574 } 575 576 # ---------------------------------------------------------------------- 577 # USAGE: _control bind <widget> <column> 578 # USAGE: _control hilite <state> <column> <panel> 579 # USAGE: _control load <widget> <column> 580 # 581 # Used internally to manage the interactivity of controls. The "bind" 582 # operation sets up bindings on the label/value for each control, so 583 # you can mouse over and click on a control to activate it. The 584 # "hilite" operation controls highlighting of the control. The "load" 585 # operation loads data into the specified radiodial <widget>. 586 # ---------------------------------------------------------------------- 587 itcl::body Rappture::ResultSet::_control {option args} { 588 switch -- $option { 589 bind { 590 if {[llength $args] != 2} { 591 error "wrong # args: should be _control bind widget column" 592 } 593 set widget [lindex $args 0] 594 set col [lindex $args 1] 595 596 set panel [winfo parent $widget] 597 if {[string match label* [winfo name $panel]]} { 598 set panel [winfo parent $panel] 599 } 600 601 bind $widget <Enter> \ 602 [itcl::code $this _control hilite on $col $panel] 603 bind $widget <Leave> \ 604 [itcl::code $this _control hilite off $col $panel] 605 bind $widget <ButtonRelease> [itcl::code $this activate $col] 606 } 607 hilite { 608 if {[llength $args] != 3} { 609 error "wrong # args: should be _control hilite state column panel" 610 } 611 if {$_layout(mode) != "usual"} { 612 # abbreviated controls? then skip highlighting 613 return 614 } 615 set state [lindex $args 0] 616 set col [lindex $args 1] 617 set panel [lindex $args 2] 618 619 if {[string index $col 0] == "@"} { 620 # handle artificial names like "@more" 621 set id [string range $col 1 end] 622 } else { 623 # get id for ordinary columns 624 set id $_cntlInfo($this-$col-id) 625 } 626 627 # highlight any non-active entries 628 if {$col != $_active} { 629 if {$state} { 630 set fg $itk_option(-controlactiveforeground) 631 $panel.label$id.name configure -fg $fg 632 $panel.label$id.value configure -fg $fg 633 $panel.label$id.arrow configure -fg $fg \ 634 -bitmap [Rappture::icon rarrow2] 635 } else { 636 set fg $itk_option(-foreground) 637 $panel.label$id.name configure -fg $fg 638 $panel.label$id.value configure -fg $fg 639 $panel.label$id.arrow configure -fg $fg \ 640 -bitmap [Rappture::icon empty] 641 } 642 } 643 } 644 load { 645 if {[llength $args] != 2} { 646 error "wrong # args: should be _control load widget column" 647 } 648 set dial [lindex $args 0] 649 set col [lindex $args 1] 650 651 if {$col == "xmlobj"} { 652 # load the Simulation # control 653 set nruns [$_results size] 654 655 # load the results into the control 656 $dial clear 657 for {set n 0} {$n < $nruns} {incr n} { 658 $dial add "#[expr {$n+1}]" $n 659 } 660 return 661 } 662 663 set havenums 1 664 set vlist "" 665 foreach rec [$_results get -format [list xmlobj $col]] { 666 set xo [lindex $rec 0] 667 set v [lindex $rec 1] 668 669 if {![info exists values($v)]} { 670 lappend vlist $v 671 foreach {raw norm} [Rappture::LibraryObj::value $xo $col] break 672 set values($v) $norm 673 674 if {$havenums && ![string is double $norm]} { 675 set havenums 0 676 } 677 } 678 } 679 680 if {!$havenums} { 681 # don't have normalized nums? then sort and create nums 682 catch {unset values} 683 684 set n 0 685 foreach v [lsort $vlist] { 686 set values($v) [incr n] 687 } 688 } 689 690 # load the results into the control 691 $dial clear 692 foreach v [array names values] { 693 $dial add $v $values($v) 694 } 695 } 696 default { 697 error "bad option \"$option\": should be bind, hilite, or load" 698 } 699 } 700 } 701 702 # ---------------------------------------------------------------------- 358 703 # USAGE: _fixControls ?<eventArgs...>? 359 704 # … … 363 708 # ---------------------------------------------------------------------- 364 709 itcl::body Rappture::ResultSet::_fixControls {args} { 365 set f [$itk_component(scroller) contents frame]366 grid columnconfigure $f 1 -weight 1367 368 710 if {[$_results size] == 0} { 369 711 return 370 712 } 371 713 714 set popup [$itk_component(options) contents frame] 715 grid columnconfigure $popup 0 -minsize 16 716 grid columnconfigure $popup 1 -weight 1 717 718 set shortlist $itk_component(dials) 719 grid columnconfigure $shortlist 1 -weight 1 720 372 721 # 373 722 # Scan through all columns in the data and create any 374 723 # controls that just appeared. 375 724 # 376 foreach col [lrange [$_results column names] 1 end] { 725 set nadded 0 726 foreach col [$_results column names] { 377 727 set xmlobj [$_results get -format xmlobj 0] 378 728 … … 381 731 # create one. 382 732 # 383 if {![info exists _c ol2widget($col)]} {384 # add an "All" button to plot all results385 label $f.all$_counter -text "All" -padx 8 \386 -borderwidth 1 -relief raised -font $itk_option(-textfont) 387 grid $f.all$_counter -row $_counter -column 0 \388 -padx 8 -pady 2 -sticky nsew389 Rappture::Tooltip::for $f.all$_counter "Plot all values for this quantity"390 391 bind $f.all$_counter <ButtonPress> \392 [itcl::code $this _toggleAll $col $f.all$_counter]393 394 # search for the first XML object with this element defined395 foreach xmlobj [$_results get -format xmlobj] {396 set str [$xmlobj get $col.about.label]397 if {"" == $str} {398 set str [$xmlobj element -as id $col]733 if {![info exists _cntlInfo($this-$col-id)]} { 734 set row [lindex [grid size $popup] 1] 735 set row2 [expr {$row+1}] 736 737 set tip "" 738 if {$col == "xmlobj"} { 739 set quantity "Simulation" 740 set tip "List of all simulations that you have performed so far." 741 } else { 742 # search for the first XML object with this element defined 743 foreach xmlobj [$_results get -format xmlobj] { 744 set quantity [$xmlobj get $col.about.label] 745 set tip [$xmlobj get $col.about.description] 746 if {"" != $quantity} { 747 break 748 } 399 749 } 400 if {"" != $str} {401 break750 if {"" == $quantity && "" != $xmlobj} { 751 set quantity [$xmlobj element -as id $col] 402 752 } 403 753 } 404 754 405 if {"" != $str} { 406 set w $f.label$_counter 407 label $w -text $str -anchor w -font $itk_option(-boldfont) 408 grid $w -row $_counter -column 1 -sticky w 409 410 grid $f.all$_counter -rowspan 2 411 Rappture::Tooltip::for $f.all$_counter "Plot all values for $str" 412 incr _counter 413 } 414 415 set w $f.cntl$_counter 416 Rappture::Radiodial $w 417 grid $w -row $_counter -column 1 -sticky ew 418 bind $w <<Value>> \ 419 [itcl::code $_dispatcher event -after 100 !settings column $col widget $w] 420 set _col2widget($col) $w 755 # 756 # Build the main control in the pop-up panel. 757 # 758 set fn $itk_option(-textfont) 759 set w $popup.label$_counter 760 frame $w 761 grid $w -row $row -column 2 -sticky ew -padx 4 -pady {4 0} 762 label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0 763 pack $w.arrow -side left -fill y 764 _control bind $w.arrow $col 765 766 label $w.name -text $quantity -anchor w \ 767 -borderwidth 0 -padx 0 -pady 1 -font $fn 768 pack $w.name -side left 769 bind $w.name <Configure> [itcl::code $this _fixValue $col resize] 770 _control bind $w.name $col 771 772 label $w.value -anchor w \ 773 -borderwidth 0 -padx 0 -pady 1 -font $fn 774 pack $w.value -side left 775 bind $w.value <Configure> [itcl::code $this _fixValue $col resize] 776 _control bind $w.value $col 777 778 Rappture::Tooltip::for $w \ 779 "@[itcl::code $this _getTooltip label $col]" 780 781 set w $popup.dial$_counter 782 Rappture::Radiodial $w -valuewidth 0 783 grid $w -row $row2 -column 2 -sticky ew -padx 4 -pady {0 4} 784 $w configure -variable ::Rappture::ResultSet::_cntlInfo($this-$col-value) 785 Rappture::Tooltip::for $w \ 786 "@[itcl::code $this _getTooltip dial $col]" 787 788 set w $popup.all$_counter 789 label $w -text "All" -padx 8 \ 790 -borderwidth 1 -relief raised -font $fn 791 grid $w -row $row -rowspan 2 -column 1 -sticky nsew -padx 2 -pady 4 792 Rappture::Tooltip::for $w \ 793 "@[itcl::code $this _getTooltip all $col]" 794 bind $w <ButtonRelease> [itcl::code $this _toggleAll $col] 795 796 # Create the controls for the "short list" area. 797 set w $shortlist.label$_counter 798 frame $w 799 grid $w -row $row -column 1 -sticky ew 800 label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0 801 pack $w.arrow -side left -fill y 802 _control bind $w.arrow $col 803 804 label $w.name -text $quantity -anchor w \ 805 -borderwidth 0 -padx 0 -pady 1 -font $fn 806 pack $w.name -side left 807 bind $w.name <Configure> [itcl::code $this _fixValue $col resize] 808 _control bind $w.name $col 809 810 label $w.value -anchor w \ 811 -borderwidth 0 -padx 0 -pady 1 -font $fn 812 pack $w.value -side left 813 bind $w.value <Configure> [itcl::code $this _fixValue $col resize] 814 _control bind $w.value $col 815 816 Rappture::Tooltip::for $w \ 817 "@[itcl::code $this _getTooltip label $col]" 818 819 # if this is the "Simulation #" control, add a separator 820 if {$col == "xmlobj"} { 821 grid $popup.all$_counter -column 0 822 grid $popup.label$_counter -column 1 -columnspan 2 823 grid $popup.dial$_counter -column 1 -columnspan 2 824 825 if {![winfo exists $popup.sep]} { 826 frame $popup.sep -height 1 -borderwidth 0 -background black 827 } 828 grid $popup.sep -row [expr {$row+2}] -column 0 \ 829 -columnspan 3 -sticky ew -pady 4 830 831 if {![winfo exists $popup.paraml]} { 832 label $popup.paraml -text "Parameters:" -font $fn 833 } 834 grid $popup.paraml -row [expr {$row+3}] -column 0 \ 835 -columnspan 3 -sticky w -padx 4 -pady {0 4} 836 } 837 838 # create a record for this control 839 lappend _cntlInfo($this-all) $col 840 set _cntlInfo($this-$col-id) $_counter 841 set _cntlInfo($this-$col-label) $quantity 842 set _cntlInfo($this-$col-tip) $tip 843 set _cntlInfo($this-$col-value) "" 844 set _cntlInfo($this-$col-usage) 0 845 set _cntlInfo($this-$col) "" 846 847 trace add variable _cntlInfo($this-$col-value) write \ 848 "[itcl::code $this _fixValue $col value]; list" 421 849 422 850 incr _counter 423 grid rowconfigure $f $_counter -minsize 4 424 incr _counter 425 426 $itk_component(scroller) configure -yscrollmode auto 851 852 # fix the shortlist layout to show as many controls as we can 853 $_dispatcher event -now !layout why data 427 854 428 855 # let clients know that a new control appeared … … 435 862 # them into the control. 436 863 # 437 catch {unset values} 438 set havenums 1 439 set vlist "" 440 foreach rec [$_results get -format [list xmlobj $col]] { 441 set xo [lindex $rec 0] 442 set v [lindex $rec 1] 443 444 if {![info exists values($v)]} { 445 lappend vlist $v 446 foreach {raw norm} [Rappture::LibraryObj::value $xo $col] break 447 set values($v) $norm 448 449 if {$havenums && ![string is double $norm]} { 450 set havenums 0 864 set id $_cntlInfo($this-$col-id) 865 set popup [$itk_component(options) contents frame] 866 set dial $popup.dial$id 867 868 _control load $popup.dial$id $col 869 870 if {$col == $_layout(active)} { 871 $shortlist.dial configure -variable "" 872 _control load $shortlist.dial $col 873 $shortlist.dial configure -variable \ 874 "::Rappture::ResultSet::_cntlInfo($this-$col-value)" 875 } 876 incr nadded 877 } 878 879 # 880 # Activate the most recent control. If a bunch of controls 881 # were just added, then activate the "Simulation" control, 882 # since that's the easiest way to page through results. 883 # 884 if {$nadded > 0} { 885 if {[$_results column names] == 2 || $nadded == 1} { 886 activate [lindex $_cntlInfo($this-all) end] 887 } else { 888 activate xmlobj 889 } 890 } 891 892 # 893 # Set all controls to the settings of the most recent addition. 894 # Setting the value slot will trigger the !settings event, which 895 # will then fix all other controls to match the one that changed. 896 # 897 if {"" != $_recent} { 898 set raw [lindex [$_results find -format xmlobj $_recent] 0] 899 set raw "#[expr {$raw+1}]" 900 set _cntlInfo($this-xmlobj-value) $raw 901 } 902 } 903 904 # ---------------------------------------------------------------------- 905 # USAGE: _fixLayout ?<eventArgs...>? 906 # 907 # Called automatically at the idle point after the controls have 908 # changed, or the size of the window has changed. Fixes the layout 909 # so that the active control is displayed, and other recent controls 910 # are shown above and/or below. At the very least, we must show the 911 # "more options..." control, which pops up a panel of all controls. 912 # ---------------------------------------------------------------------- 913 itcl::body Rappture::ResultSet::_fixLayout {args} { 914 array set eventdata $args 915 916 set popup [$itk_component(options) contents frame] 917 set shortlist $itk_component(dials) 918 919 # clear out the short list area 920 foreach w [grid slaves $shortlist] { 921 grid forget $w 922 } 923 924 # reset all labels back to an ordinary font/background 925 set fn $itk_option(-textfont) 926 set bg $itk_option(-background) 927 set fg $itk_option(-foreground) 928 foreach col $_cntlInfo($this-all) { 929 set id $_cntlInfo($this-$col-id) 930 $popup.label$id configure -background $bg 931 $popup.label$id.arrow configure -background $bg \ 932 -bitmap [Rappture::icon empty] 933 $popup.label$id.name configure -font $fn -background $bg 934 $popup.label$id.value configure -background $bg 935 $popup.all$id configure -background $bg -foreground $fg \ 936 -relief raised 937 $popup.dial$id configure -background $bg 938 $shortlist.label$id configure -background $bg 939 $shortlist.label$id.arrow configure -background $bg \ 940 -bitmap [Rappture::icon empty] 941 $shortlist.label$id.name configure -font $fn -background $bg 942 $shortlist.label$id.value configure -background $bg 943 } 944 945 # only 1 result? then we don't need any controls 946 if {[$_results size] < 2} { 947 return 948 } 949 950 # compute the number of controls that will fit in the shortlist area 951 set dials $itk_component(dials) 952 set h [winfo height $dials] 953 set normalLine [font metrics $itk_option(-textfont) -linespace] 954 set boldLine [font metrics $itk_option(-boldfont) -linespace] 955 set active [expr {$boldLine+[winfo reqheight $dials.dial]+4}] 956 957 if {$h < $active+$normalLine} { 958 # active control kinda big? then show parameter values only 959 set _layout(mode) abbreviated 960 set ncntls [expr {int(floor(double($h)/$normalLine))}] 961 } else { 962 set _layout(mode) usual 963 set ncntls [expr {int(floor(double($h-$active)/$normalLine))+1}] 964 } 965 966 # find the controls with the most usage 967 set order "" 968 foreach col $_cntlInfo($this-all) { 969 lappend order [list $col $_cntlInfo($this-$col-usage)] 970 } 971 set order [lsort -integer -decreasing -index 1 $order] 972 973 set mostUsed "" 974 if {[llength $order] <= $ncntls} { 975 # plenty of space? then show all controls 976 foreach item $order { 977 lappend mostUsed [lindex $item 0] 978 } 979 } else { 980 # otherwise, limit to the most-used controls 981 foreach item [lrange $order 0 [expr {$ncntls-1}]] { 982 lappend mostUsed [lindex $item 0] 983 } 984 985 # make sure the active control is included 986 if {"" != $_active && [lsearch -exact $mostUsed $_active] < 0} { 987 set mostUsed [lreplace [linsert $mostUsed 0 $_active] end end] 988 } 989 990 # if there are more controls, add the "more parameters..." entry 991 if {$ncntls > 2} { 992 set mostUsed [lreplace $mostUsed end end @more] 993 set rest [expr {[llength $order]-($ncntls-1)}] 994 if {$rest == 1} { 995 $dials.labelmore.name configure -text "1 more parameter..." 996 } else { 997 $dials.labelmore.name configure -text "$rest more parameters..." 998 } 999 } 1000 } 1001 1002 # draw the active control 1003 set row 0 1004 foreach col [concat $_cntlInfo($this-all) @more] { 1005 # this control not on the short list? then ignore it 1006 if {[lsearch $mostUsed $col] < 0} { 1007 continue 1008 } 1009 1010 if {[string index $col 0] == "@"} { 1011 set id [string range $col 1 end] 1012 } else { 1013 set id $_cntlInfo($this-$col-id) 1014 } 1015 grid $shortlist.label$id -row $row -column 1 -sticky ew -padx 4 1016 1017 if {$col == $_active} { 1018 # put the background behind the active control in the popup 1019 set id $_cntlInfo($this-$_active-id) 1020 array set ginfo [grid info $popup.label$id] 1021 grid $popup.bg -row $ginfo(-row) -rowspan 2 \ 1022 -column 0 -columnspan 3 -sticky nsew 1023 lower $popup.bg 1024 1025 if {$_layout(mode) == "usual"} { 1026 # put the background behind the active control in the shortlist 1027 grid $shortlist.bg -row $row -rowspan 2 \ 1028 -column 0 -columnspan 2 -sticky nsew 1029 lower $shortlist.bg 1030 1031 # place the All and dial in the shortlist area 1032 grid $shortlist.all -row $row -rowspan 2 -column 0 \ 1033 -sticky nsew -padx 2 -pady 2 1034 grid $shortlist.dial -row [expr {$row+1}] -column 1 \ 1035 -sticky ew -padx 4 1036 incr row 1037 1038 if {$_layout(active) != $_active} { 1039 $shortlist.dial configure -variable "" 1040 _control load $shortlist.dial $col 1041 $shortlist.dial configure -variable \ 1042 "::Rappture::ResultSet::_cntlInfo($this-$col-value)" 1043 set _layout(active) $_active 451 1044 } 452 1045 } 453 1046 } 454 455 if {!$havenums} { 456 # don't have normalized nums? then sort and create nums 457 catch {unset values} 458 459 set n 0 460 foreach v [lsort $vlist] { 461 set values($v) [incr n] 462 } 463 } 464 465 # load the results into the control 466 set w $_col2widget($col) 467 $w clear 468 foreach v [array names values] { 469 $w add $v $values($v) 470 } 471 } 472 473 # 474 # Set all controls to the settings of the most recent 475 # addition. 476 # 477 if {"" != $_recent} { 478 foreach col [array names _col2widget] { 479 set raw [lindex [Rappture::LibraryObj::value $_recent $col] 0] 480 $_col2widget($col) current $raw 481 } 482 } 483 484 # fix the settings after everything settles 485 $_dispatcher event -after 100 !settings 1047 incr row 1048 } 1049 1050 # highlight the active control 1051 if {[info exists _cntlInfo($this-$_active-id)]} { 1052 set id $_cntlInfo($this-$_active-id) 1053 set bf $itk_option(-boldfont) 1054 set fg $itk_option(-activecontrolforeground) 1055 set bg $itk_option(-activecontrolbackground) 1056 1057 $popup.label$id configure -background $bg 1058 $popup.label$id.arrow configure -foreground $fg -background $bg \ 1059 -bitmap [Rappture::icon rarrow] 1060 $popup.label$id.name configure -foreground $fg -background $bg \ 1061 -font $bf 1062 $popup.label$id.value configure -foreground $fg -background $bg 1063 $popup.dial$id configure -background $bg 1064 $popup.bg configure -background $bg 1065 1066 if {$_plotall} { 1067 $popup.all$id configure -relief sunken \ 1068 -background $itk_option(-togglebackground) \ 1069 -foreground $itk_option(-toggleforeground) 1070 } else { 1071 $popup.all$id configure -relief raised \ 1072 -background $itk_option(-activecontrolbackground) \ 1073 -foreground $itk_option(-activecontrolforeground) 1074 } 1075 1076 if {$_layout(mode) == "usual"} { 1077 $shortlist.label$id configure -background $bg 1078 $shortlist.label$id.arrow configure -foreground $fg \ 1079 -background $bg -bitmap [Rappture::icon rarrow] 1080 $shortlist.label$id.name configure -foreground $fg \ 1081 -background $bg -font $bf 1082 $shortlist.label$id.value configure -foreground $fg \ 1083 -background $bg 1084 $shortlist.dial configure -background $bg 1085 $shortlist.bg configure -background $bg 1086 1087 if {[$shortlist.all cget -relief] == "raised"} { 1088 $shortlist.all configure -foreground $fg -background $bg 1089 } 1090 } 1091 } 486 1092 } 487 1093 … … 497 1103 # ---------------------------------------------------------------------- 498 1104 itcl::body Rappture::ResultSet::_fixSettings {args} { 1105 array set eventdata $args 1106 if {[info exists eventdata(column)]} { 1107 set changed $eventdata(column) 1108 } else { 1109 set changed "" 1110 } 499 1111 _doPrompt off 500 1112 … … 512 1124 513 1125 # 1126 # Find the selected run. If the run setting changed, then 1127 # look at its current value. Otherwise, search the results 1128 # for a tuple that matches the current settings. 1129 # 1130 if {$changed == "xmlobj"} { 1131 # value is "#2" -- skip # and adjust range starting from 0 1132 set irun [string range $_cntlInfo($this-xmlobj-value) 1 end] 1133 if {"" != $irun} { set irun [expr {$irun-1}] } 1134 } else { 1135 set format "" 1136 set tuple "" 1137 foreach col [lrange [$_results column names] 1 end] { 1138 lappend format $col 1139 lappend tuple $_cntlInfo($this-$col-value) 1140 } 1141 set irun [lindex [$_results find -format $format -- $tuple] 0] 1142 1143 if {"" == $irun && "" != $changed 1144 && $itk_option(-missingdata) == "skip"} { 1145 # 1146 # No data for these settings. Try leaving the next 1147 # column open, then the next, and so forth, until 1148 # we find some data. 1149 # 1150 # allcols: foo bar baz qux 1151 # ^^^changed 1152 # 1153 # search: baz qux foo 1154 # 1155 set val $_cntlInfo($this-$changed-value) 1156 set allcols [lrange [$_results column names] 1 end] 1157 set i [lsearch -exact $allcols $changed] 1158 set search [concat \ 1159 [lrange $allcols [expr {$i+1}] end] \ 1160 [lrange $allcols 0 [expr {$i-1}]] \ 1161 ] 1162 set nsearch [llength $search] 1163 1164 for {set i 0} {$i < $nsearch} {incr i} { 1165 set format $changed 1166 set tuple [list $val] 1167 for {set j [expr {$i+1}]} {$j < $nsearch} {incr j} { 1168 set col [lindex $search $j] 1169 lappend format $col 1170 lappend tuple $_cntlInfo($this-$col-value) 1171 } 1172 set irun [lindex [$_results find -format $format -- $tuple] 0] 1173 if {"" != $irun} { 1174 break 1175 } 1176 } 1177 } 1178 } 1179 1180 # 1181 # If we found a particular run, then load its values into all 1182 # controls. 1183 # 1184 if {"" != $irun} { 1185 # stop reacting to value changes 1186 set _settings 1 1187 1188 set format [lrange [$_results column names] 1 end] 1189 set data [lindex [$_results get -format $format $irun] 0] 1190 foreach col $format val $data { 1191 set _cntlInfo($this-$col-value) $val 1192 } 1193 set _cntlInfo($this-xmlobj-value) "#[expr {$irun+1}]" 1194 1195 # okay, react to value changes again 1196 set _settings 0 1197 } 1198 1199 # 514 1200 # Search for tuples matching the current setting and 515 1201 # plot them. 516 1202 # 517 set format "" 518 set tuple "" 519 foreach col [lrange [$_results column names] 1 end] { 520 if {$col != $_plotall} { 521 lappend format $col 522 set w $_col2widget($col) 523 lappend tuple [$w get current] 1203 if {$_plotall && $_active == "xmlobj"} { 1204 set format "" 1205 } else { 1206 set format "" 1207 set tuple "" 1208 foreach col [lrange [$_results column names] 1 end] { 1209 if {!$_plotall || $col != $_active} { 1210 lappend format $col 1211 lappend tuple $_cntlInfo($this-$col-value) 1212 } 524 1213 } 525 1214 } … … 537 1226 foreach col [lrange [$_results column names] 1 end] { 538 1227 lappend format $col 539 set w $_col2widget($col) 540 lappend tuple [$w get current] 1228 lappend tuple $_cntlInfo($this-$col-value) 541 1229 } 542 1230 set icurr [$_results find -format $format -- $tuple] … … 570 1258 # 571 1259 _doSettings $plist 572 } elseif {$itk_option(-missingdata) == "skip"} {573 #574 # No data for these settings. Try leaving the next575 # column open, then the next, and so forth, until576 # we find some data.577 #578 array set eventdata $args579 if {[info exists eventdata(column)]} {580 set changed $eventdata(column)581 set allcols [lrange [$_results column names] 1 end]582 set i [lsearch -exact $allcols $changed]583 set search [concat \584 [lrange $allcols [expr {$i+1}] end] \585 [lrange $allcols 0 [expr {$i-1}]] \586 ]587 set nsearch [llength $search]588 589 set tweak(widget) ""590 set tweak(value) ""591 for {set i 0} {$i < $nsearch} {incr i} {592 set format $eventdata(column)593 set tuple [list [$eventdata(widget) get current]]594 for {set j [expr {$i+1}]} {$j < $nsearch} {incr j} {595 set col [lindex $search $j]596 set w $_col2widget($col)597 lappend format $col598 lappend tuple [$w get current]599 }600 set ilist [$_results find -format $format -- $tuple]601 if {[llength $ilist] > 0} {602 set col [lindex $search $i]603 set tweak(widget) $_col2widget($col)604 set first [lindex $ilist 0]605 set tweak(value) [lindex [$_results get -format $col -- $first] 0]606 break607 }608 }609 610 # set the value to the next valid result611 if {$tweak(widget) != ""} {612 $tweak(widget) current $tweak(value)613 }614 }615 1260 616 1261 } elseif {$itk_option(-missingdata) == "prompt"} { 617 1262 # prompt the user to simulate these settings 618 1263 _doPrompt on 619 } 620 } 621 622 # ---------------------------------------------------------------------- 623 # USAGE: _doPrompt <state> 624 # 625 # Used internally whenever the current settings represent a point 626 # with no data. Invokes the -promptcommand with an explanation of 627 # the missing data, prompting the user to simulate it. 628 # ---------------------------------------------------------------------- 629 itcl::body Rappture::ResultSet::_doPrompt {state} { 630 if {[string length $itk_option(-promptcommand)] > 0} { 631 if {$state} { 632 set message "No data for these settings" 633 set settings "" 634 foreach col [lrange [$_results column names] 1 end] { 635 set w $_col2widget($col) 636 set val [$w get current] 637 lappend settings $col $val 638 } 639 uplevel #0 $itk_option(-promptcommand) [list on $message $settings] 1264 _doSettings ;# clear plotting area 1265 1266 # clear the current run selection -- there is no run for this 1267 set _settings 1 1268 set _cntlInfo($this-xmlobj-value) "" 1269 set _settings 0 1270 } 1271 } 1272 1273 # ---------------------------------------------------------------------- 1274 # USAGE: _fixExplore 1275 # 1276 # Called automatically whenever the user toggles the "Explore" button 1277 # on the parameter popup. Changes the -missingdata option back and 1278 # forth, to allow for missing data or skip it. 1279 # ---------------------------------------------------------------------- 1280 itcl::body Rappture::ResultSet::_fixExplore {} { 1281 if {$_explore} { 1282 configure -missingdata prompt 1283 } else { 1284 configure -missingdata skip 1285 } 1286 } 1287 1288 # ---------------------------------------------------------------------- 1289 # USAGE: _fixValue <columnName> <why> 1290 # 1291 # Called automatically whenver a value for a parameter dial changes. 1292 # Updates the interface to display the new value. The <why> is a 1293 # reason for the change, which may be "resize" (draw old value in 1294 # new size) or "value" (value changed). 1295 # ---------------------------------------------------------------------- 1296 itcl::body Rappture::ResultSet::_fixValue {col why} { 1297 if {[info exists _cntlInfo($this-$col-id)]} { 1298 set id $_cntlInfo($this-$col-id) 1299 1300 set popup [$itk_component(options) contents frame] 1301 set widget $popup.label$id 1302 set wmax [winfo width $popup.dial$id] 1303 _drawValue $col $widget $wmax 1304 1305 set widget $itk_component(dials).label$id 1306 set wmax [winfo width $itk_component(dials).dial] 1307 if {$wmax <= 1} { 1308 set wmax [expr {round(0.9*[winfo width $itk_component(cntls)])}] 1309 } 1310 _drawValue $col $widget $wmax 1311 1312 if {$why == "value" && !$_settings} { 1313 # keep track of usage, so we know which controls are popular 1314 incr _cntlInfo($this-$col-usage) 1315 1316 # adjust the settings according to the value in the column 1317 $_dispatcher event -idle !settings column $col 1318 } 1319 } 1320 } 1321 1322 # ---------------------------------------------------------------------- 1323 # USAGE: _drawValue <columnName> <widget> <widthMax> 1324 # 1325 # Used internally to fix the rendering of a "quantity = value" display. 1326 # If the name/value in <widget> are smaller than <widthMax>, then the 1327 # full "quantity = value" string is displayed. Otherwise, an 1328 # abbreviated form is displayed. 1329 # ---------------------------------------------------------------------- 1330 itcl::body Rappture::ResultSet::_drawValue {col widget wmax} { 1331 set quantity $_cntlInfo($this-$col-label) 1332 regsub -all {\n} $quantity " " quantity ;# take out newlines 1333 1334 set newval $_cntlInfo($this-$col-value) 1335 regsub -all {\n} $newval " " newval ;# take out newlines 1336 1337 set lfont [$widget.name cget -font] 1338 set vfont [$widget.value cget -font] 1339 1340 set wn [font measure $lfont $quantity] 1341 set wv [font measure $lfont " = $newval"] 1342 set w [expr {$wn + $wv}] 1343 1344 if {$w <= $wmax} { 1345 # if the text fits, then shown "quantity = value" 1346 $widget.name configure -text $quantity 1347 $widget.value configure -text " = $newval" 1348 } else { 1349 # Otherwise, we'll have to appreviate. 1350 # If the value is really long, then just show a little bit 1351 # of it. Otherwise, show as much of the value as we can. 1352 if {[string length $newval] > 30} { 1353 set frac 0.8 640 1354 } else { 641 uplevel #0 $itk_option(-promptcommand) off 642 } 643 } 644 } 645 646 # ---------------------------------------------------------------------- 647 # USAGE: _toggleAll <path> <widget> 1355 set frac 0.2 1356 } 1357 set wNameSpace [expr {round($frac*$wmax)}] 1358 set wValueSpace [expr {$wmax-$wNameSpace}] 1359 1360 # fit as much of the "quantity" label in the space available 1361 if {$wn < $wNameSpace} { 1362 $widget.name configure -text $quantity 1363 set wValueSpace [expr {$wmax-$wn}] 1364 } else { 1365 set wDots [font measure $lfont "..."] 1366 set wchar [expr {double($wn)/[string length $quantity]}] 1367 while {1} { 1368 # figure out a good size for the abbreviated string 1369 set cmax [expr {round(($wNameSpace-$wDots)/$wchar)}] 1370 if {$cmax < 0} {set cmax 0} 1371 set str "[string range $quantity 0 $cmax]..." 1372 if {[font measure $lfont $str] <= $wNameSpace 1373 || $wDots >= $wNameSpace} { 1374 break 1375 } 1376 # we're measuring with average chars, so we may have 1377 # to shave a little off and do this again 1378 set wDots [expr {$wDots+2*$wchar}] 1379 } 1380 $widget.name configure -text $str 1381 set wValueSpace [expr {$wmax-[font measure $lfont $str]}] 1382 } 1383 1384 if {$wv < $wValueSpace} { 1385 $widget.value configure -text " = $newval" 1386 } else { 1387 set wDots [font measure $vfont "..."] 1388 set wEq [font measure $vfont " = "] 1389 set wchar [expr {double($wv)/[string length " = $newval"]}] 1390 while {1} { 1391 # figure out a good size for the abbreviated string 1392 set cmax [expr {round(($wValueSpace-$wDots-$wEq)/$wchar)}] 1393 if {$cmax < 0} {set cmax 0} 1394 set str " = [string range $newval 0 $cmax]..." 1395 if {[font measure $vfont $str] <= $wValueSpace 1396 || $wDots >= $wValueSpace} { 1397 break 1398 } 1399 # we're measuring with average chars, so we may have 1400 # to shave a little off and do this again 1401 set wDots [expr {$wDots+2*$wchar}] 1402 } 1403 $widget.value configure -text $str 1404 } 1405 } 1406 } 1407 1408 # ---------------------------------------------------------------------- 1409 # USAGE: _toggleAll ?<columnName>? 648 1410 # 649 1411 # Called automatically whenever the user clicks on an "All" button. 650 1412 # Toggles the button between its on/off states. In the "on" state, 651 # all results associated with the <path> are sent to the result viewer. 652 # ---------------------------------------------------------------------- 653 itcl::body Rappture::ResultSet::_toggleAll {path widget} { 654 if {[$widget cget -relief] == "sunken"} { 655 $widget configure -relief raised \ 1413 # all results associated with the current control are sent to the 1414 # result viewer. 1415 # ---------------------------------------------------------------------- 1416 itcl::body Rappture::ResultSet::_toggleAll {{col "current"}} { 1417 if {$col == "current"} { 1418 set col $_active 1419 } 1420 if {![info exists _cntlInfo($this-$col-id)]} { 1421 return 1422 } 1423 set id $_cntlInfo($this-$col-id) 1424 set popup [$itk_component(options) contents frame] 1425 set pbutton $popup.all$id 1426 set current [$pbutton cget -relief] 1427 set sbutton $itk_component(dials).all 1428 1429 foreach c $_cntlInfo($this-all) { 1430 set id $_cntlInfo($this-$c-id) 1431 $popup.all$id configure -relief raised \ 656 1432 -background $itk_option(-background) \ 657 1433 -foreground $itk_option(-foreground) 658 659 set _plotall "" 1434 } 1435 1436 if {$current == "sunken"} { 1437 $pbutton configure -relief raised \ 1438 -background $itk_option(-activecontrolbackground) \ 1439 -foreground $itk_option(-activecontrolforeground) 1440 $sbutton configure -relief raised \ 1441 -background $itk_option(-activecontrolbackground) \ 1442 -foreground $itk_option(-activecontrolforeground) 1443 set _plotall 0 660 1444 } else { 661 # pop out all other "All" buttons 662 set f [$itk_component(scroller) contents frame] 663 for {set i 0} {$i < $_counter} {incr i} { 664 if {[winfo exists $f.all$i]} { 665 $f.all$i configure -relief raised \ 666 -background $itk_option(-background) \ 667 -foreground $itk_option(-foreground) 668 } 669 } 670 671 # push this one in 672 $widget configure -relief sunken \ 1445 $pbutton configure -relief sunken \ 673 1446 -background $itk_option(-togglebackground) \ 674 1447 -foreground $itk_option(-toggleforeground) 675 676 # switch the "All" context to this path 677 set _plotall $path 1448 $sbutton configure -relief sunken \ 1449 -background $itk_option(-togglebackground) \ 1450 -foreground $itk_option(-toggleforeground) 1451 set _plotall 1 1452 1453 if {$col != $_active} { 1454 # clicked on an inactive "All" button? then activate that column 1455 activate $col 1456 } 678 1457 } 679 1458 $_dispatcher event -idle !settings 1459 } 1460 1461 # ---------------------------------------------------------------------- 1462 # USAGE: _getTooltip <role> <column> 1463 # 1464 # Called automatically whenever the user hovers a control within 1465 # this widget. Returns the tooltip associated with the control. 1466 # ---------------------------------------------------------------------- 1467 itcl::body Rappture::ResultSet::_getTooltip {role column} { 1468 set label "" 1469 set tip "" 1470 if {$column == "active"} { 1471 set column $_active 1472 } 1473 if {[info exists _cntlInfo($this-$column-label)]} { 1474 set label $_cntlInfo($this-$column-label) 1475 } 1476 if {[info exists _cntlInfo($this-$column-tip)]} { 1477 set tip $_cntlInfo($this-$column-tip) 1478 } 1479 1480 switch -- $role { 1481 label { 1482 if {$column != $_active} { 1483 append tip "\n\nClick to activate this control." 1484 } 1485 } 1486 dial { 1487 append tip "\n\nClick to change the value of this parameter." 1488 } 1489 all { 1490 if {$label == ""} { 1491 set tip "Plot all values for this quantity." 1492 } else { 1493 set tip "Plot all values for $label." 1494 } 1495 if {$_plotall} { 1496 set what "all values" 1497 } else { 1498 set what "one value" 1499 } 1500 append tip "\n\nCurrently, plotting $what. Click to toggle." 1501 } 1502 more { 1503 set tip "Click to access all parameters." 1504 } 1505 } 1506 return $tip 680 1507 } 681 1508 … … 688 1515 error "bad value \"$itk_option(-missingdata)\": should be [join $opts {, }]" 689 1516 } 690 } 1517 set _explore [expr {$itk_option(-missingdata) != "skip"}] 1518 } 1519 1520 # ---------------------------------------------------------------------- 1521 # OPTION: -activecontrolbackground 1522 # ---------------------------------------------------------------------- 1523 itcl::configbody Rappture::ResultSet::activecontrolbackground { 1524 $_dispatcher event -idle !layout 1525 } 1526 1527 # ---------------------------------------------------------------------- 1528 # OPTION: -activecontrolforeground 1529 # ---------------------------------------------------------------------- 1530 itcl::configbody Rappture::ResultSet::activecontrolforeground { 1531 $_dispatcher event -idle !layout 1532 } -
trunk/gui/scripts/textresult.tcl
r193 r413 36 36 public method find {option} 37 37 38 set _dataobj "" ;# data object currently being displayed 39 40 private common icons 41 set dir [file dirname [info script]] 42 set icons(up) [image create photo -file [file join $dir images findup.gif]] 43 set icons(down) [image create photo -file [file join $dir images finddn.gif]] 38 private variable _dataobj "" ;# data object currently being displayed 39 private variable _raised ;# maps all data objects => -raise param 44 40 } 45 41 … … 80 76 81 77 itk_component add finddown { 82 button $itk_component(controls).finddown -image $icons(down) \ 78 button $itk_component(controls).finddown \ 79 -image [Rappture::icon finddn] \ 83 80 -relief flat -overrelief raised \ 84 81 -command [itcl::code $this find down] … … 90 87 91 88 itk_component add findup { 92 button $itk_component(controls).findup -image $icons(up) \ 89 button $itk_component(controls).findup \ 90 -image [Rappture::icon findup] \ 93 91 -relief flat -overrelief raised \ 94 92 -command [itcl::code $this find up] … … 153 151 -width "" 154 152 -linestyle "" 155 -raise ""153 -raise 0 156 154 } 157 155 foreach {opt val} $settings { … … 162 160 } 163 161 164 $itk_component(text) configure -state normal 165 $itk_component(text) delete 1.0 end 166 162 set replace 0 167 163 if {"" != $dataobj} { 164 set _raised($dataobj) $params(-raise) 165 if {"" == $_dataobj} { 166 set replace 1 167 } elseif {$_raised($_dataobj) == 0 && $params(-raise)} { 168 set replace 1 169 } 170 } 171 172 if {$replace} { 173 $itk_component(text) configure -state normal 174 $itk_component(text) delete 1.0 end 175 168 176 if {[$dataobj element -as type] == "log"} { 169 177 # log output -- remove special =RAPPTURE-???=> messages … … 204 212 $itk_component(text) insert end [$dataobj get] 205 213 } 206 }207 208 $itk_component(text) configure -state disabled209 set _dataobj $dataobj214 $itk_component(text) configure -state disabled 215 216 set _dataobj $dataobj 217 } 210 218 } 211 219 … … 227 235 # ---------------------------------------------------------------------- 228 236 itcl::body Rappture::TextResult::delete {args} { 229 $itk_component(text) configure -state normal 230 $itk_component(text) delete 1.0 end 231 $itk_component(text) configure -state disabled 232 set _dataobj "" 237 if {[llength $args] == 0} { 238 # delete everything 239 catch {unset _raised} 240 set _dataobj "" 241 $itk_component(text) configure -state normal 242 $itk_component(text) delete 1.0 end 243 $itk_component(text) configure -state disabled 244 } else { 245 # delete these specific objects 246 foreach obj $args { 247 catch {unset _raised($obj)} 248 if {$obj == $_dataobj} { 249 set _dataobj "" 250 $itk_component(text) configure -state normal 251 $itk_component(text) delete 1.0 end 252 $itk_component(text) configure -state disabled 253 } 254 } 255 } 233 256 } 234 257 -
trunk/gui/scripts/tool.tcl
r405 r413 35 35 private common job ;# array var used for blt::bgexec jobs 36 36 private common jobnum 0 ;# counter for unique job number 37 38 # resources file tells us the application name 39 public common _appname "" 40 public proc setAppName {name} { set _appname $name } 41 } 42 43 # must use this name -- plugs into Rappture::resources::load 44 proc tool_init_resources {} { 45 Rappture::resources::register \ 46 application_name Rappture::Tool::setAppName 37 47 } 38 48 … … 79 89 itcl::body Rappture::Tool::run {args} { 80 90 global errorInfo 91 92 # make sure that we save the proper application name 93 if {"" != $_appname} { 94 $_xmlobj put tool.name $_appname 95 } 81 96 82 97 # sync all widgets to the XML tree -
trunk/gui/scripts/tooltip.tcl
r213 r413 59 59 bind RapptureTooltip <KeyPress> \ 60 60 [list ::Rappture::Tooltip::tooltip cancel] 61 62 private common icons63 set dir [file dirname [info script]]64 set icons(cue) [image create photo -file [file join $dir images cue24.gif]]65 61 } 66 62 … … 141 137 142 138 # strings can't be too big, or they'll go off screen! 143 if {[string length $mesg] > 1000} {144 set mesg "[string range $mesg 0 1000]..."145 }146 139 set pos 0 147 140 ::for {set i 0} {$pos >= 0 && $i < 20} {incr i} { … … 152 145 set mesg "[string range $mesg 0 $pos]..." 153 146 } 147 if {[string length $mesg] > 1000} { 148 set mesg "[string range $mesg 0 1500]..." 149 } 154 150 $itk_component(text) configure -text $mesg 155 151 156 152 # 157 # Make sure the tooltip doesn't go off screen. Then, put it up.153 # Make sure the tooltip doesn't go off screen. 158 154 # 159 155 update idletasks … … 182 178 } 183 179 180 # 181 # Will the tooltip pop up under the mouse pointer? If so, then 182 # it will just disappear. Doh! We should figure out a better 183 # place to pop it up. 184 # 185 set px [winfo pointerx $hull] 186 set py [winfo pointery $hull] 187 if {$px >= $xpos && $px <= $xpos+[winfo reqwidth $hull] 188 && $py >= $ypos && $py <= $ypos+[winfo reqheight $hull]} { 189 190 if {$px > [winfo screenwidth $hull]/2} { 191 set signx "-" 192 set xpos [expr {[winfo screenwidth $hull]-$px+4}] 193 } else { 194 set signx "+" 195 set xpos [expr {$px+4}] 196 } 197 if {$py > [winfo screenheight $hull]/2} { 198 set signy "-" 199 set ypos [expr {[winfo screenheight $hull]-$py+4}] 200 } else { 201 set signy "+" 202 set ypos [expr {$py+4}] 203 } 204 } 205 206 # 207 # Finally, put it up. 208 # 184 209 wm geometry $hull $signx$xpos$signy$ypos 185 210 update … … 276 301 error "wrong # args: should be \"tooltip pending widget ?@x,y?\"" 277 302 } 278 set widget[lindex $args 0]303 set tag [lindex $args 0] 279 304 set loc [lindex $args 1] 280 305 281 if {[winfo exists $widget]} { 282 .rappturetooltip configure -message $catalog($widget) 306 # tag name may be .g-axis -- get widget ".g" part 307 set widget $tag 308 if {[regexp {^(\.[^-]+)-[^\.]+$} $widget match wname]} { 309 set widget $wname 310 } 311 312 if {[winfo exists $widget] && [info exists catalog($tag)]} { 313 .rappturetooltip configure -message $catalog($tag) 283 314 if {[string index $loc 0] == "@"} { 284 315 .rappturetooltip show $loc … … 381 412 # create a tooltip widget to show error cues 382 413 Rappture::Tooltip .rappturetoolcue \ 383 -icon $Rappture::Tooltip::icons(cue)\414 -icon [Rappture::icon cue24] \ 384 415 -background black -outline #333333 -foreground white 385 416 -
trunk/gui/scripts/xyresult.tcl
r411 r413 32 32 33 33 option add *XyResult*Balloon*Entry.background white widgetDefault 34 35 blt::bitmap define XyResult-reset {36 #define reset_width 1237 #define reset_height 1238 static unsigned char reset_bits[] = {39 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02,40 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};41 }42 43 blt::bitmap define XyResult-dismiss {44 #define dismiss_width 1045 #define dismiss_height 846 static unsigned char dismiss_bits[] = {47 0x87, 0x03, 0xce, 0x01, 0xfc, 0x00, 0x78, 0x00, 0x78, 0x00, 0xfc, 0x00,48 0xce, 0x01, 0x87, 0x03};49 }50 51 34 52 35 itcl::class Rappture::XyResult { … … 117 100 button $itk_component(controls).reset \ 118 101 -borderwidth 1 -padx 1 -pady 1 \ 119 -bitmap XyResult-reset\102 -bitmap [Rappture::icon reset] \ 120 103 -command [itcl::code $this _zoom reset] 121 104 } { … … 150 133 # Add support for editing axes: 151 134 # 152 Rappture::Balloon $itk_component(hull).axes 135 Rappture::Balloon $itk_component(hull).axes -title "Axis Options" 153 136 set inner [$itk_component(hull).axes component inner] 154 set inner [frame $inner.bd -borderwidth 4 -relief flat]155 pack $inner -expand yes -fill both156 157 button $inner.dismiss -bitmap XyResult-dismiss \158 -relief flat -overrelief raised -command "159 Rappture::Tooltip::cue hide160 [list $itk_component(hull).axes deactivate]161 "162 grid $inner.dismiss -row 0 -column 1 -sticky e163 137 164 138 label $inner.labell -text "Label:" … … 494 468 $g axis configure $axis -title $label -hide no 495 469 set _label2axis($ax-$label) $axis 470 471 # if this axis has a description, add it as a tooltip 472 set desc [string trim [$xydata hints ${ax}desc]] 473 Rappture::Tooltip::text $g-$axis $desc 496 474 } 497 475 } … … 531 509 $g axis bind $axis <ButtonRelease> \ 532 510 [itcl::code $this _axis release $axis %x %y] 511 $g axis bind $axis <KeyPress> \ 512 [list ::Rappture::Tooltip::tooltip cancel] 533 513 } 534 514 … … 775 755 if {$x > 0.5*[winfo width $g]} { 776 756 if {$x < 4} { 777 set x "-0"757 set tipx "-0" 778 758 } else { 779 set x "-[expr {$x-4}]" ;# move tooltip to the left759 set tipx "-[expr {$x-4}]" ;# move tooltip to the left 780 760 } 781 761 } else { 782 762 if {$x < -4} { 783 set x "+0"763 set tipx "+0" 784 764 } else { 785 set x "+[expr {$x+4}]" ;# move tooltip to the right765 set tipx "+[expr {$x+4}]" ;# move tooltip to the right 786 766 } 787 767 } 788 768 if {$y > 0.5*[winfo height $g]} { 789 769 if {$y < 4} { 790 set y "-0"770 set tipy "-0" 791 771 } else { 792 set y "-[expr {$y-4}]" ;# move tooltip to the top772 set tipy "-[expr {$y-4}]" ;# move tooltip to the top 793 773 } 794 774 } else { 795 775 if {$y < -4} { 796 set y "+0"776 set tipy "+0" 797 777 } else { 798 set y "+[expr {$y+4}]" ;# move tooltip to the bottom778 set tipy "+[expr {$y+4}]" ;# move tooltip to the bottom 799 779 } 800 780 } 801 781 Rappture::Tooltip::text $g $tip 802 Rappture::Tooltip::tooltip show $g $ x,$y782 Rappture::Tooltip::tooltip show $g $tipx,$tipy 803 783 } 804 784 } else { … … 832 812 833 813 $g crosshairs configure -hide yes 834 Rappture::Tooltip::tooltip cancel 814 815 # only cancel in plotting area or we'll mess up axes 816 if {[$g inside $x $y]} { 817 Rappture::Tooltip::tooltip cancel 818 } 835 819 836 820 # there is no currently highlighted element … … 857 841 # ---------------------------------------------------------------------- 858 842 itcl::body Rappture::XyResult::_axis {option args} { 859 set inner [$itk_component(hull).axes component inner] .bd843 set inner [$itk_component(hull).axes component inner] 860 844 861 845 switch -- $option { … … 864 848 error "wrong # args: should be \"_axis hilite axis state\"" 865 849 } 850 set g $itk_component(plot) 866 851 set axis [lindex $args 0] 867 852 set state [lindex $args 1] 868 853 869 854 if {$state} { 870 $ itk_component(plot)axis configure $axis \855 $g axis configure $axis \ 871 856 -color $itk_option(-activecolor) \ 872 857 -titlecolor $itk_option(-activecolor) 858 859 set x [expr {[winfo pointerx $g]+4}] 860 set y [expr {[winfo pointery $g]+4}] 861 Rappture::Tooltip::tooltip pending $g-$axis @$x,$y 873 862 } else { 874 $ itk_component(plot)axis configure $axis \863 $g axis configure $axis \ 875 864 -color $itk_option(-foreground) \ 876 865 -titlecolor $itk_option(-foreground) 866 Rappture::Tooltip::tooltip cancel 877 867 } 878 868 } … … 892 882 set _axis(min0) $min 893 883 set _axis(max0) $max 884 Rappture::Tooltip::tooltip cancel 894 885 } 895 886 drag { -
trunk/src2/core/Makefile
r370 r413 10 10 test: test.o RpOutcome.o RpMesh1D.o RpField1D.o RpMeshTri2D.o RpFieldTri2D.o RpMeshRect3D.o RpFieldRect3D.o RpMeshPrism3D.o RpFieldPrism3D.o RpSerialBuffer.o RpSerializer.o RpSerializable.o 11 11 g++ $(CFLAGS) -o test test.o RpOutcome.o RpMesh1D.o RpField1D.o RpMeshTri2D.o RpFieldTri2D.o RpMeshRect3D.o RpFieldRect3D.o RpMeshPrism3D.o RpFieldPrism3D.o RpSerialBuffer.o RpSerializer.o RpSerializable.o 12 13 docs: 14 if test ! -d ../../docs/rappture2; then \ 15 mkdir ../../docs; \ 16 mkdir ../../docs/rappture2; \ 17 fi 18 doxygen 12 19 13 20 test.o: test.cc RpPtr.h -
trunk/src2/core/RpSerialBuffer.cc
r364 r413 1 1 /* 2 * ====================================================================== 3 * Rappture::SerialBuffer 4 * 5 * AUTHOR: Michael McLennan, Purdue University 6 * Carol X Song, Purdue University 7 * 8 * Copyright (c) 2004-2006 Purdue Research Foundation 2 9 * ---------------------------------------------------------------------- 3 * Rappture::SerialBuffer4 * Used by the Serializer to build up the buffer of serialized5 * data. Similar to a string, but it handles nulls and other6 * control characters. Also handles big/little endian order7 * properly.8 *9 * ======================================================================10 * AUTHOR: Carol X Song, Purdue University11 * Michael McLennan, Purdue University12 * Copyright (c) 2004-2006 Purdue Research Foundation13 *14 10 * See the file "license.terms" for information on usage and 15 11 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. … … 28 24 using namespace Rappture; 29 25 26 /** 27 * Construct an empty SerialBuffer. 28 */ 30 29 SerialBuffer::SerialBuffer() 31 30 : _buffer(), … … 34 33 } 35 34 35 /** 36 * Construct a SerialBuffer loaded with bytes produced by another 37 * SerialBuffer. This is used to decode information from the buffer. 38 * 39 * @param bytes pointer to bytes being decoded. 40 * @param nbytes number of bytes being decoded. 41 */ 36 42 SerialBuffer::SerialBuffer(const char* bytes, int nbytes) 37 43 : _buffer(), … … 44 50 } 45 51 52 /** 53 * Copy constructor 54 */ 46 55 SerialBuffer::SerialBuffer(const SerialBuffer& sb) 47 56 : _buffer(sb._buffer), … … 50 59 } 51 60 61 /** 62 * Assignment operator 63 */ 52 64 SerialBuffer& 53 65 SerialBuffer::operator=(const SerialBuffer& sb) … … 61 73 } 62 74 75 /** 76 * Get the bytes currently stored in the buffer. These bytes can 77 * be stored, and used later to construct another SerialBuffer to 78 * decode the information. 79 * 80 * @return Pointer to the bytes in the buffer. 81 */ 63 82 const char* 64 83 SerialBuffer::bytes() const … … 67 86 } 68 87 88 /** 89 * Get the number of bytes currently stored in the buffer. 90 * @return Number of the bytes in the buffer. 91 */ 69 92 int 70 93 SerialBuffer::size() const … … 73 96 } 74 97 98 /** 99 * Clear the buffer, making it empty. 100 */ 75 101 SerialBuffer& 76 102 SerialBuffer::clear() -
trunk/src2/core/RpSerialBuffer.h
r364 r413 1 1 /* 2 * ====================================================================== 3 * Rappture::SerialBuffer 4 * 5 * AUTHOR: Michael McLennan, Purdue University 6 * Carol X Song, Purdue University 7 * 8 * Copyright (c) 2004-2006 Purdue Research Foundation 2 9 * ---------------------------------------------------------------------- 3 * Rappture::SerialBuffer4 * Used by the Serializer to build up the buffer of serialized5 * data. Similar to a string, but it handles nulls and other6 * control characters. Also handles big/little endian order7 * properly.8 *9 * ======================================================================10 * AUTHOR: Carol X Song, Purdue University11 * Michael McLennan, Purdue University12 * Copyright (c) 2004-2006 Purdue Research Foundation13 *14 10 * See the file "license.terms" for information on usage and 15 11 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. … … 24 20 namespace Rappture { 25 21 22 /** 23 * Used by the Serializer to build up the buffer of serialized 24 * data. Similar to a string, but it handles nulls and other 25 * control characters. Also handles big/little endian order 26 * properly. 27 */ 26 28 class SerialBuffer { 27 29 public: … … 51 53 52 54 private: 53 std::vector<char> _buffer; // data within this buffer 54 int _pos; // position for read functions 55 /// Contains the actual data within this buffer. 56 std::vector<char> _buffer; 57 58 /// Position for the various readXyz() functions. 59 int _pos; 55 60 }; 56 61 -
trunk/src2/core/RpSerializable.cc
r370 r413 1 1 /* 2 * ====================================================================== 3 * Rappture::Serializable 4 * 5 * AUTHOR: Michael McLennan, Purdue University 6 * Carol X Song, Purdue University 7 * 8 * Copyright (c) 2004-2006 Purdue Research Foundation 2 9 * ---------------------------------------------------------------------- 3 * Rappture::Serializable4 * Base class for any object that can be serialized into a stream,5 * then saved to a file or written to a socket, and reconstituted6 * into its original form. Serializable objects can be added to7 * a serializer, which handles the overall conversion.8 *9 * ======================================================================10 * AUTHOR: Carol X Song, Purdue University11 * Michael McLennan, Purdue University12 * Copyright (c) 2004-2006 Purdue Research Foundation13 *14 10 * See the file "license.terms" for information on usage and 15 11 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. -
trunk/src2/core/RpSerializable.h
r370 r413 1 1 /* 2 * ====================================================================== 3 * Rappture::Serializable 4 * 5 * AUTHOR: Michael McLennan, Purdue University 6 * Carol X Song, Purdue University 7 * 8 * Copyright (c) 2004-2006 Purdue Research Foundation 2 9 * ---------------------------------------------------------------------- 3 * Rappture::Serializable4 * Base class for any object that can be serialized into a stream,5 * then saved to a file or written to a socket, and reconstituted6 * into its original form. Serializable objects can be added to7 * a serializer, which handles the overall conversion.8 *9 * ======================================================================10 * AUTHOR: Carol X Song, Purdue University11 * Michael McLennan, Purdue University12 * Copyright (c) 2004-2006 Purdue Research Foundation13 *14 10 * See the file "license.terms" for information on usage and 15 11 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. … … 29 25 class SerialConversion; // see below 30 26 27 /** 28 * Base class for any object that can be serialized into a stream, 29 * then saved to a file or written to a socket, and reconstituted 30 * into its original form. Serializable objects can be added to 31 * a serializer, which handles the overall conversion. 32 */ 31 33 class Serializable { 32 34 public: … … 59 61 }; 60 62 63 /** 64 * Each class derived from Serializable should have a SerialConversion 65 * stored as a static data member. This declares information needed 66 * to serialize/deserialize the class, making objects in that class 67 * serializable. 68 */ 61 69 class SerialConversion { 62 70 public:
Note: See TracChangeset
for help on using the changeset viewer.