Changeset 5275 for branches/1.4
- Timestamp:
- Apr 17, 2015, 11:40:55 PM (9 years ago)
- Location:
- branches/1.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4
- Property svn:mergeinfo changed
/trunk merged: 5258,5270,5274
- Property svn:mergeinfo changed
-
branches/1.4/gui/scripts/flowvisviewer.tcl
r5248 r5275 77 77 78 78 # The following methods are only used by this class. 79 private method AddIsoMarker { x y } 79 80 private method AdjustSetting {what {value ""}} 80 private method AddIsoMarker { x y }81 81 private method BuildCameraTab {} 82 82 private method BuildCutplanesTab {} … … 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 … … 594 594 continue 595 595 } 596 set _ obj2flow($dataobj-$comp) $flowobj596 set _dataset2flow($dataobj-$comp) $flowobj 597 597 } 598 598 set pos [lsearch -exact $_dlist $dataobj] 599 599 if {$pos < 0} { 600 600 lappend _dlist $dataobj 601 set _allDataObjs($dataobj) 1602 601 set _obj2ovride($dataobj-color) $params(-color) 603 602 set _obj2ovride($dataobj-width) $params(-width) … … 683 682 set _dlist [lreplace $_dlist $pos $pos] 684 683 array unset _obj2ovride $dataobj-* 685 array unset _ obj2flow $dataobj-*686 array unset _server Objs $dataobj-*687 array unset _ obj2style $dataobj-*684 array unset _dataset2flow $dataobj-* 685 array unset _serverDatasets $dataobj-* 686 array unset _dataset2style $dataobj-* 688 687 set changed 1 689 688 } … … 692 691 if {$changed} { 693 692 # Repair the reverse lookup 694 foreach tf [array names _style2 objs] {693 foreach tf [array names _style2datasets] { 695 694 set list {} 696 foreach {dataobj comp} $_style2 objs($tf) break697 if { [info exists _server Objs($dataobj-$comp)] } {695 foreach {dataobj comp} $_style2datasets($tf) break 696 if { [info exists _serverDatasets($dataobj-$comp)] } { 698 697 lappend list $dataobj $comp 699 698 } 700 699 if { $list == "" } { 701 array unset _style2 objs $tf700 array unset _style2datasets $tf 702 701 } else { 703 set _style2 objs($tf) $list702 set _style2datasets($tf) $list 704 703 } 705 704 } … … 929 928 930 929 # disconnected -- no more data sitting on server 931 array unset _server Objs932 } 933 934 # ---------------------------------------------------------------------- 935 # USAGE: SendTransferFunc s936 # ---------------------------------------------------------------------- 937 itcl::body Rappture::FlowvisViewer::SendTransferFunc s {} {930 array unset _serverDatasets 931 } 932 933 # ---------------------------------------------------------------------- 934 # USAGE: SendTransferFunctions 935 # ---------------------------------------------------------------------- 936 itcl::body Rappture::FlowvisViewer::SendTransferFunctions {} { 938 937 if { $_activeTf == "" } { 939 938 puts stderr "no active tf" … … 955 954 set _settings($this-$tf-thickness) $thickness 956 955 957 foreach key [array names _ obj2style $_first-*] {958 if { [info exists _ obj2style($key)] } {959 foreach tf $_ obj2style($key) {960 ComputeTransferFunc $tf956 foreach key [array names _dataset2style $_first-*] { 957 if { [info exists _dataset2style($key)] } { 958 foreach tf $_dataset2style($key) { 959 ComputeTransferFunction $tf 961 960 } 962 961 } … … 1001 1000 1002 1001 # 1003 # ReceiveLegend -- 1004 # 1005 # The procedure is the response from the render server to each "legend" 1006 # command. The server sends back a "legend" command invoked our 1007 # the slave interpreter. The purpose is to collect data of the image 1008 # representing the legend in the canvas. In addition, the isomarkers 1009 # of the active transfer function are displayed. 1010 # 1011 # I don't know is this is the right place to display the isomarkers. 1012 # I don't know all the different paths used to draw the plot. There's 1013 # "Rebuild", "add", etc. 1014 # 1015 itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } { 1016 if { ![isconnected] } { 1017 return 1018 } 1019 #puts stderr "receive legend $tag $vmin $vmax $size" 1020 set bytes [ReceiveBytes $size] 1021 $_image(legend) configure -data $bytes 1022 ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 1023 1002 # DrawLegend -- 1003 # 1004 itcl::body Rappture::FlowvisViewer::DrawLegend { tag } { 1024 1005 set c $itk_component(legend) 1025 1006 set w [winfo width $c] … … 1037 1018 $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y] 1038 1019 } 1039 # Display the markers used by the active transfer function. 1040 set tf $_obj2style($tag) 1020 1021 # Display the markers used by the current transfer function. 1022 set tf $_dataset2style($tag) 1041 1023 foreach {vmin vmax} [limits $tf] break 1042 1024 $c itemconfigure vmin -text [format %g $vmin] … … 1051 1033 } 1052 1034 } 1035 } 1036 1037 # 1038 # ReceiveLegend -- 1039 # 1040 # The procedure is the response from the render server to each "legend" 1041 # command. The server sends back a "legend" command invoked our 1042 # the slave interpreter. The purpose is to collect data of the image 1043 # representing the legend in the canvas. In addition, the 1044 # active transfer function is displayed. 1045 # 1046 itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } { 1047 if { ![isconnected] } { 1048 return 1049 } 1050 #puts stderr "receive legend $tag $vmin $vmax $size" 1051 set bytes [ReceiveBytes $size] 1052 $_image(legend) configure -data $bytes 1053 ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 1054 1055 DrawLegend $tag 1053 1056 } 1054 1057 … … 1062 1065 # doesn't parse 3D data formats, we rely on the server (flowvis) to 1063 1066 # tell us what the limits are. Once we've received the limits to all 1064 # the data we've sent (tracked by _recv Objs) we can then determine1067 # the data we've sent (tracked by _recvdDatasets) we can then determine 1065 1068 # what the transfer functions are for these # volumes. 1066 1069 # … … 1082 1085 set parts [split $tag -] 1083 1086 set dataobj [lindex $parts 0] 1084 set _server Objs($tag) 01087 set _serverDatasets($tag) 0 1085 1088 set _limits($tag) [list $values(min) $values(max)] 1086 unset _recv Objs($tag)1087 if { [array size _recv Objs] == 0 } {1089 unset _recvdDatasets($tag) 1090 if { [array size _recvdDatasets] == 0 } { 1088 1091 updateTransferFunctions 1089 1092 } … … 1164 1167 } 1165 1168 SendData $data 1166 NameTransferFunc $dataobj $comp1167 set _recv Objs($tag) 11169 NameTransferFunction $dataobj $comp 1170 set _recvdDatasets($tag) 1 1168 1171 } 1169 1172 } … … 1186 1189 1187 1190 } 1188 set _settings( $this-qw) $_view(-qw)1189 set _settings( $this-qx) $_view(-qx)1190 set _settings( $this-qy) $_view(-qy)1191 set _settings( $this-qz) $_view(-qz)1192 set _settings( $this-xpan) $_view(-xpan)1193 set _settings( $this-ypan) $_view(-ypan)1194 set _settings( $this-zoom) $_view(-zoom)1191 set _settings(-qw) $_view(-qw) 1192 set _settings(-qx) $_view(-qx) 1193 set _settings(-qy) $_view(-qy) 1194 set _settings(-qz) $_view(-qz) 1195 set _settings(-xpan) $_view(-xpan) 1196 set _settings(-ypan) $_view(-ypan) 1197 set _settings(-zoom) $_view(-zoom) 1195 1198 1196 1199 set q [ViewToQuaternion] … … 1203 1206 foreach dataobj [get] { 1204 1207 foreach comp [$dataobj components] { 1205 NameTransferFunc $dataobj $comp1208 NameTransferFunction $dataobj $comp 1206 1209 } 1207 1210 } … … 1219 1222 } 1220 1223 set comp [lindex [$_first components] 0] 1221 set _activeTf [lindex $_ obj2style($_first-$comp) 0]1224 set _activeTf [lindex $_dataset2style($_first-$comp) 0] 1222 1225 } 1223 1226 … … 1253 1256 return 1254 1257 } 1255 foreach key [array names _server Objs *-*] {1258 foreach key [array names _serverDatasets *-*] { 1256 1259 if {[string match $_first-* $key]} { 1257 1260 array set style { … … 1261 1264 array set style [lindex [$dataobj components -style $comp] 0] 1262 1265 if {$what != "-cutplanes" || $style(-cutplanes)} { 1263 lappend rlist $_server Objs($key)1266 lappend rlist $_serverDatasets($key) 1264 1267 } 1265 1268 } … … 1280 1283 "in" { 1281 1284 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1282 set _settings( $this-zoom) $_view(-zoom)1285 set _settings(-zoom) $_view(-zoom) 1283 1286 SendCmd "camera zoom $_view(-zoom)" 1284 1287 } 1285 1288 "out" { 1286 1289 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1287 set _settings( $this-zoom) $_view(-zoom)1290 set _settings(-zoom) $_view(-zoom) 1288 1291 SendCmd "camera zoom $_view(-zoom)" 1289 1292 } … … 1294 1297 -qy 0.353553 1295 1298 -qz 0.146447 1296 -zoom 1.01297 1299 -xpan 0 1298 1300 -ypan 0 1301 -zoom 1.0 1299 1302 } 1300 1303 if { $_first != "" } { … … 1308 1311 SendCmd "camera orient $q" 1309 1312 SendCmd "camera reset" 1310 set _settings( $this-qw) $_view(-qw)1311 set _settings( $this-qx) $_view(-qx)1312 set _settings( $this-qy) $_view(-qy)1313 set _settings( $this-qz) $_view(-qz)1314 set _settings( $this-xpan) $_view(-xpan)1315 set _settings( $this-ypan) $_view(-ypan)1316 set _settings( $this-zoom) $_view(-zoom)1313 set _settings(-qw) $_view(-qw) 1314 set _settings(-qx) $_view(-qx) 1315 set _settings(-qy) $_view(-qy) 1316 set _settings(-qz) $_view(-qz) 1317 set _settings(-xpan) $_view(-xpan) 1318 set _settings(-ypan) $_view(-ypan) 1319 set _settings(-zoom) $_view(-zoom) 1317 1320 } 1318 1321 } … … 1360 1363 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1361 1364 QuaternionToView $q 1362 set _settings( $this-qw) $_view(-qw)1363 set _settings( $this-qx) $_view(-qx)1364 set _settings( $this-qy) $_view(-qy)1365 set _settings( $this-qz) $_view(-qz)1365 set _settings(-qw) $_view(-qw) 1366 set _settings(-qx) $_view(-qx) 1367 set _settings(-qy) $_view(-qy) 1368 set _settings(-qz) $_view(-qz) 1366 1369 SendCmd "camera orient $q" 1367 1370 … … 1399 1402 set _view(-ypan) [expr $_view(-ypan) + $y] 1400 1403 PanCamera 1401 set _settings( $this-xpan) $_view(-xpan)1402 set _settings( $this-ypan) $_view(-ypan)1404 set _settings(-xpan) $_view(-xpan) 1405 set _settings(-ypan) $_view(-ypan) 1403 1406 return 1404 1407 } … … 1416 1419 set _view(-ypan) [expr $_view(-ypan) - $dy] 1417 1420 PanCamera 1418 set _settings( $this-xpan) $_view(-xpan)1419 set _settings( $this-ypan) $_view(-ypan)1421 set _settings(-xpan) $_view(-xpan) 1422 set _settings(-ypan) $_view(-ypan) 1420 1423 } 1421 1424 if { $option == "release" } { … … 1666 1669 set comp [lindex [$_first components] 0] 1667 1670 set tag $_first-$comp 1668 #set _activeTf [lindex $_ obj2style($tag) 0]1671 #set _activeTf [lindex $_dataset2style($tag) 0] 1669 1672 if {$w > 0 && $h > 0 && "" != $_activeTf} { 1670 1673 #SendCmd "legend $_activeTf $w $h" … … 1679 1682 1680 1683 # 1681 # NameTransferFunc --1684 # NameTransferFunction -- 1682 1685 # 1683 1686 # Creates a transfer function name based on the <style> settings in the … … 1693 1696 # now. 1694 1697 # 1695 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } {1698 itcl::body Rappture::FlowvisViewer::NameTransferFunction { dataobj cname } { 1696 1699 array set style { 1697 1700 -color BCGYR … … 1701 1704 array set style [lindex [$dataobj components -style $cname] 0] 1702 1705 set _settings($this-opacity) [expr $style(-opacity) * 100] 1703 set _ obj2style($dataobj-$cname) $cname1704 lappend _style2 objs($cname) $dataobj $cname1706 set _dataset2style($dataobj-$cname) $cname 1707 lappend _style2datasets($cname) $dataobj $cname 1705 1708 return $cname 1706 1709 } 1707 1710 1708 1711 # 1709 # ComputeTransferFunc --1712 # ComputeTransferFunction -- 1710 1713 # 1711 1714 # Computes and sends the transfer function to the render server. It's … … 1715 1718 # the alpha map of the transfer function. 1716 1719 # 1717 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {1720 itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } { 1718 1721 array set style { 1719 1722 -color BCGYR … … 1722 1725 } 1723 1726 set dataobj ""; set comp "" 1724 foreach {dataobj comp} $_style2 objs($tf) break1727 foreach {dataobj comp} $_style2datasets($tf) break 1725 1728 if { $dataobj == "" } { 1726 1729 return 0 … … 1930 1933 1931 1934 # ---------------------------------------------------------------------- 1932 # USAGE: UpdateTransferFunc s1935 # USAGE: UpdateTransferFunctions 1933 1936 # ---------------------------------------------------------------------- 1934 1937 itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} { … … 1993 1996 itcl::body Rappture::FlowvisViewer::limits { cname } { 1994 1997 set _limits(v) [list 0.0 1.0] 1995 if { ![info exists _style2 objs($cname)] } {1996 puts stderr "no style2objs for $cnamecname=($cname)"1998 if { ![info exists _style2datasets($cname)] } { 1999 puts stderr "no _style2datasets for cname=($cname)" 1997 2000 return [array get _limits] 1998 2001 } 1999 2002 set min ""; set max "" 2000 2003 foreach tag [GetDatasetsWithComponent $cname] { 2001 if { ![info exists _server Objs($tag)] } {2002 puts stderr "$tag not in serverObjs?"2004 if { ![info exists _serverDatasets($tag)] } { 2005 puts stderr "$tag not in _serverDatasets?" 2003 2006 continue 2004 2007 } … … 2303 2306 label $inner.${tag}label -text $tag -font "Arial 9" 2304 2307 entry $inner.${tag} -font "Arial 9" -bg white \ 2305 -textvariable [itcl::scope _settings( $this-$tag)]2308 -textvariable [itcl::scope _settings(-$tag)] 2306 2309 bind $inner.${tag} <Return> \ 2307 2310 [itcl::code $this camera set -${tag}] … … 2322 2325 itcl::body Rappture::FlowvisViewer::GetFlowInfo { w } { 2323 2326 set flowobj "" 2324 foreach key [array names _ obj2flow] {2325 set flowobj $_ obj2flow($key)2327 foreach key [array names _dataset2flow] { 2328 set flowobj $_dataset2flow($key) 2326 2329 break 2327 2330 } … … 2538 2541 itcl::body Rappture::FlowvisViewer::SendFlowCmd { dataobj comp nbytes extents } { 2539 2542 set tag "$dataobj-$comp" 2540 if { ![info exists _ obj2flow($tag)] } {2543 if { ![info exists _dataset2flow($tag)] } { 2541 2544 SendCmd "flow add $tag" 2542 2545 SendCmd "$tag data follows $nbytes $extents" 2543 2546 return 0 2544 2547 } 2545 set flowobj $_ obj2flow($tag)2548 set flowobj $_dataset2flow($tag) 2546 2549 if { $flowobj == "" } { 2547 2550 puts stderr "no flowobj" … … 2922 2925 set _view(-ypan) 0.0 2923 2926 set _view(-zoom) 1.0 2924 set _settings( $this-xpan) $_view(-xpan)2925 set _settings( $this-ypan) $_view(-ypan)2926 set _settings( $this-zoom) $_view(-zoom)2927 set _settings(-xpan) $_view(-xpan) 2928 set _settings(-ypan) $_view(-ypan) 2929 set _settings(-zoom) $_view(-zoom) 2927 2930 } 2928 2931 … … 2944 2947 set list "" 2945 2948 foreach tag $_volcomponents($cname) { 2946 if { ![info exists _server Objs($tag)] } {2949 if { ![info exists _serverDatasets($tag)] } { 2947 2950 continue 2948 2951 }
Note: See TracChangeset
for help on using the changeset viewer.