- Timestamp:
- May 30, 2009, 9:24:42 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/flowvisviewer.tcl
r1473 r1479 127 127 private variable _allDataObjs 128 128 private variable _obj2ovride ;# maps dataobj => style override 129 private variable _ obj2id;# maps dataobj-component to volume ID129 private variable _serverObjs ;# maps dataobj-component to volume ID 130 130 # in the server 131 private variable _id2obj ;# maps dataobj => volume ID in server132 131 private variable _sendobjs "" ;# list of data objs to send to server 133 132 private variable _recvObjs ;# list of data objs to send to server … … 222 221 pan-y 0 223 222 } 224 set _obj2id(count) 0225 set _id2obj(count) 0226 223 set _limits(vmin) 0.0 227 224 set _limits(vmax) 1.0 … … 659 656 if { $pos >= 0 } { 660 657 foreach comp [$dataobj components] { 661 if { [info exists obj2id($dataobj-$comp)] } { 662 set ivol $_obj2id($dataobj-$comp) 663 array unset _limits $ivol-* 664 } 658 array unset _limits $dataobj-$comp-* 665 659 } 666 660 set _dlist [lreplace $_dlist $pos $pos] 667 661 array unset _obj2ovride $dataobj-* 668 662 array unset _obj2flow $dataobj-* 669 array unset _ obj2id$dataobj-*663 array unset _serverObjs $dataobj-* 670 664 array unset _obj2style $dataobj-* 671 665 set changed 1 … … 678 672 set list {} 679 673 foreach {dataobj comp} $_style2objs($tf) break 680 if { [info exists _ obj2id($dataobj-$comp)] } {674 if { [info exists _serverObjs($dataobj-$comp)] } { 681 675 lappend list $dataobj $comp 682 676 } … … 856 850 # disconnected -- no more data sitting on server 857 851 set _outbuf "" 858 catch {unset _obj2id} 859 array unset _id2obj 860 set _obj2id(count) 0 861 set _id2obj(count) 0 852 array unset _serverObjs 862 853 set _sendobjs "" 863 854 } … … 908 899 } 909 900 } 910 if { ![SendBytes $cmd] } {901 f { ![SendBytes $cmd] } { 911 902 puts stderr "can't send" 912 903 return … … 916 907 return 917 908 } 918 set ivol $_obj2id(count)919 incr _obj2id(count)920 921 909 NameTransferFunc $dataobj $comp 922 910 set _recvObjs($dataobj-$comp) 1 … … 962 950 } 963 951 964 if 0 {965 SendCmd "volume state 0"966 set vols {}967 foreach key [array names _obj2id $_first-*] {968 lappend vols $_obj2id($key)969 }970 if { $vols != "" && $_settings($this-volume) } {971 SendCmd "volume state 1 $vols"972 }973 # sync the state of slicers974 set vols [CurrentVolumeIds -cutplanes]975 foreach axis {x y z} {976 SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols"977 set pos [expr {0.01*$_settings($this-${axis}cutposition)}]978 SendCmd "cutplane position $pos $axis $vols"979 }980 981 # Add this when we fix grid for volumes982 SendCmd "volume axis label x \"\""983 SendCmd "volume axis label y \"\""984 SendCmd "volume axis label z \"\""985 SendCmd "grid axisname x X eV"986 SendCmd "grid axisname y Y eV"987 SendCmd "grid axisname z Z eV"988 }989 952 SendCmd "flow reset" 990 953 … … 1028 991 } 1029 992 } 1030 ResizeLegend993 EventuallyResizeLegend 1031 994 } 1032 995 … … 1071 1034 # "Rebuild", "add", etc. 1072 1035 # 1073 itcl::body Rappture::FlowvisViewer::ReceiveLegend { t fvmin vmax size } {1036 itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } { 1074 1037 if { ![isconnected] } { 1075 1038 return 1076 1039 } 1040 puts stderr "receive legend $tag $vmin $vmax $size" 1077 1041 set bytes [ReceiveBytes $size] 1078 1042 $_image(legend) configure -data $bytes … … 1082 1046 set w [winfo width $c] 1083 1047 set h [winfo height $c] 1084 #foreach { dataobj comp } $_id2obj($ivol) break1085 1048 set lx 10 1086 1049 set ly [expr {$h - 1}] … … 1097 1060 } 1098 1061 # Display the markers used by the active transfer function. 1099 #set tf $_activeTf 1100 1062 set tf $_obj2style($tag) 1101 1063 array set limits [limits $tf] 1102 $c itemconfigure vmin -text [format %.2g $limits( min)]1064 $c itemconfigure vmin -text [format %.2g $limits(vmin)] 1103 1065 $c coords vmin $lx $ly 1104 1066 1105 $c itemconfigure vmax -text [format %.2g $limits( max)]1067 $c itemconfigure vmax -text [format %.2g $limits(vmax)] 1106 1068 $c coords vmax [expr {$w-$lx}] $ly 1107 1069 … … 1138 1100 } 1139 1101 # Arguments from server are name value pairs. Stuff them in an array. 1140 array set info $args 1141 1142 set ivol $info(id); # Id of volume created by server. 1143 set tag $info(tag) 1102 array set values $args 1103 set tag $values(tag) 1144 1104 set parts [split $tag -] 1145 1146 #1147 # Volumes don't exist until we're told about them.1148 #1149 set _id2obj($ivol) $parts1150 1105 set dataobj [lindex $parts 0] 1151 set _obj2id($tag) $ivol 1152 # It's a lie. There's no volume yet. 1153 if { $_settings($this-volume) && $dataobj == $_first } { 1154 SendCmd "volume state 1" 1155 } 1156 set _limits($ivol-min) $info(min); # Minimum value of the volume. 1157 set _limits($ivol-max) $info(max); # Maximum value of the volume. 1158 set _limits(vmin) $info(vmin); # Overall minimum value. 1159 set _limits(vmax) $info(vmax); # Overall maximum value. 1160 1106 set _serverObjs($tag) 0 1107 set _limits($tag-min) $values(min); # Minimum value of the volume. 1108 set _limits($tag-max) $values(max); # Maximum value of the volume. 1161 1109 unset _recvObjs($tag) 1162 1110 if { [array size _recvObjs] == 0 } { … … 1183 1131 } 1184 1132 1133 if 0 { 1185 1134 # in the midst of sending data? then bail out 1186 1135 if {[llength $_sendobjs] > 0} { … … 1188 1137 return 1189 1138 } 1190 1139 } 1191 1140 # Turn on buffering of commands to the server. We don't want to 1192 1141 # be preempted by a server disconnect/reconnect (which automatically … … 1198 1147 EventuallyResize $w $h 1199 1148 1200 # Find any new data that needs to be sent to the server. Queue this up on1201 # the _sendobjs list, and send it out a little at a time. Do this first,1202 # before we rebuild the rest.1203 1149 foreach dataobj [get] { 1204 set comp [lindex [$dataobj components] 0] 1205 if {![info exists _obj2id($dataobj-$comp)]} { 1206 if { [lsearch -exact $_sendobjs $dataobj] < 0 } { 1207 lappend _sendobjs $dataobj 1208 } 1209 } 1210 } 1150 foreach comp [$dataobj components] { 1151 # Send the data as one huge base64-encoded mess -- yuck! 1152 set data [$dataobj blob $comp] 1153 set nbytes [string length $data] 1154 set extents [$dataobj extents $comp] 1155 # I have a field. Is a vector field or a volume field? 1156 if { $extents == 1 } { 1157 set cmd "volume data follows $nbytes $dataobj-$comp\n" 1158 } else { 1159 set cmd [FlowCmd $dataobj $comp $nbytes $extents] 1160 if { $cmd == "" } { 1161 puts stderr "no command" 1162 continue 1163 } 1164 } 1165 append _outbuf $cmd 1166 append _outbuf $data 1167 NameTransferFunc $dataobj $comp 1168 set _recvObjs($dataobj-$comp) 1 1169 } 1170 } 1171 set _sendobjs "" 1211 1172 1212 1173 # 1213 1174 # Reset the camera and other view parameters 1214 1175 # 1215 FixSettings light1216 FixSettings transp1217 1176 FixSettings isosurface 1218 1177 FixSettings grid 1219 1178 FixSettings axes 1220 FixSettings outline 1179 # nothing to send -- activate the proper ivol 1180 set _first [lindex [get] 0] 1181 if {"" != $_first} { 1182 FixSettings light 1183 FixSettings transp 1184 FixSettings outline 1185 1186 set axis [$_first hints updir] 1187 if {"" != $axis} { 1188 SendCmd "up $axis" 1189 } 1190 set location [$_first hints camera] 1191 if { $location != "" } { 1192 array set _view $location 1193 } 1194 } 1195 set _settings($this-theta) $_view(theta) 1196 set _settings($this-phi) $_view(phi) 1197 set _settings($this-psi) $_view(psi) 1198 set _settings($this-pan-x) $_view(pan-x) 1199 set _settings($this-pan-y) $_view(pan-y) 1200 set _settings($this-zoom) $_view(zoom) 1201 1202 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1203 SendCmd "camera angle $xyz" 1204 PanCamera 1205 SendCmd "camera zoom $_view(zoom)" 1206 1207 foreach dataobj [get] { 1208 foreach comp [$dataobj components] { 1209 NameTransferFunc $dataobj $comp 1210 } 1211 } 1212 1213 if {[llength $_sendobjs] > 0} { 1214 # send off new data objects 1215 $_dispatcher event -idle !send_dataobjs 1216 puts stderr "more sendobjs " 1217 return 1218 } 1219 1221 1220 # nothing to send -- activate the proper ivol 1222 1221 set _first [lindex [get] 0] … … 1230 1229 array set _view $location 1231 1230 } 1232 }1233 set _settings($this-theta) $_view(theta)1234 set _settings($this-phi) $_view(phi)1235 set _settings($this-psi) $_view(psi)1236 set _settings($this-pan-x) $_view(pan-x)1237 set _settings($this-pan-y) $_view(pan-y)1238 set _settings($this-zoom) $_view(zoom)1239 1240 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]1241 SendCmd "camera angle $xyz"1242 PanCamera1243 SendCmd "camera zoom $_view(zoom)"1244 1245 if {[llength $_sendobjs] > 0} {1246 # send off new data objects1247 $_dispatcher event -idle !send_dataobjs1248 puts stderr "more sendobjs "1249 return1250 }1251 1252 # nothing to send -- activate the proper ivol1253 set _first [lindex [get] 0]1254 if {"" != $_first} {1255 set axis [$_first hints updir]1256 if {"" != $axis} {1257 SendCmd "up $axis"1258 }1259 set location [$_first hints camera]1260 if { $location != "" } {1261 array set _view $location1262 }1263 if { 0 && $_settings($this-volume) } {1264 SendCmd "volume state 0"1265 foreach key [array names _obj2id $_first-*] {1266 lappend vols $_obj2id($key)1267 }1268 SendCmd "volume state 1 $vols"1269 }1270 #1271 # The _obj2id and _id2style arrays may or may not have the right1272 # information. It's possible for the server to know about volumes1273 # that the client has assumed it's deleted. We could add checks.1274 # But this problem needs to be fixed not bandaided.1275 1231 set comp [lindex [$_first components] 0] 1276 set ivol $_obj2id($_first-$comp) 1277 1278 } 1279 foreach dataobj [get] { 1280 foreach comp [$_first components] { 1281 NameTransferFunc $dataobj $comp 1282 } 1283 } 1232 set _activeTf [lindex $_obj2style($_first-$comp) 0] 1233 } 1234 1284 1235 1285 1236 # sync the state of slicers … … 1291 1242 } 1292 1243 SendCmd "volume data state $_settings($this-volume)" 1293 $_dispatcher event -idle !legend1244 EventuallyResizeLegend 1294 1245 1295 1246 # Actually write the commands to the server socket. If it fails, we don't 1296 1247 # care. We're finished here. 1248 blt::busy hold $itk_component(hull); update idletasks 1297 1249 SendBytes $_outbuf; 1250 blt::busy release $itk_component(hull) 1298 1251 set _buffering 0; # Turn off buffering. 1299 1252 set _outbuf ""; # Clear the buffer. … … 1309 1262 # ---------------------------------------------------------------------- 1310 1263 itcl::body Rappture::FlowvisViewer::CurrentVolumeIds {{what -all}} { 1311 set rlist""1264 return "" 1312 1265 if { $_first == "" } { 1313 1266 return 1314 1267 } 1315 foreach key [array names _ obj2id*-*] {1268 foreach key [array names _serverObjs *-*] { 1316 1269 if {[string match $_first-* $key]} { 1317 1270 array set style { … … 1320 1273 foreach {dataobj comp} [split $key -] break 1321 1274 array set style [lindex [$dataobj components -style $comp] 0] 1322 1323 1275 if {$what != "-cutplanes" || $style(-cutplanes)} { 1324 lappend rlist $_ obj2id($key)1276 lappend rlist $_serverObjs($key) 1325 1277 } 1326 1278 } … … 1619 1571 light { 1620 1572 if {[isconnected]} { 1621 set val $_settings($this-light) 1622 set sval [expr {0.1*$val}] 1623 SendCmd "volume shading diffuse $sval"1624 set s val [expr {sqrt($val+1.0)}]1625 SendCmd " volume shading specular $sval"1573 set comp [lindex [$_first components] 0] 1574 set tag $_first-$comp 1575 set diffuse [expr {0.1*$_settings($this-light)}] 1576 set specular [expr {sqrt($_settings($this-light)+1.0)}] 1577 SendCmd "$tag configure -diffuse $diffuse -specular $specular" 1626 1578 } 1627 1579 } 1628 1580 transp { 1629 1581 if {[isconnected]} { 1630 set val $_settings($this-transp) 1631 set sval [expr {0.2*$val+1}] 1632 SendCmd "volume shading opacity $sval" 1582 set comp [lindex [$_first components] 0] 1583 set tag $_first-$comp 1584 set opacity [expr {0.2*$_settings($this-transp)+1}] 1585 SendCmd "$tag configure -opacity $opacity" 1633 1586 } 1634 1587 } 1635 1588 opacity { 1636 1589 if {[isconnected] && $_activeTf != "" } { 1637 set val $_settings($this-opacity) 1638 set sval [expr { 0.01 * double($val) }] 1590 set opacity [expr { 0.01 * double($_settings($this-opacity)) }] 1639 1591 set tf $_activeTf 1640 set _settings($this-$tf-opacity) $ sval1592 set _settings($this-$tf-opacity) $opacity 1641 1593 updatetransferfuncs 1642 1594 } … … 1655 1607 "outline" { 1656 1608 if {[isconnected]} { 1657 SendCmd "volume outline state $_settings($this-outline)" 1609 set comp [lindex [$_first components] 0] 1610 set tag $_first-$comp 1611 SendCmd "$tag configure -outline $_settings($this-outline)" 1658 1612 } 1659 1613 } … … 1685 1639 "volume" { 1686 1640 if { [isconnected] } { 1687 set vols [CurrentVolumeIds -cutplanes] 1688 SendCmd "volume data state $_settings($this-volume) $vols" 1641 set comp [lindex [$_first components] 0] 1642 set tag $_first-$comp 1643 SendCmd "$tag configure -volume $_settings($this-volume)" 1689 1644 } 1690 1645 } … … 1718 1673 # ---------------------------------------------------------------------- 1719 1674 itcl::body Rappture::FlowvisViewer::ResizeLegend {} { 1675 puts stderr "ResizeLegend" 1720 1676 set _resizeLegendPending 0 1721 1677 set lineht [font metrics $itk_option(-font) -linespace] 1722 1678 set w [expr {$_width-20}] 1723 1679 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 1680 1681 if { $_first == "" } { 1682 return 1683 } 1684 set comp [lindex [$_first components] 0] 1685 set tag $_first-$comp 1686 #set _activeTf [lindex $_obj2style($tag) 0] 1724 1687 if {$w > 0 && $h > 0 && "" != $_activeTf} { 1725 SendCmd "legend $_activeTf $w $h" 1688 #SendCmd "legend $_activeTf $w $h" 1689 SendCmd "$tag legend $w $h" 1726 1690 } else { 1727 1691 # Can't do this as this will remove the items associated with the … … 1755 1719 array set style [lindex [$dataobj components -style $comp] 0] 1756 1720 set tf "$style(-color):$style(-levels):$style(-opacity)" 1757 lappend_obj2style($dataobj-$comp) $tf1721 set _obj2style($dataobj-$comp) $tf 1758 1722 lappend _style2objs($tf) $dataobj $comp 1759 1723 return $tf … … 1807 1771 set style(-color) "white:yellow:green:cyan:blue:magenta" 1808 1772 } 1809 set clist [split $style(-color) :] 1810 set cmap "0.0 [Color2RGB white] " 1811 for {set i 0} {$i < [llength $clist]} {incr i} { 1812 set x [expr {double($i+1)/([llength $clist]+1)}] 1813 set color [lindex $clist $i] 1814 append cmap "$x [Color2RGB $color] " 1815 } 1816 append cmap "1.0 [Color2RGB $color]" 1817 1773 if { [info exists style(-nonuniformcolors)] } { 1774 foreach { value color } $style(-nonuniformcolors) { 1775 append cmap "$value [Color2RGB $color] " 1776 } 1777 } else { 1778 set clist [split $style(-color) :] 1779 set cmap "0.0 [Color2RGB white] " 1780 for {set i 0} {$i < [llength $clist]} {incr i} { 1781 set x [expr {double($i+1)/([llength $clist]+1)}] 1782 set color [lindex $clist $i] 1783 append cmap "$x [Color2RGB $color] " 1784 } 1785 append cmap "1.0 [Color2RGB $color]" 1786 } 1818 1787 set tag $this-$tf 1819 1788 if { ![info exists _settings($tag-opacity)] } { … … 1874 1843 lappend wmap 1.0 0.0 1875 1844 } 1876 Send Bytes"transfunc define $tf { $cmap } { $wmap }\n"1877 return [Send Bytes"$dataobj-$comp configure -transferfunction $tf\n"]1845 SendCmd "transfunc define $tf { $cmap } { $wmap }\n" 1846 return [SendCmd "$dataobj-$comp configure -transferfunction $tf\n"] 1878 1847 } 1879 1848 … … 1978 1947 # ---------------------------------------------------------------------- 1979 1948 itcl::body Rappture::FlowvisViewer::updatetransferfuncs {} { 1980 $_dispatcher event - idle!send_transfunc1949 $_dispatcher event -after 100 !send_transfunc 1981 1950 } 1982 1951 … … 2036 2005 2037 2006 itcl::body Rappture::FlowvisViewer::limits { tf } { 2038 set _limits( min) 0.02039 set _limits( max) 1.02007 set _limits(vmin) 0.0 2008 set _limits(vmax) 1.0 2040 2009 if { ![info exists _style2objs($tf)] } { 2010 puts stderr "no style2objs for $tf tf=($tf)" 2041 2011 return [array get _limits] 2042 2012 } 2043 2013 set min ""; set max "" 2044 2014 foreach {dataobj comp} $_style2objs($tf) { 2045 if { ![info exists _obj2id($dataobj-$comp)] } { 2015 set tag $dataobj-$comp 2016 if { ![info exists _serverObjs($tag)] } { 2017 puts stderr "$tag not in serverObjs?" 2046 2018 continue 2047 2019 } 2048 set ivol $_obj2id($dataobj-$comp)2049 if { ![info exists _limits($ivol-min)] } {2020 if { ![info exists _limits($tag-min)] } { 2021 puts stderr "$tag no min?" 2050 2022 continue 2051 2023 } 2052 if { $min == "" || $min > $_limits($ ivol-min) } {2053 set min $_limits($ ivol-min)2054 } 2055 if { $max == "" || $max < $_limits($ ivol-max) } {2056 set max $_limits($ ivol-max)2024 if { $min == "" || $min > $_limits($tag-min) } { 2025 set min $_limits($tag-min) 2026 } 2027 if { $max == "" || $max < $_limits($tag-max) } { 2028 set max $_limits($tag-max) 2057 2029 } 2058 2030 } 2059 2031 if { $min != "" } { 2060 set _limits( min) $min2032 set _limits(vmin) $min 2061 2033 } 2062 2034 if { $max != "" } { 2063 set _limits( max) $max2035 set _limits(vmax) $max 2064 2036 } 2065 2037 return [array get _limits] … … 2502 2474 itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} { 2503 2475 if { !$_resizeLegendPending } { 2504 $_dispatcher event -idle !legend 2476 puts stderr "in EventuallyResizeLegend" 2477 $_dispatcher event -after 100 !legend 2505 2478 set _resizeLegendPending 1 2506 2479 } -
trunk/gui/scripts/isomarker.tcl
r1436 r1479 102 102 if { $x == "-get" } { 103 103 array set limits [$nvobj_ limits $tf_] 104 if { $limits( max) == $limits(min) } {105 if { $limits( max) == 0.0 } {106 set limits( min) 0.0107 set limits( max) 1.0104 if { $limits(vmax) == $limits(vmin) } { 105 if { $limits(vmax) == 0.0 } { 106 set limits(vmin) 0.0 107 set limits(vmax) 1.0 108 108 } else { 109 set limits( max) [expr $limits(min) + 1.0]109 set limits(vmax) [expr $limits(vmin) + 1.0] 110 110 } 111 111 } 112 return [expr {($value_-$limits(min))/($limits(max) - $limits(min))}] 112 return [expr {($value_-$limits(vmin))/ 113 ($limits(vmax) - $limits(vmin))}] 113 114 } 114 115 array set limits [$nvobj_ limits $tf_] 115 if { $limits( max) == $limits(min) } {116 if { $limits(vmax) == $limits(vmin) } { 116 117 set limits(min) 0.0 117 118 set limits(max) 1.0 118 119 } 119 set r [expr $limits( max) - $limits(min)]120 absval [expr {($x * $r) + $limits( min)}]120 set r [expr $limits(vmax) - $limits(vmin)] 121 absval [expr {($x * $r) + $limits(vmin)}] 121 122 } 122 123 private method HandleEvent { option args } {
Note: See TracChangeset
for help on using the changeset viewer.