Changeset 5642 for trunk/gui/scripts/flowvisviewer.tcl
- Timestamp:
- May 31, 2015 5:06:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/flowvisviewer.tcl
r5612 r5642 129 129 private variable _dlist "" ;# list of data objects 130 130 private variable _obj2ovride ;# maps dataobj => style override 131 private variable _ serverDatasets;# contains all the dataobj-component131 private variable _datasets ;# contains all the dataobj-component 132 132 ;# to volumes in the server 133 private variable _recvdDatasets ;# list of data objs to send to server134 133 private variable _dataset2style ;# maps dataobj-component to transfunc 135 134 private variable _style2datasets ;# maps tf back to list of … … 223 222 $_arcball quaternion [ViewToQuaternion] 224 223 225 set _limits(v) [list 0.0 1.0]226 224 set _reset 1 227 225 … … 593 591 # ---------------------------------------------------------------------- 594 592 itcl::body Rappture::FlowvisViewer::add {dataobj {settings ""}} { 593 if { ![$dataobj isvalid] } { 594 return; # Object doesn't contain valid data. 595 } 595 596 array set params { 596 597 -color auto … … 698 699 if { $pos >= 0 } { 699 700 set _dlist [lreplace $_dlist $pos $pos] 700 array unset _limits $dataobj-*701 701 array unset _obj2ovride $dataobj-* 702 array unset _dataset2flow $dataobj-*703 array unset _serverDatasets $dataobj-*704 array unset _dataset2style $dataobj-*705 702 set changed 1 706 703 } … … 708 705 # If anything changed, then rebuild the plot 709 706 if {$changed} { 710 # Repair the reverse lookup711 foreach tf [array names _style2datasets] {712 set list {}713 foreach {dataobj cname} $_style2datasets($tf) break714 if { [info exists _serverDatasets($dataobj-$cname)] } {715 lappend list $dataobj $cname716 }717 if { $list == "" } {718 array unset _style2datasets $tf719 } else {720 set _style2datasets($tf) $list721 }722 }723 707 $_dispatcher event -idle !rebuild 724 708 } … … 758 742 set _limits($cname) $limits(v) 759 743 } 760 foreach axis {x y z v} {744 foreach axis {x y z} { 761 745 foreach { min max } [$dataobj limits $axis] break 762 746 if {"" != $min && "" != $max} { … … 834 818 } 835 819 default { 836 error "bad download format $_downloadPopup(format)"820 error "bad download format \"$_downloadPopup(format)\"" 837 821 } 838 822 } … … 917 901 918 902 # disconnected -- no more data sitting on server 919 array unset _ serverDatasets903 array unset _datasets 920 904 } 921 905 … … 967 951 array set info $args 968 952 set bytes [ReceiveBytes $info(-bytes)] 969 ReceiveEcho <<line "<read $info(-bytes) bytes" 970 switch -- $info(-type) { 953 switch -- $info(-type) { 971 954 "image" { 955 #puts stderr "received image [image width $_image(plot)]x[image height $_image(plot)]" 972 956 $_image(plot) configure -data $bytes 973 #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]"974 957 } 975 958 "print" { … … 982 965 } 983 966 default { 984 puts stderr "unknown downloadtype $info(-type)"967 puts stderr "unknown image type $info(-type)" 985 968 } 986 969 } … … 1058 1041 # The procedure is the response from the render server to each "data 1059 1042 # follows" command. The server sends back a "data" command invoked our 1060 # the slave interpreter. The purpose is to collect the min/max of the 1061 # volume sent to the render server. Since the client (flowvisviewer) 1062 # doesn't parse 3D data formats, we rely on the server (nanovis) to 1063 # tell us what the limits are. Once we've received the limits to all 1064 # the data we've sent (tracked by _recvdDatasets) we can then determine 1065 # what the transfer functions are for these volumes. 1066 # 1067 # 1068 # Note: There is a considerable tradeoff in having the server report 1069 # back what the data limits are. It means that much of the code 1070 # having to do with transfer-functions has to wait for the data 1071 # to come back, since the isomarkers are calculated based upon 1072 # the data limits. The client code is much messier because of 1073 # this. The alternative is to parse any of the 3D formats on the 1074 # client side. 1043 # the slave interpreter. The purpose was to collect the min/max of the 1044 # volume sent to the render server. This is no longer needed since we 1045 # already know the limits. 1075 1046 # 1076 1047 itcl::body Rappture::FlowvisViewer::ReceiveData { args } { … … 1083 1054 1084 1055 set tag $info(tag) 1085 set parts [split $tag -]1086 1087 #1088 # Volumes don't exist until we're told about them.1089 #1090 set dataobj [lindex $parts 0]1091 set _serverDatasets($tag) 01092 1056 set _limits($tag) [list $info(min) $info(max)] 1093 1094 unset _recvdDatasets($tag)1095 if { [array size _recvdDatasets] == 0 } {1096 updateTransferFunctions1097 }1098 1057 } 1099 1058 … … 1136 1095 1137 1096 set _first "" 1138 foreach dataobj [get] { 1097 foreach dataobj [get -objects] { 1098 if { [info exists _obj2ovride($dataobj-raise)] && $_first == "" } { 1099 set _first $dataobj 1100 } 1139 1101 foreach cname [$dataobj components] { 1140 1102 set tag $dataobj-$cname 1141 if {[$dataobj type] == "dx"} { 1142 set data [$dataobj blob $cname] 1143 } else { 1144 set data [$dataobj vtkdata $cname] 1145 } 1146 set nbytes [string length $data] 1147 if { $_reportClientInfo } { 1148 set info {} 1149 lappend info "tool_id" [$dataobj hints toolid] 1150 lappend info "tool_name" [$dataobj hints toolname] 1151 lappend info "tool_title" [$dataobj hints tooltitle] 1152 lappend info "tool_command" [$dataobj hints toolcommand] 1153 lappend info "tool_revision" [$dataobj hints toolrevision] 1154 lappend info "dataset_label" [$dataobj hints label] 1155 lappend info "dataset_size" $nbytes 1156 lappend info "dataset_tag" $tag 1157 SendCmd "clientinfo [list $info]" 1158 } 1159 set numComponents [$dataobj numComponents $cname] 1160 # I have a field. Is a vector field or a volume field? 1161 if { $numComponents == 1 } { 1162 SendCmd "volume data follows $nbytes $tag" 1163 } else { 1164 if {[SendFlowCmd $dataobj $cname $nbytes $numComponents] < 0} { 1165 continue 1103 if { ![info exists _datasets($tag)] } { 1104 if { [$dataobj type] == "dx" } { 1105 set data [$dataobj blob $cname] 1106 } else { 1107 set data [$dataobj vtkdata $cname] 1166 1108 } 1167 } 1168 SendData $data 1169 NameTransferFunction $dataobj $cname 1170 set _recvdDatasets($tag) 1 1171 } 1172 } 1173 1174 set _first [lindex [get] 0] 1109 set nbytes [string length $data] 1110 if { $_reportClientInfo } { 1111 set info {} 1112 lappend info "tool_id" [$dataobj hints toolid] 1113 lappend info "tool_name" [$dataobj hints toolname] 1114 lappend info "tool_title" [$dataobj hints tooltitle] 1115 lappend info "tool_command" [$dataobj hints toolcommand] 1116 lappend info "tool_revision" [$dataobj hints toolrevision] 1117 lappend info "dataset_label" [$dataobj hints label] 1118 lappend info "dataset_size" $nbytes 1119 lappend info "dataset_tag" $tag 1120 SendCmd "clientinfo [list $info]" 1121 } 1122 set numComponents [$dataobj numComponents $cname] 1123 # I have a field. Is a vector field or a volume field? 1124 if { $numComponents == 1 } { 1125 SendCmd "volume data follows $nbytes $tag" 1126 } else { 1127 if {[SendFlowCmd $dataobj $cname $nbytes $numComponents] < 0} { 1128 continue 1129 } 1130 } 1131 SendData $data 1132 set _datasets($tag) 1 1133 NameTransferFunction $dataobj $cname 1134 } 1135 } 1136 } 1175 1137 1176 1138 # Turn off cutplanes for all volumes … … 1179 1141 } 1180 1142 1181 # Reset the camera and other view parameters 1182 InitSettings -axesvisible -gridvisible \ 1183 -opacity -light2side -isosurfaceshading \ 1184 -ambient -diffuse -specularlevel -specularexponent \ 1185 -volume -outlinevisible -cutplanesvisible \ 1143 InitSettings -volume -outlinevisible -cutplanesvisible \ 1186 1144 -xcutplanevisible -ycutplanevisible -zcutplanevisible \ 1187 1145 -xcutplaneposition -ycutplaneposition -zcutplaneposition 1188 1146 1189 # nothing to send -- activate the proper volume 1147 if { $_reset } { 1148 InitSettings -axesvisible -gridvisible \ 1149 -opacity -light2side -isosurfaceshading \ 1150 -ambient -diffuse -specularlevel -specularexponent 1151 1152 # 1153 # Reset the camera and other view parameters 1154 # 1155 if {"" != $_first} { 1156 set axis [$_first hints updir] 1157 if { "" != $axis } { 1158 SendCmd "up $axis" 1159 } 1160 set location [$_first hints camera] 1161 if { $location != "" } { 1162 array set _view $location 1163 } 1164 } 1165 set _settings(-qw) $_view(-qw) 1166 set _settings(-qx) $_view(-qx) 1167 set _settings(-qy) $_view(-qy) 1168 set _settings(-qz) $_view(-qz) 1169 set _settings(-xpan) $_view(-xpan) 1170 set _settings(-ypan) $_view(-ypan) 1171 set _settings(-zoom) $_view(-zoom) 1172 1173 set q [ViewToQuaternion] 1174 $_arcball quaternion $q 1175 SendCmd "camera orient $q" 1176 SendCmd "camera reset" 1177 PanCamera 1178 SendCmd "camera zoom $_view(-zoom)" 1179 } 1180 1190 1181 if {"" != $_first} { 1191 set axis [$_first hints updir]1192 if {"" != $axis} {1193 SendCmd "up $axis"1194 }1195 set location [$_first hints camera]1196 if { $location != "" } {1197 array set _view $location1198 }1199 }1200 set _settings(-qw) $_view(-qw)1201 set _settings(-qx) $_view(-qx)1202 set _settings(-qy) $_view(-qy)1203 set _settings(-qz) $_view(-qz)1204 set _settings(-xpan) $_view(-xpan)1205 set _settings(-ypan) $_view(-ypan)1206 set _settings(-zoom) $_view(-zoom)1207 1208 set q [ViewToQuaternion]1209 $_arcball quaternion $q1210 SendCmd "camera orient $q"1211 SendCmd "camera reset"1212 PanCamera1213 SendCmd "camera zoom $_view(-zoom)"1214 1215 foreach dataobj [get] {1216 foreach cname [$dataobj components] {1217 NameTransferFunction $dataobj $cname1218 }1219 }1220 1221 # nothing to send -- activate the proper ivol1222 set _first [lindex [get] 0]1223 if {"" != $_first} {1224 set axis [$_first hints updir]1225 if {"" != $axis} {1226 SendCmd "up $axis"1227 }1228 set location [$_first hints camera]1229 if { $location != "" } {1230 array set _view $location1231 }1232 1182 set cname [lindex [$_first components] 0] 1233 1183 set _activeTf [lindex $_dataset2style($_first-$cname) 0] 1234 } 1235 1236 # sync the state of slicers 1237 set vols [CurrentDatasets -cutplanes] 1238 foreach axis {x y z} { 1239 set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}] 1240 SendCmd "cutplane position $pos $axis $vols" 1241 } 1242 SendCmd "volume data state $_settings(-volume)" 1243 EventuallyRedrawLegend 1184 # Make sure we display the proper transfer function in the legend. 1185 updateTransferFunctions 1186 } 1244 1187 1245 1188 # Actually write the commands to the server socket. If it fails, we don't … … 1259 1202 # ---------------------------------------------------------------------- 1260 1203 itcl::body Rappture::FlowvisViewer::CurrentDatasets {{what -all}} { 1261 return""1204 set rlist "" 1262 1205 if { $_first == "" } { 1263 1206 return 1264 1207 } 1265 foreach tag [array names _serverDatasets *-*] { 1266 if {[string match $_first-* $tag]} { 1208 foreach cname [$_first components] { 1209 set tag $_first-$cname 1210 if { [info exists _datasets($tag)] && $_datasets($tag) } { 1267 1211 array set style { 1268 1212 -cutplanes 1 1269 1213 } 1270 foreach {dataobj cname} [split $tag -] break 1271 array set style [lindex [$dataobj components -style $cname] 0] 1272 if {$what != "-cutplanes" || $style(-cutplanes)} { 1273 lappend rlist $_serverDatasets($tag) 1214 array set style [lindex [$_first components -style $cname] 0] 1215 if { $what != "-cutplanes" || $style(-cutplanes) } { 1216 lappend rlist $tag 1274 1217 } 1275 1218 } … … 1943 1886 1944 1887 itcl::body Rappture::FlowvisViewer::limits { cname } { 1945 set _limits(v) [list 0.0 1.0] 1946 if { ![info exists _style2datasets($cname)] } { 1947 puts stderr "no _style2datasets for cname=($cname)" 1948 return [array get _limits] 1949 } 1950 set min ""; set max "" 1951 foreach tag [GetDatasetsWithComponent $cname] { 1952 if { ![info exists _serverDatasets($tag)] } { 1953 puts stderr "$tag not in _serverDatasets?" 1954 continue 1955 } 1956 if { ![info exists _limits($tag)] } { 1957 puts stderr "$tag no min?" 1958 continue 1959 } 1960 foreach {vmin vmax} $_limits($tag) break 1961 if { $min == "" || $min > $vmin } { 1962 set min $vmin 1963 } 1964 if { $max == "" || $max < $vmax } { 1965 set max $vmax 1966 } 1967 } 1968 if { $min != "" && $max != "" } { 1969 set _limits(v) [list $min $max] 1970 set _limits($cname) [list $min $max] 1888 if { ![info exists _limits($cname)] } { 1889 puts stderr "no limits for cname=($cname)" 1890 return [list 0.0 1.0] 1971 1891 } 1972 1892 return $_limits($cname) … … 3022 2942 set list "" 3023 2943 foreach tag $_volcomponents($cname) { 3024 if { ![info exists _ serverDatasets($tag)] } {2944 if { ![info exists _datasets($tag)] } { 3025 2945 continue 3026 2946 }
Note: See TracChangeset
for help on using the changeset viewer.