Changeset 5101 for branches/1.4/gui/scripts/flowvisviewer.tcl
- Timestamp:
- Mar 8, 2015, 3:23:52 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4/gui/scripts/flowvisviewer.tcl
r5095 r5101 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: flowvisviewer - 3D flow rendering 4 #5 4 # 6 5 # This widget performs volume and flow rendering on 3D scalar/vector datasets. … … 65 64 public method limits { cname } 66 65 public method overMarker { m x } 67 public method parameters {title args} { 68 # do nothing 66 public method parameters {title args} { 67 # do nothing 69 68 } 70 69 public method removeDuplicateMarker { m x } … … 89 88 private method CurrentVolumeIds {{what -all}} 90 89 private method Disconnect {} 91 private method EventuallyResize { w h } 92 private method EventuallyGoto { nSteps } 93 private method EventuallyResizeLegend { } 90 private method EventuallyResize { w h } 91 private method EventuallyGoto { nSteps } 92 private method EventuallyResizeLegend { } 94 93 private method FlowCmd { dataobj comp nbytes extents } 95 private method GetDatasetsWithComponent { cname } 94 private method GetDatasetsWithComponent { cname } 96 95 private method GetFlowInfo { widget } 97 96 private method GetMovie { widget width height } … … 103 102 private method ParseLevelsOption { tf levels } 104 103 private method ParseMarkersOption { tf markers } 105 private method QuaternionToView { q } { 104 private method QuaternionToView { q } { 106 105 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 107 106 } … … 117 116 private method Slice {option args} 118 117 private method SlicerTip {axis} 119 private method ViewToQuaternion {} { 118 private method ViewToQuaternion {} { 120 119 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 121 120 } 122 121 private method WaitIcon { option widget } 123 122 private method Zoom {option} 124 private method arrows { tag name } 125 private method box { tag name } 126 private method millisecs2str { value } 127 private method particles { tag name } 128 private method str2millisecs { value } 129 private method streams { tag name } 123 private method arrows { tag name } 124 private method box { tag name } 125 private method millisecs2str { value } 126 private method particles { tag name } 127 private method str2millisecs { value } 128 private method streams { tag name } 130 129 131 130 private variable _arcball "" … … 133 132 private variable _allDataObjs 134 133 private variable _obj2ovride ;# maps dataobj => style override 135 private variable _serverObjs ;# maps dataobj-component to volume ID 134 private variable _serverObjs ;# maps dataobj-component to volume ID 136 135 # in the server 137 private variable _recvObjs ;# list of data objs to send to server136 private variable _recvObjs ;# list of data objs to send to server 138 137 private variable _obj2style ;# maps dataobj-component to transfunc 139 private variable _style2objs ;# maps tf back to list of 138 private variable _style2objs ;# maps tf back to list of 140 139 # dataobj-components using the tf. 141 private variable _obj2flow; 142 143 private variable _reset 1 ; # Connection to server has been reset140 private variable _obj2flow; # Maps dataobj-component to a flow. 141 142 private variable _reset 1 ;# Connection to server has been reset 144 143 private variable _click ;# info used for rotate operations 145 144 private variable _limits ;# autoscale min/max for all axes 146 145 private variable _view ;# view params for 3D view 147 private variable _isomarkers 146 private variable _isomarkers ;# array of isosurface level values 0..1 148 147 private common _settings 149 148 private variable _activeTf "" ;# The currently active transfer function. 150 149 private variable _first "" ;# This is the topmost volume. 151 private variable _volcomponents ; # Array of components found152 private variable _componentsList ; # Array of components found150 private variable _volcomponents ;# Array of components found 151 private variable _componentsList ;# Array of components found 153 152 private variable _nextToken 0 154 153 private variable _icon 0 155 154 private variable _flow 156 # This157 # indicates which isomarkers and transfer158 # function to use when changing markers,159 # opacity, or thickness.160 155 private common _downloadPopup ;# download options from popup 161 156 … … 198 193 $_dispatcher register !play 199 194 $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list" 200 195 201 196 # Draw legend event 202 197 $_dispatcher register !goto … … 239 234 $this-qy $_view(-qy) 240 235 $this-qz $_view(-qz) 241 $this-zoom $_view(-zoom) 236 $this-zoom $_view(-zoom) 242 237 $this-xpan $_view(-xpan) 243 238 $this-ypan $_view(-ypan) … … 346 341 [itcl::code $this EventuallyResizeLegend] 347 342 348 # Hack around the Tk panewindow. The problem is that the requested 343 # Hack around the Tk panewindow. The problem is that the requested 349 344 # size of the 3d view isn't set until an image is retrieved from 350 345 # the server. So the panewindow uses the tiny size. … … 354 349 0,0 $itk_component(3dview) -fill both -reqwidth $w \ 355 350 1,0 $itk_component(legend) -fill x 356 blt::table configure $itk_component(plotarea) r1 -resize none 351 blt::table configure $itk_component(plotarea) r1 -resize none 357 352 # Create flow controls... 358 353 359 354 itk_component add flowcontrols { 360 frame $itk_interior.flowcontrols 355 frame $itk_interior.flowcontrols 361 356 } { 362 357 usual … … 405 400 -offimage [Rappture::icon flow-play] \ 406 401 -variable [itcl::scope _settings($this-play)] \ 407 -command [itcl::code $this flow toggle] 402 -command [itcl::code $this flow toggle] 408 403 } 409 404 set fg [option get $itk_component(hull) font Font] … … 457 452 } { 458 453 usual 459 ignore -highlightthickness 454 ignore -highlightthickness 460 455 rename -background -controlbackground controlBackground Background 461 456 } … … 466 461 } { 467 462 usual 468 ignore -highlightthickness 463 ignore -highlightthickness 469 464 rename -background -controlbackground controlBackground Background 470 465 } … … 476 471 } { 477 472 usual 478 ignore -highlightthickness 473 ignore -highlightthickness 479 474 rename -background -controlbackground controlBackground Background 480 475 } … … 493 488 0,4 $itk_component(dial) -fill x -padx {2 0 } \ 494 489 0,5 $itk_component(duration) -padx { 0 0} \ 495 0,7 $itk_component(speed) -padx {2 3} 496 497 # 0,6 $itk_component(speedlabel) -padx {2 0} 490 0,7 $itk_component(speed) -padx {2 3} 491 492 # 0,6 $itk_component(speedlabel) -padx {2 0} 498 493 blt::table configure $itk_component(flowcontrols) c* -resize none 499 494 blt::table configure $itk_component(flowcontrols) c4 -resize both … … 695 690 # If anything changed, then rebuild the plot 696 691 if {$changed} { 697 # Repair the reverse lookup 692 # Repair the reverse lookup 698 693 foreach tf [array names _style2objs] { 699 694 set list {} … … 728 723 -opacity 0.5 729 724 } 730 array unset _limits 731 array unset _volcomponents 725 array unset _limits 726 array unset _volcomponents 732 727 foreach dataobj $args { 733 728 if { ![$dataobj isvalid] } { … … 873 868 return 0 874 869 } 875 set _reset 1 870 set _reset 1 876 871 set result [VisViewer::Connect $_hosts] 877 872 if { $result } { … … 883 878 set info {} 884 879 set user "???" 885 880 if { [info exists env(USER)] } { 886 881 set user $env(USER) 887 882 } 888 883 set session "???" 889 884 if { [info exists env(SESSION)] } { 890 885 set session $env(SESSION) 891 886 } 892 887 lappend info "version" "$Rappture::version" 893 888 lappend info "build" "$Rappture::build" … … 990 985 $_image(plot) configure -data $bytes 991 986 #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]" 992 } 987 } 993 988 "print" { 994 989 set tag $this-$info(-token) 995 990 set _hardcopy($tag) $bytes 996 } 991 } 997 992 "movie" { 998 993 set tag $this-$info(-token) … … 1010 1005 # The procedure is the response from the render server to each "legend" 1011 1006 # command. The server sends back a "legend" command invoked our 1012 # the slave interpreter. The purpose is to collect data of the image 1007 # the slave interpreter. The purpose is to collect data of the image 1013 1008 # representing the legend in the canvas. In addition, the isomarkers 1014 1009 # of the active transfer function are displayed. 1015 1010 # 1016 1011 # I don't know is this is the right place to display the isomarkers. 1017 # I don't know all the different paths used to draw the plot. There's 1012 # I don't know all the different paths used to draw the plot. There's 1018 1013 # "Rebuild", "add", etc. 1019 1014 # … … 1100 1095 # Called automatically whenever something changes that affects the data 1101 1096 # in the widget. Clears any existing data and rebuilds the widget to 1102 # display new data. 1097 # display new data. 1103 1098 # 1104 1099 itcl::body Rappture::FlowvisViewer::Rebuild {} { … … 1113 1108 # Turn on buffering of commands to the server. We don't want to 1114 1109 # be preempted by a server disconnect/reconnect (which automatically 1115 # generates a new call to Rebuild). 1110 # generates a new call to Rebuild). 1116 1111 StartBufferingCommands 1117 1112 … … 1461 1456 record { 1462 1457 if { [$itk_component(rewind) cget -relief] != "sunken" } { 1463 $itk_component(rewind) configure -relief sunken 1464 $itk_component(stop) configure -relief raised 1465 $itk_component(play) configure -relief raised 1458 $itk_component(rewind) configure -relief sunken 1459 $itk_component(stop) configure -relief raised 1460 $itk_component(play) configure -relief raised 1466 1461 set inner $itk_component(settingsFrame) 1467 1462 set frames [$inner.framecnt value] … … 1473 1468 stop { 1474 1469 if { [$itk_component(stop) cget -relief] != "sunken" } { 1475 $itk_component(rewind) configure -relief raised 1476 $itk_component(stop) configure -relief sunken 1477 $itk_component(play) configure -relief raised 1470 $itk_component(rewind) configure -relief raised 1471 $itk_component(stop) configure -relief sunken 1472 $itk_component(play) configure -relief raised 1478 1473 _pause 1479 1474 set cmds "flow reset" … … 1484 1479 if { [$itk_component(play) cget -relief] != "sunken" } { 1485 1480 $itk_component(rewind) configure -relief raised 1486 $itk_component(stop) configure -relief raised 1481 $itk_component(stop) configure -relief raised 1487 1482 $itk_component(play) configure \ 1488 1483 -image [Rappture::icon flow-pause] \ 1489 -relief sunken 1484 -relief sunken 1490 1485 bind $itk_component(play) <ButtonPress> \ 1491 1486 [itcl::code $this _pause] … … 1527 1522 $itk_component(play) configure \ 1528 1523 -image [Rappture::icon flow-start] \ 1529 -relief raised 1524 -relief raised 1530 1525 bind $itk_component(play) <ButtonPress> \ 1531 1526 [itcl::code $this Flow movie play toggle] … … 1555 1550 switch -- $what { 1556 1551 colormap { 1557 set color [$itk_component(colormap) value] 1558 set _settings(colormap) $color 1559 #ResetColormap $color 1552 set color [$itk_component(colormap) value] 1553 set _settings(colormap) $color 1554 #ResetColormap $color 1560 1555 } 1561 1556 light { … … 1622 1617 blt::table $itk_component(plotarea) \ 1623 1618 0,0 $itk_component(3dview) -fill both \ 1624 1,0 $itk_component(legend) -fill x 1619 1,0 $itk_component(legend) -fill x 1625 1620 blt::table configure $itk_component(plotarea) r1 -resize none 1626 1621 } else { … … 1639 1634 set bool $_settings($this-$what) 1640 1635 if { [isconnected] } { 1641 set vols [CurrentVolumeIds -cutplanes] 1636 set vols [CurrentVolumeIds -cutplanes] 1642 1637 SendCmd "cutplane state $bool $axis $vols" 1643 1638 } … … 1743 1738 # reference. 1744 1739 # 1745 # FIXME: The current way we generate transfer-function names completely 1746 # ignores the -markers option. The problem is that we are forced 1747 # to compute the name from an increasing complex set of values: 1740 # FIXME: The current way we generate transfer-function names completely 1741 # ignores the -markers option. The problem is that we are forced 1742 # to compute the name from an increasing complex set of values: 1748 1743 # color, levels, marker, opacity. I think the cow's out of the 1749 1744 # barn on this one. … … 1891 1886 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) 1892 1887 $m relval $x 1893 lappend _isomarkers($tf) $m 1888 lappend _isomarkers($tf) $m 1894 1889 } 1895 1890 } else { … … 1898 1893 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) 1899 1894 $m relval $x 1900 lappend _isomarkers($tf) $m 1895 lappend _isomarkers($tf) $m 1901 1896 } 1902 1897 } … … 1905 1900 # 1906 1901 # The -markers option takes a list of zero or more values (the values 1907 # may be separated either by spaces or commas) that have the following 1902 # may be separated either by spaces or commas) that have the following 1908 1903 # format: 1909 1904 # … … 1921 1916 set n [scan $marker "%g%s" value suffix] 1922 1917 if { $n == 2 && $suffix == "%" } { 1923 # ${n}% : Set relative value. 1918 # ${n}% : Set relative value. 1924 1919 set value [expr {$value * 0.01}] 1925 1920 set m [Rappture::IsoMarker \#auto $c $this $tf] … … 1938 1933 1939 1934 # ---------------------------------------------------------------------- 1940 # USAGE: UndateTransferFuncs 1935 # USAGE: UndateTransferFuncs 1941 1936 # ---------------------------------------------------------------------- 1942 1937 itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} { … … 1948 1943 error "active transfer function isn't set" 1949 1944 } 1950 set tf $_activeTf 1945 set tf $_activeTf 1951 1946 set c $itk_component(legend) 1952 1947 set m [Rappture::IsoMarker \#auto $c $this $tf] … … 2107 2102 2,0 $inner.outline -cspan 2 -anchor w \ 2108 2103 3,0 $inner.volume -cspan 2 -anchor w \ 2109 4,0 $inner.legend -cspan 2 -anchor w 2104 4,0 $inner.legend -cspan 2 -anchor w 2110 2105 2111 2106 bind $inner <Map> [itcl::code $this GetFlowInfo $inner] … … 2157 2152 label $inner.thick -text "Thick" -font $fg 2158 2153 2159 label $inner.colormap_l -text "Colormap" -font "Arial 9" 2154 label $inner.colormap_l -text "Colormap" -font "Arial 9" 2160 2155 itk_component add colormap { 2161 2156 Rappture::Combobox $inner.colormap -width 10 -editable no … … 2292 2287 $inner configure -borderwidth 4 2293 2288 2294 label $inner.view_l -text "view" -font "Arial 9" 2295 set f [frame $inner.view] 2296 foreach side { front back left right top bottom } { 2289 label $inner.view_l -text "view" -font "Arial 9" 2290 set f [frame $inner.view] 2291 foreach side { front back left right top bottom } { 2297 2292 button $f.$side -image [Rappture::icon view$side] \ 2298 -command [itcl::code $this SetOrientation $side] 2299 Rappture::Tooltip::for $f.$side "Change the view to $side" 2300 pack $f.$side -side left 2293 -command [itcl::code $this SetOrientation $side] 2294 Rappture::Tooltip::for $f.$side "Change the view to $side" 2295 pack $f.$side -side left 2301 2296 } 2302 2297 2303 2298 blt::table $inner \ 2304 2299 0,0 $inner.view_l -anchor e -pady 2 \ 2305 0,1 $inner.view -anchor w -pady 2 2300 0,1 $inner.view -anchor w -pady 2 2306 2301 blt::table configure $inner r0 -resize none 2307 2302 2308 set row 1 2303 set row 1 2309 2304 set labels { qw qx qy qz xpan ypan zoom } 2310 2305 foreach tag $labels { … … 2360 2355 blt::table $inner \ 2361 2356 1,0 $inner.showstreams -anchor w \ 2362 2,0 $inner.showarrows -anchor w 2357 2,0 $inner.showarrows -anchor w 2363 2358 blt::table configure $inner c0 c1 -resize none 2364 2359 blt::table configure $inner c2 -resize expand … … 2383 2378 -font "Arial 9" 2384 2379 Rappture::Tooltip::for $inner.part$row $info(description) 2385 blt::table $inner $row,0 $inner.part$row -anchor w 2380 blt::table $inner $row,0 $inner.part$row -anchor w 2386 2381 if { !$_settings($this-particles-$name) } { 2387 2382 $inner.part$row select 2388 } 2383 } 2389 2384 incr row 2390 2385 } … … 2410 2405 if { !$_settings($this-box-$name) } { 2411 2406 $inner.box$row select 2412 } 2407 } 2413 2408 incr row 2414 2409 } … … 2416 2411 blt::table configure $inner r$row -resize expand 2417 2412 blt::table configure $inner c3 -resize expand 2418 event generate [winfo parent [winfo parent $w]] <Configure> 2413 event generate [winfo parent [winfo parent $w]] <Configure> 2419 2414 } 2420 2415 … … 2510 2505 } 2511 2506 2512 # camera -- 2507 # camera -- 2513 2508 itcl::body Rappture::FlowvisViewer::camera {option args} { 2514 switch -- $option { 2509 switch -- $option { 2515 2510 "show" { 2516 2511 puts [array get _view] … … 2597 2592 append cmd " -corner1 {$info(corner1)} " 2598 2593 append cmd " -corner2 {$info(corner2)}\n" 2599 } 2594 } 2600 2595 append cmd "$tag data follows $nbytes $extents\n" 2601 2596 return $cmd … … 2665 2660 "stop" { 2666 2661 if { $_flow(state) } { 2667 flow off 2662 flow off 2668 2663 flow reset 2669 2664 } … … 2671 2666 "pause" { 2672 2667 if { $_flow(state) } { 2673 flow off 2668 flow off 2674 2669 } 2675 2670 } … … 2684 2679 set _settings($this-step) 1 2685 2680 SendCmd "flow reset" 2686 } 2681 } 2687 2682 flow next 2688 2683 } … … 2691 2686 if { $_settings($this-play) } { 2692 2687 flow play 2693 } else { 2688 } else { 2694 2689 flow pause 2695 2690 } … … 2716 2711 } 2717 2712 $_dispatcher event -after $_flow(delay) !play 2718 } 2713 } 2719 2714 default { 2720 2715 error "bad option \"$option\": should be play, stop, toggle, or reset." … … 2767 2762 1,0 $inner.please -anchor w \ 2768 2763 1,1 $inner.icon -anchor e \ 2769 2,0 $inner.cancel -cspan 2 2770 blt::table configure $inner r0 -pady 4 2771 blt::table configure $inner r2 -pady 4 2764 2,0 $inner.cancel -cspan 2 2765 blt::table configure $inner r0 -pady 4 2766 blt::table configure $inner r2 -pady 4 2772 2767 bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke] 2773 2768 } else { … … 2785 2780 update idletasks 2786 2781 update 2787 # We wait here for either 2788 # 1) the png to be delivered or 2789 # 2) timeout or 2782 # We wait here for either 2783 # 1) the png to be delivered or 2784 # 2) timeout or 2790 2785 # 3) user cancels the operation. 2791 2786 tkwait variable $var … … 2826 2821 1,0 $inner.please -anchor w \ 2827 2822 1,1 $inner.icon -anchor e \ 2828 2,0 $inner.cancel -cspan 2 2829 blt::table configure $inner r0 -pady 4 2830 blt::table configure $inner r2 -pady 4 2823 2,0 $inner.cancel -cspan 2 2824 blt::table configure $inner r0 -pady 4 2825 blt::table configure $inner r2 -pady 4 2831 2826 bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke] 2832 2827 } else { 2833 2828 set inner [$popup component inner] 2834 2829 } 2835 update 2830 update 2836 2831 # Timeout is set to 10 minutes. 2837 2832 $_dispatcher event -after 600000 !movietimeout … … 2839 2834 grab set $inner 2840 2835 focus $inner.cancel 2841 2836 2842 2837 flow duration 2843 2838 flow speed … … 2851 2846 set start [clock seconds] 2852 2847 SendCmd "flow video $token -width $w -height $h -numframes $nframes " 2853 2848 2854 2849 $popup activate $widget below 2855 update idletasks 2850 update idletasks 2856 2851 update 2857 2852 # We wait here until 2858 # 1. the movie is delivered or 2859 # 2. we've timed out or 2853 # 1. the movie is delivered or 2854 # 2. we've timed out or 2860 2855 # 3. the user has canceled the operation.b 2861 2856 tkwait variable $var … … 2872 2867 2873 2868 # This will both cancel the movie generation (if it hasn't already 2874 # completed) and reset the flow. 2869 # completed) and reset the flow. 2875 2870 SendCmd "flow reset" 2876 2871 if { $_hardcopy($this-$token) != "" } { … … 2906 2901 } 2907 2902 2908 itcl::body Rappture::FlowvisViewer::SetOrientation { side } { 2909 array set positions { 2910 front "1 0 0 0" 2911 back "0 0 1 0" 2912 left "0.707107 0 -0.707107 0" 2913 right "0.707107 0 0.707107 0" 2914 top "0.707107 -0.707107 0 0" 2915 bottom "0.707107 0.707107 0 0" 2916 } 2917 foreach name { -qw -qx -qy -qz } value $positions($side) { 2903 itcl::body Rappture::FlowvisViewer::SetOrientation { side } { 2904 array set positions { 2905 front "1 0 0 0" 2906 back "0 0 1 0" 2907 left "0.707107 0 -0.707107 0" 2908 right "0.707107 0 0.707107 0" 2909 top "0.707107 -0.707107 0 0" 2910 bottom "0.707107 0.707107 0 0" 2911 } 2912 foreach name { -qw -qx -qy -qz } value $positions($side) { 2918 2913 set _view($name) $value 2919 } 2914 } 2920 2915 set q [ViewToQuaternion] 2921 2916 $_arcball quaternion $q 2922 SendCmd "camera orient $q" 2917 SendCmd "camera orient $q" 2923 2918 SendCmd "camera reset" 2924 2919 set _view(-xpan) 0.0 … … 2931 2926 2932 2927 # Reset global settings from dataset's settings. 2933 itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} { 2928 itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} { 2934 2929 $itk_component(volcomponents) choices delete 0 end 2935 2930 foreach name $_componentsList { … … 2941 2936 2942 2937 # Reset global settings from dataset's settings. 2943 itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } { 2938 itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } { 2944 2939 if { ![info exists _volcomponents($cname)] } { 2945 2940 return ""
Note: See TracChangeset
for help on using the changeset viewer.