- Timestamp:
- Apr 17, 2015, 10:51:06 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/flowvisviewer.tcl
r5258 r5270 84 84 private method BuildVolumeComponents {} 85 85 private method BuildVolumeTab {} 86 private method ComputeTransferFunc { tf }86 private method ComputeTransferFunction { tf } 87 87 private method Connect {} 88 88 private method CurrentVolumeIds {{what -all}} 89 89 private method Disconnect {} 90 private method DrawLegend { tf } 90 91 private method EventuallyResize { w h } 91 92 private method EventuallyGoto { nSteps } … … 96 97 private method GetPngImage { widget width height } 97 98 private method InitSettings { args } 98 private method NameTransferFunc { dataobj comp }99 private method NameTransferFunction { dataobj comp } 99 100 private method Pan {option x y} 100 101 private method PanCamera {} … … 112 113 private method Rotate {option x y} 113 114 private method SendFlowCmd { dataobj comp nbytes extents } 114 private method SendTransferFunc s {}115 private method SendTransferFunctions {} 115 116 private method SetOrientation { side } 116 117 private method Slice {option args} … … 129 130 130 131 private variable _arcball "" 131 private variable _dlist "" ;# list of data objects 132 private variable _allDataObjs 133 private variable _obj2ovride ;# maps dataobj => style override 134 private variable _serverObjs ;# maps dataobj-component to volume ID 135 # in the server 136 private variable _recvObjs ;# list of data objs to send to server 137 private variable _obj2style ;# maps dataobj-component to transfunc 138 private variable _style2objs ;# maps tf back to list of 139 # dataobj-components using the tf. 140 private variable _obj2flow; # Maps dataobj-component to a flow. 141 142 private variable _reset 1 ;# Connection to server has been reset 143 private variable _click ;# info used for rotate operations 144 private variable _limits ;# autoscale min/max for all axes 145 private variable _view ;# view params for 3D view 146 private variable _isomarkers ;# array of isosurface level values 0..1 132 private variable _dlist "" ;# list of data objects 133 private variable _obj2ovride ;# maps dataobj => style override 134 private variable _serverDatasets ;# maps dataobj-component to volume ID 135 # in the server 136 private variable _recvdDatasets ;# list of data objs to send to server 137 private variable _dataset2style ;# maps dataobj-component to transfunc 138 private variable _style2datasets ;# maps tf back to list of 139 # dataobj-components using the tf. 140 private variable _dataset2flow ;# Maps dataobj-component to a flow. 141 142 private variable _reset 1 ;# Connection to server has been reset 143 private variable _click ;# info used for rotate operations 144 private variable _limits ;# Autoscale min/max for all axes 145 private variable _view ;# View params for 3D view 146 private variable _isomarkers ;# array of isosurface level values 0..1 147 147 private common _settings 148 private variable _activeTf "" ;# The currently active transfer function.149 private variable _first "" ;# This is the topmost volume.150 private variable _volcomponents ;# Array of components found151 private variable _componentsList ;# Array of components found148 private variable _activeTf "" ;# The currently active transfer function. 149 private variable _first "" ;# This is the topmost volume. 150 private variable _volcomponents ;# Array of components found 151 private variable _componentsList ;# Array of components found 152 152 private variable _nextToken 0 153 153 private variable _icon 0 154 154 private variable _flow 155 private common _downloadPopup ;# download options from popup 156 155 156 private common _downloadPopup ;# download options from popup 157 157 private common _hardcopy 158 158 private variable _width 0 … … 181 181 $_dispatcher register !send_transfunc 182 182 $_dispatcher dispatch $this !send_transfunc \ 183 "[itcl::code $this SendTransferFunc s]; list"183 "[itcl::code $this SendTransferFunctions]; list" 184 184 185 185 # Rebuild event. … … 230 230 231 231 array set _settings [subst { 232 $this-qw$_view(-qw)233 $this-qx$_view(-qx)234 $this-qy$_view(-qy)235 $this-qz$_view(-qz)236 $this-zoom$_view(-zoom)237 $this-xpan$_view(-xpan)238 $this-ypan$_view(-ypan)232 -qw $_view(-qw) 233 -qx $_view(-qx) 234 -qy $_view(-qy) 235 -qz $_view(-qz) 236 -zoom $_view(-zoom) 237 -xpan $_view(-xpan) 238 -ypan $_view(-ypan) 239 239 $this-arrows 0 240 240 $this-currenttime 0 … … 609 609 continue 610 610 } 611 set _ obj2flow($dataobj-$comp) $flowobj611 set _dataset2flow($dataobj-$comp) $flowobj 612 612 } 613 613 set pos [lsearch -exact $_dlist $dataobj] 614 614 if {$pos < 0} { 615 615 lappend _dlist $dataobj 616 set _allDataObjs($dataobj) 1617 616 set _obj2ovride($dataobj-color) $params(-color) 618 617 set _obj2ovride($dataobj-width) $params(-width) … … 698 697 set _dlist [lreplace $_dlist $pos $pos] 699 698 array unset _obj2ovride $dataobj-* 700 array unset _ obj2flow $dataobj-*701 array unset _server Objs $dataobj-*702 array unset _ obj2style $dataobj-*699 array unset _dataset2flow $dataobj-* 700 array unset _serverDatasets $dataobj-* 701 array unset _dataset2style $dataobj-* 703 702 set changed 1 704 703 } … … 707 706 if {$changed} { 708 707 # Repair the reverse lookup 709 foreach tf [array names _style2 objs] {708 foreach tf [array names _style2datasets] { 710 709 set list {} 711 foreach {dataobj comp} $_style2 objs($tf) break712 if { [info exists _server Objs($dataobj-$comp)] } {710 foreach {dataobj comp} $_style2datasets($tf) break 711 if { [info exists _serverDatasets($dataobj-$comp)] } { 713 712 lappend list $dataobj $comp 714 713 } 715 714 if { $list == "" } { 716 array unset _style2 objs $tf715 array unset _style2datasets $tf 717 716 } else { 718 set _style2 objs($tf) $list717 set _style2datasets($tf) $list 719 718 } 720 719 } … … 944 943 945 944 # disconnected -- no more data sitting on server 946 array unset _server Objs947 } 948 949 # ---------------------------------------------------------------------- 950 # USAGE: SendTransferFunc s951 # ---------------------------------------------------------------------- 952 itcl::body Rappture::FlowvisViewer::SendTransferFunc s {} {945 array unset _serverDatasets 946 } 947 948 # ---------------------------------------------------------------------- 949 # USAGE: SendTransferFunctions 950 # ---------------------------------------------------------------------- 951 itcl::body Rappture::FlowvisViewer::SendTransferFunctions {} { 953 952 if { $_activeTf == "" } { 954 953 puts stderr "no active tf" … … 970 969 set _settings($this-$tf-thickness) $thickness 971 970 972 foreach key [array names _ obj2style $_first-*] {973 if { [info exists _ obj2style($key)] } {974 foreach tf $_ obj2style($key) {975 ComputeTransferFunc $tf971 foreach key [array names _dataset2style $_first-*] { 972 if { [info exists _dataset2style($key)] } { 973 foreach tf $_dataset2style($key) { 974 ComputeTransferFunction $tf 976 975 } 977 976 } … … 1016 1015 1017 1016 # 1018 # ReceiveLegend -- 1019 # 1020 # The procedure is the response from the render server to each "legend" 1021 # command. The server sends back a "legend" command invoked our 1022 # the slave interpreter. The purpose is to collect data of the image 1023 # representing the legend in the canvas. In addition, the isomarkers 1024 # of the active transfer function are displayed. 1025 # 1026 # I don't know is this is the right place to display the isomarkers. 1027 # I don't know all the different paths used to draw the plot. There's 1028 # "Rebuild", "add", etc. 1029 # 1030 itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } { 1031 if { ![isconnected] } { 1032 return 1033 } 1034 #puts stderr "receive legend $tag $vmin $vmax $size" 1035 set bytes [ReceiveBytes $size] 1036 $_image(legend) configure -data $bytes 1037 ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 1038 1017 # DrawLegend -- 1018 # 1019 itcl::body Rappture::FlowvisViewer::DrawLegend { tag } { 1039 1020 set c $itk_component(legend) 1040 1021 set w [winfo width $c] … … 1052 1033 $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y] 1053 1034 } 1054 # Display the markers used by the active transfer function. 1055 set tf $_obj2style($tag) 1035 1036 # Display the markers used by the current transfer function. 1037 set tf $_dataset2style($tag) 1056 1038 foreach {vmin vmax} [limits $tf] break 1057 1039 $c itemconfigure vmin -text [format %g $vmin] … … 1066 1048 } 1067 1049 } 1050 } 1051 1052 # 1053 # ReceiveLegend -- 1054 # 1055 # The procedure is the response from the render server to each "legend" 1056 # command. The server sends back a "legend" command invoked our 1057 # the slave interpreter. The purpose is to collect data of the image 1058 # representing the legend in the canvas. In addition, the 1059 # active transfer function is displayed. 1060 # 1061 itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } { 1062 if { ![isconnected] } { 1063 return 1064 } 1065 #puts stderr "receive legend $tag $vmin $vmax $size" 1066 set bytes [ReceiveBytes $size] 1067 $_image(legend) configure -data $bytes 1068 ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 1069 1070 DrawLegend $tag 1068 1071 } 1069 1072 … … 1077 1080 # doesn't parse 3D data formats, we rely on the server (flowvis) to 1078 1081 # tell us what the limits are. Once we've received the limits to all 1079 # the data we've sent (tracked by _recv Objs) we can then determine1082 # the data we've sent (tracked by _recvdDatasets) we can then determine 1080 1083 # what the transfer functions are for these # volumes. 1081 1084 # … … 1097 1100 set parts [split $tag -] 1098 1101 set dataobj [lindex $parts 0] 1099 set _server Objs($tag) 01102 set _serverDatasets($tag) 0 1100 1103 set _limits($tag) [list $values(min) $values(max)] 1101 unset _recv Objs($tag)1102 if { [array size _recv Objs] == 0 } {1104 unset _recvdDatasets($tag) 1105 if { [array size _recvdDatasets] == 0 } { 1103 1106 updateTransferFunctions 1104 1107 } … … 1179 1182 } 1180 1183 SendData $data 1181 NameTransferFunc $dataobj $comp1182 set _recv Objs($tag) 11184 NameTransferFunction $dataobj $comp 1185 set _recvdDatasets($tag) 1 1183 1186 } 1184 1187 } … … 1208 1211 1209 1212 } 1210 set _settings( $this-qw) $_view(-qw)1211 set _settings( $this-qx) $_view(-qx)1212 set _settings( $this-qy) $_view(-qy)1213 set _settings( $this-qz) $_view(-qz)1214 set _settings( $this-xpan) $_view(-xpan)1215 set _settings( $this-ypan) $_view(-ypan)1216 set _settings( $this-zoom) $_view(-zoom)1213 set _settings(-qw) $_view(-qw) 1214 set _settings(-qx) $_view(-qx) 1215 set _settings(-qy) $_view(-qy) 1216 set _settings(-qz) $_view(-qz) 1217 set _settings(-xpan) $_view(-xpan) 1218 set _settings(-ypan) $_view(-ypan) 1219 set _settings(-zoom) $_view(-zoom) 1217 1220 1218 1221 set q [ViewToQuaternion] … … 1225 1228 foreach dataobj [get] { 1226 1229 foreach comp [$dataobj components] { 1227 NameTransferFunc $dataobj $comp1230 NameTransferFunction $dataobj $comp 1228 1231 } 1229 1232 } … … 1241 1244 } 1242 1245 set comp [lindex [$_first components] 0] 1243 set _activeTf [lindex $_ obj2style($_first-$comp) 0]1246 set _activeTf [lindex $_dataset2style($_first-$comp) 0] 1244 1247 } 1245 1248 … … 1274 1277 return 1275 1278 } 1276 foreach key [array names _server Objs *-*] {1279 foreach key [array names _serverDatasets *-*] { 1277 1280 if {[string match $_first-* $key]} { 1278 1281 array set style { … … 1282 1285 array set style [lindex [$dataobj components -style $comp] 0] 1283 1286 if {$what != "-cutplanes" || $style(-cutplanes)} { 1284 lappend rlist $_server Objs($key)1287 lappend rlist $_serverDatasets($key) 1285 1288 } 1286 1289 } … … 1301 1304 "in" { 1302 1305 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1303 set _settings( $this-zoom) $_view(-zoom)1306 set _settings(-zoom) $_view(-zoom) 1304 1307 SendCmd "camera zoom $_view(-zoom)" 1305 1308 } 1306 1309 "out" { 1307 1310 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1308 set _settings( $this-zoom) $_view(-zoom)1311 set _settings(-zoom) $_view(-zoom) 1309 1312 SendCmd "camera zoom $_view(-zoom)" 1310 1313 } … … 1329 1332 SendCmd "camera orient $q" 1330 1333 SendCmd "camera reset" 1331 set _settings( $this-qw) $_view(-qw)1332 set _settings( $this-qx) $_view(-qx)1333 set _settings( $this-qy) $_view(-qy)1334 set _settings( $this-qz) $_view(-qz)1335 set _settings( $this-xpan) $_view(-xpan)1336 set _settings( $this-ypan) $_view(-ypan)1337 set _settings( $this-zoom) $_view(-zoom)1334 set _settings(-qw) $_view(-qw) 1335 set _settings(-qx) $_view(-qx) 1336 set _settings(-qy) $_view(-qy) 1337 set _settings(-qz) $_view(-qz) 1338 set _settings(-xpan) $_view(-xpan) 1339 set _settings(-ypan) $_view(-ypan) 1340 set _settings(-zoom) $_view(-zoom) 1338 1341 } 1339 1342 } … … 1381 1384 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1382 1385 QuaternionToView $q 1383 set _settings( $this-qw) $_view(-qw)1384 set _settings( $this-qx) $_view(-qx)1385 set _settings( $this-qy) $_view(-qy)1386 set _settings( $this-qz) $_view(-qz)1386 set _settings(-qw) $_view(-qw) 1387 set _settings(-qx) $_view(-qx) 1388 set _settings(-qy) $_view(-qy) 1389 set _settings(-qz) $_view(-qz) 1387 1390 SendCmd "camera orient $q" 1388 1391 … … 1420 1423 set _view(-ypan) [expr $_view(-ypan) + $y] 1421 1424 PanCamera 1422 set _settings( $this-xpan) $_view(-xpan)1423 set _settings( $this-ypan) $_view(-ypan)1425 set _settings(-xpan) $_view(-xpan) 1426 set _settings(-ypan) $_view(-ypan) 1424 1427 return 1425 1428 } … … 1437 1440 set _view(-ypan) [expr $_view(-ypan) - $dy] 1438 1441 PanCamera 1439 set _settings( $this-xpan) $_view(-xpan)1440 set _settings( $this-ypan) $_view(-ypan)1442 set _settings(-xpan) $_view(-xpan) 1443 set _settings(-ypan) $_view(-ypan) 1441 1444 } 1442 1445 if { $option == "release" } { … … 1717 1720 set comp [lindex [$_first components] 0] 1718 1721 set tag $_first-$comp 1719 #set _activeTf [lindex $_ obj2style($tag) 0]1722 #set _activeTf [lindex $_dataset2style($tag) 0] 1720 1723 if {$w > 0 && $h > 0 && "" != $_activeTf} { 1721 1724 #SendCmd "legend $_activeTf $w $h" … … 1730 1733 1731 1734 # 1732 # NameTransferFunc --1735 # NameTransferFunction -- 1733 1736 # 1734 1737 # Creates a transfer function name based on the <style> settings in the … … 1744 1747 # now. 1745 1748 # 1746 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } {1749 itcl::body Rappture::FlowvisViewer::NameTransferFunction { dataobj cname } { 1747 1750 array set style { 1748 1751 -color BCGYR … … 1752 1755 array set style [lindex [$dataobj components -style $cname] 0] 1753 1756 set _settings($this-opacity) [expr $style(-opacity) * 100] 1754 set _ obj2style($dataobj-$cname) $cname1755 lappend _style2 objs($cname) $dataobj $cname1757 set _dataset2style($dataobj-$cname) $cname 1758 lappend _style2datasets($cname) $dataobj $cname 1756 1759 return $cname 1757 1760 } 1758 1761 1759 1762 # 1760 # ComputeTransferFunc --1763 # ComputeTransferFunction -- 1761 1764 # 1762 1765 # Computes and sends the transfer function to the render server. It's … … 1766 1769 # the alpha map of the transfer function. 1767 1770 # 1768 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {1771 itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } { 1769 1772 array set style { 1770 1773 -color BCGYR … … 1773 1776 } 1774 1777 set dataobj ""; set comp "" 1775 foreach {dataobj comp} $_style2 objs($tf) break1778 foreach {dataobj comp} $_style2datasets($tf) break 1776 1779 if { $dataobj == "" } { 1777 1780 return 0 … … 1981 1984 1982 1985 # ---------------------------------------------------------------------- 1983 # USAGE: UpdateTransferFunc s1986 # USAGE: UpdateTransferFunctions 1984 1987 # ---------------------------------------------------------------------- 1985 1988 itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} { … … 2044 2047 itcl::body Rappture::FlowvisViewer::limits { cname } { 2045 2048 set _limits(v) [list 0.0 1.0] 2046 if { ![info exists _style2 objs($cname)] } {2047 puts stderr "no style2objs for $cname cname=($cname)"2049 if { ![info exists _style2datasets($cname)] } { 2050 puts stderr "no _style2datasets for $cname cname=($cname)" 2048 2051 return [array get _limits] 2049 2052 } 2050 2053 set min ""; set max "" 2051 2054 foreach tag [GetDatasetsWithComponent $cname] { 2052 if { ![info exists _server Objs($tag)] } {2055 if { ![info exists _serverDatasets($tag)] } { 2053 2056 puts stderr "$tag not in serverObjs?" 2054 2057 continue … … 2378 2381 label $inner.${tag}label -text $tag -font "Arial 9" 2379 2382 entry $inner.${tag} -font "Arial 9" -bg white \ 2380 -textvariable [itcl::scope _settings( $this-$tag)]2383 -textvariable [itcl::scope _settings(-$tag)] 2381 2384 bind $inner.${tag} <Return> \ 2382 2385 [itcl::code $this camera set -${tag}] … … 2397 2400 itcl::body Rappture::FlowvisViewer::GetFlowInfo { w } { 2398 2401 set flowobj "" 2399 foreach key [array names _ obj2flow] {2400 set flowobj $_ obj2flow($key)2402 foreach key [array names _dataset2flow] { 2403 set flowobj $_dataset2flow($key) 2401 2404 break 2402 2405 } … … 2613 2616 itcl::body Rappture::FlowvisViewer::SendFlowCmd { dataobj comp nbytes extents } { 2614 2617 set tag "$dataobj-$comp" 2615 if { ![info exists _ obj2flow($tag)] } {2618 if { ![info exists _dataset2flow($tag)] } { 2616 2619 SendCmd "flow add $tag" 2617 2620 SendCmd "$tag data follows $nbytes $extents" 2618 2621 return 0 2619 2622 } 2620 set flowobj $_ obj2flow($tag)2623 set flowobj $_dataset2flow($tag) 2621 2624 if { $flowobj == "" } { 2622 2625 puts stderr "no flowobj" … … 2997 3000 set _view(-ypan) 0.0 2998 3001 set _view(-zoom) 1.0 2999 set _settings( $this-xpan) $_view(-xpan)3000 set _settings( $this-ypan) $_view(-ypan)3001 set _settings( $this-zoom) $_view(-zoom)3002 set _settings(-xpan) $_view(-xpan) 3003 set _settings(-ypan) $_view(-ypan) 3004 set _settings(-zoom) $_view(-zoom) 3002 3005 } 3003 3006 … … 3019 3022 set list "" 3020 3023 foreach tag $_volcomponents($cname) { 3021 if { ![info exists _server Objs($tag)] } {3024 if { ![info exists _serverDatasets($tag)] } { 3022 3025 continue 3023 3026 }
Note: See TracChangeset
for help on using the changeset viewer.