Changeset 1442
- Timestamp:
- May 14, 2009, 10:28:24 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/Makefile.in
r1375 r1442 48 48 $(srcdir)/field3dresult.tcl \ 49 49 $(srcdir)/filexfer.tcl \ 50 $(srcdir)/flowhints.tcl \ 50 51 $(srcdir)/flowvisviewer.tcl \ 51 52 $(srcdir)/gauge.tcl \ … … 79 80 $(srcdir)/postern.tcl \ 80 81 $(srcdir)/progress.tcl \ 82 $(srcdir)/pushbutton.tcl \ 81 83 $(srcdir)/radiodial.tcl \ 82 84 $(srcdir)/resources.tcl \ -
trunk/gui/scripts/analyzer.tcl
r1348 r1442 377 377 } 378 378 set args "" 379 } 379 } 380 380 381 381 # simulation is needed -- go to simulation page -
trunk/gui/scripts/flowvisviewer.tcl
r1391 r1442 1 2 1 3 2 # ---------------------------------------------------------------------- … … 24 23 option add *FlowvisViewer.height 4i widgetDefault 25 24 option add *FlowvisViewer.foreground black widgetDefault 25 option add *FlowvisViewer.controlBackground gray widgetDefault 26 option add *FlowvisViewer.controlDarkBackground #999999 widgetDefault 26 27 option add *FlowvisViewer.plotBackground black widgetDefault 27 28 option add *FlowvisViewer.plotForeground white widgetDefault 28 #FIXME: why is plot outline gray? not white?29 29 option add *FlowvisViewer.plotOutline gray widgetDefault 30 30 option add *FlowvisViewer.font \ … … 56 56 } 57 57 public method add {dataobj {settings ""}} 58 public method camera {option args} 59 public method delete {args} 60 public method download {option args} 61 public method flow {option} 58 62 public method get {args} 59 public method delete {args} 63 public method isconnected {} 64 public method limits { tf } 65 public method overmarker { m x } 66 public method parameters {title args} { 67 # do nothing 68 } 69 public method rmdupmarker { m x } 60 70 public method scale {args} 61 public method download {option args}62 public method parameters {title args} {63 # do nothing64 }65 public method isconnected {}66 67 public method limits { tf }68 71 public method updatetransferfuncs {} 69 public method rmdupmarker { m x }70 public method overmarker { m x }71 72 public method camera {option args}73 72 74 73 protected method Connect {} 74 protected method CurrentVolumeIds {{what -all}} 75 75 protected method Disconnect {} 76 76 protected method DoResize {} 77 protected method FixLegend {} 78 protected method FixSettings {what {value ""}} 79 protected method Pan {option x y} 80 protected method Rebuild {} 81 protected method ReceiveData { args } 82 protected method ReceiveImage { args } 83 protected method ReceiveLegend { tf vmin vmax size } 84 protected method Rotate {option x y} 77 85 protected method SendCmd {string} 78 protected method _send {string}79 86 protected method SendDataObjs {} 80 87 protected method SendTransferFuncs {} 81 82 protected method ReceiveImage { args }83 protected method ReceiveLegend { ivol vmin vmax size }84 protected method ReceiveData { args }85 86 protected method Rebuild {}87 protected method CurrentVolumeIds {{what -all}}88 protected method Zoom {option}89 protected method Pan {option x y}90 protected method Rotate {option x y}91 88 protected method Slice {option args} 92 89 protected method SlicerTip {axis} 93 90 protected method Zoom {option} 91 92 # soon to be removed. 94 93 protected method Flow {option args} 95 94 protected method Play {} 96 95 protected method Pause {} 97 public method flow {option} 98 99 protected method State {comp} 100 protected method DoResize {} 101 protected method FixSettings {what {value ""}} 102 protected method FixLegend {} 103 private method EventuallyResize { w h } 104 private method EventuallyResizeLegend { } 96 105 97 106 98 # The following methods are only used by this class. 107 private method NameTransferFunc { ivol } 108 private method ComputeTransferFunc { tf } 99 109 100 private method AddIsoMarker { x y } 110 private method ParseMarkersOption { tf ivol markers } 111 private method ParseLevelsOption { tf ivol levels } 101 private method BuildCameraTab {} 112 102 private method BuildCutplanesTab {} 113 103 private method BuildViewTab {} 114 104 private method BuildVolumeTab {} 115 private method BuildCameraTab {} 105 private method ComputeTransferFunc { tf } 106 private method EventuallyResize { w h } 107 private method EventuallyResizeLegend { } 108 private method FlowCmd { dataobj comp nbytes extents } 109 private method GetMovie { widget width height } 110 private method NameTransferFunc { dataobj comp } 116 111 private method PanCamera {} 117 private method GetMovie { widget width height } 112 private method ParseLevelsOption { tf levels } 113 private method ParseMarkersOption { tf markers } 118 114 private method WaitIcon { option widget } 119 115 120 private variable outbuf_ ;# buffer for outgoing commands 121 122 private variable dlist_ "" ;# list of data objects 123 private variable all_data_objs_ 124 private variable id2style_ ;# maps id => style settings 125 private variable obj2ovride_ ;# maps dataobj => style override 126 private variable obj2id_ ;# maps dataobj => volume ID in server 127 private variable id2obj_ ;# maps dataobj => volume ID in server 128 private variable sendobjs_ "" ;# list of data objs to send to server 129 private variable receiveIds_ ;# list of data objs to send to server 130 private variable obj2styles_ ;# maps id => style settings 131 private variable style2ids_ ;# maps id => style settings 132 133 private variable click_ ;# info used for Rotate operations 134 private variable limits_ ;# autoscale min/max for all axes 135 private variable view_ ;# view params for 3D view 136 private variable isomarkers_ ;# array of isosurface level values 0..1 137 private common settings_ 138 private variable activeTf_ "" ;# The currently active transfer function. 139 private variable flow_ 116 private method GetFlowInfo { widget } 117 private method particles { tag name } 118 private method box { tag name } 119 private method streams { tag name } 120 121 private variable _outbuf ;# buffer for outgoing commands 122 123 private variable _dlist "" ;# list of data objects 124 private variable _allDataObjs 125 private variable _obj2ovride ;# maps dataobj => style override 126 private variable _obj2id ;# maps dataobj-component to volume ID 127 # in the server 128 private variable _id2obj ;# maps dataobj => volume ID in server 129 private variable _sendobjs "" ;# list of data objs to send to server 130 private variable _receiveIds ;# list of data objs to send to server 131 private variable _obj2style ;# maps dataobj-component to transfunc 132 private variable _style2objs ;# maps tf back to list of 133 # dataobj-components using the tf. 134 private variable _obj2flow; # Maps dataobj-component to a flow. 135 136 private variable _click ;# info used for rotate operations 137 private variable _limits ;# autoscale min/max for all axes 138 private variable _view ;# view params for 3D view 139 private variable _isomarkers ;# array of isosurface level values 0..1 140 private common _settings 141 private variable _activeTf "" ;# The currently active transfer function. 142 private variable _first "" ;# This is the topmost volume. 143 private variable _buffering 0 144 private variable _flow 140 145 # This 141 146 # indicates which isomarkers and transfer 142 147 # function to use when changing markers, 143 148 # opacity, or thickness. 144 common downloadPopup_ ;# download options from popup 145 146 private common hardcopy_ 149 common _downloadPopup ;# download options from popup 150 151 private common _hardcopy 152 private variable _width 0 153 private variable _height 0 147 154 } 148 155 … … 160 167 $_dispatcher register !legend 161 168 $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list" 169 162 170 # Send dataobjs event 163 171 $_dispatcher register !send_dataobjs 164 172 $_dispatcher dispatch $this !send_dataobjs \ 165 173 "[itcl::code $this SendDataObjs]; list" 166 # Send transfer functions event 174 175 # Send transferfunctions event 167 176 $_dispatcher register !send_transfunc 168 177 $_dispatcher dispatch $this !send_transfunc \ 169 178 "[itcl::code $this SendTransferFuncs]; list" 170 # Rebuild event 179 180 # Rebuild event. 171 181 $_dispatcher register !rebuild 172 182 $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list" 173 183 174 # Draw resize event184 # Resize event. 175 185 $_dispatcher register !resize 176 186 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" … … 179 189 $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list" 180 190 181 set outbuf_ "" 182 set flow_(state) "stopped" 183 array set downloadPopup_ { 191 set _flow(frame) 0 192 set _flow(state) 0 193 194 set _outbuf "" 195 196 array set _downloadPopup { 184 197 format draft 185 }186 array set play_ {187 198 } 188 199 # … … 194 205 195 206 # Initialize the view to some default parameters. 196 array set view_{207 array set _view { 197 208 theta 45 198 209 phi 45 … … 202 213 pan-y 0 203 214 } 204 set obj2id_(count) 0 205 set id2obj_(count) 0 206 set limits_(vmin) 0.0 207 set limits_(vmax) 1.0 208 set settings_($this-theta) $view_(theta) 209 set settings_($this-phi) $view_(phi) 210 set settings_($this-psi) $view_(psi) 211 set settings_($this-pan-x) $view_(pan-x) 212 set settings_($this-pan-y) $view_(pan-y) 213 set settings_($this-zoom) $view_(zoom) 214 set settings_($this-speed) 10 215 set _obj2id(count) 0 216 set _id2obj(count) 0 217 set _limits(vmin) 0.0 218 set _limits(vmax) 1.0 219 220 array set _settings [subst { 221 $this-loop 0 222 $this-pan-x $_view(pan-x) 223 $this-pan-y $_view(pan-y) 224 $this-phi $_view(phi) 225 $this-play 0 226 $this-psi $_view(psi) 227 $this-speed 500 228 $this-theta $_view(theta) 229 $this-volume 1 230 $this-xcutplane 0 231 $this-xcutposition 0 232 $this-ycutplane 0 233 $this-ycutposition 0 234 $this-zcutplane 0 235 $this-zcutposition 0 236 $this-zoom $_view(zoom) 237 }] 215 238 216 239 set f [$itk_component(main) component controls] … … 251 274 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 252 275 253 #254 # Volume toggle...255 #256 276 itk_component add volume { 257 label $f.volume -borderwidth 1 -relief sunken -padx 1 -pady 1 \ 258 -text "Volume" \ 259 -image [Rappture::icon playback-record] 260 } 261 bind $itk_component(volume) <ButtonPress> \ 262 [itcl::code $this Slice volume toggle] 277 Rappture::PushButton $f.volume \ 278 -onimage [Rappture::icon volume-on] \ 279 -offimage [Rappture::icon volume-off] \ 280 -command [itcl::code $this FixSettings volume] \ 281 -variable [itcl::scope _settings($this-volume)] 282 } 283 $itk_component(volume) select 263 284 Rappture::Tooltip::for $itk_component(volume) \ 264 285 "Toggle the volume cloud on/off" … … 281 302 } 282 303 bind $itk_component(legend) <Configure> \ 283 [list $_dispatcher event -idle !legend]304 [itcl::code $this EventuallyResizeLegend] 284 305 285 306 # Hack around the Tk panewindow. The problem is that the requested 286 307 # size of the 3d view isn't set until an image is retrieved from 287 308 # the server. So the panewindow uses the tiny size. 288 set w [expr [winfo reqwidth $itk_component(hull)] - 80] 309 set w 10000 310 pack forget $itk_component(3dview) 289 311 blt::table $itk_component(plotarea) \ 290 312 0,0 $itk_component(3dview) -fill both -reqwidth $w \ 291 1,0 $itk_component(legend) -fill both292 313 1,0 $itk_component(legend) -fill x 314 blt::table configure $itk_component(plotarea) r1 -resize none 293 315 # Create flow controls... 294 316 295 itk_component add flowc trl {296 frame $itk_interior.flowc trl317 itk_component add flowcontrol { 318 frame $itk_interior.flowcontrol 297 319 } { 298 320 usual 299 321 rename -background -controlbackground controlBackground Background 300 322 } 301 pack $itk_component(flowctrl) -side top -padx 4 -pady 0 -fill x 323 pack forget $itk_component(main) 324 blt::table $itk_interior \ 325 0,0 $itk_component(main) -fill both \ 326 1,0 $itk_component(flowcontrol) -fill x 327 blt::table configure $itk_interior r1 -resize none 302 328 303 329 # flow record button... 304 330 itk_component add rewind { 305 button $itk_component(flowc trl).reset \331 button $itk_component(flowcontrol).reset \ 306 332 -borderwidth 1 -padx 1 -pady 1 \ 307 333 -image [Rappture::icon flow-rewind] \ 308 -command [itcl::code $this flow re wind]334 -command [itcl::code $this flow reset] 309 335 } { 310 336 usual … … 313 339 } 314 340 Rappture::Tooltip::for $itk_component(rewind) \ 315 "Rewind the flow sequence to the beginning" 316 pack $itk_component(rewind) -padx 1 -side left 341 "Rewind flow" 317 342 318 343 # flow stop button... 319 344 itk_component add stop { 320 button $itk_component(flowc trl).stop \345 button $itk_component(flowcontrol).stop \ 321 346 -borderwidth 1 -padx 1 -pady 1 \ 322 347 -image [Rappture::icon flow-stop] \ … … 328 353 } 329 354 Rappture::Tooltip::for $itk_component(stop) \ 330 "Stop flow visualization" 331 pack $itk_component(stop) -padx 1 -side left 355 "Stop flow" 332 356 333 357 # … … 335 359 # 336 360 itk_component add play { 337 button $itk_component(flowctrl).play \ 338 -borderwidth 1 -padx 1 -pady 1 \ 339 -image [Rappture::icon flow-play] \ 340 -command [itcl::code $this flow toggle] 361 Rappture::PushButton $itk_component(flowcontrol).play \ 362 -onimage [Rappture::icon flow-pause] \ 363 -offimage [Rappture::icon flow-play] \ 364 -variable [itcl::scope _settings($this-play)] \ 365 -command [itcl::code $this flow toggle] 366 } 367 set fg [option get $itk_component(hull) font Font] 368 Rappture::Tooltip::for $itk_component(play) \ 369 "Play/Pause flow" 370 371 itk_component add loop { 372 Rappture::PushButton $itk_component(flowcontrol).loop \ 373 -onimage [Rappture::icon loop] \ 374 -offimage [Rappture::icon loop] \ 375 -variable [itcl::scope _settings($this-loop)] 376 } 377 Rappture::Tooltip::for $itk_component(loop) \ 378 "Play continuously" 379 380 # how do we know when to make something an itk component? 381 382 itk_component add numframes { 383 Rappture::Spinint $itk_component(flowcontrol).numframes \ 384 -min 0 -max 10000 341 385 } { 342 386 usual 343 ignore -borderwidth 344 rename -highlightbackground -controlbackground controlBackground Background 345 } 346 set fg [option get $itk_component(hull) font Font] 347 348 Rappture::Tooltip::for $itk_component(play) \ 349 "Play/Pause flow visualization" 350 pack $itk_component(play) -padx 1 -side left 351 352 # how do we know when to make something an itk component? 353 354 ::scale $itk_component(flowctrl).value -from 100 -to 1 \ 355 -showvalue 0 -orient horizontal -width 12 -length 150 \ 356 -variable [itcl::scope settings_(speed)] 357 pack $itk_component(flowctrl).value -side right 358 359 itk_component add speedlabel { 360 label $itk_component(flowctrl).speedl -text "Flow Rate:" -font $fg 387 ignore -highlightthickness 388 rename -background -controlbackground controlBackground Background 389 } 390 $itk_component(numframes) value 100 391 392 itk_component add numframeslabel { 393 label $itk_component(flowcontrol).framel -text "# Steps:" -font $fg \ 394 -highlightthickness 0 361 395 } { 362 396 usual 397 ignore -highlightthickness 363 398 rename -background -controlbackground controlBackground Background 364 399 } 365 pack $itk_component(speedlabel) -side right 366 367 Rappture::Spinint $itk_component(flowctrl).framecnt 368 $itk_component(flowctrl).framecnt value 100 369 pack $itk_component(flowctrl).framecnt -side right 370 label $itk_component(flowctrl).framecntlabel -text "# Frames" -font $fg 371 pack $itk_component(flowctrl).framecntlabel -side right 372 373 400 401 itk_component add speedlabel { 402 label $itk_component(flowcontrol).speedl -text "Speed:" -font $fg \ 403 -highlightthickness 0 404 } { 405 usual 406 ignore -highlightthickness 407 rename -background -controlbackground controlBackground Background 408 } 409 410 itk_component add speed { 411 ::scale $itk_component(flowcontrol).speed -from 500 -to 50 \ 412 -showvalue 0 -orient horizontal -width 14 -length 150 \ 413 -variable [itcl::scope _settings(speed)] \ 414 -highlightthickness 0 415 } { 416 usual 417 ignore -highlightthickness 418 rename -background -controlbackground controlBackground Background 419 } 420 $itk_component(speed) set 500 421 422 blt::table $itk_component(flowcontrol) \ 423 0,0 $itk_component(rewind) -padx {3 0} \ 424 0,1 $itk_component(stop) -padx {2 0} \ 425 0,2 $itk_component(play) -padx {2 0} \ 426 0,3 $itk_component(loop) -padx {2 0} \ 427 0,5 $itk_component(speedlabel) -padx {2 0} \ 428 0,6 $itk_component(speed) -fill x \ 429 0,7 $itk_component(numframeslabel) -padx {2 0} \ 430 0,8 $itk_component(numframes) -fill x -padx { 0 3} 431 blt::table configure $itk_component(flowcontrol) c* -resize none 432 blt::table configure $itk_component(flowcontrol) c4 c6 -resize both 433 blt::table configure $itk_component(flowcontrol) r0 -pady 1 374 434 # Bindings for rotation via mouse 375 435 bind $itk_component(3dview) <ButtonPress-1> \ … … 380 440 [itcl::code $this Rotate release %x %y] 381 441 bind $itk_component(3dview) <Configure> \ 382 [itcl::code $this SendCmd "screen %w %h"]442 [itcl::code $this EventuallyResize %w %h] 383 443 384 444 # Bindings for panning via mouse … … 433 493 # ---------------------------------------------------------------------- 434 494 itcl::body Rappture::FlowvisViewer::destructor {} { 435 set sendobjs_"" ;# stop any send in progress495 set _sendobjs "" ;# stop any send in progress 436 496 $_dispatcher cancel !rebuild 437 497 $_dispatcher cancel !send_dataobjs … … 440 500 image delete $_image(legend) 441 501 image delete $_image(download) 442 array unset settings_$this-*502 array unset _settings $this-* 443 503 } 444 504 … … 470 530 set params(-color) black 471 531 } 472 473 set pos [lsearch -exact $dataobj $dlist_] 532 foreach comp [$dataobj components] { 533 set flowobj [$dataobj flowhints $comp] 534 if { $flowobj == "" } { 535 puts stderr "no flowhints $dataobj-$comp" 536 continue 537 } 538 set _obj2flow($dataobj-$comp) $flowobj 539 } 540 set pos [lsearch -exact $dataobj $_dlist] 474 541 if {$pos < 0} { 475 lappend dlist_$dataobj476 set all_data_objs_($dataobj) 1477 set obj2ovride_($dataobj-color) $params(-color)478 set obj2ovride_($dataobj-width) $params(-width)479 set obj2ovride_($dataobj-raise) $params(-raise)542 lappend _dlist $dataobj 543 set _allDataObjs($dataobj) 1 544 set _obj2ovride($dataobj-color) $params(-color) 545 set _obj2ovride($dataobj-width) $params(-width) 546 set _obj2ovride($dataobj-raise) $params(-raise) 480 547 $_dispatcher event -idle !rebuild 481 548 } … … 499 566 -objects { 500 567 # put the dataobj list in order according to -raise options 501 set dlist $ dlist_568 set dlist $_dlist 502 569 foreach obj $dlist { 503 if {[info exists obj2ovride_($obj-raise)] && $obj2ovride_($obj-raise)} {570 if {[info exists _obj2ovride($obj-raise)] && $_obj2ovride($obj-raise)} { 504 571 set i [lsearch -exact $dlist $obj] 505 572 if {$i >= 0} { … … 543 610 itcl::body Rappture::FlowvisViewer::delete {args} { 544 611 if {[llength $args] == 0} { 545 set args $dlist_ 546 } 612 set args $_dlist 613 } 614 547 615 # Delete all specified dataobjs 548 616 set changed 0 549 617 foreach dataobj $args { 550 set pos [lsearch -exact $ dlist_$dataobj]618 set pos [lsearch -exact $_dlist $dataobj] 551 619 if { $pos >= 0 } { 552 set dlist_ [lreplace $dlist_ $pos $pos] 553 foreach key [array names obj2ovride_ $dataobj-*] { 554 unset obj2ovride_($key) 555 } 620 foreach comp [$dataobj components] { 621 if { [info exists obj2id($dataobj-$comp)] } { 622 set ivol $_obj2id($dataobj-$comp) 623 array unset _limits $ivol-* 624 } 625 } 626 set _dlist [lreplace $_dlist $pos $pos] 627 array unset _obj2ovride $dataobj-* 628 array unset _obj2flow $dataobj-* 629 array unset _obj2id $dataobj-* 630 array unset _obj2style $dataobj-* 556 631 set changed 1 557 632 } … … 559 634 # If anything changed, then rebuild the plot 560 635 if {$changed} { 636 # Repair the reverse lookup 637 foreach tf [array names _style2objs] { 638 set list {} 639 foreach {dataobj comp} $_style2objs($tf) break 640 if { [info exists _obj2id($dataobj-$comp)] } { 641 lappend list $dataobj $comp 642 } 643 if { $list == "" } { 644 array unset _style2objs $tf 645 } else { 646 set _style2objs($tf) $list 647 } 648 } 561 649 $_dispatcher event -idle !rebuild 562 650 } … … 574 662 itcl::body Rappture::FlowvisViewer::scale {args} { 575 663 foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} { 576 set limits_($val) ""664 set _limits($val) "" 577 665 } 578 666 foreach obj $args { … … 582 670 583 671 if {"" != $min && "" != $max} { 584 if {"" == $ limits_(${axis}min)} {585 set limits_(${axis}min) $min586 set limits_(${axis}max) $max672 if {"" == $_limits(${axis}min)} { 673 set _limits(${axis}min) $min 674 set _limits(${axis}max) $max 587 675 } else { 588 if {$min < $ limits_(${axis}min)} {589 set limits_(${axis}min) $min676 if {$min < $_limits(${axis}min)} { 677 set _limits(${axis}min) $min 590 678 } 591 if {$max > $ limits_(${axis}max)} {592 set limits_(${axis}max) $max679 if {$max > $_limits(${axis}max)} { 680 set _limits(${axis}max) $max 593 681 } 594 682 } … … 611 699 switch $option { 612 700 coming { 613 if {[catch {blt::winop snap $itk_component(plotarea) \ 614 $_image(download)}]} { 701 if {[catch { 702 blt::winop snap $itk_component(plotarea) $_image(download) 703 }]} { 615 704 $_image(download) configure -width 1 -height 1 616 705 $_image(download) put #000000 … … 644 733 -value $res 645 734 pack $inner.high -anchor w 646 735 button $inner.go -text [Rappture::filexfer::label download] \ 736 -command [lindex $args 0] 737 pack $inner.go -pady 4 738 $inner.draft select 647 739 } else { 648 740 set inner [$popup component inner] … … 699 791 set w [winfo width $itk_component(3dview)] 700 792 set h [winfo height $itk_component(3dview)] 701 SendCmd "screen $w $h"793 EventuallyResize $w $h 702 794 } 703 795 return $result … … 723 815 724 816 # disconnected -- no more data sitting on server 725 set outbuf_ "" 726 catch {unset obj2id_} 727 array unset id2obj_ 728 set obj2id_(count) 0 729 set id2obj_(count) 0 730 set sendobjs_ "" 731 } 732 733 itcl::body Rappture::FlowvisViewer::_send {string} { 734 SendCmd $string 735 } 817 set _outbuf "" 818 catch {unset _obj2id} 819 array unset _id2obj 820 set _obj2id(count) 0 821 set _id2obj(count) 0 822 set _sendobjs "" 823 } 824 736 825 # 737 826 # SendCmd … … 742 831 # 743 832 itcl::body Rappture::FlowvisViewer::SendCmd { string } { 744 if { [llength $sendobjs_] > 0} {745 append outbuf_$string "\n"833 if { $_buffering } { 834 append _outbuf $string "\n" 746 835 } else { 747 748 749 750 SendBytes $string 836 foreach line [split $string \n] { 837 SendEcho >>line $line 838 } 839 SendBytes "$string\n" 751 840 } 752 841 } … … 760 849 # ---------------------------------------------------------------------- 761 850 itcl::body Rappture::FlowvisViewer::SendDataObjs {} { 851 puts stderr "in SendDataObjs" 852 762 853 blt::busy hold $itk_component(hull); update idletasks 763 foreach dataobj $ sendobjs_{854 foreach dataobj $_sendobjs { 764 855 foreach comp [$dataobj components] { 765 856 # Send the data as one huge base64-encoded mess -- yuck! … … 767 858 set nbytes [string length $data] 768 859 set extents [$dataobj extents $comp] 769 770 860 # I have a field. Is a vector field or a volume field? 771 861 if { $extents == 1 } { 772 set cmd "volume data follows $nbytes "862 set cmd "volume data follows $nbytes $dataobj-$comp\n" 773 863 } else { 774 set cmd "flow data follows $nbytes $extents" 864 set cmd [FlowCmd $dataobj $comp $nbytes $extents] 865 if { $cmd == "" } { 866 puts stderr "no command" 867 continue 868 } 775 869 } 776 870 if { ![SendBytes $cmd] } { 871 puts stderr "can't send" 777 872 return 778 873 } 779 874 if { ![SendBytes $data] } { 875 puts stderr "can't send" 780 876 return 781 877 } 782 set ivol $obj2id_(count) 783 incr obj2id_(count) 784 785 set id2obj_($ivol) [list $dataobj $comp] 786 set obj2id_($dataobj-$comp) $ivol 787 NameTransferFunc $ivol 788 set receiveIds_($ivol) 1 789 } 790 } 791 set sendobjs_ "" 878 set ivol $_obj2id(count) 879 incr _obj2id(count) 880 881 NameTransferFunc $dataobj $comp 882 set _receiveIds($ivol) 1 883 } 884 } 885 set _sendobjs "" 792 886 blt::busy release $itk_component(hull) 793 887 888 # Turn on buffering of commands to the server. We don't want to 889 # be preempted by a server disconnect/reconnect (which automatically 890 # generates a new call to Rebuild). 891 set _buffering 1 892 794 893 # activate the proper volume 795 set first [lindex [get] 0]796 if { "" != $ first } {797 set axis [$ first hints updir]894 set _first [lindex [get] 0] 895 if { "" != $_first } { 896 set axis [$_first hints updir] 798 897 if {"" != $axis} { 799 898 SendCmd "up $axis" … … 802 901 # the first data object. This assumes that the data is always 803 902 # successfully transferred. 804 set comp [lindex [$first components] 0] 805 set activeTf_ $id2style_($obj2id_($first-$comp)) 806 } 807 foreach key [array names obj2id_ *-*] { 808 set state [string match $first-* $key] 809 set ivol $obj2id_($key) 810 SendCmd "volume state $state $ivol" 811 } 812 903 set comp [lindex [$_first components] 0] 904 set _activeTf [lindex $_obj2style($_first-$comp) 0] 905 } 906 907 if 0 { 908 SendCmd "volume state 0" 909 set vols {} 910 foreach key [array names _obj2id $_first-*] { 911 lappend vols $_obj2id($key) 912 } 913 if { $vols != "" && $_settings($this-volume) } { 914 SendCmd "volume state 1 $vols" 915 } 813 916 # sync the state of slicers 814 917 set vols [CurrentVolumeIds -cutplanes] 815 918 foreach axis {x y z} { 816 SendCmd "cutplane state [State ${axis}CutButton] $axis $vols" 817 set pos [expr {0.01*[$itk_component(${axis}CutScale) get]}] 818 SendCmd "cutplane position $pos $axis $vols" 819 } 820 SendCmd "volume data state [State volume] $vols" 821 822 if 0 { 919 SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols" 920 set pos [expr {0.01*$_settings($this-${axis}cutposition)}] 921 SendCmd "cutplane position $pos $axis $vols" 922 } 923 823 924 # Add this when we fix grid for volumes 824 925 SendCmd "volume axis label x \"\"" … … 829 930 SendCmd "grid axisname z Z eV" 830 931 } 831 # if there are any commands in the buffer, send them now that we're done 832 SendBytes $outbuf_ 833 set outbuf_ "" 932 933 # Actually write the commands to the server socket. If it fails, we don't 934 # care. We're finished here. 935 SendBytes $_outbuf; 936 set _buffering 0; # Turn off buffering. 937 set _outbuf ""; # Clear the buffer. 834 938 } 835 939 … … 838 942 # ---------------------------------------------------------------------- 839 943 itcl::body Rappture::FlowvisViewer::SendTransferFuncs {} { 840 if { $activeTf_ == "" } { 841 return 842 } 843 set tf $activeTf_ 844 set first [lindex [get] 0] 944 if { $_activeTf == "" } { 945 return 946 } 947 set tf $_activeTf 948 if { $_first == "" } { 949 return 950 } 845 951 846 952 # Insure that the global opacity and thickness settings (in the slider 847 953 # settings widgets) are used for the active transfer-function. Update the 848 # values in the settings_ varible. 849 set inner $itk_component(settingsFrame) 850 set value [$inner.opacity get] 954 # values in the _settings varible. 955 set value $_settings($this-opacity) 851 956 set opacity [expr { double($value) * 0.01 }] 852 set settings_($this-$tf-opacity) $opacity853 set value [$inner.thickness get]957 set _settings($this-$tf-opacity) $opacity 958 set value $_settings($this-thickness) 854 959 # Scale values between 0.00001 and 0.01000 855 960 set thickness [expr {double($value) * 0.0001}] 856 set settings_($this-$tf-thickness) $thickness 857 858 if { ![info exists $obj2styles_($first)] } { 859 foreach tf $obj2styles_($first) { 860 ComputeTransferFunc $tf 861 } 862 FixLegend 863 } 864 } 865 866 # ---------------------------------------------------------------------- 867 # USAGE: ReceiveImage -bytes <size> 961 set _settings($this-$tf-thickness) $thickness 962 963 foreach key [array names _obj2style $_first-*] { 964 if { [info exists _obj2style($key)] } { 965 foreach tf $_obj2style($key) { 966 ComputeTransferFunc $tf 967 } 968 } 969 } 970 FixLegend 971 } 972 973 # ---------------------------------------------------------------------- 974 # USAGE: ReceiveImage -bytes $size -type $type -token $token 868 975 # 869 976 # Invoked automatically whenever the "image" command comes in from … … 871 978 # specified <size> will follow. 872 979 # ---------------------------------------------------------------------- 873 set counter 0874 980 itcl::body Rappture::FlowvisViewer::ReceiveImage { args } { 875 981 if {![isconnected]} { … … 877 983 } 878 984 array set info { 985 -token "???" 986 -bytes 0 879 987 -type image 880 988 } … … 885 993 ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>" 886 994 $_image(plot) configure -data $bytes 995 } elseif { $info(type) == "print" } { 996 set tag $this-print-$info(-token) 997 set _hardcopy($tag) $bytes 887 998 } elseif { $info(type) == "movie" } { 888 999 set tag $this-movie-$info(-token) 889 set hardcopy_($tag) $bytes1000 set _hardcopy($tag) $bytes 890 1001 } 891 1002 } … … 915 1026 set w [winfo width $c] 916 1027 set h [winfo height $c] 917 #foreach { dataobj comp } $ id2obj_($ivol) break1028 #foreach { dataobj comp } $_id2obj($ivol) break 918 1029 set lx 10 919 1030 set ly [expr {$h - 1}] … … 930 1041 } 931 1042 # Display the markers used by the active transfer function. 932 #set tf $ activeTf_1043 #set tf $_activeTf 933 1044 934 1045 array set limits [limits $tf] … … 939 1050 $c coords vmax [expr {$w-$lx}] $ly 940 1051 941 if { [info exists isomarkers_($tf)] } {942 foreach m $ isomarkers_($tf) {943 $m visible on1052 if { [info exists _isomarkers($tf)] } { 1053 foreach m $_isomarkers($tf) { 1054 $m visible yes 944 1055 } 945 1056 } … … 951 1062 # The procedure is the response from the render server to each "data 952 1063 # follows" command. The server sends back a "data" command invoked our 953 # the #slave interpreter. The purpose is to collect the min/max of the954 # volume sent #to the render server. Since the client (flowvisviewer)955 # doesn't parse 3D #data formats, we rely on the server (flowvis) to956 # tell us what the limits #are. Once we've received the limits to all957 # the data we've sent (tracked by # receiveIds_) we can then determine1064 # the slave interpreter. The purpose is to collect the min/max of the 1065 # volume sent to the render server. Since the client (flowvisviewer) 1066 # doesn't parse 3D data formats, we rely on the server (flowvis) to 1067 # tell us what the limits are. Once we've received the limits to all 1068 # the data we've sent (tracked by _receiveIds) we can then determine 958 1069 # what the transfer functions are for these # volumes. 959 1070 # … … 974 1085 975 1086 set ivol $info(id); # Id of volume created by server. 976 977 set limits_($ivol-min) $info(min); # Minimum value of the volume. 978 set limits_($ivol-max) $info(max); # Maximum value of the volume. 979 set limits_(vmin) $info(vmin); # Overall minimum value. 980 set limits_(vmax) $info(vmax); # Overall maximum value. 981 982 unset receiveIds_($ivol) 983 if { [array size receiveIds_] == 0 } { 1087 set tag $info(tag) 1088 set parts [split $tag -] 1089 1090 # 1091 # Volumes don't exist until we're told about them. 1092 # 1093 set _id2obj($ivol) $parts 1094 set dataobj [lindex $parts 0] 1095 set _obj2id($tag) $ivol 1096 # It's a lie. There's no volume yet. 1097 if { $_settings($this-volume) && $dataobj == $_first } { 1098 SendCmd "volume state 1" 1099 } 1100 set _limits($ivol-min) $info(min); # Minimum value of the volume. 1101 set _limits($ivol-max) $info(max); # Maximum value of the volume. 1102 set _limits(vmin) $info(vmin); # Overall minimum value. 1103 set _limits(vmax) $info(vmax); # Overall maximum value. 1104 1105 unset _receiveIds($ivol) 1106 if { [array size _receiveIds] == 0 } { 984 1107 updatetransferfuncs 985 1108 } … … 994 1117 # 995 1118 itcl::body Rappture::FlowvisViewer::Rebuild {} { 996 1119 puts stderr "in Rebuild" 997 1120 # Hide all the isomarkers. Can't remove them. Have to remember the 998 1121 # settings since the user may have created/deleted/moved markers. 999 1122 1000 foreach tf [array names isomarkers_] {1001 foreach m $ isomarkers_($tf) {1002 $m visible off1123 foreach tf [array names _isomarkers] { 1124 foreach m $_isomarkers($tf) { 1125 $m visible no 1003 1126 } 1004 1127 } 1005 1128 1006 1129 # in the midst of sending data? then bail out 1007 if {[llength $ sendobjs_] > 0} {1130 if {[llength $_sendobjs] > 0} { 1008 1131 return 1009 1132 } 1010 1133 1134 # Turn on buffering of commands to the server. We don't want to 1135 # be preempted by a server disconnect/reconnect (which automatically 1136 # generates a new call to Rebuild). 1137 set _buffering 1 1138 1011 1139 # Find any new data that needs to be sent to the server. Queue this up on 1012 # the sendobjs_list, and send it out a little at a time. Do this first,1140 # the _sendobjs list, and send it out a little at a time. Do this first, 1013 1141 # before we rebuild the rest. 1014 1142 foreach dataobj [get] { 1015 1143 set comp [lindex [$dataobj components] 0] 1016 if {![info exists obj2id_($dataobj-$comp)]} { 1017 set i [lsearch -exact $sendobjs_ $dataobj] 1018 if {$i < 0} { 1019 lappend sendobjs_ $dataobj 1144 if {![info exists _obj2id($dataobj-$comp)]} { 1145 if { [lsearch -exact $_sendobjs $dataobj] < 0 } { 1146 lappend _sendobjs $dataobj 1020 1147 } 1021 1148 } … … 1023 1150 set w [winfo width $itk_component(3dview)] 1024 1151 set h [winfo height $itk_component(3dview)] 1025 SendCmd "screen $w $h"1152 EventuallyResize $w $h 1026 1153 1027 1154 # 1028 1155 # Reset the camera and other view parameters 1029 1156 # 1030 set xyz [Euler2XYZ $ view_(theta) $view_(phi) $view_(psi)]1157 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1031 1158 SendCmd "camera angle $xyz" 1032 1159 PanCamera 1033 SendCmd "camera zoom $ view_(zoom)"1034 1035 set settings_($this-theta) $view_(theta)1036 set settings_($this-phi) $view_(phi)1037 set settings_($this-psi) $view_(psi)1038 set settings_($this-pan-x) $view_(pan-x)1039 set settings_($this-pan-y) $view_(pan-y)1040 set settings_($this-zoom) $view_(zoom)1160 SendCmd "camera zoom $_view(zoom)" 1161 1162 set _settings($this-theta) $_view(theta) 1163 set _settings($this-phi) $_view(phi) 1164 set _settings($this-psi) $_view(psi) 1165 set _settings($this-pan-x) $_view(pan-x) 1166 set _settings($this-pan-y) $_view(pan-y) 1167 set _settings($this-zoom) $_view(zoom) 1041 1168 1042 1169 FixSettings light … … 1047 1174 FixSettings outline 1048 1175 1049 if {[llength $ sendobjs_] > 0} {1176 if {[llength $_sendobjs] > 0} { 1050 1177 # send off new data objects 1051 1178 $_dispatcher event -idle !send_dataobjs … … 1054 1181 1055 1182 # nothing to send -- activate the proper ivol 1056 set first [lindex [get] 0]1057 if {"" != $ first} {1058 set axis [$ first hints updir]1183 set _first [lindex [get] 0] 1184 if {"" != $_first} { 1185 set axis [$_first hints updir] 1059 1186 if {"" != $axis} { 1060 1187 SendCmd "up $axis" 1061 1188 } 1062 foreach key [array names obj2id_ *-*] { 1063 set state [string match $first-* $key] 1064 SendCmd "volume state $state $obj2id_($key)" 1065 } 1189 if { 0 && $_settings($this-volume) } { 1190 SendCmd "volume state 0" 1191 foreach key [array names _obj2id $_first-*] { 1192 lappend vols $_obj2id($key) 1193 } 1194 SendCmd "volume state 1 $vols" 1195 } 1066 1196 # 1067 # The obj2id_ and id2style_arrays may or may not have the right1197 # The _obj2id and _id2style arrays may or may not have the right 1068 1198 # information. It's possible for the server to know about volumes 1069 1199 # that the client has assumed it's deleted. We could add checks. 1070 1200 # But this problem needs to be fixed not bandaided. 1071 set comp [lindex [$ first components] 0]1072 set ivol $ obj2id_($first-$comp)1073 1074 foreach comp [$first components] {1075 foreach ivol $obj2id_($first-$comp){1076 NameTransferFunc $ivol1077 } 1201 set comp [lindex [$_first components] 0] 1202 set ivol $_obj2id($_first-$comp) 1203 1204 } 1205 foreach dataobj [get] { 1206 foreach comp [$_first components] { 1207 NameTransferFunc $dataobj $comp 1078 1208 } 1079 1209 } … … 1082 1212 set vols [CurrentVolumeIds -cutplanes] 1083 1213 foreach axis {x y z} { 1084 SendCmd "cutplane state [State ${axis}CutButton]$axis $vols"1085 set pos [expr {0.01*[$itk_component(${axis}CutScale) get]}]1086 1087 } 1088 SendCmd "volume data state [State volume] $vols"1214 SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols" 1215 set pos [expr {0.01*$_settings($this-${axis}cutposition)}] 1216 SendCmd "cutplane position $pos $axis $vols" 1217 } 1218 SendCmd "volume data state $_settings($this-volume)" 1089 1219 $_dispatcher event -idle !legend 1220 1221 # Actually write the commands to the server socket. If it fails, we don't 1222 # care. We're finished here. 1223 SendBytes $_outbuf; 1224 set _buffering 0; # Turn off buffering. 1225 set _outbuf ""; # Clear the buffer. 1226 puts stderr "exit Rebuild" 1090 1227 } 1091 1228 … … 1099 1236 itcl::body Rappture::FlowvisViewer::CurrentVolumeIds {{what -all}} { 1100 1237 set rlist "" 1101 1102 set first [lindex [get] 0] 1103 foreach key [array names obj2id_ *-*] { 1104 if {[string match $first-* $key]} { 1238 if { $_first == "" } { 1239 return 1240 } 1241 foreach key [array names _obj2id *-*] { 1242 if {[string match $_first-* $key]} { 1105 1243 array set style { 1106 1244 -cutplanes 1 … … 1110 1248 1111 1249 if {$what != "-cutplanes" || $style(-cutplanes)} { 1112 lappend rlist $ obj2id_($key)1250 lappend rlist $_obj2id($key) 1113 1251 } 1114 1252 } … … 1128 1266 switch -- $option { 1129 1267 "in" { 1130 set view_(zoom) [expr {$view_(zoom)*1.25}]1131 set settings_($this-zoom) $view_(zoom)1268 set _view(zoom) [expr {$_view(zoom)*1.25}] 1269 set _settings($this-zoom) $_view(zoom) 1132 1270 } 1133 1271 "out" { 1134 set view_(zoom) [expr {$view_(zoom)*0.8}]1135 set settings_($this-zoom) $view_(zoom)1272 set _view(zoom) [expr {$_view(zoom)*0.8}] 1273 set _settings($this-zoom) $_view(zoom) 1136 1274 } 1137 1275 "reset" { 1138 array set view_{1276 array set _view { 1139 1277 theta 45 1140 1278 phi 45 … … 1144 1282 pan-y 0 1145 1283 } 1146 set first [lindex [get] 0] 1147 if { $first != "" } { 1148 set location [$first hints camera] 1284 if { $_first != "" } { 1285 set location [$_first hints camera] 1149 1286 if { $location != "" } { 1150 array set view_$location1287 array set _view $location 1151 1288 } 1152 1289 } 1153 set xyz [Euler2XYZ $ view_(theta) $view_(phi) $view_(psi)]1290 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1154 1291 SendCmd "camera angle $xyz" 1155 1292 PanCamera 1156 set settings_($this-theta) $view_(theta)1157 set settings_($this-phi) $view_(phi)1158 set settings_($this-psi) $view_(psi)1159 set settings_($this-pan-x) $view_(pan-x)1160 set settings_($this-pan-y) $view_(pan-y)1161 set settings_($this-zoom) $view_(zoom)1162 } 1163 } 1164 SendCmd "camera zoom $ view_(zoom)"1293 set _settings($this-theta) $_view(theta) 1294 set _settings($this-phi) $_view(phi) 1295 set _settings($this-psi) $_view(psi) 1296 set _settings($this-pan-x) $_view(pan-x) 1297 set _settings($this-pan-y) $_view(pan-y) 1298 set _settings($this-zoom) $_view(zoom) 1299 } 1300 } 1301 SendCmd "camera zoom $_view(zoom)" 1165 1302 } 1166 1303 1167 1304 itcl::body Rappture::FlowvisViewer::PanCamera {} { 1168 #set x [expr ($ view_(pan-x)) / $limits_(xrange)]1169 #set y [expr ($ view_(pan-y)) / $limits_(yrange)]1170 set x $ view_(pan-x)1171 set y $ view_(pan-y)1305 #set x [expr ($_view(pan-x)) / $_limits(xrange)] 1306 #set y [expr ($_view(pan-y)) / $_limits(yrange)] 1307 set x $_view(pan-x) 1308 set y $_view(pan-y) 1172 1309 SendCmd "camera pan $x $y" 1173 1310 } … … 1185 1322 click { 1186 1323 $itk_component(3dview) configure -cursor fleur 1187 set click_(x) $x1188 set click_(y) $y1189 set click_(theta) $view_(theta)1190 set click_(phi) $view_(phi)1324 set _click(x) $x 1325 set _click(y) $y 1326 set _click(theta) $_view(theta) 1327 set _click(phi) $_view(phi) 1191 1328 } 1192 1329 drag { 1193 if {[array size click_] == 0} {1330 if {[array size _click] == 0} { 1194 1331 Rotate click $x $y 1195 1332 } else { … … 1202 1339 if {[catch { 1203 1340 # this fails sometimes for no apparent reason 1204 set dx [expr {double($x-$ click_(x))/$w}]1205 set dy [expr {double($y-$ click_(y))/$h}]1341 set dx [expr {double($x-$_click(x))/$w}] 1342 set dy [expr {double($y-$_click(y))/$h}] 1206 1343 }]} { 1207 1344 return … … 1211 1348 # Rotate the camera in 3D 1212 1349 # 1213 if {$ view_(psi) > 90 || $view_(psi) < -90} {1350 if {$_view(psi) > 90 || $_view(psi) < -90} { 1214 1351 # when psi is flipped around, theta moves backwards 1215 1352 set dy [expr {-$dy}] 1216 1353 } 1217 set theta [expr {$ view_(theta) - $dy*180}]1354 set theta [expr {$_view(theta) - $dy*180}] 1218 1355 while {$theta < 0} { set theta [expr {$theta+180}] } 1219 1356 while {$theta > 180} { set theta [expr {$theta-180}] } 1220 1357 1221 1358 if {abs($theta) >= 30 && abs($theta) <= 160} { 1222 set phi [expr {$ view_(phi) - $dx*360}]1359 set phi [expr {$_view(phi) - $dx*360}] 1223 1360 while {$phi < 0} { set phi [expr {$phi+360}] } 1224 1361 while {$phi > 360} { set phi [expr {$phi-360}] } 1225 set psi $ view_(psi)1362 set psi $_view(psi) 1226 1363 } else { 1227 set phi $ view_(phi)1228 set psi [expr {$ view_(psi) - $dx*360}]1364 set phi $_view(phi) 1365 set psi [expr {$_view(psi) - $dx*360}] 1229 1366 while {$psi < -180} { set psi [expr {$psi+360}] } 1230 1367 while {$psi > 180} { set psi [expr {$psi-360}] } 1231 1368 } 1232 1369 1233 set view_(theta) $theta1234 set view_(phi) $phi1235 set view_(psi) $psi1370 set _view(theta) $theta 1371 set _view(phi) $phi 1372 set _view(psi) $psi 1236 1373 set xyz [Euler2XYZ $theta $phi $psi] 1237 set settings_($this-theta) $view_(theta)1238 set settings_($this-phi) $view_(phi)1239 set settings_($this-psi) $view_(psi)1374 set _settings($this-theta) $_view(theta) 1375 set _settings($this-phi) $_view(phi) 1376 set _settings($this-psi) $_view(psi) 1240 1377 SendCmd "camera angle $xyz" 1241 set click_(x) $x1242 set click_(y) $y1378 set _click(x) $x 1379 set _click(y) $y 1243 1380 } 1244 1381 } … … 1246 1383 Rotate drag $x $y 1247 1384 $itk_component(3dview) configure -cursor "" 1248 catch {unset click_}1385 catch {unset _click} 1249 1386 } 1250 1387 default { … … 1269 1406 set x [expr $x / double($w)] 1270 1407 set y [expr $y / double($h)] 1271 set view_(pan-x) [expr $view_(pan-x) + $x]1272 set view_(pan-y) [expr $view_(pan-y) + $y]1408 set _view(pan-x) [expr $_view(pan-x) + $x] 1409 set _view(pan-y) [expr $_view(pan-y) + $y] 1273 1410 PanCamera 1274 set settings_($this-pan-x) $view_(pan-x)1275 set settings_($this-pan-y) $view_(pan-y)1411 set _settings($this-pan-x) $_view(pan-x) 1412 set _settings($this-pan-y) $_view(pan-y) 1276 1413 return 1277 1414 } 1278 1415 if { $option == "click" } { 1279 set click_(x) $x1280 set click_(y) $y1416 set _click(x) $x 1417 set _click(y) $y 1281 1418 $itk_component(3dview) configure -cursor hand1 1282 1419 } 1283 1420 if { $option == "drag" || $option == "release" } { 1284 set dx [expr ($ click_(x) - $x)/double($w)]1285 set dy [expr ($ click_(y) - $y)/double($h)]1286 set click_(x) $x1287 set click_(y) $y1288 set view_(pan-x) [expr $view_(pan-x) - $dx]1289 set view_(pan-y) [expr $view_(pan-y) - $dy]1421 set dx [expr ($_click(x) - $x)/double($w)] 1422 set dy [expr ($_click(y) - $y)/double($h)] 1423 set _click(x) $x 1424 set _click(y) $y 1425 set _view(pan-x) [expr $_view(pan-x) - $dx] 1426 set _view(pan-y) [expr $_view(pan-y) - $dy] 1290 1427 PanCamera 1291 set settings_($this-pan-x) $view_(pan-x)1292 set settings_($this-pan-y) $view_(pan-y)1428 set _settings($this-pan-x) $_view(pan-x) 1429 set _settings($this-pan-y) $_view(pan-y) 1293 1430 } 1294 1431 if { $option == "release" } { … … 1297 1434 } 1298 1435 1299 # ----------------------------------------------------------------------1300 # USAGE: Slice axis x|y|z ?on|off|toggle?1301 # USAGE: Slice move x|y|z <newval>1302 # USAGE: Slice volume ?on|off|toggle?1303 #1304 # Called automatically when the user drags the slider to move the1305 # cut plane that slices 3D data. Gets the current value from the1306 # slider and moves the cut plane to the appropriate point in the1307 # data set.1308 # ----------------------------------------------------------------------1309 itcl::body Rappture::FlowvisViewer::Slice {option args} {1310 switch -- $option {1311 axis {1312 if {[llength $args] < 1 || [llength $args] > 2} {1313 error "wrong # args: should be \"Slice axis x|y|z ?on|off|toggle?\""1314 }1315 set axis [lindex $args 0]1316 set op [lindex $args 1]1317 if {$op == ""} {1318 set op "on"1319 }1320 set current [State ${axis}CutButton]1321 if {$op == "toggle"} {1322 if {$current == "on"} {1323 set op "off"1324 } else {1325 set op "on"1326 }1327 }1328 if {$op} {1329 $itk_component(${axis}CutButton) configure \1330 -relief sunken -image [Rappture::icon ${axis}-cutplane-on]1331 SendCmd "cutplane state 1 $axis [CurrentVolumeIds -cutplanes]"1332 $itk_component(${axis}CutScale) configure -state normal \1333 -troughcolor grey651334 } else {1335 $itk_component(${axis}CutButton) configure \1336 -relief raised -image [Rappture::icon ${axis}-cutplane-off]1337 SendCmd "cutplane state 0 $axis [CurrentVolumeIds -cutplanes]"1338 $itk_component(${axis}CutScale) configure -state disabled \1339 -troughcolor grey821340 }1341 }1342 move {1343 if {[llength $args] != 2} {1344 error "wrong # args: should be \"Slice move x|y|z newval\""1345 }1346 set axis [lindex $args 0]1347 set newval [lindex $args 1]1348 1349 set newpos [expr {0.01*$newval}]1350 # set newval [expr {0.01*($newval-50)1351 # *($limits_(${axis}max)-$limits_(${axis}min))1352 # + 0.5*($limits_(${axis}max)+$limits_(${axis}min))}]1353 1354 # show the current value in the readout1355 #puts "readout: $axis = $newval"1356 1357 set ids [CurrentVolumeIds -cutplanes]1358 SendCmd "cutplane position $newpos $axis $ids"1359 }1360 volume {1361 if {[llength $args] > 1} {1362 error "wrong # args: should be \"Slice volume ?on|off|toggle?\""1363 }1364 set op [lindex $args 0]1365 if {$op == ""} { set op "on" }1366 1367 set current $settings_($this-volume)1368 if {$op == "toggle"} {1369 if {$current} {1370 set op "off"1371 } else {1372 set op "on"1373 }1374 }1375 1376 if {$op} {1377 SendCmd "volume data state on [CurrentVolumeIds]"1378 $itk_component(volume) configure -relief sunken1379 set settings_($this-volume) 11380 } else {1381 SendCmd "volume data state off [CurrentVolumeIds]"1382 $itk_component(volume) configure -relief raised1383 set settings_($this-volume) 01384 }1385 }1386 default {1387 error "bad option \"$option\": should be axis, move, or volume"1388 }1389 }1390 }1391 1392 # ----------------------------------------------------------------------1393 # USAGE: SlicerTip <axis>1394 #1395 # Used internally to generate a tooltip for the x/y/z slicer controls.1396 # Returns a message that includes the current slicer value.1397 # ----------------------------------------------------------------------1398 itcl::body Rappture::FlowvisViewer::SlicerTip {axis} {1399 set val [$itk_component(${axis}CutScale) get]1400 # set val [expr {0.01*($val-50)1401 # *($limits_(${axis}max)-$limits_(${axis}min))1402 # + 0.5*($limits_(${axis}max)+$limits_(${axis}min))}]1403 return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%"1404 }1405 1436 1406 1437 # ---------------------------------------------------------------------- … … 1437 1468 set inner $itk_component(settingsFrame) 1438 1469 set frames [$inner.framecnt value] 1439 set settings_(numframes) $frames1470 set _settings(numframes) $frames 1440 1471 set cmds "flow capture $frames" 1441 _send $cmds1472 SendCmd $cmds 1442 1473 } 1443 1474 } … … 1449 1480 _pause 1450 1481 set cmds "flow reset" 1451 _send $cmds1482 SendCmd $cmds 1452 1483 } 1453 1484 } … … 1482 1513 itcl::body Rappture::FlowvisViewer::Play {} { 1483 1514 SendCmd "flow next" 1484 set delay [expr {int(ceil(pow($ settings_(speed)/10.0+2,2.0)*15))}]1515 set delay [expr {int(ceil(pow($_settings(speed)/10.0+2,2.0)*15))}] 1485 1516 $_dispatcher event -after $delay !play 1486 1517 } … … 1504 1535 1505 1536 # ---------------------------------------------------------------------- 1506 # USAGE: State <component>1507 #1508 # Used internally to determine the state of a toggle button.1509 # The <component> is the itk component name of the button.1510 # Returns on/off for the state of the button.1511 # ----------------------------------------------------------------------1512 itcl::body Rappture::FlowvisViewer::State {comp} {1513 if {[$itk_component(${comp}) cget -relief] == "sunken"} {1514 return "on"1515 }1516 return "off"1517 }1518 1519 # ----------------------------------------------------------------------1520 1537 # USAGE: FixSettings <what> ?<value>? 1521 1538 # … … 1528 1545 light { 1529 1546 if {[isconnected]} { 1530 set val $ settings_($this-light)1547 set val $_settings($this-light) 1531 1548 set sval [expr {0.1*$val}] 1532 1549 SendCmd "volume shading diffuse $sval" … … 1537 1554 transp { 1538 1555 if {[isconnected]} { 1539 set val $ settings_($this-transp)1556 set val $_settings($this-transp) 1540 1557 set sval [expr {0.2*$val+1}] 1541 1558 SendCmd "volume shading opacity $sval" … … 1543 1560 } 1544 1561 opacity { 1545 if {[isconnected] && $ activeTf_!= "" } {1546 set val $ settings_($this-opacity)1562 if {[isconnected] && $_activeTf != "" } { 1563 set val $_settings($this-opacity) 1547 1564 set sval [expr { 0.01 * double($val) }] 1548 set tf $ activeTf_1549 set settings_($this-$tf-opacity) $sval1565 set tf $_activeTf 1566 set _settings($this-$tf-opacity) $sval 1550 1567 updatetransferfuncs 1551 1568 } … … 1553 1570 1554 1571 thickness { 1555 if {[isconnected] && $ activeTf_!= "" } {1556 set val $ settings_($this-thickness)1572 if {[isconnected] && $_activeTf != "" } { 1573 set val $_settings($this-thickness) 1557 1574 # Scale values between 0.00001 and 0.01000 1558 1575 set sval [expr {0.0001*double($val)}] 1559 set tf $ activeTf_1560 set settings_($this-$tf-thickness) $sval1576 set tf $_activeTf 1577 set _settings($this-$tf-thickness) $sval 1561 1578 updatetransferfuncs 1562 1579 } … … 1564 1581 "outline" { 1565 1582 if {[isconnected]} { 1566 SendCmd "volume outline state $ settings_($this-outline)"1583 SendCmd "volume outline state $_settings($this-outline)" 1567 1584 } 1568 1585 } 1569 1586 "isosurface" { 1570 1587 if {[isconnected]} { 1571 SendCmd "volume shading isosurface $ settings_($this-isosurface)"1588 SendCmd "volume shading isosurface $_settings($this-isosurface)" 1572 1589 } 1573 1590 } 1574 1591 "grid" { 1575 1592 if { [isconnected] } { 1576 SendCmd "grid visible $ settings_($this-grid)"1593 SendCmd "grid visible $_settings($this-grid)" 1577 1594 } 1578 1595 } 1579 1596 "axes" { 1580 1597 if { [isconnected] } { 1581 SendCmd "axis visible $ settings_($this-axes)"1598 SendCmd "axis visible $_settings($this-axes)" 1582 1599 } 1583 1600 } 1584 1601 "legend" { 1585 if { $ settings_($this-legend) } {1602 if { $_settings($this-legend) } { 1586 1603 blt::table $itk_component(plotarea) \ 1587 1,0 $itk_component(legend) -fill x 1604 0,0 $itk_component(3dview) -fill both \ 1605 1,0 $itk_component(legend) -fill x 1606 blt::table configure $itk_component(plotarea) r1 -resize none 1588 1607 } else { 1589 1608 blt::table forget $itk_component(legend) … … 1591 1610 } 1592 1611 "volume" { 1593 Slice volume $settings_($this-volume) 1594 } 1595 "particles" { 1612 if { [isconnected] } { 1613 set vols [CurrentVolumeIds -cutplanes] 1614 SendCmd "volume data state $_settings($this-volume) $vols" 1615 } 1616 } 1617 "xcutplane" - "ycutplane" - "zcutplane" { 1618 set axis [string range $what 0 1] 1619 set bool $_settings($this-$what) 1620 if { [isconnected] } { 1621 set vols [CurrentVolumeIds -cutplanes] 1622 SendCmd "cutplane state $bool $axis $vols" 1623 } 1624 if { $bool } { 1625 $itk_component(${axis}CutScale) configure -state normal \ 1626 -troughcolor white 1627 } else { 1628 $itk_component(${axis}CutScale) configure -state disabled \ 1629 -troughcolor grey82 1630 } 1596 1631 } 1597 1632 default { … … 1610 1645 itcl::body Rappture::FlowvisViewer::FixLegend {} { 1611 1646 set lineht [font metrics $itk_option(-font) -linespace] 1612 set w [expr { [winfo width $itk_component(legend)]-20}]1647 set w [expr {$_width-20}] 1613 1648 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 1614 if {$w > 0 && $h > 0 && "" != $ activeTf_} {1615 SendCmd "legend $ activeTf_$w $h"1649 if {$w > 0 && $h > 0 && "" != $_activeTf} { 1650 SendCmd "legend $_activeTf $w $h" 1616 1651 } else { 1617 1652 # Can't do this as this will remove the items associated with the … … 1637 1672 # now. 1638 1673 # 1639 itcl::body Rappture::FlowvisViewer::NameTransferFunc { ivol} {1674 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj comp } { 1640 1675 array set style { 1641 1676 -color rainbow … … 1643 1678 -opacity 1.0 1644 1679 } 1645 foreach {dataobj comp} $id2obj_($ivol) break1646 1680 array set style [lindex [$dataobj components -style $comp] 0] 1647 1681 set tf "$style(-color):$style(-levels):$style(-opacity)" 1648 1649 set id2style_($ivol) $tf 1650 lappend obj2styles_($dataobj) $tf 1651 lappend style2ids_($tf) $ivol 1682 lappend _obj2style($dataobj-$comp) $tf 1683 puts stderr "creating tf=$tf $dataobj-$comp" 1684 parray _obj2style 1685 lappend _style2objs($tf) $dataobj $comp 1686 return $tf 1652 1687 } 1653 1688 … … 1668 1703 } 1669 1704 set dataobj ""; set comp "" 1670 foreach ivol $style2ids_($tf) { 1671 if { [info exists id2obj_($ivol)] } { 1672 foreach {dataobj comp} $id2obj_($ivol) break 1673 break 1674 } 1675 } 1705 foreach {dataobj comp} $_style2objs($tf) break 1676 1706 if { $dataobj == "" } { 1677 1707 return 0 … … 1693 1723 # barn on this one. 1694 1724 1695 if { ![info exists isomarkers_($tf)] } {1725 if { ![info exists _isomarkers($tf)] } { 1696 1726 # Have to defer creation of isomarkers until we have data limits 1697 1727 if { [info exists style(-markers)] } { 1698 ParseMarkersOption $tf $ ivol $style(-markers)1728 ParseMarkersOption $tf $style(-markers) 1699 1729 } else { 1700 ParseLevelsOption $tf $ ivol $style(-levels)1730 ParseLevelsOption $tf $style(-levels) 1701 1731 } 1702 1732 } … … 1714 1744 1715 1745 set tag $this-$tf 1716 if { ![info exists settings_($tag-opacity)] } {1717 set settings_($tag-opacity) $style(-opacity)1718 } 1719 set max $ settings_($tag-opacity)1746 if { ![info exists _settings($tag-opacity)] } { 1747 set _settings($tag-opacity) $style(-opacity) 1748 } 1749 set max $_settings($tag-opacity) 1720 1750 1721 1751 set isovalues {} 1722 foreach m $ isomarkers_($tf) {1752 foreach m $_isomarkers($tf) { 1723 1753 lappend isovalues [$m relval] 1724 1754 } … … 1726 1756 set isovalues [lsort -real $isovalues] 1727 1757 1728 if { ![info exists settings_($tag-thickness)]} {1729 set settings_($tag-thickness) 0.051730 } 1731 set delta $ settings_($tag-thickness)1758 if { ![info exists _settings($tag-thickness)]} { 1759 set _settings($tag-thickness) 0.05 1760 } 1761 set delta $_settings($tag-thickness) 1732 1762 1733 1763 set first [lindex $isovalues 0] … … 1772 1802 } 1773 1803 SendBytes "transfunc define $tf { $cmap } { $wmap }\n" 1774 return [SendBytes " volume shading transfunc $tf $style2ids_($tf)\n"]1804 return [SendBytes "$dataobj-$comp configure -transferfunction $tf\n"] 1775 1805 } 1776 1806 … … 1820 1850 # marker is a relative value from 0.0 to 1.0. 1821 1851 # 1822 itcl::body Rappture::FlowvisViewer::ParseLevelsOption { tf ivollevels } {1852 itcl::body Rappture::FlowvisViewer::ParseLevelsOption { tf levels } { 1823 1853 set c $itk_component(legend) 1824 1854 regsub -all "," $levels " " levels … … 1826 1856 for {set i 1} { $i <= $levels } {incr i} { 1827 1857 set x [expr {double($i)/($levels+1)}] 1828 set m [ IsoMarker \#auto $c $this $tf]1858 set m [Rappture::IsoMarker \#auto $c $this $tf] 1829 1859 $m relval $x 1830 lappend isomarkers_($tf) $m1860 lappend _isomarkers($tf) $m 1831 1861 } 1832 1862 } else { 1833 1863 foreach x $levels { 1834 set m [ IsoMarker \#auto $c $this $tf]1864 set m [Rappture::IsoMarker \#auto $c $this $tf] 1835 1865 $m relval $x 1836 lappend isomarkers_($tf) $m1866 lappend _isomarkers($tf) $m 1837 1867 } 1838 1868 } … … 1851 1881 # not be seen. 1852 1882 # 1853 itcl::body Rappture::FlowvisViewer::ParseMarkersOption { tf ivolmarkers } {1883 itcl::body Rappture::FlowvisViewer::ParseMarkersOption { tf markers } { 1854 1884 set c $itk_component(legend) 1855 1885 regsub -all "," $markers " " markers … … 1859 1889 # ${n}% : Set relative value. 1860 1890 set value [expr {$value * 0.01}] 1861 set m [ IsoMarker \#auto $c $this $tf]1891 set m [Rappture::IsoMarker \#auto $c $this $tf] 1862 1892 $m relval $value 1863 lappend isomarkers_($tf) $m1893 lappend _isomarkers($tf) $m 1864 1894 } else { 1865 1895 # ${n} : Set absolute value. 1866 set m [ IsoMarker \#auto $c $this $tf]1896 set m [Rappture::IsoMarker \#auto $c $this $tf] 1867 1897 $m absval $value 1868 lappend isomarkers_($tf) $m1898 lappend _isomarkers($tf) $m 1869 1899 } 1870 1900 } … … 1879 1909 1880 1910 itcl::body Rappture::FlowvisViewer::AddIsoMarker { x y } { 1881 if { $ activeTf_== "" } {1911 if { $_activeTf == "" } { 1882 1912 error "active transfer function isn't set" 1883 1913 } 1884 set tf $ activeTf_1914 set tf $_activeTf 1885 1915 set c $itk_component(legend) 1886 set m [ IsoMarker \#auto $c $this $tf]1916 set m [Rappture::IsoMarker \#auto $c $this $tf] 1887 1917 set w [winfo width $c] 1888 1918 $m relval [expr {double($x-10)/($w-20)}] 1889 lappend isomarkers_($tf) $m1919 lappend _isomarkers($tf) $m 1890 1920 updatetransferfuncs 1891 1921 return 1 … … 1895 1925 set tf [$marker transferfunc] 1896 1926 set bool 0 1897 if { [info exists isomarkers_($tf)] } {1927 if { [info exists _isomarkers($tf)] } { 1898 1928 set list {} 1899 1929 set marker [namespace tail $marker] 1900 foreach m $ isomarkers_($tf) {1930 foreach m $_isomarkers($tf) { 1901 1931 set sx [$m screenpos] 1902 1932 if { $m != $marker } { … … 1911 1941 lappend list $m 1912 1942 } 1913 set isomarkers_($tf) $list1943 set _isomarkers($tf) $list 1914 1944 updatetransferfuncs 1915 1945 } … … 1919 1949 itcl::body Rappture::FlowvisViewer::overmarker { marker x } { 1920 1950 set tf [$marker transferfunc] 1921 if { [info exists isomarkers_($tf)] } {1951 if { [info exists _isomarkers($tf)] } { 1922 1952 set marker [namespace tail $marker] 1923 foreach m $ isomarkers_($tf) {1953 foreach m $_isomarkers($tf) { 1924 1954 set sx [$m screenpos] 1925 1955 if { $m != $marker } { … … 1933 1963 1934 1964 itcl::body Rappture::FlowvisViewer::limits { tf } { 1935 set limits_(min) "" 1936 set limits_(max) "" 1937 foreach ivol $style2ids_($tf) { 1938 if { ![info exists limits_($ivol-min)] } { 1939 error "can't find $ivol limits" 1940 } 1941 if { $limits_(min) == "" || $limits_(min) > $limits_($ivol-min) } { 1942 set limits_(min) $limits_($ivol-min) 1943 } 1944 if { $limits_(max) == "" || $limits_(max) < $limits_($ivol-max) } { 1945 set limits_(max) $limits_($ivol-max) 1946 } 1947 } 1948 return [array get limits_] 1949 } 1950 1951 1952 # 1953 # flow -- 1954 # 1955 # Called when the user clicks on the stop or play buttons 1956 # for flow visualization. 1957 # 1958 # $this flow start 1959 # $this flow stop 1960 # $this flow toggle 1961 # $this flow rewind 1962 # $this flow pause 1963 # $this flow next 1964 # 1965 itcl::body Rappture::FlowvisViewer::flow {option} { 1966 switch -- $option { 1967 "stop" { 1968 if { $flow_(state) != "stopped" } { 1969 # Reset the play button to off 1970 $itk_component(play) configure -image [Rappture::icon flow-play] 1971 $_dispatcher cancel !play 1972 SendCmd "flow reset" 1973 set flow_(state) "stopped" 1974 } 1975 } 1976 "pause" { 1977 if { $flow_(state) == "playing" } { 1978 # Reset the play button to pause 1979 # Convert to the play button. 1980 $itk_component(play) configure -image [Rappture::icon flow-play] 1981 $_dispatcher cancel !play 1982 set flow_(state) "paused" 1983 } 1984 } 1985 "start" { 1986 if { $flow_(state) != "playing" } { 1987 # Starts the "flow next" requests to the server. 1988 # Convert to the pause button. 1989 $itk_component(play) configure \ 1990 -image [Rappture::icon flow-pause] 1991 flow next 1992 set flow_(state) "playing" 1993 } 1994 } 1995 "toggle" { 1996 if { $flow_(state) == "playing" } { 1997 flow pause 1998 } else { 1999 flow start 2000 } 2001 } 2002 "rewind" { 2003 if { $flow_(state) != "stopped" } { 2004 SendCmd "flow reset" 2005 } 2006 } 2007 "next" { 2008 # This operation should not be called by public routines. 2009 SendCmd "flow next" 2010 set delay [expr {int(ceil(pow($settings_(speed)/10.0+2,2.0)*15))}] 2011 $_dispatcher event -after $delay !play 2012 } 2013 default { 2014 error "bad option \"$option\": should be start, stop, toggle, or reset." 2015 } 2016 } 2017 } 1965 set _limits(min) 0.0 1966 set _limits(max) 1.0 1967 if { ![info exists _style2objs($tf)] } { 1968 return [array get _limits] 1969 } 1970 set min ""; set max "" 1971 foreach {dataobj comp} $_style2objs($tf) { 1972 if { ![info exists _obj2id($dataobj-$comp)] } { 1973 continue 1974 } 1975 set ivol $_obj2id($dataobj-$comp) 1976 if { ![info exists _limits($ivol-min)] } { 1977 continue 1978 } 1979 if { $min == "" || $min > $_limits($ivol-min) } { 1980 set min $_limits($ivol-min) 1981 } 1982 if { $max == "" || $max < $_limits($ivol-max) } { 1983 set max $_limits($ivol-max) 1984 } 1985 } 1986 if { $min != "" } { 1987 set _limits(min) $min 1988 } 1989 if { $max != "" } { 1990 set _limits(max) $max 1991 } 1992 return [array get _limits] 1993 } 1994 2018 1995 2019 1996 … … 2021 1998 foreach { key value } { 2022 1999 grid 0 2023 axes 12000 axes 0 2024 2001 outline 1 2025 2002 volume 1 … … 2028 2005 lic 1 2029 2006 } { 2030 set settings_($this-$key) $value2007 set _settings($this-$key) $value 2031 2008 } 2032 2009 … … 2039 2016 $inner configure -borderwidth 4 2040 2017 2041 set ::Rappture::FlowvisViewer:: settings_($this-isosurface) 02018 set ::Rappture::FlowvisViewer::_settings($this-isosurface) 0 2042 2019 checkbutton $inner.isosurface \ 2043 2020 -text "Isosurface shading" \ 2044 -variable [itcl::scope settings_($this-isosurface)] \2021 -variable [itcl::scope _settings($this-isosurface)] \ 2045 2022 -command [itcl::code $this FixSettings isosurface] \ 2046 2023 -font "Arial 9" … … 2048 2025 checkbutton $inner.axes \ 2049 2026 -text "Axes" \ 2050 -variable [itcl::scope settings_($this-axes)] \2027 -variable [itcl::scope _settings($this-axes)] \ 2051 2028 -command [itcl::code $this FixSettings axes] \ 2052 2029 -font "Arial 9" … … 2054 2031 checkbutton $inner.grid \ 2055 2032 -text "Grid" \ 2056 -variable [itcl::scope settings_($this-grid)] \2033 -variable [itcl::scope _settings($this-grid)] \ 2057 2034 -command [itcl::code $this FixSettings grid] \ 2058 2035 -font "Arial 9" … … 2060 2037 checkbutton $inner.outline \ 2061 2038 -text "Outline" \ 2062 -variable [itcl::scope settings_($this-outline)] \2039 -variable [itcl::scope _settings($this-outline)] \ 2063 2040 -command [itcl::code $this FixSettings outline] \ 2064 2041 -font "Arial 9" … … 2066 2043 checkbutton $inner.legend \ 2067 2044 -text "Legend" \ 2068 -variable [itcl::scope settings_($this-legend)] \2045 -variable [itcl::scope _settings($this-legend)] \ 2069 2046 -command [itcl::code $this FixSettings legend] \ 2070 2047 -font "Arial 9" … … 2072 2049 checkbutton $inner.volume \ 2073 2050 -text "Volume" \ 2074 -variable [itcl::scope settings_($this-volume)] \2051 -variable [itcl::scope _settings($this-volume)] \ 2075 2052 -command [itcl::code $this FixSettings volume] \ 2076 2053 -font "Arial 9" … … 2078 2055 checkbutton $inner.particles \ 2079 2056 -text "Particles" \ 2080 -variable [itcl::scope settings_($this-particles)] \2057 -variable [itcl::scope _settings($this-particles)] \ 2081 2058 -command [itcl::code $this FixSettings particles] \ 2082 2059 -font "Arial 9" … … 2084 2061 checkbutton $inner.lic \ 2085 2062 -text "Lic" \ 2086 -variable [itcl::scope settings_($this-lic)] \2063 -variable [itcl::scope _settings($this-lic)] \ 2087 2064 -command [itcl::code $this FixSettings lic] \ 2088 2065 -font "Arial 9" 2066 2067 frame $inner.frame 2089 2068 2090 2069 blt::table $inner \ … … 2093 2072 2,0 $inner.outline -columnspan 2 -anchor w \ 2094 2073 3,0 $inner.volume -columnspan 2 -anchor w \ 2095 4,0 $inner.legend -columnspan 2 -anchor w \ 2096 5,0 $inner.particles -columnspan 2 -anchor w \ 2097 6,0 $inner.lic -columnspan 1 -anchor w \ 2098 2099 for {set n 0} {$n <= 6} {incr n} { 2100 blt::table configure $inner r$n -resize none 2101 } 2102 blt::table configure $inner r$n -resize expand 2074 4,0 $inner.legend -columnspan 2 -anchor w 2075 2076 bind $inner <Map> [itcl::code $this GetFlowInfo $inner] 2077 2078 blt::table configure $inner r* -resize none 2079 blt::table configure $inner r5 -resize expand 2103 2080 } 2104 2081 … … 2110 2087 thickness 350 2111 2088 } { 2112 set settings_($this-$key) $value2089 set _settings($this-$key) $value 2113 2090 } 2114 2091 2115 2092 set inner [$itk_component(main) insert end \ 2116 2093 -title "Volume Settings" \ 2117 -icon [Rappture::icon playback-record]]2094 -icon [Rappture::icon volume-on]] 2118 2095 $inner configure -borderwidth 4 2119 2096 … … 2123 2100 label $inner.dim -text "Dim" -font $fg 2124 2101 ::scale $inner.light -from 0 -to 100 -orient horizontal \ 2125 -variable [itcl::scope settings_($this-light)] \2102 -variable [itcl::scope _settings($this-light)] \ 2126 2103 -width 10 \ 2127 2104 -showvalue off -command [itcl::code $this FixSettings light] … … 2130 2107 label $inner.fog -text "Fog" -font $fg 2131 2108 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 2132 -variable [itcl::scope settings_($this-transp)] \2109 -variable [itcl::scope _settings($this-transp)] \ 2133 2110 -width 10 \ 2134 2111 -showvalue off -command [itcl::code $this FixSettings transp] … … 2137 2114 label $inner.clear -text "Clear" -font $fg 2138 2115 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2139 -variable [itcl::scope settings_($this-opacity)] \2116 -variable [itcl::scope _settings($this-opacity)] \ 2140 2117 -width 10 \ 2141 2118 -showvalue off -command [itcl::code $this FixSettings opacity] … … 2144 2121 label $inner.thin -text "Thin" -font $fg 2145 2122 ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \ 2146 -variable [itcl::scope settings_($this-thickness)] \2123 -variable [itcl::scope _settings($this-thickness)] \ 2147 2124 -width 10 \ 2148 2125 -showvalue off -command [itcl::code $this FixSettings thickness] … … 2163 2140 3,3 $inner.thick -anchor w -pady 2 2164 2141 2165 for {set n 0} {$n <= 3} {incr n} { 2166 blt::table configure $inner r$n -resize none 2167 } 2168 blt::table configure $inner r$n -resize expand 2142 blt::table configure $inner c0 c1 c3 r* -resize none 2143 blt::table configure $inner r6 -resize expand 2169 2144 } 2170 2145 … … 2177 2152 # X-value slicer... 2178 2153 itk_component add xCutButton { 2179 label $inner.xbutton \ 2180 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 2181 -image [Rappture::icon x-cutplane-off] \ 2182 -highlightthickness 0 2183 } { 2184 usual 2185 ignore -borderwidth -highlightthickness -font 2186 } 2187 bind $itk_component(xCutButton) <ButtonPress> \ 2188 [itcl::code $this Slice axis x toggle] 2154 Rappture::PushButton $inner.xbutton \ 2155 -onimage [Rappture::icon x-cutplane-on] \ 2156 -offimage [Rappture::icon x-cutplane-off] \ 2157 -command [itcl::code $this FixSettings xcutplane] \ 2158 -variable [itcl::scope _settings($this-xcutplane)] 2159 } 2189 2160 Rappture::Tooltip::for $itk_component(xCutButton) \ 2190 2161 "Toggle the X cut plane on/off" … … 2194 2165 -width 10 -orient vertical -showvalue off \ 2195 2166 -borderwidth 1 -highlightthickness 0 \ 2196 -command [itcl::code $this Slice move x] 2167 -command [itcl::code $this Slice move x] \ 2168 -variable [itcl::scope _settings($this-xcutposition)] 2197 2169 } { 2198 2170 usual … … 2207 2179 # Y-value slicer... 2208 2180 itk_component add yCutButton { 2209 label $inner.ybutton \ 2210 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 2211 -image [Rappture::icon y-cutplane-off] \ 2212 -highlightthickness 0 2213 } { 2214 usual 2215 ignore -borderwidth -highlightthickness -font 2216 } 2217 bind $itk_component(yCutButton) <ButtonPress> \ 2218 [itcl::code $this Slice axis y toggle] 2181 Rappture::PushButton $inner.ybutton \ 2182 -onimage [Rappture::icon y-cutplane-on] \ 2183 -offimage [Rappture::icon y-cutplane-off] \ 2184 -command [itcl::code $this FixSettings ycutplane] \ 2185 -variable [itcl::scope _settings($this-ycutplane)] 2186 } 2219 2187 Rappture::Tooltip::for $itk_component(yCutButton) \ 2220 2188 "Toggle the Y cut plane on/off" … … 2224 2192 -width 10 -orient vertical -showvalue off \ 2225 2193 -borderwidth 1 -highlightthickness 0 \ 2226 -command [itcl::code $this Slice move y] 2194 -command [itcl::code $this Slice move y] \ 2195 -variable [itcl::scope _settings($this-ycutposition)] 2227 2196 } { 2228 2197 usual … … 2237 2206 # Z-value slicer... 2238 2207 itk_component add zCutButton { 2239 label $inner.zbutton \ 2240 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 2241 -image [Rappture::icon z-cutplane-off] \ 2242 -highlightthickness 0 2243 } { 2244 usual 2245 ignore -borderwidth -highlightthickness -font 2246 } 2247 bind $itk_component(zCutButton) <ButtonPress> \ 2248 [itcl::code $this Slice axis z toggle] 2208 Rappture::PushButton $inner.zbutton \ 2209 -onimage [Rappture::icon z-cutplane-on] \ 2210 -offimage [Rappture::icon z-cutplane-off] \ 2211 -command [itcl::code $this FixSettings zcutplane] \ 2212 -variable [itcl::scope _settings($this-zcutplane)] 2213 } 2249 2214 Rappture::Tooltip::for $itk_component(zCutButton) \ 2250 2215 "Toggle the Z cut plane on/off" … … 2254 2219 -width 10 -orient vertical -showvalue off \ 2255 2220 -borderwidth 1 -highlightthickness 0 \ 2256 -command [itcl::code $this Slice move z] 2221 -command [itcl::code $this Slice move z] \ 2222 -variable [itcl::scope _settings($this-zcutposition)] 2257 2223 } { 2258 2224 usual … … 2290 2256 label $inner.${tag}label -text $tag -font "Arial 9" 2291 2257 entry $inner.${tag} -font "Arial 9" -bg white \ 2292 -textvariable [itcl::scope settings_($this-$tag)]2258 -textvariable [itcl::scope _settings($this-$tag)] 2293 2259 bind $inner.${tag} <KeyPress-Return> \ 2294 2260 [itcl::code $this camera set ${tag}] … … 2304 2270 } 2305 2271 2272 itcl::body Rappture::FlowvisViewer::GetFlowInfo { w } { 2273 foreach key [array names _obj2flow] { 2274 set flowobj $_obj2flow($key) 2275 break 2276 } 2277 if { [winfo exists $w.frame] } { 2278 destroy $w.frame 2279 } 2280 set inner [frame $w.frame] 2281 blt::table $w \ 2282 5,0 $inner -fill both -columnspan 2 -anchor nw 2283 array set hints [$flowobj hints] 2284 checkbutton $inner.showstreams -text "Streams Plane" \ 2285 -variable [itcl::scope _settings($this-streams)] \ 2286 -command [itcl::code $this streams $key $hints(name)] \ 2287 -font "Arial 9" 2288 label $inner.particles -text "Particles" -font "Arial 9 bold" 2289 label $inner.boxes -text "Boxes" -font "Arial 9 bold" 2290 2291 blt::table $inner \ 2292 1,0 $inner.showstreams -anchor w 2293 blt::table configure $inner c0 -resize none 2294 blt::table configure $inner c1 -resize expand 2295 2296 set row 2 2297 set particles [$flowobj particles] 2298 if { [llength $particles] > 0 } { 2299 blt::table $inner $row,0 $inner.particles -anchor w 2300 incr row 2301 } 2302 foreach part $particles { 2303 array unset info 2304 array set info $part 2305 set name $info(name) 2306 if { ![info exists _settings($this-particles-$name)] } { 2307 set _settings($this-particles-$name) $info(hide) 2308 } 2309 checkbutton $inner.part$row -text $name \ 2310 -variable [itcl::scope _settings($this-particles-$name)] \ 2311 -onvalue 0 -offvalue 1 \ 2312 -command [itcl::code $this particles $key $name] \ 2313 -font "Arial 9 italic" 2314 blt::table $inner $row,0 $inner.part$row -anchor w 2315 if { !$_settings($this-particles-$name) } { 2316 $inner.part$row select 2317 } 2318 incr row 2319 } 2320 set boxes [$flowobj boxes] 2321 if { [llength $boxes] > 0 } { 2322 blt::table $inner $row,0 $inner.boxes -anchor w 2323 incr row 2324 } 2325 foreach box $boxes { 2326 array unset info 2327 array set info $box 2328 set name $info(name) 2329 if { ![info exists _settings($this-box-$name)] } { 2330 set _settings($this-box-$name) $info(hide) 2331 } 2332 checkbutton $inner.box$row -text $info(name) \ 2333 -variable [itcl::scope _settings($this-box-$name)] \ 2334 -onvalue 0 -offvalue 1 \ 2335 -command [itcl::code $this box $key $name] \ 2336 -font "Arial 9 italic" 2337 blt::table $inner $row,0 $inner.box$row -anchor w 2338 if { !$_settings($this-box-$name) } { 2339 $inner.box$row select 2340 } 2341 incr row 2342 } 2343 blt::table configure $inner r* -resize none 2344 blt::table configure $inner r$row -resize expand 2345 blt::table configure $inner c3 -resize expand 2346 event generate [winfo parent [winfo parent $w]] <Configure> 2347 } 2348 2349 itcl::body Rappture::FlowvisViewer::particles { tag name } { 2350 set bool $_settings($this-particles-$name) 2351 SendCmd "$tag particles configure $name -hide $bool" 2352 } 2353 2354 itcl::body Rappture::FlowvisViewer::box { tag name } { 2355 set bool $_settings($this-box-$name) 2356 SendCmd "$tag box configure $name -hide $bool" 2357 } 2358 2359 itcl::body Rappture::FlowvisViewer::streams { tag name } { 2360 set bool $_settings($this-streams) 2361 SendCmd "$tag configure -slice $bool" 2362 } 2363 2364 # ---------------------------------------------------------------------- 2365 # USAGE: Slice move x|y|z <newval> 2366 # 2367 # Called automatically when the user drags the slider to move the 2368 # cut plane that slices 3D data. Gets the current value from the 2369 # slider and moves the cut plane to the appropriate point in the 2370 # data set. 2371 # ---------------------------------------------------------------------- 2372 itcl::body Rappture::FlowvisViewer::Slice {option args} { 2373 switch -- $option { 2374 move { 2375 if {[llength $args] != 2} { 2376 error "wrong # args: should be \"Slice move x|y|z newval\"" 2377 } 2378 set axis [lindex $args 0] 2379 set newval [lindex $args 1] 2380 set newpos [expr {0.01*$newval}] 2381 2382 # show the current value in the readout 2383 2384 set ids [CurrentVolumeIds -cutplanes] 2385 SendCmd "cutplane position $newpos $axis $ids" 2386 } 2387 default { 2388 error "bad option \"$option\": should be axis, move, or volume" 2389 } 2390 } 2391 } 2392 2393 # ---------------------------------------------------------------------- 2394 # USAGE: SlicerTip <axis> 2395 # 2396 # Used internally to generate a tooltip for the x/y/z slicer controls. 2397 # Returns a message that includes the current slicer value. 2398 # ---------------------------------------------------------------------- 2399 itcl::body Rappture::FlowvisViewer::SlicerTip {axis} { 2400 set val [$itk_component(${axis}CutScale) get] 2401 # set val [expr {0.01*($val-50) 2402 # *($_limits(${axis}max)-$_limits(${axis}min)) 2403 # + 0.5*($_limits(${axis}max)+$_limits(${axis}min))}] 2404 return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%" 2405 } 2406 2407 2408 itcl::body Rappture::FlowvisViewer::DoResize {} { 2409 SendCmd "screen $_width $_height" 2410 } 2411 2412 itcl::body Rappture::FlowvisViewer::EventuallyResize { w h } { 2413 if { $_width != $w || $_height != $h } { 2414 set _width $w 2415 set _height $h 2416 $_dispatcher event -idle !resize 2417 } 2418 } 2419 2420 itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} { 2421 $_dispatcher event -idle !legend 2422 } 2423 2306 2424 # camera -- 2307 2425 itcl::body Rappture::FlowvisViewer::camera {option args} { 2308 2426 switch -- $option { 2309 2427 "show" { 2310 puts [array get view_]2428 puts [array get _view] 2311 2429 } 2312 2430 "set" { 2313 2431 set who [lindex $args 0] 2314 set x $ settings_($this-$who)2432 set x $_settings($this-$who) 2315 2433 set code [catch { string is double $x } result] 2316 2434 if { $code != 0 || !$result } { 2317 set settings_($this-$who) $view_($who)2435 set _settings($this-$who) $_view($who) 2318 2436 return 2319 2437 } 2320 2438 switch -- $who { 2321 2439 "pan-x" - "pan-y" { 2322 set view_($who) $settings_($this-$who)2440 set _view($who) $_settings($this-$who) 2323 2441 PanCamera 2324 2442 } 2325 2443 "phi" - "theta" - "psi" { 2326 set view_($who) $settings_($this-$who)2327 set xyz [Euler2XYZ $ view_(theta) $view_(phi) $view_(psi)]2328 _send "camera angle $xyz"2444 set _view($who) $_settings($this-$who) 2445 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 2446 SendCmd "camera angle $xyz" 2329 2447 } 2330 2448 "zoom" { 2331 set view_($who) $settings_($this-$who)2332 _send "camera zoom $view_(zoom)"2449 set _view($who) $_settings($this-$who) 2450 SendCmd "camera zoom $_view(zoom)" 2333 2451 } 2334 2452 } 2453 } 2454 } 2455 } 2456 2457 itcl::body Rappture::FlowvisViewer::FlowCmd { dataobj comp nbytes extents } { 2458 set tag "$dataobj-$comp" 2459 if { ![info exists _obj2flow($tag)] } { 2460 puts stderr "no obj $tag" 2461 return 2462 } 2463 set flowobj $_obj2flow($tag) 2464 if { $flowobj == "" } { 2465 puts stderr "no flowobj" 2466 return "" 2467 } 2468 set cmd {} 2469 append cmd "if {\[flow exists $tag\]} {flow delete $tag}\n" 2470 array set info [$flowobj hints] 2471 append cmd "flow add $tag -position $info(position) -axis $info(axis) " 2472 append cmd "-volume $info(volume) -outline $info(outline) " 2473 append cmd "-slice $info(streams)\n" 2474 foreach part [$flowobj particles] { 2475 array unset info 2476 array set info $part 2477 set color [Color2RGB $info(color)] 2478 append cmd "$tag particles add $info(name) -position $info(position) " 2479 append cmd "-axis $info(axis) -color {$color}\n" 2480 } 2481 puts stderr "boxes=[$flowobj boxes]" 2482 foreach box [$flowobj boxes] { 2483 array unset info 2484 set info(corner1) "" 2485 set info(corner2) "" 2486 array set info $box 2487 if { $info(corner1) == "" || $info(corner2) == "" } { 2488 continue 2489 } 2490 set color [Color2RGB $info(color)] 2491 append cmd "$tag box add $info(name) -color {$color} " 2492 append cmd "-hide $info(hide) " 2493 append cmd "-corner1 {$info(corner1)} -corner2 {$info(corner2)}\n" 2494 } 2495 append cmd "$tag data follows $nbytes $extents\n" 2496 return $cmd 2497 } 2498 2499 2500 # 2501 # flow -- 2502 # 2503 # Called when the user clicks on the stop or play buttons 2504 # for flow visualization. 2505 # 2506 # $this flow play 2507 # $this flow stop 2508 # $this flow toggle 2509 # $this flow reset 2510 # $this flow pause 2511 # $this flow next 2512 # 2513 itcl::body Rappture::FlowvisViewer::flow {option} { 2514 switch -- $option { 2515 "off" { 2516 set _flow(state) 0 2517 $_dispatcher cancel !play 2518 $itk_component(play) deselect 2519 } 2520 "on" { 2521 set _flow(state) 1 2522 $itk_component(play) select 2523 } 2524 "stop" { 2525 if { $_flow(state) } { 2526 flow off 2527 flow reset 2528 } 2529 } 2530 "pause" { 2531 if { $_flow(state) } { 2532 flow off 2533 } 2534 } 2535 "play" { 2536 # If the flow is currently off, then restart it. 2537 if { !$_flow(state) } { 2538 flow on 2539 # If we're at the end of the flow, reset the flow. 2540 set count [$itk_component(numframes) value] 2541 if { $_flow(frame) >= $count } { 2542 set _flow(frame) 1 2543 SendCmd "flow reset" 2544 } 2545 flow next 2546 } 2547 } 2548 "toggle" { 2549 if { $_settings($this-play) } { 2550 flow play 2551 } else { 2552 flow pause 2553 } 2554 } 2555 "reset" { 2556 set _flow(frame) 0 2557 SendCmd "flow reset" 2558 if { !$_flow(state) } { 2559 SendCmd "flow next" 2560 } 2561 } 2562 "next" { 2563 set count [$itk_component(numframes) value] 2564 incr _flow(frame) 2565 if { $_flow(frame) >= $count } { 2566 if { !$_settings($this-loop) } { 2567 flow off 2568 return 2569 } 2570 flow reset 2571 } else { 2572 SendCmd "flow next" 2573 } 2574 set delay [expr {int(ceil(pow($_settings(speed)/10.0+2,2.0)*15))}] 2575 set delay2 [expr round(log($_settings(speed)+0.00001)*100.0)] 2576 $_dispatcher event -after $_settings(speed) !play 2577 } 2578 default { 2579 error "bad option \"$option\": should be play, stop, toggle, or reset." 2335 2580 } 2336 2581 } … … 2342 2587 $_dispatcher dispatch $this !waiticon \ 2343 2588 "[itcl::code $this WaitIcon "next" $widget] ; list" 2344 set icon_02345 $widget configure -image [Rappture::icon bigroller${ icon_}]2589 set _icon 0 2590 $widget configure -image [Rappture::icon bigroller${_icon}] 2346 2591 $_dispatcher event -after 100 !waiticon 2347 2592 } 2348 2593 "next" { 2349 incr icon_2350 if { $ icon_>= 8 } {2351 set icon_02594 incr _icon 2595 if { $_icon >= 8 } { 2596 set _icon 0 2352 2597 } 2353 $widget configure -image [Rappture::icon bigroller${ icon_}]2598 $widget configure -image [Rappture::icon bigroller${_icon}] 2354 2599 $_dispatcher event -after 100 !waiticon 2355 2600 } … … 2361 2606 2362 2607 itcl::body Rappture::FlowvisViewer::GetMovie { widget width height } { 2363 set token "movie[incr nextToken_]"2364 set var ::Rappture::MolvisViewer:: hardcopy_($this-$token)2608 set token "movie[incr _nextToken]" 2609 set var ::Rappture::MolvisViewer::_hardcopy($this-$token) 2365 2610 set $var "" 2366 2611 … … 2389 2634 focus $inner.cancel 2390 2635 2391 SendCmd "flow video $width $height $ settings_(numframes) 2.0 1000"2636 SendCmd "flow video $width $height $_settings(numframes) 2.0 1000" 2392 2637 2393 2638 $popup activate $widget below … … 2407 2652 update 2408 2653 2409 if { $ hardcopy_($this-$token) != "" } {2410 return [list .png $ hardcopy_($this-$token)]2654 if { $_hardcopy($this-$token) != "" } { 2655 return [list .png $_hardcopy($this-$token)] 2411 2656 } 2412 2657 return "" 2413 2658 } 2414 2659 2415 itcl::body Rappture::FlowvisViewer::DoResize {} {2416 SendCmd "screen $width_ $height_"2417 }2418 2419 itcl::body Rappture::FlowvisViewer::EventuallyResize { w h } {2420 if { $width_ != $w || $height_ != $h } {2421 set width_ $w2422 set height_ $h2423 $_dispatcher event -idle !resize2424 }2425 }2426 2427 itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} {2428 $_dispatcher event -idle !legend2429 }
Note: See TracChangeset
for help on using the changeset viewer.