Changeset 1448 for trunk/gui/scripts/flowvisviewer.tcl
- Timestamp:
- May 18, 2009 11:45:37 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/flowvisviewer.tcl
r1444 r1448 19 19 package require Img 20 20 21 option add *FlowvisViewer.width 4i widgetDefault21 option add *FlowvisViewer.width 5i widgetDefault 22 22 option add *FlowvisViewer*cursor crosshair widgetDefault 23 23 option add *FlowvisViewer.height 4i widgetDefault … … 75 75 protected method Disconnect {} 76 76 protected method DoResize {} 77 protected method FixLegend {}77 protected method ResizeLegend {} 78 78 protected method FixSettings {what {value ""}} 79 79 protected method Pan {option x y} … … 128 128 private variable _id2obj ;# maps dataobj => volume ID in server 129 129 private variable _sendobjs "" ;# list of data objs to send to server 130 private variable _rec eiveIds;# list of data objs to send to server130 private variable _recvObjs ;# list of data objs to send to server 131 131 private variable _obj2style ;# maps dataobj-component to transfunc 132 132 private variable _style2objs ;# maps tf back to list of … … 152 152 private variable _width 0 153 153 private variable _height 0 154 private variable _resizePending 0 155 private variable _resizeLegendPending 0 154 156 } 155 157 … … 166 168 # Draw legend event 167 169 $_dispatcher register !legend 168 $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list"170 $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list" 169 171 170 172 # Send dataobjs event … … 189 191 $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list" 190 192 191 set _flow(frame) 0192 193 set _flow(state) 0 193 194 … … 226 227 $this-psi $_view(psi) 227 228 $this-speed 500 229 $this-step 0 230 $this-nsteps 100 228 231 $this-theta $_view(theta) 229 232 $this-volume 1 … … 291 294 BuildCameraTab 292 295 296 297 bind $itk_component(3dview) <Configure> \ 298 [itcl::code $this EventuallyResize %w %h] 299 293 300 # Legend 294 295 301 set _image(legend) [image create photo] 296 302 itk_component add legend { … … 315 321 # Create flow controls... 316 322 317 itk_component add flowcontrol {318 frame $itk_interior.flowcontrol 323 itk_component add flowcontrols { 324 frame $itk_interior.flowcontrols 319 325 } { 320 326 usual … … 324 330 blt::table $itk_interior \ 325 331 0,0 $itk_component(main) -fill both \ 326 1,0 $itk_component(flowcontrol ) -fill x332 1,0 $itk_component(flowcontrols) -fill x 327 333 blt::table configure $itk_interior r1 -resize none 328 334 329 # flow record button...335 # Rewind 330 336 itk_component add rewind { 331 button $itk_component(flowcontrol ).reset \337 button $itk_component(flowcontrols).reset \ 332 338 -borderwidth 1 -padx 1 -pady 1 \ 333 339 -image [Rappture::icon flow-rewind] \ … … 336 342 usual 337 343 ignore -borderwidth 338 rename -highlightbackground -controlbackground controlBackground Background 344 rename -highlightbackground -controlbackground controlBackground \ 345 Background 339 346 } 340 347 Rappture::Tooltip::for $itk_component(rewind) \ 341 348 "Rewind flow" 342 349 343 # flow stop button...350 # Stop 344 351 itk_component add stop { 345 button $itk_component(flowcontrol ).stop \352 button $itk_component(flowcontrols).stop \ 346 353 -borderwidth 1 -padx 1 -pady 1 \ 347 354 -image [Rappture::icon flow-stop] \ … … 350 357 usual 351 358 ignore -borderwidth 352 rename -highlightbackground -controlbackground controlBackground Background 359 rename -highlightbackground -controlbackground controlBackground \ 360 Background 353 361 } 354 362 Rappture::Tooltip::for $itk_component(stop) \ 355 363 "Stop flow" 356 364 357 # 358 # flow play/pause button... 359 # 365 # Play 360 366 itk_component add play { 361 Rappture::PushButton $itk_component(flowcontrol ).play \367 Rappture::PushButton $itk_component(flowcontrols).play \ 362 368 -onimage [Rappture::icon flow-pause] \ 363 369 -offimage [Rappture::icon flow-play] \ … … 369 375 "Play/Pause flow" 370 376 377 # Loop 371 378 itk_component add loop { 372 Rappture::PushButton $itk_component(flowcontrol ).loop \379 Rappture::PushButton $itk_component(flowcontrols).loop \ 373 380 -onimage [Rappture::icon loop] \ 374 381 -offimage [Rappture::icon loop] \ … … 378 385 "Play continuously" 379 386 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 387 # Frame 388 itk_component add frame { 389 ::scale $itk_component(flowcontrols).frame -from 1 -to 100 \ 390 -showvalue 0 -orient horizontal -width 14 \ 391 -state disabled \ 392 -variable [itcl::scope _settings($this-step)] \ 393 -highlightthickness 0 394 } { 395 usual 396 ignore -highlightthickness 397 rename -background -controlbackground controlBackground Background 398 } 399 $itk_component(frame) set 1 400 401 # Number of steps 402 itk_component add nsteps { 403 Rappture::Spinint $itk_component(flowcontrols).nsteps \ 404 -min 0 -max 10000 -width 4 385 405 } { 386 406 usual … … 388 408 rename -background -controlbackground controlBackground Background 389 409 } 390 $itk_component(n umframes) value 100391 392 itk_component add n umframeslabel {393 label $itk_component(flowcontrol ).framel -text "# Steps:" -font $fg \410 $itk_component(nsteps) value 100 411 412 itk_component add nstepslabel { 413 label $itk_component(flowcontrols).framel -text "# Steps:" -font $fg \ 394 414 -highlightthickness 0 395 415 } { … … 400 420 401 421 itk_component add speedlabel { 402 label $itk_component(flowcontrol ).speedl -text "Speed:" -font $fg \422 label $itk_component(flowcontrols).speedl -text "Speed:" -font $fg \ 403 423 -highlightthickness 0 404 424 } { … … 408 428 } 409 429 430 # Speed 410 431 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 432 Rappture::Spinint $itk_component(flowcontrols).speed \ 433 -min 1 -max 10 -width 2 415 434 } { 416 usual 435 usual 417 436 ignore -highlightthickness 418 437 rename -background -controlbackground controlBackground Background 419 438 } 420 $itk_component(speed) set 500 421 422 blt::table $itk_component(flowcontrol) \ 439 $itk_component(speed) value 1 440 bind $itk_component(speed) <<Value>> [itcl::code $this flow speed] 441 442 443 blt::table $itk_component(flowcontrols) \ 423 444 0,0 $itk_component(rewind) -padx {3 0} \ 424 445 0,1 $itk_component(stop) -padx {2 0} \ 425 446 0,2 $itk_component(play) -padx {2 0} \ 426 447 0,3 $itk_component(loop) -padx {2 0} \ 448 0,4 $itk_component(frame) -fill x -padx {2 0 } \ 427 449 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 450 0,6 $itk_component(speed) -padx {2 0} \ 451 0,7 $itk_component(nstepslabel) -padx {2 0} \ 452 0,8 $itk_component(nsteps) -padx { 2 3} 453 454 blt::table configure $itk_component(flowcontrols) c* -resize none 455 blt::table configure $itk_component(flowcontrols) c4 -resize both 456 blt::table configure $itk_component(flowcontrols) r0 -pady 1 434 457 # Bindings for rotation via mouse 435 458 bind $itk_component(3dview) <ButtonPress-1> \ … … 439 462 bind $itk_component(3dview) <ButtonRelease-1> \ 440 463 [itcl::code $this Rotate release %x %y] 464 441 465 bind $itk_component(3dview) <Configure> \ 442 466 [itcl::code $this EventuallyResize %w %h] … … 609 633 # ---------------------------------------------------------------------- 610 634 itcl::body Rappture::FlowvisViewer::delete {args} { 635 flow stop 611 636 if {[llength $args] == 0} { 612 637 set args $_dlist … … 880 905 881 906 NameTransferFunc $dataobj $comp 882 set _rec eiveIds($ivol) 1907 set _recvObjs($dataobj-$comp) 1 883 908 } 884 909 } … … 898 923 SendCmd "up $axis" 899 924 } 925 926 if 0 { 927 set location [$_first hints camera] 928 if { $location != "" } { 929 array set _view $location 930 } 931 set _settings($this-theta) $_view(theta) 932 set _settings($this-phi) $_view(phi) 933 set _settings($this-psi) $_view(psi) 934 set _settings($this-pan-x) $_view(pan-x) 935 set _settings($this-pan-y) $_view(pan-y) 936 set _settings($this-zoom) $_view(zoom) 937 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 938 SendCmd "camera angle $xyz" 939 PanCamera 940 SendCmd "camera zoom $_view(zoom)" 941 } 900 942 # The active transfer function is by default the first component of 901 943 # the first data object. This assumes that the data is always … … 943 985 itcl::body Rappture::FlowvisViewer::SendTransferFuncs {} { 944 986 if { $_activeTf == "" } { 987 puts stderr "no active tf" 945 988 return 946 989 } 947 990 set tf $_activeTf 948 991 if { $_first == "" } { 992 puts stderr "no first" 949 993 return 950 994 } … … 968 1012 } 969 1013 } 970 FixLegend1014 ResizeLegend 971 1015 } 972 1016 … … 979 1023 # ---------------------------------------------------------------------- 980 1024 itcl::body Rappture::FlowvisViewer::ReceiveImage { args } { 981 if {![isconnected]} {982 return983 }984 1025 array set info { 985 1026 -token "???" … … 991 1032 ReceiveEcho <<line "<read $info(-bytes) bytes" 992 1033 if { $info(-type) == "image" } { 993 ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>"994 1034 $_image(plot) configure -data $bytes 995 1035 } elseif { $info(type) == "print" } { … … 1066 1106 # doesn't parse 3D data formats, we rely on the server (flowvis) to 1067 1107 # tell us what the limits are. Once we've received the limits to all 1068 # the data we've sent (tracked by _rec eiveIds) we can then determine1108 # the data we've sent (tracked by _recvObjs) we can then determine 1069 1109 # what the transfer functions are for these # volumes. 1070 1110 # … … 1103 1143 set _limits(vmax) $info(vmax); # Overall maximum value. 1104 1144 1105 unset _rec eiveIds($ivol)1106 if { [array size _rec eiveIds] == 0 } {1145 unset _recvObjs($tag) 1146 if { [array size _recvObjs] == 0 } { 1107 1147 updatetransferfuncs 1108 1148 } … … 1117 1157 # 1118 1158 itcl::body Rappture::FlowvisViewer::Rebuild {} { 1119 puts stderr "in Rebuild"1159 #puts stderr "in Rebuild" 1120 1160 # Hide all the isomarkers. Can't remove them. Have to remember the 1121 1161 # settings since the user may have created/deleted/moved markers. … … 1129 1169 # in the midst of sending data? then bail out 1130 1170 if {[llength $_sendobjs] > 0} { 1171 $_dispatcher event -idle !rebuild 1131 1172 return 1132 1173 } … … 1136 1177 # generates a new call to Rebuild). 1137 1178 set _buffering 1 1179 1180 set w [winfo width $itk_component(3dview)] 1181 set h [winfo height $itk_component(3dview)] 1182 EventuallyResize $w $h 1138 1183 1139 1184 # Find any new data that needs to be sent to the server. Queue this up on … … 1148 1193 } 1149 1194 } 1150 set w [winfo width $itk_component(3dview)]1151 set h [winfo height $itk_component(3dview)]1152 EventuallyResize $w $h1153 1195 1154 1196 # 1155 1197 # Reset the camera and other view parameters 1156 1198 # 1157 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1158 SendCmd "camera angle $xyz" 1159 PanCamera 1160 SendCmd "camera zoom $_view(zoom)" 1161 1199 FixSettings light 1200 FixSettings transp 1201 FixSettings isosurface 1202 FixSettings grid 1203 FixSettings axes 1204 FixSettings outline 1205 # nothing to send -- activate the proper ivol 1206 set _first [lindex [get] 0] 1207 if {"" != $_first} { 1208 set axis [$_first hints updir] 1209 if {"" != $axis} { 1210 SendCmd "up $axis" 1211 } 1212 set location [$_first hints camera] 1213 if { $location != "" } { 1214 array set _view $location 1215 } 1216 } 1162 1217 set _settings($this-theta) $_view(theta) 1163 1218 set _settings($this-phi) $_view(phi) … … 1167 1222 set _settings($this-zoom) $_view(zoom) 1168 1223 1169 FixSettings light 1170 FixSettings transp 1171 FixSettings isosurface 1172 FixSettings grid 1173 FixSettings axes 1174 FixSettings outline 1224 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1225 SendCmd "camera angle $xyz" 1226 PanCamera 1227 SendCmd "camera zoom $_view(zoom)" 1175 1228 1176 1229 if {[llength $_sendobjs] > 0} { 1177 1230 # send off new data objects 1178 1231 $_dispatcher event -idle !send_dataobjs 1232 puts stderr "more sendobjs " 1179 1233 return 1180 1234 } … … 1187 1241 SendCmd "up $axis" 1188 1242 } 1243 set location [$_first hints camera] 1244 if { $location != "" } { 1245 array set _view $location 1246 } 1189 1247 if { 0 && $_settings($this-volume) } { 1190 1248 SendCmd "volume state 0" … … 1224 1282 set _buffering 0; # Turn off buffering. 1225 1283 set _outbuf ""; # Clear the buffer. 1226 puts stderr "exit Rebuild"1284 #puts stderr "exit Rebuild" 1227 1285 } 1228 1286 … … 1468 1526 set inner $itk_component(settingsFrame) 1469 1527 set frames [$inner.framecnt value] 1470 set _settings(n umframes) $frames1528 set _settings(nsteps) $frames 1471 1529 set cmds "flow capture $frames" 1472 1530 SendCmd $cmds … … 1637 1695 1638 1696 # ---------------------------------------------------------------------- 1639 # USAGE: FixLegend1697 # USAGE: ResizeLegend 1640 1698 # 1641 1699 # Used internally to update the legend area whenever it changes size … … 1643 1701 # for the current field. 1644 1702 # ---------------------------------------------------------------------- 1645 itcl::body Rappture::FlowvisViewer::FixLegend {} { 1703 itcl::body Rappture::FlowvisViewer::ResizeLegend {} { 1704 set _resizeLegendPending 0 1646 1705 set lineht [font metrics $itk_option(-font) -linespace] 1647 1706 set w [expr {$_width-20}] … … 1681 1740 set tf "$style(-color):$style(-levels):$style(-opacity)" 1682 1741 lappend _obj2style($dataobj-$comp) $tf 1683 puts stderr "creating tf=$tf $dataobj-$comp"1684 parray _obj2style1685 1742 lappend _style2objs($tf) $dataobj $comp 1686 1743 return $tf … … 2311 2368 set _settings($this-particles-$name) $info(hide) 2312 2369 } 2313 checkbutton $inner.part$row -text $ name\2370 checkbutton $inner.part$row -text $info(label) \ 2314 2371 -variable [itcl::scope _settings($this-particles-$name)] \ 2315 2372 -onvalue 0 -offvalue 1 \ … … 2334 2391 set _settings($this-box-$name) $info(hide) 2335 2392 } 2336 checkbutton $inner.box$row -text $info( name) \2393 checkbutton $inner.box$row -text $info(label) \ 2337 2394 -variable [itcl::scope _settings($this-box-$name)] \ 2338 2395 -onvalue 0 -offvalue 1 \ … … 2353 2410 itcl::body Rappture::FlowvisViewer::particles { tag name } { 2354 2411 set bool $_settings($this-particles-$name) 2355 SendCmd "$tag particles configure $name-hide $bool"2412 SendCmd "$tag particles configure {$name} -hide $bool" 2356 2413 } 2357 2414 2358 2415 itcl::body Rappture::FlowvisViewer::box { tag name } { 2359 2416 set bool $_settings($this-box-$name) 2360 SendCmd "$tag box configure $name-hide $bool"2417 SendCmd "$tag box configure {$name} -hide $bool" 2361 2418 } 2362 2419 … … 2412 2469 itcl::body Rappture::FlowvisViewer::DoResize {} { 2413 2470 SendCmd "screen $_width $_height" 2471 set _resizePending 0 2414 2472 } 2415 2473 2416 2474 itcl::body Rappture::FlowvisViewer::EventuallyResize { w h } { 2417 if { $_width != $w || $_height != $h } {2418 set _width $w 2419 set _height $h 2475 set _width $w 2476 set _height $h 2477 if { !$_resizePending } { 2420 2478 $_dispatcher event -idle !resize 2479 set _resizePending 1 2421 2480 } 2422 2481 } 2423 2482 2424 2483 itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} { 2425 $_dispatcher event -idle !legend 2484 if { !$_resizeLegendPending } { 2485 $_dispatcher event -idle !legend 2486 set _resizeLegendPending 1 2487 } 2426 2488 } 2427 2489 … … 2483 2545 append cmd "-axis $info(axis) -color {$color}\n" 2484 2546 } 2485 puts stderr "boxes=[$flowobj boxes]"2486 2547 foreach box [$flowobj boxes] { 2487 2548 array unset info … … 2515 2576 # $this flow next 2516 2577 # 2517 itcl::body Rappture::FlowvisViewer::flow {option} { 2578 itcl::body Rappture::FlowvisViewer::flow { args } { 2579 set option [lindex $args 0] 2518 2580 switch -- $option { 2581 "speed" { 2582 set speed [$itk_component(speed) value] 2583 set _settings($this-speed) [expr int(round(500.0/$speed))] 2584 } 2585 "nsteps" { 2586 set n [$itk_component(nsteps) value] 2587 $itk_component(frame) configure -max $n 2588 set settings($this-nsteps) $n 2589 } 2519 2590 "off" { 2520 2591 set _flow(state) 0 … … 2542 2613 flow on 2543 2614 # If we're at the end of the flow, reset the flow. 2544 set count [$itk_component(numframes) value]2545 if { $ _flow(frame) >= $count} {2546 set _ flow(frame) 12615 set n $_settings($this-step) 2616 if { $n >= $_settings($this-nsteps) } { 2617 set _settings($this-step) 1 2547 2618 SendCmd "flow reset" 2548 2619 } … … 2558 2629 } 2559 2630 "reset" { 2560 set _ flow(frame) 02631 set _settings($this-step) 0 2561 2632 SendCmd "flow reset" 2562 2633 if { !$_flow(state) } { … … 2565 2636 } 2566 2637 "next" { 2567 set count [$itk_component(numframes) value] 2568 incr _flow(frame) 2569 if { $_flow(frame) >= $count } { 2638 set w $itk_component(3dview) 2639 while { $w != "" } { 2640 if { ![winfo ismapped $w] } { 2641 flow stop 2642 puts stderr "$w isn't mapped" 2643 return 2644 } 2645 set w [winfo parent $w] 2646 if { [winfo toplevel $w] == $w } { 2647 break 2648 } 2649 } 2650 set n [incr _settings($this-step)] 2651 if { $n >= $_settings($this-nsteps) } { 2570 2652 if { !$_settings($this-loop) } { 2571 2653 flow off … … 2576 2658 SendCmd "flow next" 2577 2659 } 2578 set delay [expr {int(ceil(pow($_settings(speed)/10.0+2,2.0)*15))}] 2579 set delay2 [expr round(log($_settings(speed)+0.00001)*100.0)] 2580 $_dispatcher event -after $_settings(speed) !play 2660 $_dispatcher event -after $_settings($this-speed) !play 2581 2661 } 2582 2662 default { … … 2638 2718 focus $inner.cancel 2639 2719 2640 SendCmd "flow video $width $height $_settings( numframes) 2.0 1000"2720 SendCmd "flow video $width $height $_settings($this-nsteps) 2.0 1000" 2641 2721 2642 2722 $popup activate $widget below
Note: See TracChangeset
for help on using the changeset viewer.