Changeset 4848 for branches/1.3/gui
- Timestamp:
- Dec 11, 2014 2:10:15 PM (9 years ago)
- Location:
- branches/1.3/gui/scripts
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/flowvisviewer.tcl
r4772 r4848 63 63 public method get {args} 64 64 public method isconnected {} 65 public method limits { cname}66 public method over Marker { m x }65 public method limits { tf } 66 public method overmarker { m x } 67 67 public method parameters {title args} { 68 68 # do nothing 69 69 } 70 public method r emoveDuplicateMarker { m x }70 public method rmdupmarker { m x } 71 71 public method scale {args} 72 public method updateTransferFunctions {} 72 public method updatetransferfuncs {} 73 74 protected method Connect {} 75 protected method CurrentVolumeIds {{what -all}} 76 protected method Disconnect {} 77 protected method Resize {} 78 protected method ResizeLegend {} 79 protected method AdjustSetting {what {value ""}} 80 protected method InitSettings { args } 81 protected method Pan {option x y} 82 protected method Rebuild {} 83 protected method ReceiveData { args } 84 protected method ReceiveImage { args } 85 protected method ReceiveLegend { tf vmin vmax size } 86 protected method Rotate {option x y} 87 protected method SendDataObjs {} 88 protected method SendTransferFuncs {} 89 protected method Slice {option args} 90 protected method SlicerTip {axis} 91 protected method Zoom {option} 73 92 74 93 # soon to be removed. 75 private method Flow {option args} 76 private method Play {} 77 private method Pause {} 94 protected method Flow {option args} 95 protected method Play {} 96 protected method Pause {} 97 78 98 79 99 # The following methods are only used by this class. 80 private method AdjustSetting {what {value ""}} 100 81 101 private method AddIsoMarker { x y } 82 102 private method BuildCameraTab {} 83 103 private method BuildCutplanesTab {} 84 104 private method BuildViewTab {} 85 private method BuildVolumeComponents {}86 105 private method BuildVolumeTab {} 87 106 private method ComputeTransferFunc { tf } 88 private method Connect {}89 private method CurrentVolumeIds {{what -all}}90 private method Disconnect {}91 107 private method EventuallyResize { w h } 92 108 private method EventuallyGoto { nSteps } 93 109 private method EventuallyResizeLegend { } 94 110 private method FlowCmd { dataobj comp nbytes extents } 95 private method GetDatasetsWithComponent { cname }96 private method GetFlowInfo { widget }97 111 private method GetMovie { widget width height } 98 112 private method GetPngImage { widget width height } 99 private method InitSettings { args }100 113 private method NameTransferFunc { dataobj comp } 101 private method Pan {option x y}102 114 private method PanCamera {} 103 115 private method ParseLevelsOption { tf levels } 104 116 private method ParseMarkersOption { tf markers } 105 private method QuaternionToView { q } { 106 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 107 } 108 private method Rebuild {} 109 private method ReceiveData { args } 110 private method ReceiveImage { args } 111 private method ReceiveLegend { tf vmin vmax size } 112 private method Resize {} 113 private method ResizeLegend {} 114 private method Rotate {option x y} 115 private method SendTransferFuncs {} 117 private method WaitIcon { option widget } 118 private method str2millisecs { value } 119 private method millisecs2str { value } 120 private method GetFlowInfo { widget } 121 private method particles { tag name } 122 private method box { tag name } 123 private method streams { tag name } 124 private method arrows { tag name } 116 125 private method SetOrientation { side } 117 private method Slice {option args}118 private method SlicerTip {axis}119 private method ViewToQuaternion {} {120 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]121 }122 private method WaitIcon { option widget }123 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 }130 126 131 127 private variable _arcball "" … … 135 131 private variable _serverObjs ;# maps dataobj-component to volume ID 136 132 # in the server 133 private variable _sendobjs "" ;# list of data objs to send to server 137 134 private variable _recvObjs ;# list of data objs to send to server 138 135 private variable _obj2style ;# maps dataobj-component to transfunc … … 149 146 private variable _activeTf "" ;# The currently active transfer function. 150 147 private variable _first "" ;# This is the topmost volume. 151 private variable _volcomponents ; # Array of components found152 private variable _componentsList ; # Array of components found153 148 private variable _nextToken 0 154 149 private variable _icon 0 … … 183 178 $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list" 184 179 180 # Send dataobjs event 181 $_dispatcher register !send_dataobjs 182 $_dispatcher dispatch $this !send_dataobjs \ 183 "[itcl::code $this SendDataObjs]; list" 184 185 185 # Send transferfunctions event 186 186 $_dispatcher register !send_transfunc … … 220 220 # Initialize the view to some default parameters. 221 221 array set _view { 222 -qw 0.853553223 -qx -0.353553224 -qy 0.353553225 -qz 0.146447226 -xpan0227 -ypan 0228 -zoom 1.0222 qw 0.853553 223 qx -0.353553 224 qy 0.353553 225 qz 0.146447 226 zoom 1.0 227 xpan 0 228 ypan 0 229 229 } 230 230 set _arcball [blt::arcball create 100 100] 231 $_arcball quaternion [ViewToQuaternion] 232 233 set _limits(v) [list 0.0 1.0] 231 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 232 $_arcball quaternion $q 233 234 set _limits(vmin) 0.0 235 set _limits(vmax) 1.0 234 236 set _reset 1 235 237 236 238 array set _settings [subst { 237 $this-qw $_view( -qw)238 $this-qx $_view( -qx)239 $this-qy $_view( -qy)240 $this-qz $_view( -qz)241 $this-zoom $_view( -zoom)242 $this-xpan $_view( -xpan)243 $this-ypan $_view( -ypan)239 $this-qw $_view(qw) 240 $this-qx $_view(qx) 241 $this-qy $_view(qy) 242 $this-qz $_view(qz) 243 $this-zoom $_view(zoom) 244 $this-xpan $_view(xpan) 245 $this-ypan $_view(ypan) 244 246 $this-arrows 0 245 247 $this-currenttime 0 … … 251 253 $this-streams 0 252 254 $this-volume 1 253 $this-light 40254 $this-light2side 1255 $this-opacity 50256 $this-thickness 350257 255 $this-xcutplane 0 258 256 $this-xcutposition 0 … … 337 335 set _image(legend) [image create photo] 338 336 itk_component add legend { 339 canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0 337 canvas $itk_component(plotarea).legend \ 338 -height 50 -highlightthickness 0 -background black 340 339 } { 341 340 usual … … 561 560 # ---------------------------------------------------------------------- 562 561 itcl::body Rappture::FlowvisViewer::destructor {} { 562 set _sendobjs "" ;# stop any send in progress 563 563 $_dispatcher cancel !rebuild 564 $_dispatcher cancel !send_dataobjs 564 565 $_dispatcher cancel !send_transfunc 565 566 image delete $_image(plot) … … 671 672 # ---------------------------------------------------------------------- 672 673 itcl::body Rappture::FlowvisViewer::delete {args} { 673 flow stop674 flow stop 674 675 if {[llength $args] == 0} { 675 676 set args $_dlist … … 721 722 # ---------------------------------------------------------------------- 722 723 itcl::body Rappture::FlowvisViewer::scale {args} { 723 array set styles { 724 -color BCGYR 725 -levels 6 726 -markers "" 727 -opacity 0.5 728 } 729 array unset _limits 730 array unset _volcomponents 731 foreach dataobj $args { 732 if { ![$dataobj isvalid] } { 733 continue; # Object doesn't contain valid data. 734 } 735 foreach cname [$dataobj components] { 736 if { ![info exists _volcomponents($cname)] } { 737 lappend _componentsList $cname 738 array set styles [lindex [$dataobj components -style $cname] 0] 739 set cmap [ColorsToColormap $styles(-color)] 740 set _cname2defaultcolormap($cname) $cmap 741 set _settings($cname-colormap) $styles(-color) 742 } 743 lappend _volcomponents($cname) $dataobj-$cname 744 array unset limits 745 array set limits [$dataobj valueLimits $cname] 746 set _limits($cname) $limits(v) 747 } 748 foreach axis {x y z v} { 749 foreach { min max } [$dataobj limits $axis] break 724 foreach val {xmin xmax ymin ymax vmin vmax} { 725 set _limits($val) "" 726 } 727 foreach obj $args { 728 foreach axis {x y v} { 729 730 foreach { min max } [$obj limits $axis] break 731 750 732 if {"" != $min && "" != $max} { 751 if { ![info exists _limits($axis)] } { 752 set _limits($axis) [list $min $max] 733 if {"" == $_limits(${axis}min)} { 734 set _limits(${axis}min) $min 735 set _limits(${axis}max) $max 753 736 } else { 754 foreach {amin amax} $_limits($axis) break 755 if {$min < $amin} { 756 set amin $min 737 if {$min < $_limits(${axis}min)} { 738 set _limits(${axis}min) $min 757 739 } 758 if {$max > $ amax} {759 set amax$max740 if {$max > $_limits(${axis}max)} { 741 set _limits(${axis}max) $max 760 742 } 761 set _limits($axis) [list $amin $amax]762 743 } 763 744 } 764 745 } 765 746 } 766 #BuildVolumeComponents767 747 } 768 748 … … 877 857 if { $_reportClientInfo } { 878 858 # Tell the server the viewer, hub, user and session. 879 # Do this immediately on connect before buff ering any commands859 # Do this immediately on connect before buffing any commands 880 860 global env 881 861 … … 934 914 # disconnected -- no more data sitting on server 935 915 array unset _serverObjs 916 set _sendobjs "" 917 } 918 919 # ---------------------------------------------------------------------- 920 # USAGE: SendDataObjs 921 # 922 # Used internally to send a series of volume objects off to the 923 # server. Sends each object, a little at a time, with updates in 924 # between so the interface doesn't lock up. 925 # ---------------------------------------------------------------------- 926 itcl::body Rappture::FlowvisViewer::SendDataObjs {} { 927 blt::busy hold $itk_component(hull) 928 foreach dataobj $_sendobjs { 929 foreach comp [$dataobj components] { 930 # Send the data as one huge base64-encoded mess -- yuck! 931 set data [$dataobj blob $comp] 932 set nbytes [string length $data] 933 set extents [$dataobj extents $comp] 934 935 # I have a field. Is a vector field or a volume field? 936 if { $extents == 1 } { 937 set cmd "volume data follows $nbytes $dataobj-$comp\n" 938 } else { 939 set cmd [FlowCmd $dataobj $comp $nbytes $extents] 940 if { $cmd == "" } { 941 puts stderr "no command" 942 continue 943 } 944 } 945 f { ![SendBytes $cmd] } { 946 puts stderr "can't send" 947 return 948 } 949 if { ![SendBytes $data] } { 950 puts stderr "can't send" 951 return 952 } 953 NameTransferFunc $dataobj $comp 954 set _recvObjs($dataobj-$comp) 1 955 } 956 } 957 set _sendobjs "" 958 blt::busy release $itk_component(hull) 959 960 # Turn on buffering of commands to the server. We don't want to 961 # be preempted by a server disconnect/reconnect (which automatically 962 # generates a new call to Rebuild). 963 StartBufferingCommands 964 965 # activate the proper volume 966 set _first [lindex [get] 0] 967 if { "" != $_first } { 968 set axis [$_first hints updir] 969 if {"" != $axis} { 970 SendCmd "up $axis" 971 } 972 973 if 0 { 974 set location [$_first hints camera] 975 if { $location != "" } { 976 array set _view $location 977 } 978 set _settings($this-qw) $_view(qw) 979 set _settings($this-qx) $_view(qx) 980 set _settings($this-qy) $_view(qy) 981 set _settings($this-qz) $_view(qz) 982 set _settings($this-xpan) $_view(xpan) 983 set _settings($this-ypan) $_view(ypan) 984 set _settings($this-zoom) $_view(zoom) 985 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 986 $_arcball quaternion $q 987 SendCmd "camera orient $q" 988 SendCmd "camera reset" 989 PanCamera 990 SendCmd "camera zoom $_view(zoom)" 991 } 992 # The active transfer function is by default the first component of 993 # the first data object. This assumes that the data is always 994 # successfully transferred. 995 set comp [lindex [$_first components] 0] 996 set _activeTf [lindex $_obj2style($_first-$comp) 0] 997 } 998 999 SendCmd "flow reset" 1000 StopBufferingCommands 936 1001 } 937 1002 … … 950 1015 } 951 1016 952 # Ensure that the global thickness setting (in the slider settings widget) 953 # is used for the active transfer-function. Update the values in the 954 # _settings varible. 955 1017 # Ensure that the global opacity and thickness settings (in the slider 1018 # settings widgets) are used for the active transfer-function. Update the 1019 # values in the _settings varible. 1020 set value $_settings($this-opacity) 1021 set opacity [expr { double($value) * 0.01 }] 1022 set _settings($this-$tf-opacity) $opacity 956 1023 set value $_settings($this-thickness) 957 1024 # Scale values between 0.00001 and 0.01000 … … 1030 1097 set h [winfo height $c] 1031 1098 set lx 10 1099 # FIXME: I don't know what I have to do this for the 2D flow 1100 # example. Otherwise the canvas background is white. 1101 # I'll get to this when we add background changes into 1102 # nanvis. 1103 $c configure -background black 1032 1104 set ly [expr {$h - 1}] 1033 if {"" == [$c find withtag colorbar]} {1105 if {"" == [$c find withtag transfunc]} { 1034 1106 $c create image 10 10 -anchor nw \ 1035 -image $_image(legend) -tags colorbar1107 -image $_image(legend) -tags transfunc 1036 1108 $c create text $lx $ly -anchor sw \ 1037 1109 -fill $itk_option(-plotforeground) -tags "limits vmin" 1038 1110 $c create text [expr {$w-$lx}] $ly -anchor se \ 1039 1111 -fill $itk_option(-plotforeground) -tags "limits vmax" 1040 $c lower colorbar 1041 $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y] 1112 $c lower transfunc 1113 $c bind transfunc <ButtonRelease-1> \ 1114 [itcl::code $this AddIsoMarker %x %y] 1042 1115 } 1043 1116 # Display the markers used by the active transfer function. 1044 1117 set tf $_obj2style($tag) 1045 foreach {vmin vmax} [limits $tf] break1046 $c itemconfigure vmin -text [format % g $vmin]1118 array set limits [limits $tf] 1119 $c itemconfigure vmin -text [format %.2g $limits(vmin)] 1047 1120 $c coords vmin $lx $ly 1048 1121 1049 $c itemconfigure vmax -text [format % g $vmax]1122 $c itemconfigure vmax -text [format %.2g $limits(vmax)] 1050 1123 $c coords vmax [expr {$w-$lx}] $ly 1051 1124 … … 1087 1160 set dataobj [lindex $parts 0] 1088 1161 set _serverObjs($tag) 0 1089 set _limits($tag) [list $values(min) $values(max)] 1162 set _limits($tag-min) $values(min); # Minimum value of the volume. 1163 set _limits($tag-max) $values(max); # Maximum value of the volume. 1090 1164 unset _recvObjs($tag) 1091 1165 if { [array size _recvObjs] == 0 } { 1092 update TransferFunctions1166 updatetransferfuncs 1093 1167 } 1094 1168 } … … 1134 1208 foreach comp [$dataobj components] { 1135 1209 set tag $dataobj-$comp 1136 set isvtk 0 1137 # FIXME: Would like to use the type method of the dataobj 1138 # but the returned value isn't well defined now 1139 if {[catch { 1140 # Send the data as one huge base64-encoded mess -- yuck! 1141 set data [$dataobj blob $comp] 1142 }]} { 1143 set data [$dataobj vtkdata $comp] 1144 set isvtk 1 1145 } 1210 # Send the data as one huge base64-encoded mess -- yuck! 1211 set data [$dataobj blob $comp] 1146 1212 set nbytes [string length $data] 1147 1213 if { $_reportClientInfo } { … … 1159 1225 set extents [$dataobj extents $comp] 1160 1226 # I have a field. Is a vector field or a volume field? 1161 if { !$isvtk &&$extents == 1 } {1162 SendCmd "volume data follows $nbytes $tag"1227 if { $extents == 1 } { 1228 set cmd "volume data follows $nbytes $tag\n" 1163 1229 } else { 1164 1230 set cmd [FlowCmd $dataobj $comp $nbytes $extents] … … 1167 1233 continue 1168 1234 } 1169 append _outbuf $cmd1170 }1235 } 1236 append _outbuf $cmd 1171 1237 append _outbuf $data 1172 1238 NameTransferFunc $dataobj $comp … … 1178 1244 1179 1245 # Reset the camera and other view parameters 1180 InitSettings light2side light opacityisosurface grid axes volume outline1181 1246 InitSettings light2side light transp isosurface grid axes volume outline 1247 1182 1248 # nothing to send -- activate the proper volume 1183 1249 if {"" != $_first} { 1250 AdjustSetting light 1251 AdjustSetting transp 1184 1252 set axis [$_first hints updir] 1185 1253 if {"" != $axis} { … … 1192 1260 1193 1261 } 1194 set _settings($this-qw) $_view( -qw)1195 set _settings($this-qx) $_view( -qx)1196 set _settings($this-qy) $_view( -qy)1197 set _settings($this-qz) $_view( -qz)1198 set _settings($this-xpan) $_view( -xpan)1199 set _settings($this-ypan) $_view( -ypan)1200 set _settings($this-zoom) $_view( -zoom)1201 1202 set q [ ViewToQuaternion]1262 set _settings($this-qw) $_view(qw) 1263 set _settings($this-qx) $_view(qx) 1264 set _settings($this-qy) $_view(qy) 1265 set _settings($this-qz) $_view(qz) 1266 set _settings($this-xpan) $_view(xpan) 1267 set _settings($this-ypan) $_view(ypan) 1268 set _settings($this-zoom) $_view(zoom) 1269 1270 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1203 1271 $_arcball quaternion $q 1204 1272 SendCmd "camera orient $q" 1205 1273 SendCmd "camera reset" 1206 1274 PanCamera 1207 SendCmd "camera zoom $_view( -zoom)"1275 SendCmd "camera zoom $_view(zoom)" 1208 1276 1209 1277 foreach dataobj [get] { … … 1261 1329 foreach key [array names _serverObjs *-*] { 1262 1330 if {[string match $_first-* $key]} { 1263 array set style s{1331 array set style { 1264 1332 -cutplanes 1 1265 1333 } 1266 1334 foreach {dataobj comp} [split $key -] break 1267 array set style s[lindex [$dataobj components -style $comp] 0]1268 if {$what != "-cutplanes" || $style s(-cutplanes)} {1335 array set style [lindex [$dataobj components -style $comp] 0] 1336 if {$what != "-cutplanes" || $style(-cutplanes)} { 1269 1337 lappend rlist $_serverObjs($key) 1270 1338 } … … 1285 1353 switch -- $option { 1286 1354 "in" { 1287 set _view( -zoom) [expr {$_view(-zoom)*1.25}]1288 set _settings($this-zoom) $_view( -zoom)1289 SendCmd "camera zoom $_view( -zoom)"1355 set _view(zoom) [expr {$_view(zoom)*1.25}] 1356 set _settings($this-zoom) $_view(zoom) 1357 SendCmd "camera zoom $_view(zoom)" 1290 1358 } 1291 1359 "out" { 1292 set _view( -zoom) [expr {$_view(-zoom)*0.8}]1293 set _settings($this-zoom) $_view( -zoom)1294 SendCmd "camera zoom $_view( -zoom)"1360 set _view(zoom) [expr {$_view(zoom)*0.8}] 1361 set _settings($this-zoom) $_view(zoom) 1362 SendCmd "camera zoom $_view(zoom)" 1295 1363 } 1296 1364 "reset" { 1297 1365 array set _view { 1298 -qw 0.8535531299 -qx -0.3535531300 -qy 0.3535531301 -qz 0.1464471302 -zoom 1.01303 -xpan01304 -ypan01366 qw 0.853553 1367 qx -0.353553 1368 qy 0.353553 1369 qz 0.146447 1370 zoom 1.0 1371 xpan 0 1372 ypan 0 1305 1373 } 1306 1374 if { $_first != "" } { … … 1310 1378 } 1311 1379 } 1312 set q [ ViewToQuaternion]1380 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1313 1381 $_arcball quaternion $q 1314 1382 SendCmd "camera orient $q" 1315 1383 SendCmd "camera reset" 1316 set _settings($this-qw) $_view( -qw)1317 set _settings($this-qx) $_view( -qx)1318 set _settings($this-qy) $_view( -qy)1319 set _settings($this-qz) $_view( -qz)1320 set _settings($this-xpan) $_view( -xpan)1321 set _settings($this-ypan) $_view( -ypan)1322 set _settings($this-zoom) $_view( -zoom)1384 set _settings($this-qw) $_view(qw) 1385 set _settings($this-qx) $_view(qx) 1386 set _settings($this-qy) $_view(qy) 1387 set _settings($this-qz) $_view(qz) 1388 set _settings($this-xpan) $_view(xpan) 1389 set _settings($this-ypan) $_view(ypan) 1390 set _settings($this-zoom) $_view(zoom) 1323 1391 } 1324 1392 } … … 1326 1394 1327 1395 itcl::body Rappture::FlowvisViewer::PanCamera {} { 1328 set x $_view(-xpan) 1329 set y $_view(-ypan) 1396 #set x [expr ($_view(xpan)) / $_limits(xrange)] 1397 #set y [expr ($_view(ypan)) / $_limits(yrange)] 1398 set x $_view(xpan) 1399 set y $_view(ypan) 1330 1400 SendCmd "camera pan $x $y" 1331 1401 } … … 1365 1435 1366 1436 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1367 QuaternionToView $q1368 set _settings($this-qw) $_view( -qw)1369 set _settings($this-qx) $_view( -qx)1370 set _settings($this-qy) $_view( -qy)1371 set _settings($this-qz) $_view( -qz)1437 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 1438 set _settings($this-qw) $_view(qw) 1439 set _settings($this-qx) $_view(qx) 1440 set _settings($this-qy) $_view(qy) 1441 set _settings($this-qz) $_view(qz) 1372 1442 SendCmd "camera orient $q" 1373 1443 … … 1402 1472 set x [expr $x / double($w)] 1403 1473 set y [expr $y / double($h)] 1404 set _view( -xpan) [expr $_view(-xpan) + $x]1405 set _view( -ypan) [expr $_view(-ypan) + $y]1474 set _view(xpan) [expr $_view(xpan) + $x] 1475 set _view(ypan) [expr $_view(ypan) + $y] 1406 1476 PanCamera 1407 set _settings($this-xpan) $_view( -xpan)1408 set _settings($this-ypan) $_view( -ypan)1477 set _settings($this-xpan) $_view(xpan) 1478 set _settings($this-ypan) $_view(ypan) 1409 1479 return 1410 1480 } … … 1419 1489 set _click(x) $x 1420 1490 set _click(y) $y 1421 set _view( -xpan) [expr $_view(-xpan) - $dx]1422 set _view( -ypan) [expr $_view(-ypan) - $dy]1491 set _view(xpan) [expr $_view(xpan) - $dx] 1492 set _view(ypan) [expr $_view(ypan) - $dy] 1423 1493 PanCamera 1424 set _settings($this-xpan) $_view( -xpan)1425 set _settings($this-ypan) $_view( -ypan)1494 set _settings($this-xpan) $_view(xpan) 1495 set _settings($this-ypan) $_view(ypan) 1426 1496 } 1427 1497 if { $option == "release" } { … … 1576 1646 } 1577 1647 } 1578 opacity{1648 transp { 1579 1649 if { $_first != "" } { 1580 1650 set comp [lindex [$_first components] 0] 1581 1651 set tag $_first-$comp 1652 set opacity [expr { 0.01 * double($_settings($this-transp)) }] 1653 SendCmd "$tag configure -opacity $opacity" 1654 } 1655 } 1656 opacity { 1657 if { $_first != "" && $_activeTf != "" } { 1582 1658 set opacity [expr { 0.01 * double($_settings($this-opacity)) }] 1583 SendCmd "$tag configure -opacity $opacity" 1584 } 1585 } 1659 set tf $_activeTf 1660 set _settings($this-$tf-opacity) $opacity 1661 updatetransferfuncs 1662 } 1663 } 1664 1586 1665 thickness { 1587 1666 if { $_first != "" && $_activeTf != "" } { … … 1591 1670 set tf $_activeTf 1592 1671 set _settings($this-$tf-thickness) $sval 1593 update TransferFunctions1672 updatetransferfuncs 1594 1673 } 1595 1674 } … … 1699 1778 # now. 1700 1779 # 1701 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj c name} {1702 array set style s{1780 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj comp } { 1781 array set style { 1703 1782 -color BCGYR 1704 1783 -levels 6 1705 -opacity 0.5 1706 } 1707 array set styles [lindex [$dataobj components -style $cname] 0] 1708 set _settings($this-opacity) [expr $styles(-opacity) * 100] 1709 set _obj2style($dataobj-$cname) $cname 1710 lappend _style2objs($cname) $dataobj $cname 1711 return $cname 1784 -opacity 1.0 1785 -light 40 1786 -transp 50 1787 } 1788 array set style [lindex [$dataobj components -style $comp] 0] 1789 set _settings($this-light) $style(-light) 1790 set _settings($this-transp) $style(-transp) 1791 set _settings($this-opacity) [expr $style(-opacity) * 100] 1792 set tf "$style(-color):$style(-levels):$style(-opacity)" 1793 set _obj2style($dataobj-$comp) $tf 1794 lappend _style2objs($tf) $dataobj $comp 1795 return $tf 1712 1796 } 1713 1797 … … 1722 1806 # 1723 1807 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } { 1724 array set style s{1808 array set style { 1725 1809 -color BCGYR 1726 1810 -levels 6 1727 -opacity 0.5 1811 -opacity 1.0 1812 -light 40 1813 -transp 50 1728 1814 } 1729 1815 set dataobj ""; set comp "" … … 1732 1818 return 0 1733 1819 } 1734 array set styles [lindex [$dataobj components -style $comp] 0] 1820 array set style [lindex [$dataobj components -style $comp] 0] 1821 1735 1822 1736 1823 # We have to parse the style attributes for a volume using this … … 1749 1836 if { ![info exists _isomarkers($tf)] } { 1750 1837 # Have to defer creation of isomarkers until we have data limits 1751 if { [info exists style s(-markers)] &&1752 [llength $style s(-markers)] > 0 } {1753 ParseMarkersOption $tf $style s(-markers)1838 if { [info exists style(-markers)] && 1839 [llength $style(-markers)] > 0 } { 1840 ParseMarkersOption $tf $style(-markers) 1754 1841 } else { 1755 ParseLevelsOption $tf $style s(-levels)1756 } 1757 } 1758 if { [info exists style s(-nonuniformcolors)] } {1759 foreach { value color } $style s(-nonuniformcolors) {1842 ParseLevelsOption $tf $style(-levels) 1843 } 1844 } 1845 if { [info exists style(-nonuniformcolors)] } { 1846 foreach { value color } $style(-nonuniformcolors) { 1760 1847 append cmap "$value [Color2RGB $color] " 1761 1848 } 1762 1849 } else { 1763 set cmap [ColorsToColormap $styles(-color)] 1764 } 1765 1766 if { ![info exists _settings($this-opacity)] } { 1767 set _settings($this-opacity) [expr $styles(-opacity) * 100] 1768 } 1769 1770 # Transfer function should be normalized with [0,1] range 1771 # The volume shading opacity setting is used to scale opacity 1772 # in the volume shader. 1773 set max 1.0 1774 1850 set cmap [ColorsToColormap $style(-color)] 1851 } 1852 set tag $this-$tf 1853 if { ![info exists _settings($tag-opacity)] } { 1854 set _settings($tag-opacity) $style(-opacity) 1855 } 1856 set max 1.0 ;#$_settings($tag-opacity) 1857 1775 1858 set isovalues {} 1776 1859 foreach m $_isomarkers($tf) { … … 1780 1863 set isovalues [lsort -real $isovalues] 1781 1864 1782 set tag $this-$tf1783 1865 if { ![info exists _settings($tag-thickness)]} { 1784 1866 set _settings($tag-thickness) 0.005 … … 1835 1917 itcl::configbody Rappture::FlowvisViewer::plotbackground { 1836 1918 if { [isconnected] } { 1837 set color $itk_option(-plotbackground) 1838 set rgb [Color2RGB $color] 1839 SendCmd "screen bgcolor $rgb" 1840 $itk_component(legend) configure -background $color 1919 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break 1920 #fix this! 1921 #SendCmd "color background $r $g $b" 1841 1922 } 1842 1923 } … … 1847 1928 itcl::configbody Rappture::FlowvisViewer::plotforeground { 1848 1929 if { [isconnected] } { 1849 set color $itk_option(-plotforeground) 1850 set rgb [Color2RGB $color] 1851 SendCmd "volume outline color $rgb" 1852 SendCmd "grid axiscolor $rgb" 1853 SendCmd "grid linecolor $rgb" 1854 $itk_component(legend) itemconfigure labels -fill $color 1855 $itk_component(legend) itemconfigure limits -fill $color 1930 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1931 #fix this! 1932 #SendCmd "color background $r $g $b" 1856 1933 } 1857 1934 } … … 1887 1964 set x [expr {double($i)/($levels+1)}] 1888 1965 set m [Rappture::IsoMarker \#auto $c $this $tf] 1889 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)1890 1966 $m relval $x 1891 1967 lappend _isomarkers($tf) $m … … 1894 1970 foreach x $levels { 1895 1971 set m [Rappture::IsoMarker \#auto $c $this $tf] 1896 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)1897 1972 $m relval $x 1898 1973 lappend _isomarkers($tf) $m … … 1922 1997 set value [expr {$value * 0.01}] 1923 1998 set m [Rappture::IsoMarker \#auto $c $this $tf] 1924 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)1925 1999 $m relval $value 1926 2000 lappend _isomarkers($tf) $m … … 1928 2002 # ${n} : Set absolute value. 1929 2003 set m [Rappture::IsoMarker \#auto $c $this $tf] 1930 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)1931 2004 $m absval $value 1932 2005 lappend _isomarkers($tf) $m … … 1938 2011 # USAGE: UndateTransferFuncs 1939 2012 # ---------------------------------------------------------------------- 1940 itcl::body Rappture::FlowvisViewer::update TransferFunctions {} {2013 itcl::body Rappture::FlowvisViewer::updatetransferfuncs {} { 1941 2014 $_dispatcher event -after 100 !send_transfunc 1942 2015 } … … 1949 2022 set c $itk_component(legend) 1950 2023 set m [Rappture::IsoMarker \#auto $c $this $tf] 1951 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)1952 2024 set w [winfo width $c] 1953 2025 $m relval [expr {double($x-10)/($w-20)}] 1954 2026 lappend _isomarkers($tf) $m 1955 update TransferFunctions2027 updatetransferfuncs 1956 2028 return 1 1957 2029 } 1958 2030 1959 itcl::body Rappture::FlowvisViewer::r emoveDuplicateMarker { marker x } {2031 itcl::body Rappture::FlowvisViewer::rmdupmarker { marker x } { 1960 2032 set tf [$marker transferfunc] 1961 2033 set bool 0 … … 1977 2049 } 1978 2050 set _isomarkers($tf) $list 1979 update TransferFunctions2051 updatetransferfuncs 1980 2052 } 1981 2053 return $bool 1982 2054 } 1983 2055 1984 itcl::body Rappture::FlowvisViewer::over Marker { marker x } {2056 itcl::body Rappture::FlowvisViewer::overmarker { marker x } { 1985 2057 set tf [$marker transferfunc] 1986 2058 if { [info exists _isomarkers($tf)] } { … … 1997 2069 } 1998 2070 1999 itcl::body Rappture::FlowvisViewer::limits { cname } { 2000 set _limits(v) [list 0.0 1.0] 2001 if { ![info exists _style2objs($cname)] } { 2002 puts stderr "no style2objs for $cname cname=($cname)" 2071 itcl::body Rappture::FlowvisViewer::limits { tf } { 2072 set _limits(vmin) 0.0 2073 set _limits(vmax) 1.0 2074 if { ![info exists _style2objs($tf)] } { 2075 puts stderr "no style2objs for $tf tf=($tf)" 2003 2076 return [array get _limits] 2004 2077 } 2005 2078 set min ""; set max "" 2006 foreach tag [GetDatasetsWithComponent $cname] { 2079 foreach {dataobj comp} $_style2objs($tf) { 2080 set tag $dataobj-$comp 2007 2081 if { ![info exists _serverObjs($tag)] } { 2008 2082 puts stderr "$tag not in serverObjs?" 2009 2083 continue 2010 2084 } 2011 if { ![info exists _limits($tag )] } {2085 if { ![info exists _limits($tag-min)] } { 2012 2086 puts stderr "$tag no min?" 2013 2087 continue 2014 2088 } 2015 foreach {vmin vmax} $_limits($tag) break 2016 if { $min == "" || $min > $vmin } { 2017 set min $vmin 2018 } 2019 if { $max == "" || $max < $vmax } { 2020 set max $vmax 2021 } 2022 } 2023 if { $min != "" && $max != "" } { 2024 set _limits(v) [list $min $max] 2025 set _limits($cname) [list $min $max] 2026 } 2027 return $_limits($cname) 2089 if { $min == "" || $min > $_limits($tag-min) } { 2090 set min $_limits($tag-min) 2091 } 2092 if { $max == "" || $max < $_limits($tag-max) } { 2093 set max $_limits($tag-max) 2094 } 2095 } 2096 if { $min != "" } { 2097 set _limits(vmin) $min 2098 } 2099 if { $max != "" } { 2100 set _limits(vmax) $max 2101 } 2102 return [array get _limits] 2028 2103 } 2029 2104 … … 2114 2189 2115 2190 itcl::body Rappture::FlowvisViewer::BuildVolumeTab {} { 2191 foreach { key value } { 2192 light2side 1 2193 light 40 2194 transp 50 2195 opacity 100 2196 thickness 350 2197 } { 2198 set _settings($this-$key) $value 2199 } 2200 2116 2201 set inner [$itk_component(main) insert end \ 2117 2202 -title "Volume Settings" \ … … 2141 2226 label $inner.bright -text "Surface" -font $fg 2142 2227 2228 label $inner.fog -text "Clear" -font $fg 2229 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 2230 -variable [itcl::scope _settings($this-transp)] \ 2231 -width 10 \ 2232 -showvalue off -command [itcl::code $this AdjustSetting transp] 2233 label $inner.plastic -text "Opaque" -font $fg 2234 2143 2235 label $inner.clear -text "Clear" -font $fg 2144 2236 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ … … 2160 2252 } 2161 2253 2162 $inner.colormap choices insert end [GetColormapList -includeNone] 2254 $inner.colormap choices insert end \ 2255 "BCGYR" "BCGYR" \ 2256 "BGYOR" "BGYOR" \ 2257 "blue" "blue" \ 2258 "blue-to-brown" "blue-to-brown" \ 2259 "blue-to-orange" "blue-to-orange" \ 2260 "blue-to-grey" "blue-to-grey" \ 2261 "green-to-magenta" "green-to-magenta" \ 2262 "greyscale" "greyscale" \ 2263 "nanohub" "nanohub" \ 2264 "rainbow" "rainbow" \ 2265 "spectral" "spectral" \ 2266 "ROYGB" "ROYGB" \ 2267 "RYGCB" "RYGCB" \ 2268 "brown-to-blue" "brown-to-blue" \ 2269 "grey-to-blue" "grey-to-blue" \ 2270 "orange-to-blue" "orange-to-blue" \ 2271 "none" "none" 2272 2163 2273 $itk_component(colormap) value "BCGYR" 2164 2274 bind $inner.colormap <<Value>> \ … … 2172 2282 3,1 $inner.light -cspan 2 -pady 2 -fill x \ 2173 2283 3,3 $inner.bright -anchor w -pady 2 \ 2174 4,0 $inner. clear-anchor e -pady 2 \2175 4,1 $inner. opacity-cspan 2 -pady 2 -fill x \2176 4,3 $inner. opaque-anchor w -pady 2 \2284 4,0 $inner.fog -anchor e -pady 2 \ 2285 4,1 $inner.transp -cspan 2 -pady 2 -fill x \ 2286 4,3 $inner.plastic -anchor w -pady 2 \ 2177 2287 5,0 $inner.thin -anchor e -pady 2 \ 2178 2288 5,1 $inner.thickness -cspan 2 -pady 2 -fill x\ … … 2302 2412 0,0 $inner.view_l -anchor e -pady 2 \ 2303 2413 0,1 $inner.view -anchor w -pady 2 2304 blt::table configure $inner r0 -resize none2305 2414 2306 2415 set row 1 … … 2310 2419 entry $inner.${tag} -font "Arial 9" -bg white \ 2311 2420 -textvariable [itcl::scope _settings($this-$tag)] 2312 bind $inner.${tag} <Return> \ 2313 [itcl::code $this camera set -${tag}] 2314 bind $inner.${tag} <KP_Enter> \ 2315 [itcl::code $this camera set -${tag}] 2421 bind $inner.${tag} <KeyPress-Return> \ 2422 [itcl::code $this camera set ${tag}] 2316 2423 blt::table $inner \ 2317 2424 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 2321 2428 } 2322 2429 2323 blt::table configure $inner c* -resize none2430 blt::table configure $inner c* r* -resize none 2324 2431 blt::table configure $inner c2 -resize expand 2325 2432 blt::table configure $inner r$row -resize expand … … 2474 2581 itcl::body Rappture::FlowvisViewer::SlicerTip {axis} { 2475 2582 set val [$itk_component(${axis}CutScale) get] 2583 # set val [expr {0.01*($val-50) 2584 # *($_limits(${axis}max)-$_limits(${axis}min)) 2585 # + 0.5*($_limits(${axis}max)+$_limits(${axis}min))}] 2476 2586 return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%" 2477 2587 } … … 2515 2625 } 2516 2626 "set" { 2517 set wh at[lindex $args 0]2518 set x $_settings($ {this}${what})2627 set who [lindex $args 0] 2628 set x $_settings($this-$who) 2519 2629 set code [catch { string is double $x } result] 2520 2630 if { $code != 0 || !$result } { 2521 set _settings($ {this}${what}) $_view($what)2631 set _settings($this-$who) $_view($who) 2522 2632 return 2523 2633 } 2524 switch -- $wh at{2525 " -xpan" - "-ypan" {2526 set _view($wh at) $_settings(${this}${what})2634 switch -- $who { 2635 "xpan" - "ypan" { 2636 set _view($who) $_settings($this-$who) 2527 2637 PanCamera 2528 2638 } 2529 " -qx" - "-qy" - "-qz" - "-qw" {2530 set _view($wh at) $_settings(${this}${what})2531 set q [ ViewToQuaternion]2639 "qx" - "qy" - "qz" - "qw" { 2640 set _view($who) $_settings($this-$who) 2641 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2532 2642 $_arcball quaternion $q 2533 2643 SendCmd "camera orient $q" 2534 2644 } 2535 " -zoom" {2536 set _view($wh at) $_settings(${this}${what})2537 SendCmd "camera zoom $_view( $what)"2645 "zoom" { 2646 set _view($who) $_settings($this-$who) 2647 SendCmd "camera zoom $_view(zoom)" 2538 2648 } 2539 2649 } … … 2913 3023 bottom "0.707107 0.707107 0 0" 2914 3024 } 2915 foreach name { -qw -qx -qy -qz } value $positions($side) {3025 foreach name { qw qx qy qz } value $positions($side) { 2916 3026 set _view($name) $value 2917 3027 } 2918 set q [ ViewToQuaternion]3028 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2919 3029 $_arcball quaternion $q 2920 3030 SendCmd "camera orient $q" 2921 3031 SendCmd "camera reset" 2922 set _view(-xpan) 0.0 2923 set _view(-ypan) 0.0 2924 set _view(-zoom) 1.0 2925 set _settings($this-xpan) $_view(-xpan) 2926 set _settings($this-ypan) $_view(-ypan) 2927 set _settings($this-zoom) $_view(-zoom) 2928 } 2929 2930 # Reset global settings from dataset's settings. 2931 itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} { 2932 $itk_component(volcomponents) choices delete 0 end 2933 foreach name $_componentsList { 2934 $itk_component(volcomponents) choices insert end $name $name 2935 } 2936 set _current [lindex $_componentsList 0] 2937 $itk_component(volcomponents) value $_current 2938 } 2939 2940 # Reset global settings from dataset's settings. 2941 itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } { 2942 if { ![info exists _volcomponents($cname)] } { 2943 return "" 2944 } 2945 set list "" 2946 foreach tag $_volcomponents($cname) { 2947 if { ![info exists _serverObjs($tag)] } { 2948 continue 2949 } 2950 lappend list $tag 2951 } 2952 return $list 2953 } 3032 set _view(xpan) 0.0 3033 set _view(ypan) 0.0 3034 set _view(zoom) 1.0 3035 set _settings($this-xpan) $_view(xpan) 3036 set _settings($this-ypan) $_view(ypan) 3037 set _settings($this-zoom) $_view(zoom) 3038 } -
branches/1.3/gui/scripts/isomarker.tcl
r4546 r4848 30 30 private common _normalIcon [Rappture::icon nvlegendmark] 31 31 private common _activeIcon [Rappture::icon nvlegendmark2] 32 private method EnterTick {}33 private method LeaveTick {}34 private method StartDrag { x y }35 private method ContinueDrag { x y }36 private method StopDrag { x y }37 32 38 constructor {c obj tf args} {} 39 destructor {} 40 public method transferfunc {} 41 public method activate { bool } 42 public method visible { bool } 43 public method screenpos {} 44 public method absval { {x "-get"} } 45 public method relval { {x "-get"} } 46 } 47 48 itcl::body Rappture::IsoMarker::constructor {c obj tf args} { 49 set _canvas $c 50 set _nvobj $obj 51 set _tf $tf 52 set w [winfo width $_canvas] 53 set h [winfo height $_canvas] 54 set _tick [$c create image 0 $h \ 55 -image $_normalIcon -anchor s \ 56 -tags "tick $this $obj" -state hidden] 57 set _label [$c create text 0 $h \ 58 -anchor n -fill white -font "Helvetica 8" \ 59 -tags "labels $this $obj" -state hidden] 60 $c bind $_tick <Enter> [itcl::code $this EnterTick] 61 $c bind $_tick <Leave> [itcl::code $this LeaveTick] 62 $c bind $_tick <ButtonPress-1> [itcl::code $this StartDrag %x %y] 63 $c bind $_tick <B1-Motion> [itcl::code $this ContinueDrag %x %y] 64 $c bind $_tick <ButtonRelease-1> [itcl::code $this StopDrag %x %y] 65 } 66 67 itcl::body Rappture::IsoMarker::destructor {} { 68 $_canvas delete $this 69 } 70 71 itcl::body Rappture::IsoMarker::transferfunc {} { 72 return $_tf 73 } 74 75 itcl::body Rappture::IsoMarker::activate { bool } { 76 if { $bool || $_activePress || $_activeMotion } { 77 $_canvas itemconfigure $_label -state normal 78 $_canvas itemconfigure $_tick -image $_activeIcon 79 $_canvas itemconfigure title -state hidden 80 } else { 81 $_canvas itemconfigure $_label -state hidden 82 $_canvas itemconfigure $_tick -image $_normalIcon 83 $_canvas itemconfigure title -state normal 33 constructor {c obj tf args} { 34 set _canvas $c 35 set _nvobj $obj 36 set _tf $tf 37 set w [winfo width $_canvas] 38 set h [winfo height $_canvas] 39 set _tick [$c create image 0 $h \ 40 -image $_normalIcon -anchor s \ 41 -tags "$this $obj" -state hidden] 42 set _label [$c create text 0 $h \ 43 -anchor n -fill white -font "Helvetica 8" \ 44 -tags "$this $obj" -state hidden] 45 $c bind $_tick <Enter> [itcl::code $this HandleEvent "enter"] 46 $c bind $_tick <Leave> [itcl::code $this HandleEvent "leave"] 47 $c bind $_tick <ButtonPress-1> \ 48 [itcl::code $this HandleEvent "start" %x %y] 49 $c bind $_tick <B1-Motion> \ 50 [itcl::code $this HandleEvent "update" %x %y] 51 $c bind $_tick <ButtonRelease-1> \ 52 [itcl::code $this HandleEvent "end" %x %y] 53 } 54 destructor { 55 $_canvas delete $this 56 } 57 public method transferfunc {} { 58 return $_tf 59 } 60 public method activate { bool } { 61 if { $bool || $_activePress || $_activeMotion } { 62 $_canvas itemconfigure $_label -state normal 63 $_canvas itemconfigure $_tick -image $_activeIcon 64 } else { 65 $_canvas itemconfigure $_label -state hidden 66 $_canvas itemconfigure $_tick -image $_normalIcon 67 } 68 } 69 public method visible { bool } { 70 if { $bool } { 71 absval $_value 72 $_canvas itemconfigure $_tick -state normal 73 $_canvas raise $_tick 74 } else { 75 $_canvas itemconfigure $_tick -state hidden 76 } 77 } 78 public method screenpos { } { 79 set x [relval] 80 if { $x < 0.0 } { 81 set x 0.0 82 } elseif { $x > 1.0 } { 83 set x 1.0 84 } 85 set low 10 86 set w [winfo width $_canvas] 87 set high [expr {$w - 10}] 88 set x [expr {round($x*($high - $low) + $low)}] 89 return $x 90 } 91 public method absval { {x "-get"} } { 92 if { $x != "-get" } { 93 set _value $x 94 set y 31 95 $_canvas itemconfigure $_label -text [format %.2g $_value] 96 set x [screenpos] 97 $_canvas coords $_tick $x [expr {$y+3}] 98 $_canvas coords $_label $x [expr {$y+5}] 99 } 100 return $_value 101 } 102 public method relval { {x "-get"} } { 103 if { $x == "-get" } { 104 array set limits [$_nvobj limits $_tf] 105 if { $limits(vmax) == $limits(vmin) } { 106 if { $limits(vmax) == 0.0 } { 107 set limits(vmin) 0.0 108 set limits(vmax) 1.0 109 } else { 110 set limits(vmax) [expr $limits(vmin) + 1.0] 111 } 112 } 113 return [expr {($_value-$limits(vmin))/ 114 ($limits(vmax) - $limits(vmin))}] 115 } 116 array set limits [$_nvobj limits $_tf] 117 if { $limits(vmax) == $limits(vmin) } { 118 set limits(vmin) 0.0 119 set limits(vmax) 1.0 120 } 121 if { [catch {expr $limits(vmax) - $limits(vmin)} r] != 0 } { 122 return 0.0 123 } 124 absval [expr {($x * $r) + $limits(vmin)}] 125 } 126 private method HandleEvent { option args } { 127 switch -- $option { 128 enter { 129 set _activeMotion 1 130 activate yes 131 $_canvas raise $_tick 132 } 133 leave { 134 set _activeMotion 0 135 activate no 136 } 137 start { 138 $_canvas raise $_tick 139 set _activePress 1 140 activate yes 141 $_canvas itemconfigure limits -state hidden 142 } 143 update { 144 set w [winfo width $_canvas] 145 set x [lindex $args 0] 146 relval [expr {double($x-10)/($w-20)}] 147 $_nvobj overmarker $this $x 148 $_nvobj updatetransferfuncs 149 } 150 end { 151 set x [lindex $args 0] 152 if { ![$_nvobj rmdupmarker $this $x]} { 153 eval HandleEvent update $args 154 } 155 set _activePress 0 156 activate no 157 $_canvas itemconfigure limits -state normal 158 } 159 default { 160 error "bad option \"$option\": should be start, update, end" 161 } 162 } 84 163 } 85 164 } 86 87 itcl::body Rappture::IsoMarker::visible { bool } {88 if { $bool } {89 absval $_value90 $_canvas itemconfigure $_tick -state normal91 $_canvas raise $_tick92 } else {93 $_canvas itemconfigure $_tick -state hidden94 }95 }96 97 itcl::body Rappture::IsoMarker::screenpos { } {98 set x [relval]99 if { $x < 0.0 } {100 set x 0.0101 } elseif { $x > 1.0 } {102 set x 1.0103 }104 set low 10105 set w [winfo width $_canvas]106 set high [expr {$w - 10}]107 set x [expr {round($x*($high - $low) + $low)}]108 return $x109 }110 111 itcl::body Rappture::IsoMarker::absval { {x "-get"} } {112 if { $x != "-get" } {113 set _value $x114 set y 31115 $_canvas itemconfigure $_label -text [format %g $_value]116 set x [screenpos]117 $_canvas coords $_tick $x [expr {$y+3}]118 $_canvas coords $_label $x [expr {$y+5}]119 }120 return $_value121 }122 123 itcl::body Rappture::IsoMarker::relval { {x "-get"} } {124 foreach {min max} [$_nvobj limits $_tf] break125 if { $x == "-get" } {126 if { $max == $min } {127 if { $max == 0.0 } {128 set min 0.0129 set max 1.0130 } else {131 set max [expr $min + 1.0]132 }133 }134 return [expr {($_value - $min) / ($max - $min)}]135 }136 if { $max == $min } {137 set min 0.0138 set max 1.0139 }140 if { [catch {expr $max - $min} r] != 0 } {141 return 0.0142 }143 absval [expr {($x * $r) + $min}]144 }145 146 itcl::body Rappture::IsoMarker::EnterTick {} {147 set _activeMotion 1148 activate yes149 $_canvas raise $_tick150 }151 152 itcl::body Rappture::IsoMarker::LeaveTick {} {153 set _activeMotion 0154 activate no155 }156 157 itcl::body Rappture::IsoMarker::StartDrag { x y } {158 $_canvas raise $_tick159 set _activePress 1160 activate yes161 $_canvas itemconfigure limits -state hidden162 $_canvas itemconfigure title -state hidden163 }164 165 itcl::body Rappture::IsoMarker::StopDrag { x y } {166 if { ![$_nvobj removeDuplicateMarker $this $x]} {167 ContinueDrag $x $y168 }169 set _activePress 0170 activate no171 $_canvas itemconfigure limits -state normal172 $_canvas itemconfigure title -state normal173 }174 175 itcl::body Rappture::IsoMarker::ContinueDrag { x y } {176 set w [winfo width $_canvas]177 relval [expr {double($x-10)/($w-20)}]178 $_nvobj overMarker $this $x179 $_nvobj updateTransferFunctions180 $_canvas raise $_tick181 set _activePress 1182 activate yes183 $_canvas itemconfigure limits -state hidden184 $_canvas itemconfigure title -state hidden185 }186 -
branches/1.3/gui/scripts/nanovisviewer.tcl
r4772 r4848 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 3 # ---------------------------------------------------------------------- 3 4 # COMPONENT: nanovisviewer - 3D volume rendering … … 75 76 public method isconnected {} 76 77 public method limits { tf } 78 public method overmarker { m x } 77 79 public method parameters {title args} { 78 80 # do nothing 79 81 } 82 public method rmdupmarker { m x } 80 83 public method scale {args} 81 public method updateTransferFunctions {} 84 public method updatetransferfuncs {} 85 86 protected method Connect {} 87 protected method CurrentDatasets {{what -all}} 88 protected method Disconnect {} 89 protected method DoResize {} 90 protected method FixLegend {} 91 protected method AdjustSetting {what {value ""}} 92 protected method InitSettings { args } 93 protected method Pan {option x y} 94 protected method Rebuild {} 95 protected method ReceiveData { args } 96 protected method ReceiveImage { args } 97 protected method ReceiveLegend { tf vmin vmax size } 98 protected method Rotate {option x y} 99 protected method SendTransferFuncs {} 100 protected method Slice {option args} 101 protected method SlicerTip {axis} 102 protected method Zoom {option} 82 103 83 104 # The following methods are only used by this class. 84 85 private method AddNewMarker { x y } 86 private method AdjustSetting {what {value ""}} 105 private method AddIsoMarker { x y } 87 106 private method BuildCameraTab {} 88 107 private method BuildCutplanesTab {} 89 108 private method BuildViewTab {} 90 private method BuildVolumeComponents {}91 109 private method BuildVolumeTab {} 92 private method ComputeAlphamap { cname } 93 private method ComputeTransferFunction { cname } 94 private method Connect {} 95 private method CurrentDatasets {{what -all}} 96 private method Disconnect {} 97 private method DoResize {} 98 private method DrawLegend { cname } 99 private method EventuallyRedrawLegend { } 110 private method ResetColormap { color } 111 private method ComputeTransferFunc { tf } 100 112 private method EventuallyResize { w h } 101 private method FixLegend {} 102 private method GetAlphamap { cname color } 103 private method GetColormap { cname color } 104 private method GetDatasetsWithComponent { cname } 113 private method EventuallyResizeLegend { } 114 private method NameTransferFunc { dataobj comp } 115 private method PanCamera {} 116 private method ParseLevelsOption { tf levels } 117 private method ParseMarkersOption { tf markers } 118 private method volume { tag name } 105 119 private method GetVolumeInfo { w } 106 private method HideAllMarkers {}107 private method InitComponentSettings { cname }108 private method InitSettings { args }109 private method NameToAlphamap { name }110 private method NameTransferFunction { dataobj comp }111 private method Pan {option x y}112 private method PanCamera {}113 private method ParseLevelsOption { cname levels }114 private method ParseMarkersOption { cname markers }115 private method QuaternionToView { q } {116 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break117 }118 private method Rebuild {}119 private method ReceiveData { args }120 private method ReceiveImage { args }121 private method ReceiveLegend { tf vmin vmax size }122 private method RemoveMarker { x y }123 private method ResetColormap { cname color }124 private method Rotate {option x y}125 private method SendTransferFunctions {}126 private method SetObjectStyle { dataobj cname }127 120 private method SetOrientation { side } 128 private method Slice {option args}129 private method SlicerTip {axis}130 private method SwitchComponent { cname }131 private method ToggleVolume { tag name }132 private method ViewToQuaternion {} {133 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]134 }135 private method Zoom {option}136 121 137 122 private variable _arcball "" 138 123 139 124 private variable _dlist "" ;# list of data objects 125 private variable _allDataObjs 140 126 private variable _obj2ovride ;# maps dataobj => style override 141 127 private variable _serverDatasets ;# contains all the dataobj-component 142 128 ;# to volumes in the server 143 private variable _ recvdDatasets; # list of data objs to send to server144 private variable _dataset2style; # maps dataobj-component to transfunc145 private variable _ style2datasets; # maps tf back to list of146 # dataobj-components using the tf.147 148 private variable _reset 1; # Connection to server has been reset.149 private variable _click; # Info used for rotate operations. 150 private variable _ limits; # Autoscale min/max for all axes151 private variable _ view; # View params for 3D view152 private variable _ parsedFunction153 private variable _ transferFunctionEditors154 private variable _ settings155 private variable _widget156 157 private variable _first "" ; # This is the topmost volume.158 private variable _current ""; # Currently selected component159 private variable _ volcomponents ; # Array of components found160 private variable _ componentsList ; # Array of components found161 private variable _cname2style 162 private variable _cname2transferFunction163 private variable _cname2defaultcolormap164 private variable _cname2defaultalphamap165 129 private variable _serverTfs ;# contains all the transfer functions 130 ;# in the server. 131 private variable _recvdDatasets ;# list of data objs to send to server 132 private variable _dataset2style ;# maps dataobj-component to transfunc 133 private variable _style2datasets ;# maps tf back to list of 134 # dataobj-components using the tf. 135 136 private variable _reset 1; # Connection to server has been reset 137 private variable _click ;# info used for rotate operations 138 private variable _limits ;# autoscale min/max for all axes 139 private variable _view ;# view params for 3D view 140 private variable _isomarkers ;# array of isosurface level values 0..1 141 private variable _settings 142 # Array of transfer functions in server. If 0 the transfer has been 143 # defined but not loaded. If 1 the transfer function has been named 144 # and loaded. 145 private variable _activeTfs 146 private variable _first "" ;# This is the topmost volume. 147 148 # This 149 # indicates which isomarkers and transfer 150 # function to use when changing markers, 151 # opacity, or thickness. 166 152 common _downloadPopup ;# download options from popup 167 153 private common _hardcopy … … 190 176 $_dispatcher register !send_transfunc 191 177 $_dispatcher dispatch $this !send_transfunc \ 192 "[itcl::code $this SendTransferFunc tions]; list"178 "[itcl::code $this SendTransferFuncs]; list" 193 179 194 180 # Rebuild event … … 209 195 # Initialize the view to some default parameters. 210 196 array set _view { 211 -qw 0.853553212 -qx -0.353553213 -qy 0.353553214 -qz 0.146447215 -xpan0216 -ypan 0217 -zoom 1.0197 qw 0.853553 198 qx -0.353553 199 qy 0.353553 200 qz 0.146447 201 zoom 1.0 202 xpan 0 203 ypan 0 218 204 } 219 205 set _arcball [blt::arcball create 100 100] 220 $_arcball quaternion [ViewToQuaternion] 221 222 set _limits(v) [list 0.0 1.0] 206 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 207 $_arcball quaternion $q 208 209 set _limits(vmin) 0.0 210 set _limits(vmax) 1.0 223 211 set _reset 1 224 212 225 array set _settings { 226 -axesvisible 1 227 -background black 228 -colormap "default" 229 -cutplanesvisible 0 230 -gridvisible 0 231 -isosurfaceshading 0 232 -legendvisible 1 233 -light 40 234 -light2side 1 235 -outlinevisible 0 236 -qw 0.853553 237 -qx -0.353553 238 -qy 0.353553 239 -qz 0.146447 240 -thickness 350 241 -volume 1 242 -volumeopacity 0.5 243 -volumevisible 1 244 -xcutplaneposition 50 245 -xcutplanevisible 1 246 -xpan 0 247 -ycutplaneposition 50 248 -ycutplanevisible 1 249 -ypan 0 250 -zcutplaneposition 50 251 -zcutplanevisible 1 252 -zoom 1.0 253 } 254 array set _widget { 255 -volumeopacity 50 256 } 213 array set _settings [subst { 214 $this-qw $_view(qw) 215 $this-qx $_view(qx) 216 $this-qy $_view(qy) 217 $this-qz $_view(qz) 218 $this-zoom $_view(zoom) 219 $this-xpan $_view(xpan) 220 $this-ypan $_view(ypan) 221 $this-volume 1 222 $this-xcutplane 0 223 $this-xcutposition 0 224 $this-ycutplane 0 225 $this-ycutposition 0 226 $this-zcutplane 0 227 $this-zcutposition 0 228 }] 229 257 230 itk_component add 3dview { 258 231 label $itk_component(plotarea).view -image $_image(plot) \ … … 275 248 } 276 249 pack $itk_component(reset) -side top -padx 2 -pady 2 277 Rappture::Tooltip::for $itk_component(reset) \ 278 "Reset the view to the default zoom level" 250 Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" 279 251 280 252 itk_component add zoomin { … … 306 278 -onimage [Rappture::icon volume-on] \ 307 279 -offimage [Rappture::icon volume-off] \ 308 -command [itcl::code $this AdjustSetting -volume] \309 -variable [itcl::scope _settings( -volume)]280 -command [itcl::code $this AdjustSetting volume] \ 281 -variable [itcl::scope _settings($this-volume)] 310 282 } 311 283 $itk_component(volume) select … … 313 285 "Toggle the volume cloud on/off" 314 286 pack $itk_component(volume) -padx 2 -pady 2 315 316 itk_component add cutplane {317 Rappture::PushButton $f.cutplane \318 -onimage [Rappture::icon cutbutton] \319 -offimage [Rappture::icon cutbutton] \320 -variable [itcl::scope _settings(-cutplanesvisible)] \321 -command [itcl::code $this AdjustSetting -cutplanesvisible]322 }323 Rappture::Tooltip::for $itk_component(cutplane) \324 "Show/Hide cutplanes"325 pack $itk_component(cutplane) -padx 2 -pady 2326 287 327 288 if { [catch { … … 336 297 337 298 # Legend 299 338 300 set _image(legend) [image create photo] 339 301 itk_component add legend { … … 345 307 } 346 308 bind $itk_component(legend) <Configure> \ 347 [itcl::code $this EventuallyRedrawLegend] 348 bind $itk_component(legend) <KeyPress-Delete> \ 349 [itcl::code $this RemoveMarker %x %y] 350 bind $itk_component(legend) <Enter> \ 351 [list focus $itk_component(legend)] 309 [itcl::code $this EventuallyResizeLegend] 352 310 353 311 # Hack around the Tk panewindow. The problem is that the requested … … 428 386 image delete $_image(legend) 429 387 image delete $_image(download) 430 foreach name [array names _transferFunctionEditors] {431 itcl::delete object $_transferFunctionEditors($cname)432 }433 388 catch { blt::arcball destroy $_arcball } 434 array unset _settings 389 array unset _settings $this-* 435 390 } 436 391 … … 464 419 if {$pos < 0} { 465 420 lappend _dlist $dataobj 421 set _allDataObjs($dataobj) 1 466 422 set _obj2ovride($dataobj-color) $params(-color) 467 423 set _obj2ovride($dataobj-width) $params(-width) … … 540 496 if { $pos >= 0 } { 541 497 set _dlist [lreplace $_dlist $pos $pos] 498 array unset _limits $dataobj* 542 499 array unset _obj2ovride $dataobj-* 543 array unset _dataset2style $dataobj-*544 500 set changed 1 545 501 } … … 561 517 # ---------------------------------------------------------------------- 562 518 itcl::body Rappture::NanovisViewer::scale {args} { 563 array set styles { 564 -color BCGYR 565 -levels 6 566 -markers "" 567 } 568 array unset _limits 569 array unset _volcomponents 519 foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} { 520 set _limits($val) "" 521 } 570 522 foreach dataobj $args { 571 523 if { ![$dataobj isvalid] } { 572 524 continue; # Object doesn't contain valid data. 573 525 } 574 foreach cname [$dataobj components] {575 if { ![info exists _volcomponents($cname)] } {576 lappend _componentsList $cname577 array set styles [lindex [$dataobj components -style $cname] 0]578 set cmap [ColorsToColormap $styles(-color)]579 set _cname2defaultcolormap($cname) $cmap580 set _settings($cname-colormap) $styles(-color)581 }582 lappend _volcomponents($cname) $dataobj-$cname583 array unset limits584 array set limits [$dataobj valueLimits $cname]585 set _limits($cname) $limits(v)586 }587 526 foreach axis {x y z v} { 588 527 foreach { min max } [$dataobj limits $axis] break 589 528 if {"" != $min && "" != $max} { 590 if { ![info exists _limits($axis)] } { 591 set _limits($axis) [list $min $max] 529 if {"" == $_limits(${axis}min)} { 530 set _limits(${axis}min) $min 531 set _limits(${axis}max) $max 592 532 } else { 593 foreach {amin amax} $_limits($axis) break 594 if {$min < $amin} { 595 set amin $min 533 if {$min < $_limits(${axis}min)} { 534 set _limits(${axis}min) $min 596 535 } 597 if {$max > $ amax} {598 set amax$max536 if {$max > $_limits(${axis}max)} { 537 set _limits(${axis}max) $max 599 538 } 600 set _limits($axis) [list $amin $amax]601 539 } 602 540 } 603 541 } 604 542 } 605 BuildVolumeComponents606 543 } 607 544 … … 666 603 if { $_reportClientInfo } { 667 604 # Tell the server the viewer, hub, user and session. 668 # Do this immediately on connect before buff ering any commands605 # Do this immediately on connect before buffing any commands 669 606 global env 670 607 … … 726 663 727 664 # ---------------------------------------------------------------------- 728 # USAGE: SendTransferFunctions 729 # ---------------------------------------------------------------------- 730 itcl::body Rappture::NanovisViewer::SendTransferFunctions {} { 731 foreach cname [array names _volcomponents] { 732 ComputeTransferFunction $cname 665 # USAGE: SendTransferFuncs 666 # ---------------------------------------------------------------------- 667 itcl::body Rappture::NanovisViewer::SendTransferFuncs {} { 668 if { $_first == "" } { 669 puts stderr "first not set" 670 return 671 } 672 # Ensure that the global opacity and thickness settings (in the slider 673 # settings widgets) are used for the active transfer-function. Update 674 # the values in the _settings varible. 675 set opacity [expr { double($_settings($this-opacity)) * 0.01 }] 676 # Scale values between 0.00001 and 0.01000 677 set thickness [expr {double($_settings($this-thickness)) * 0.0001}] 678 679 foreach tag [CurrentDatasets] { 680 if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } { 681 # The volume hasn't reached the server yet. How did we get 682 # here? 683 puts stderr "Don't have $tag in _serverDatasets" 684 continue 685 } 686 if { ![info exists _dataset2style($tag)] } { 687 puts stderr "don't have style for volume $tag" 688 continue; # How does this happen? 689 } 690 set tf $_dataset2style($tag) 691 set _settings($this-$tf-opacity) $opacity 692 set _settings($this-$tf-thickness) $thickness 693 ComputeTransferFunc $tf 694 # FIXME: Need to the send information as to what transfer functions 695 # to update so that we only update the transfer function 696 # as necessary. Right now, all transfer functions are 697 # updated. This makes moving the isomarker slider chunky. 698 if { ![info exists _activeTfs($tf)] || !$_activeTfs($tf) } { 699 set _activeTfs($tf) 1 700 } 701 SendCmd "volume shading transfunc $tf $tag" 733 702 } 734 703 FixLegend … … 761 730 762 731 # 763 # DrawLegend -- 764 # 765 itcl::body Rappture::NanovisViewer::DrawLegend { cname } { 732 # ReceiveLegend -- 733 # 734 # The procedure is the response from the render server to each "legend" 735 # command. The server sends back a "legend" command invoked our 736 # the slave interpreter. The purpose is to collect data of the image 737 # representing the legend in the canvas. In addition, the isomarkers 738 # of the active transfer function are displayed. 739 # 740 # I don't know is this is the right place to display the isomarkers. 741 # I don't know all the different paths used to draw the plot. There's 742 # "Rebuild", "add", etc. 743 # 744 itcl::body Rappture::NanovisViewer::ReceiveLegend { tf vmin vmax size } { 745 if { ![isconnected] } { 746 return 747 } 748 set bytes [ReceiveBytes $size] 749 $_image(legend) configure -data $bytes 750 ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 751 766 752 set c $itk_component(legend) 767 753 set w [winfo width $c] … … 769 755 set lx 10 770 756 set ly [expr {$h - 1}] 771 if {"" == [$c find withtag colorbar]} {757 if {"" == [$c find withtag transfunc]} { 772 758 $c create image 10 10 -anchor nw \ 773 -image $_image(legend) -tags colorbar759 -image $_image(legend) -tags transfunc 774 760 $c create text $lx $ly -anchor sw \ 775 -fill $itk_option(-plotforeground) -tags "limits textvmin"761 -fill $itk_option(-plotforeground) -tags "limits vmin" 776 762 $c create text [expr {$w-$lx}] $ly -anchor se \ 777 -fill $itk_option(-plotforeground) -tags "limits text vmax" 778 $c create text [expr {$w/2}] $ly -anchor s \ 779 -fill $itk_option(-plotforeground) -tags "limits text title" 780 $c lower colorbar 781 $c bind colorbar <ButtonRelease-1> [itcl::code $this AddNewMarker %x %y] 782 } 783 784 # Display the markers used by the current transfer function. 785 HideAllMarkers 786 $_transferFunctionEditors($cname) showMarkers $_limits($cname) 787 788 foreach {min max} $_limits($cname) break 789 $c itemconfigure vmin -text [format %g $min] 763 -fill $itk_option(-plotforeground) -tags "limits vmax" 764 $c lower transfunc 765 $c bind transfunc <ButtonRelease-1> \ 766 [itcl::code $this AddIsoMarker %x %y] 767 } 768 # Display the markers used by the active transfer function. 769 770 array set limits [limits $tf] 771 $c itemconfigure vmin -text [format %.2g $limits(min)] 790 772 $c coords vmin $lx $ly 791 773 792 $c itemconfigure vmax -text [format % g $max]774 $c itemconfigure vmax -text [format %.2g $limits(max)] 793 775 $c coords vmax [expr {$w-$lx}] $ly 794 776 795 set title [$_first hints label] 796 set units [$_first hints units] 797 if { $units != "" } { 798 set title "$title ($units)" 799 } 800 $c itemconfigure title -text $title 801 $c coords title [expr {$w/2}] $ly 777 if { [info exists _isomarkers($tf)] } { 778 foreach m $_isomarkers($tf) { 779 $m visible yes 780 } 781 } 802 782 803 783 # The colormap may have changed. Resync the slicers with the colormap. 804 InitSettings -cutplanesvisible -xcutplanevisible -ycutplanevisible \ 805 -zcutplanevisible 806 } 807 808 # 809 # 810 # ReceiveLegend -- 811 # 812 # The procedure is the response from the render server to each "legend" 813 # command. The server sends back a "legend" command invoked our 814 # the slave interpreter. The purpose is to collect data of the image 815 # representing the legend in the canvas. In addition, the 816 # active transfer function is displayed. 817 # 818 # 819 itcl::body Rappture::NanovisViewer::ReceiveLegend { cname vmin vmax size } { 820 if { ![isconnected] } { 821 return 822 } 823 set bytes [ReceiveBytes $size] 824 $_image(legend) configure -data $bytes 825 ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 826 827 DrawLegend $_current 784 set datasets [CurrentDatasets -cutplanes] 785 SendCmd "volume data state $_settings($this-volume) $datasets" 786 787 # Adjust the cutplane for only the first component in the topmost volume 788 # (i.e. the first volume designated in the field). 789 set tag [lindex $datasets 0] 790 foreach axis {x y z} { 791 # Turn off cutplanes for all volumes 792 SendCmd "cutplane state 0 $axis" 793 if { $_settings($this-${axis}cutplane) } { 794 # Turn on cutplane for this particular volume and set the position 795 SendCmd "cutplane state 1 $axis $tag" 796 set pos [expr {0.01*$_settings($this-${axis}cutposition)}] 797 SendCmd "cutplane position $pos $axis $tag" 798 } 799 } 828 800 } 829 801 … … 865 837 set dataobj [lindex $parts 0] 866 838 set _serverDatasets($tag) 1 867 if { $_settings( -volumevisible) && $dataobj == $_first } {839 if { $_settings($this-volume) && $dataobj == $_first } { 868 840 SendCmd "volume state 1 $tag" 869 841 } 870 set _limits($tag) [list $info(min) $info(max)] 871 set _limits(v) [list $info(vmin) $info(vmax)] 842 set _limits($tag-min) $info(min); # Minimum value of the volume. 843 set _limits($tag-max) $info(max); # Maximum value of the volume. 844 set _limits(vmin) $info(vmin); # Overall minimum value. 845 set _limits(vmax) $info(vmax); # Overall maximum value. 872 846 873 847 unset _recvdDatasets($tag) 874 848 if { [array size _recvdDatasets] == 0 } { 875 updateTransferFunctions 849 # The active transfer function is by default the first component of 850 # the first data object. This assumes that the data is always 851 # successfully transferred. 852 updatetransferfuncs 876 853 } 877 854 } … … 897 874 StartBufferingCommands 898 875 876 # Hide all the isomarkers. Can't remove them. Have to remember the 877 # settings since the user may have created/deleted/moved markers. 878 879 foreach tf [array names _isomarkers] { 880 foreach m $_isomarkers($tf) { 881 $m visible no 882 } 883 } 884 899 885 if { $_width != $w || $_height != $h || $_reset } { 900 886 set _width $w … … 903 889 DoResize 904 890 } 905 906 891 foreach dataobj [get] { 907 892 foreach cname [$dataobj components] { … … 913 898 puts stderr "??? $dataobj is invalid" 914 899 } 915 set data [$dataobj blob$cname]900 set data [$dataobj values $cname] 916 901 } else { 917 902 set data [$dataobj vtkdata $cname] 918 903 if 0 { 919 904 set f [open "/tmp/volume.vtk" "w"] 920 fconfigure $f -translation binary -encoding binary 921 puts -nonewline $f $data 905 puts $f $data 922 906 close $f 923 907 } … … 941 925 set _serverDatasets($tag) 0 942 926 } 943 SetObjectStyle $dataobj $cname 944 } 945 } 946 947 # Outline seems to need to be reset every update. 948 InitSettings -outlinevisible -cutplanesvisible -current 949 927 NameTransferFunc $dataobj $cname 928 } 929 } 950 930 set _first [lindex [get] 0] 951 931 if { $_reset } { … … 953 933 # Reset the camera and other view parameters 954 934 # 955 set _settings( -qw) $_view(-qw)956 set _settings( -qx) $_view(-qx)957 set _settings( -qy) $_view(-qy)958 set _settings( -qz) $_view(-qz)959 set _settings( -xpan) $_view(-xpan)960 set _settings( -ypan) $_view(-ypan)961 set _settings( -zoom) $_view(-zoom)962 963 set q [ ViewToQuaternion]935 set _settings($this-qw) $_view(qw) 936 set _settings($this-qx) $_view(qx) 937 set _settings($this-qy) $_view(qy) 938 set _settings($this-qz) $_view(qz) 939 set _settings($this-xpan) $_view(xpan) 940 set _settings($this-ypan) $_view(ypan) 941 set _settings($this-zoom) $_view(zoom) 942 943 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 964 944 $_arcball quaternion $q 965 945 SendCmd "camera orient $q" 966 946 SendCmd "camera reset" 967 947 PanCamera 968 SendCmd "camera zoom $_view(-zoom)" 948 SendCmd "camera zoom $_view(zoom)" 949 InitSettings light2side light transp isosurface grid axes 969 950 970 #cutplane state 0 all971 951 foreach axis {x y z} { 972 952 # Turn off cutplanes for all volumes 973 953 SendCmd "cutplane state 0 $axis" 974 954 } 975 976 InitSettings -light2side -light -volumeopacity \977 -isosurfaceshading -gridvisible -axesvisible \978 979 955 if {"" != $_first} { 980 956 set axis [$_first hints updir] … … 988 964 } 989 965 } 990 966 # Outline seems to need to be reset every update. 967 InitSettings outline 991 968 # nothing to send -- activate the proper ivol 992 969 SendCmd "volume state 0" … … 1000 977 set cname [lindex [$_first components] 0] 1001 978 if { [info exists _serverDatasets($_first-$cname)] } { 1002 update TransferFunctions979 updatetransferfuncs 1003 980 } 1004 981 } … … 1026 1003 set tag $_first-$cname 1027 1004 if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } { 1028 array set style s{1005 array set style { 1029 1006 -cutplanes 1 1030 1007 } 1031 array set style s[lindex [$_first components -style $cname] 0]1032 if { $what != "-cutplanes" || $style s(-cutplanes) } {1008 array set style [lindex [$_first components -style $cname] 0] 1009 if { $what != "-cutplanes" || $style(-cutplanes) } { 1033 1010 lappend rlist $tag 1034 1011 } … … 1049 1026 switch -- $option { 1050 1027 "in" { 1051 set _view( -zoom) [expr {$_view(-zoom)*1.25}]1052 set _settings( -zoom) $_view(-zoom)1053 SendCmd "camera zoom $_view( -zoom)"1028 set _view(zoom) [expr {$_view(zoom)*1.25}] 1029 set _settings($this-zoom) $_view(zoom) 1030 SendCmd "camera zoom $_view(zoom)" 1054 1031 } 1055 1032 "out" { 1056 set _view( -zoom) [expr {$_view(-zoom)*0.8}]1057 set _settings( -zoom) $_view(-zoom)1058 SendCmd "camera zoom $_view( -zoom)"1033 set _view(zoom) [expr {$_view(zoom)*0.8}] 1034 set _settings($this-zoom) $_view(zoom) 1035 SendCmd "camera zoom $_view(zoom)" 1059 1036 } 1060 1037 "reset" { 1061 1038 array set _view { 1062 -qw 0.8535531063 -qx -0.3535531064 -qy 0.3535531065 -qz 0.1464471066 -xpan01067 -ypan01068 -zoom 1.01039 qw 0.853553 1040 qx -0.353553 1041 qy 0.353553 1042 qz 0.146447 1043 zoom 1.0 1044 xpan 0 1045 ypan 0 1069 1046 } 1070 1047 if { $_first != "" } { … … 1074 1051 } 1075 1052 } 1076 set q [ ViewToQuaternion]1053 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1077 1054 $_arcball quaternion $q 1078 1055 SendCmd "camera orient $q" 1079 1056 SendCmd "camera reset" 1080 set _settings( -qw) $_view(-qw)1081 set _settings( -qx) $_view(-qx)1082 set _settings( -qy) $_view(-qy)1083 set _settings( -qz) $_view(-qz)1084 set _settings( -xpan) $_view(-xpan)1085 set _settings( -ypan) $_view(-ypan)1086 set _settings( -zoom) $_view(-zoom)1057 set _settings($this-qw) $_view(qw) 1058 set _settings($this-qx) $_view(qx) 1059 set _settings($this-qy) $_view(qy) 1060 set _settings($this-qz) $_view(qz) 1061 set _settings($this-xpan) $_view(xpan) 1062 set _settings($this-ypan) $_view(ypan) 1063 set _settings($this-zoom) $_view(zoom) 1087 1064 } 1088 1065 } … … 1090 1067 1091 1068 itcl::body Rappture::NanovisViewer::PanCamera {} { 1092 set x $_view(-xpan) 1093 set y $_view(-ypan) 1069 #set x [expr ($_view(xpan)) / $_limits(xrange)] 1070 #set y [expr ($_view(ypan)) / $_limits(yrange)] 1071 set x $_view(xpan) 1072 set y $_view(ypan) 1094 1073 SendCmd "camera pan $x $y" 1095 1074 } … … 1130 1109 1131 1110 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1132 QuaternionToView $q1133 set _settings( -qw) $_view(-qw)1134 set _settings( -qx) $_view(-qx)1135 set _settings( -qy) $_view(-qy)1136 set _settings( -qz) $_view(-qz)1111 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 1112 set _settings($this-qw) $_view(qw) 1113 set _settings($this-qx) $_view(qx) 1114 set _settings($this-qy) $_view(qy) 1115 set _settings($this-qz) $_view(qz) 1137 1116 SendCmd "camera orient $q" 1138 1117 … … 1167 1146 set x [expr $x / double($w)] 1168 1147 set y [expr $y / double($h)] 1169 set _view( -xpan) [expr $_view(-xpan) + $x]1170 set _view( -ypan) [expr $_view(-ypan) + $y]1148 set _view(xpan) [expr $_view(xpan) + $x] 1149 set _view(ypan) [expr $_view(ypan) + $y] 1171 1150 PanCamera 1172 set _settings( -xpan) $_view(-xpan)1173 set _settings( -ypan) $_view(-ypan)1151 set _settings($this-xpan) $_view(xpan) 1152 set _settings($this-ypan) $_view(ypan) 1174 1153 return 1175 1154 } … … 1184 1163 set _click(x) $x 1185 1164 set _click(y) $y 1186 set _view( -xpan) [expr $_view(-xpan) - $dx]1187 set _view( -ypan) [expr $_view(-ypan) - $dy]1165 set _view(xpan) [expr $_view(xpan) - $dx] 1166 set _view(ypan) [expr $_view(ypan) - $dy] 1188 1167 PanCamera 1189 set _settings( -xpan) $_view(-xpan)1190 set _settings( -ypan) $_view(-ypan)1168 set _settings($this-xpan) $_view(xpan) 1169 set _settings($this-ypan) $_view(ypan) 1191 1170 } 1192 1171 if { $option == "release" } { … … 1220 1199 } 1221 1200 switch -- $what { 1222 "-axesvisible" { 1223 SendCmd "axis visible $_settings($what)" 1224 } 1225 "-background" { 1226 set bgcolor [$itk_component(background) value] 1227 array set fgcolors { 1228 "black" "white" 1229 "white" "black" 1230 "grey" "black" 1231 } 1232 configure -plotbackground $bgcolor \ 1233 -plotforeground $fgcolors($bgcolor) 1234 DrawLegend $_current 1235 } 1236 "-colormap" { 1201 light { 1202 set val $_settings($this-light) 1203 set diffuse [expr {0.01*$val}] 1204 set ambient [expr {1.0-$diffuse}] 1205 set specularLevel 0.3 1206 set specularExp 90.0 1207 SendCmd "volume shading ambient $ambient" 1208 SendCmd "volume shading diffuse $diffuse" 1209 SendCmd "volume shading specularLevel $specularLevel" 1210 SendCmd "volume shading specularExp $specularExp" 1211 } 1212 light2side { 1213 set val $_settings($this-light2side) 1214 SendCmd "volume shading light2side $val" 1215 } 1216 transp { 1217 set val $_settings($this-transp) 1218 set sval [expr { 0.01 * double($val) }] 1219 SendCmd "volume shading opacity $sval" 1220 } 1221 opacity { 1222 set val $_settings($this-opacity) 1223 set sval [expr { 0.01 * double($val) }] 1224 foreach tf [array names _activeTfs] { 1225 set _settings($this-$tf-opacity) $sval 1226 set _activeTfs($tf) 0 1227 } 1228 updatetransferfuncs 1229 } 1230 thickness { 1231 if { [array names _activeTfs] > 0 } { 1232 set val $_settings($this-thickness) 1233 # Scale values between 0.00001 and 0.01000 1234 set sval [expr {0.0001*double($val)}] 1235 foreach tf [array names _activeTfs] { 1236 set _settings($this-$tf-thickness) $sval 1237 set _activeTfs($tf) 0 1238 } 1239 updatetransferfuncs 1240 } 1241 } 1242 "outline" { 1243 SendCmd "volume outline state $_settings($this-outline)" 1244 } 1245 "isosurface" { 1246 SendCmd "volume shading isosurface $_settings($this-isosurface)" 1247 } 1248 "colormap" { 1237 1249 set color [$itk_component(colormap) value] 1238 set _settings($what) $color 1239 set _settings($_current${what}) $color 1240 ResetColormap $_current $color 1241 } 1242 "-current" { 1243 set cname [$itk_component(volcomponents) value] 1244 SwitchComponent $cname 1245 } 1246 "-cutplanesvisible" { 1247 set bool $_settings($what) 1248 # We only set cutplanes on the first dataset. 1249 set datasets [CurrentDatasets -cutplanes] 1250 set tag [lindex $datasets 0] 1251 if { $bool } { 1252 foreach axis { x y z } { 1253 if { $_settings(-${axis}cutplanevisible) } { 1254 SendCmd "cutplane state 1 $axis $tag" 1255 } 1256 } 1257 } else { 1258 foreach axis { x y z } { 1259 SendCmd "cutplane state 0 $axis $tag" 1260 } 1261 } 1262 } 1263 "-gridvisible" { 1264 SendCmd "grid visible $_settings($what)" 1265 } 1266 "-isosurfaceshading" { 1267 SendCmd "volume shading isosurface $_settings($what)" 1268 } 1269 "-legendvisible" { 1270 if { $_settings($what) } { 1250 set _settings(colormap) $color 1251 # Only set the colormap on the first volume. Ignore the others. 1252 #ResetColormap $color 1253 } 1254 "grid" { 1255 SendCmd "grid visible $_settings($this-grid)" 1256 } 1257 "axes" { 1258 SendCmd "axis visible $_settings($this-axes)" 1259 } 1260 "legend" { 1261 if { $_settings($this-legend) } { 1271 1262 blt::table $itk_component(plotarea) \ 1272 1263 0,0 $itk_component(3dview) -fill both \ … … 1277 1268 } 1278 1269 } 1279 "-light" { 1280 set _settings($_current${what}) $_settings($what) 1281 set val $_settings($what) 1282 set diffuse [expr {0.01*$val}] 1283 set ambient [expr {1.0-$diffuse}] 1284 set specularLevel 0.3 1285 set specularExp 90.0 1286 foreach tag [GetDatasetsWithComponent $_current] { 1287 SendCmd "volume shading ambient $ambient $tag" 1288 SendCmd "volume shading diffuse $diffuse $tag" 1289 SendCmd "volume shading specularLevel $specularLevel $tag" 1290 SendCmd "volume shading specularExp $specularExp $tag" 1291 } 1292 } 1293 "-light2side" { 1294 set _settings($_current${what}) $_settings($what) 1295 set val $_settings($what) 1296 foreach tag [GetDatasetsWithComponent $_current] { 1297 SendCmd "volume shading light2side $val $tag" 1298 } 1299 } 1300 "-outlinevisible" { 1301 SendCmd "volume outline state $_settings($what)" 1302 } 1303 "-thickness" { 1304 set val $_settings($what) 1305 set _settings($_current${what}) $val 1306 updateTransferFunctions 1307 } 1308 "-volume" { 1309 # This is the global volume visibility control. It controls the 1310 # visibility of all the all volumes. Whenever it's changed, you 1311 # have to synchronize each of the local controls (see below) with 1312 # this. 1313 set datasets [CurrentDatasets] 1314 set bool $_settings($what) 1315 SendCmd "volume data state $bool $datasets" 1316 foreach cname $_componentsList { 1317 set _settings($cname-volumevisible) $bool 1318 } 1319 set _settings(-volumevisible) $bool 1320 } 1321 "-volumeopacity" { 1322 set _settings($what) [expr $_widget($what) * 0.01] 1323 set _settings($_current${what}) $_settings($what) 1324 foreach tag [GetDatasetsWithComponent $_current] { 1325 SendCmd "volume shading opacity $_settings($what) $tag" 1326 } 1327 } 1328 "-volumevisible" { 1329 # This is the component specific control. It changes the 1330 # visibility of only the current component. 1331 set _settings($_current${what}) $_settings($what) 1332 foreach tag [GetDatasetsWithComponent $_current] { 1333 SendCmd "volume data state $_settings($what) $tag" 1334 } 1335 } 1336 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1337 set axis [string range $what 1 1] 1338 set bool $_settings($what) 1339 # We only set cutplanes on the first dataset. 1270 "volume" { 1271 set datasets [CurrentDatasets -cutplanes] 1272 SendCmd "volume data state $_settings($this-volume) $datasets" 1273 } 1274 "xcutplane" - "ycutplane" - "zcutplane" { 1275 set axis [string range $what 0 0] 1276 set bool $_settings($this-$what) 1340 1277 set datasets [CurrentDatasets -cutplanes] 1341 1278 set tag [lindex $datasets 0] 1342 if { $_settings(-cutplanesvisible) } { 1343 SendCmd "cutplane state $bool $axis $tag" 1344 } 1279 SendCmd "cutplane state $bool $axis $tag" 1345 1280 if { $bool } { 1346 1281 $itk_component(${axis}CutScale) configure -state normal \ … … 1369 1304 set w [expr {$_width-20}] 1370 1305 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 1371 if {$w > 0 && $h > 0 && $_first != "" } { 1372 if { [info exists _cname2transferFunction($_current)] } { 1373 SendCmd "legend $_current $w $h" 1374 } 1375 } 1376 } 1377 1378 # 1379 # NameTransferFunction -- 1306 if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } { 1307 set tag [lindex [CurrentDatasets] 0] 1308 if { [info exists _dataset2style($tag)] } { 1309 SendCmd "legend $_dataset2style($tag) $w $h" 1310 } 1311 } else { 1312 # Can't do this as this will remove the items associated with the 1313 # isomarkers. 1314 1315 #$itk_component(legend) delete all 1316 } 1317 } 1318 1319 # 1320 # NameTransferFunc -- 1380 1321 # 1381 1322 # Creates a transfer function name based on the <style> settings in the … … 1385 1326 # server parses the 3D data and sends back the limits via ReceiveData.] 1386 1327 # 1387 itcl::body Rappture::NanovisViewer::NameTransferFunction { dataobj cname } { 1388 array set styles { 1328 # FIXME: The current way we generate transfer-function names completely 1329 # ignores the -markers option. The problem is that we are forced 1330 # to compute the name from an increasing complex set of values: 1331 # color, levels, marker, opacity. I think we're stuck doing it 1332 # now. 1333 # 1334 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } { 1335 array set style { 1389 1336 -color BCGYR 1390 1337 -levels 6 1338 -opacity 1.0 1391 1339 -markers "" 1392 1340 } 1393 1341 set tag $dataobj-$cname 1394 array set styles [lindex [$dataobj components -style $cname] 0] 1395 if { ![info exists _cname2transferFunction($cname)] } { 1396 # Get the colormap right now, since it doesn't change with marker 1397 # changes. 1398 set cmap [ColorsToColormap $styles(-color)] 1399 set wmap [list 0.0 0.0 1.0 1.0] 1400 set _cname2transferFunction($cname) [list $cmap $wmap] 1401 SendCmd [list transfunc define $cname $cmap $wmap] 1402 } 1403 SendCmd "volume shading transfunc $cname $tag" 1404 if { ![info exists _transferFunctionEditors($cname)] } { 1405 set _transferFunctionEditors($cname) \ 1406 [Rappture::TransferFunctionEditor ::\#auto $itk_component(legend) \ 1407 $cname \ 1408 -command [itcl::code $this updateTransferFunctions]] 1409 } 1410 set _dataset2style($tag) $cname 1411 lappend _style2datasets($cname) $tag 1412 return $cname 1413 } 1414 1415 # 1416 # ComputeTransferFunction -- 1417 # 1418 # Computes and sends the transfer function to the render server. It's 1419 # assumed that the volume data limits are known and that the global 1420 # transfer-functions slider values have been set up. Both parts are 1421 # needed to compute the relative value (location) of the marker, and 1422 # the alpha map of the transfer function. 1423 # 1424 itcl::body Rappture::NanovisViewer::ComputeTransferFunction { cname } { 1425 foreach {cmap wmap} $_cname2transferFunction($cname) break 1342 array set style [lindex [$dataobj components -style $cname] 0] 1343 set tf "$style(-color):$style(-levels):$style(-opacity)" 1344 set _dataset2style($tag) $tf 1345 lappend _style2datasets($tf) $tag 1346 return $tf 1347 } 1348 1349 # 1350 # ComputeTransferFunc -- 1351 # 1352 # Computes and sends the transfer function to the render server. It's 1353 # assumed that the volume data limits are known and that the global 1354 # transfer-functions slider values have been set up. Both parts are 1355 # needed to compute the relative value (location) of the marker, and 1356 # the alpha map of the transfer function. 1357 # 1358 itcl::body Rappture::NanovisViewer::ComputeTransferFunc { tf } { 1359 array set style { 1360 -color BCGYR 1361 -levels 6 1362 -opacity 1.0 1363 -markers "" 1364 } 1365 1366 foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break 1367 array set style [lindex [$dataobj components -style $cname] 0] 1426 1368 1427 1369 # We have to parse the style attributes for a volume using this … … 1431 1373 # of the volumes (the first in the list) using the transfer-function as a 1432 1374 # reference. 1433 if { ![info exists _parsedFunction($cname)] } { 1434 array set styles { 1435 -color BCGYR 1436 -levels 6 1437 -markers "" 1438 } 1439 # Accumulate the style from all the datasets using it. 1440 foreach tag [GetDatasetsWithComponent $cname] { 1441 foreach {dataobj cname} [split [lindex $tag 0] -] break 1442 array set styles [lindex [$dataobj components -style $cname] 0] 1443 } 1444 eval $_transferFunctionEditors($cname) limits $_limits($cname) 1375 # 1376 # FIXME: The current way we generate transfer-function names completely 1377 # ignores the -markers option. The problem is that we are forced 1378 # to compute the name from an increasing complex set of values: 1379 # color, levels, marker, opacity. I think the cow's out of the 1380 # barn on this one. 1381 1382 if { ![info exists _isomarkers($tf)] } { 1445 1383 # Have to defer creation of isomarkers until we have data limits 1446 if { [info exists style s(-markers)] &&1447 [llength $style s(-markers)] > 0 } {1448 ParseMarkersOption $ cname $styles(-markers)1384 if { [info exists style(-markers)] && 1385 [llength $style(-markers)] > 0 } { 1386 ParseMarkersOption $tf $style(-markers) 1449 1387 } else { 1450 ParseLevelsOption $cname $styles(-levels) 1451 } 1452 1453 } 1454 set wmap [ComputeAlphamap $cname] 1455 set _cname2transferFunction($cname) [list $cmap $wmap] 1456 SendCmd [list transfunc define $cname $cmap $wmap] 1457 } 1458 1459 itcl::body Rappture::NanovisViewer::AddNewMarker { x y } { 1460 if { ![info exists _transferFunctionEditors($_current)] } { 1461 continue 1462 } 1463 # Add a new marker to the current transfer function 1464 $_transferFunctionEditors($_current) newMarker $x $y normal 1465 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) 1466 } 1467 1468 itcl::body Rappture::NanovisViewer::RemoveMarker { x y } { 1469 if { ![info exists _transferFunctionEditors($_current)] } { 1470 continue 1471 } 1472 # Add a new marker to the current transfer function 1473 $_transferFunctionEditors($_current) deleteMarker $x $y 1388 ParseLevelsOption $tf $style(-levels) 1389 } 1390 } 1391 set cmap [ColorsToColormap $style(-color)] 1392 set tag $this-$tf 1393 if { ![info exists _settings($tag-opacity)] } { 1394 set _settings($tag-opacity) $style(-opacity) 1395 } 1396 set max 1.0 ;#$_settings($tag-opacity) 1397 1398 set isovalues {} 1399 foreach m $_isomarkers($tf) { 1400 lappend isovalues [$m relval] 1401 } 1402 # Sort the isovalues 1403 set isovalues [lsort -real $isovalues] 1404 1405 if { ![info exists _settings($tag-thickness)]} { 1406 set _settings($tag-thickness) 0.005 1407 } 1408 set delta $_settings($tag-thickness) 1409 1410 set first [lindex $isovalues 0] 1411 set last [lindex $isovalues end] 1412 set wmap "" 1413 if { $first == "" || $first != 0.0 } { 1414 lappend wmap 0.0 0.0 1415 } 1416 foreach x $isovalues { 1417 set x1 [expr {$x-$delta-0.00001}] 1418 set x2 [expr {$x-$delta}] 1419 set x3 [expr {$x+$delta}] 1420 set x4 [expr {$x+$delta+0.00001}] 1421 if { $x1 < 0.0 } { 1422 set x1 0.0 1423 } elseif { $x1 > 1.0 } { 1424 set x1 1.0 1425 } 1426 if { $x2 < 0.0 } { 1427 set x2 0.0 1428 } elseif { $x2 > 1.0 } { 1429 set x2 1.0 1430 } 1431 if { $x3 < 0.0 } { 1432 set x3 0.0 1433 } elseif { $x3 > 1.0 } { 1434 set x3 1.0 1435 } 1436 if { $x4 < 0.0 } { 1437 set x4 0.0 1438 } elseif { $x4 > 1.0 } { 1439 set x4 1.0 1440 } 1441 # add spikes in the middle 1442 lappend wmap $x1 0.0 1443 lappend wmap $x2 $max 1444 lappend wmap $x3 $max 1445 lappend wmap $x4 0.0 1446 } 1447 if { $last == "" || $last != 1.0 } { 1448 lappend wmap 1.0 0.0 1449 } 1450 SendCmd "transfunc define $tf { $cmap } { $wmap }" 1474 1451 } 1475 1452 … … 1479 1456 itcl::configbody Rappture::NanovisViewer::plotbackground { 1480 1457 if { [isconnected] } { 1481 set color $itk_option(-plotbackground) 1482 set rgb [Color2RGB $color] 1483 SendCmd "screen bgcolor $rgb" 1484 $itk_component(legend) configure -background $color 1458 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break 1459 #fix this! 1460 #SendCmd "color background $r $g $b" 1485 1461 } 1486 1462 } … … 1491 1467 itcl::configbody Rappture::NanovisViewer::plotforeground { 1492 1468 if { [isconnected] } { 1493 set color $itk_option(-plotforeground) 1494 set rgb [Color2RGB $color] 1495 SendCmd "volume outline color $rgb" 1496 SendCmd "grid axiscolor $rgb" 1497 SendCmd "grid linecolor $rgb" 1498 $itk_component(legend) itemconfigure labels -fill $color 1499 $itk_component(legend) itemconfigure limits -fill $color 1469 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1470 #fix this! 1471 #SendCmd "color background $r $g $b" 1500 1472 } 1501 1473 } … … 1524 1496 # marker is a relative value from 0.0 to 1.0. 1525 1497 # 1526 itcl::body Rappture::NanovisViewer::ParseLevelsOption { cnamelevels } {1498 itcl::body Rappture::NanovisViewer::ParseLevelsOption { tf levels } { 1527 1499 set c $itk_component(legend) 1528 set list {}1529 1500 regsub -all "," $levels " " levels 1530 1501 if {[string is int $levels]} { 1531 1502 for {set i 1} { $i <= $levels } {incr i} { 1532 lappend list [expr {double($i)/($levels+1)}] 1503 set x [expr {double($i)/($levels+1)}] 1504 set m [Rappture::IsoMarker \#auto $c $this $tf] 1505 $m relval $x 1506 lappend _isomarkers($tf) $m 1533 1507 } 1534 1508 } else { 1535 1509 foreach x $levels { 1536 lappend list $x 1537 } 1538 } 1539 set _parsedFunction($cname) 1 1540 $_transferFunctionEditors($cname) addMarkers $list 1541 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) 1510 set m [Rappture::IsoMarker \#auto $c $this $tf] 1511 $m relval $x 1512 lappend _isomarkers($tf) $m 1513 } 1514 } 1542 1515 } 1543 1516 … … 1554 1527 # not be seen. 1555 1528 # 1556 itcl::body Rappture::NanovisViewer::ParseMarkersOption { cnamemarkers } {1529 itcl::body Rappture::NanovisViewer::ParseMarkersOption { tf markers } { 1557 1530 set c $itk_component(legend) 1558 set list {}1559 foreach { min max } $_limits($cname) break1560 1531 regsub -all "," $markers " " markers 1561 1532 foreach marker $markers { 1562 1533 set n [scan $marker "%g%s" value suffix] 1563 1534 if { $n == 2 && $suffix == "%" } { 1564 # $n% : Set relative value (0..1). 1565 lappend list [expr {$value * 0.01}] 1535 # ${n}% : Set relative value. 1536 set value [expr {$value * 0.01}] 1537 set m [Rappture::IsoMarker \#auto $c $this $tf] 1538 $m relval $value 1539 lappend _isomarkers($tf) $m 1566 1540 } else { 1567 # $n : absolute value, compute relative 1568 lappend list [expr {(double($value)-$min)/($max-$min)]} 1569 } 1570 } 1571 set _parsedFunction($cname) 1 1572 $_transferFunctionEditors($cname) addMarkers $list 1573 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) 1541 # ${n} : Set absolute value. 1542 set m [Rappture::IsoMarker \#auto $c $this $tf] 1543 $m absval $value 1544 lappend _isomarkers($tf) $m 1545 } 1546 } 1574 1547 } 1575 1548 … … 1577 1550 # USAGE: UndateTransferFuncs 1578 1551 # ---------------------------------------------------------------------- 1579 itcl::body Rappture::NanovisViewer::update TransferFunctions {} {1552 itcl::body Rappture::NanovisViewer::updatetransferfuncs {} { 1580 1553 $_dispatcher event -idle !send_transfunc 1581 1554 } 1582 1555 1583 itcl::body Rappture::NanovisViewer::limits { cname } { 1556 itcl::body Rappture::NanovisViewer::AddIsoMarker { x y } { 1557 if { $_first == "" } { 1558 error "active transfer function isn't set" 1559 } 1560 set tag [lindex [CurrentDatasets] 0] 1561 set tf $_dataset2style($tag) 1562 set c $itk_component(legend) 1563 set m [Rappture::IsoMarker \#auto $c $this $tf] 1564 set w [winfo width $c] 1565 $m relval [expr {double($x-10)/($w-20)}] 1566 lappend _isomarkers($tf) $m 1567 updatetransferfuncs 1568 return 1 1569 } 1570 1571 itcl::body Rappture::NanovisViewer::rmdupmarker { marker x } { 1572 set tf [$marker transferfunc] 1573 set bool 0 1574 if { [info exists _isomarkers($tf)] } { 1575 set list {} 1576 set marker [namespace tail $marker] 1577 foreach m $_isomarkers($tf) { 1578 set sx [$m screenpos] 1579 if { $m != $marker } { 1580 if { $x >= ($sx-3) && $x <= ($sx+3) } { 1581 $marker relval [$m relval] 1582 itcl::delete object $m 1583 bell 1584 set bool 1 1585 continue 1586 } 1587 } 1588 lappend list $m 1589 } 1590 set _isomarkers($tf) $list 1591 updatetransferfuncs 1592 } 1593 return $bool 1594 } 1595 1596 itcl::body Rappture::NanovisViewer::overmarker { marker x } { 1597 set tf [$marker transferfunc] 1598 if { [info exists _isomarkers($tf)] } { 1599 set marker [namespace tail $marker] 1600 foreach m $_isomarkers($tf) { 1601 set sx [$m screenpos] 1602 if { $m != $marker } { 1603 set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }] 1604 $m activate $bool 1605 } 1606 } 1607 } 1608 return "" 1609 } 1610 1611 itcl::body Rappture::NanovisViewer::limits { tf } { 1584 1612 set _limits(min) 0.0 1585 1613 set _limits(max) 1.0 1586 if { ![info exists _style2datasets($ cname)] } {1614 if { ![info exists _style2datasets($tf)] } { 1587 1615 return [array get _limits] 1588 1616 } 1589 1617 set min ""; set max "" 1590 foreach tag [GetDatasetsWithComponent $cname]{1591 if { ![info exists _ limits($tag)] } {1618 foreach tag $_style2datasets($tf) { 1619 if { ![info exists _serverDatasets($tag)] } { 1592 1620 continue 1593 1621 } 1594 foreach {amin amax} $_limits($tag) break 1595 if { $min == "" || $min > $amin } { 1596 set min $amin 1597 } 1598 if { $max == "" || $max < $amax } { 1599 set max $amax 1622 if { ![info exists _limits($tag-min)] } { 1623 continue 1624 } 1625 if { $min == "" || $min > $_limits($tag-min) } { 1626 set min $_limits($tag-min) 1627 } 1628 if { $max == "" || $max < $_limits($tag-max) } { 1629 set max $_limits($tag-max) 1600 1630 } 1601 1631 } … … 1606 1636 set _limits(max) $max 1607 1637 } 1608 return [ list $_limits(min) $_limits(max)]1638 return [array get _limits] 1609 1639 } 1610 1640 1611 1641 1612 1642 itcl::body Rappture::NanovisViewer::BuildViewTab {} { 1643 foreach { key value } { 1644 grid 0 1645 axes 1 1646 outline 0 1647 volume 1 1648 legend 1 1649 particles 1 1650 lic 1 1651 } { 1652 set _settings($this-$key) $value 1653 } 1654 1613 1655 set fg [option get $itk_component(hull) font Font] 1614 1656 #set bfg [option get $itk_component(hull) boldFont Font] … … 1619 1661 $inner configure -borderwidth 4 1620 1662 1621 set ::Rappture::NanovisViewer::_settings( -isosurfaceshading) 01663 set ::Rappture::NanovisViewer::_settings($this-isosurface) 0 1622 1664 checkbutton $inner.isosurface \ 1623 1665 -text "Isosurface shading" \ 1624 -variable [itcl::scope _settings( -isosurfaceshading)] \1625 -command [itcl::code $this AdjustSetting -isosurfaceshading] \1666 -variable [itcl::scope _settings($this-isosurface)] \ 1667 -command [itcl::code $this AdjustSetting isosurface] \ 1626 1668 -font "Arial 9" 1627 1669 1628 1670 checkbutton $inner.axes \ 1629 1671 -text "Axes" \ 1630 -variable [itcl::scope _settings( -axesvisible)] \1631 -command [itcl::code $this AdjustSetting -axesvisible] \1672 -variable [itcl::scope _settings($this-axes)] \ 1673 -command [itcl::code $this AdjustSetting axes] \ 1632 1674 -font "Arial 9" 1633 1675 1634 1676 checkbutton $inner.grid \ 1635 1677 -text "Grid" \ 1636 -variable [itcl::scope _settings( -gridvisible)] \1637 -command [itcl::code $this AdjustSetting -gridvisible] \1678 -variable [itcl::scope _settings($this-grid)] \ 1679 -command [itcl::code $this AdjustSetting grid] \ 1638 1680 -font "Arial 9" 1639 1681 1640 1682 checkbutton $inner.outline \ 1641 1683 -text "Outline" \ 1642 -variable [itcl::scope _settings( -outlinevisible)] \1643 -command [itcl::code $this AdjustSetting -outlinevisible] \1684 -variable [itcl::scope _settings($this-outline)] \ 1685 -command [itcl::code $this AdjustSetting outline] \ 1644 1686 -font "Arial 9" 1645 1687 1646 1688 checkbutton $inner.legend \ 1647 1689 -text "Legend" \ 1648 -variable [itcl::scope _settings( -legendvisible)] \1649 -command [itcl::code $this AdjustSetting -legendvisible] \1690 -variable [itcl::scope _settings($this-legend)] \ 1691 -command [itcl::code $this AdjustSetting legend] \ 1650 1692 -font "Arial 9" 1651 1693 1652 1694 checkbutton $inner.volume \ 1653 1695 -text "Volume" \ 1654 -variable [itcl::scope _settings( -volume)] \1655 -command [itcl::code $this AdjustSetting -volume] \1696 -variable [itcl::scope _settings($this-volume)] \ 1697 -command [itcl::code $this AdjustSetting volume] \ 1656 1698 -font "Arial 9" 1657 1658 label $inner.background_l -text "Background" -font "Arial 9"1659 itk_component add background {1660 Rappture::Combobox $inner.background -width 10 -editable no1661 }1662 $inner.background choices insert end \1663 "black" "black" \1664 "white" "white" \1665 "grey" "grey"1666 1667 $itk_component(background) value $_settings(-background)1668 bind $inner.background <<Value>> \1669 [itcl::code $this AdjustSetting -background]1670 1699 1671 1700 blt::table $inner \ … … 1674 1703 2,0 $inner.outline -cspan 2 -anchor w \ 1675 1704 3,0 $inner.volume -cspan 2 -anchor w \ 1676 4,0 $inner.legend -cspan 2 -anchor w \ 1677 5,0 $inner.background_l -anchor e -pady 2 \ 1678 5,1 $inner.background -fill x \ 1705 4,0 $inner.legend -cspan 2 -anchor w 1679 1706 1680 1707 if 0 { … … 1682 1709 } 1683 1710 blt::table configure $inner r* -resize none 1684 blt::table configure $inner r 6-resize expand1711 blt::table configure $inner r5 -resize expand 1685 1712 } 1686 1713 1687 1714 itcl::body Rappture::NanovisViewer::BuildVolumeTab {} { 1715 foreach { key value } { 1716 light2side 1 1717 light 40 1718 transp 50 1719 opacity 100 1720 thickness 350 1721 } { 1722 set _settings($this-$key) $value 1723 } 1724 1688 1725 set inner [$itk_component(main) insert end \ 1689 1726 -title "Volume Settings" \ … … 1694 1731 #set bfg [option get $itk_component(hull) boldFont Font] 1695 1732 1733 checkbutton $inner.vol -text "Show volume" -font $fg \ 1734 -variable [itcl::scope _settings($this-volume)] \ 1735 -command [itcl::code $this AdjustSetting volume] 1696 1736 label $inner.shading -text "Shading:" -font $fg 1697 1737 1698 1738 checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ 1699 -variable [itcl::scope _settings(-light2side)] \ 1700 -command [itcl::code $this AdjustSetting -light2side] 1701 1702 checkbutton $inner.visibility -text "Visible" -font $fg \ 1703 -variable [itcl::scope _settings(-volumevisible)] \ 1704 -command [itcl::code $this AdjustSetting -volumevisible] 1739 -variable [itcl::scope _settings($this-light2side)] \ 1740 -command [itcl::code $this AdjustSetting light2side] 1705 1741 1706 1742 label $inner.dim -text "Glow" -font $fg 1707 1743 ::scale $inner.light -from 0 -to 100 -orient horizontal \ 1708 -variable [itcl::scope _settings( -light)] \1744 -variable [itcl::scope _settings($this-light)] \ 1709 1745 -width 10 \ 1710 -showvalue off -command [itcl::code $this AdjustSetting -light]1746 -showvalue off -command [itcl::code $this AdjustSetting light] 1711 1747 label $inner.bright -text "Surface" -font $fg 1712 1748 1713 # Opacity1714 1749 label $inner.fog -text "Clear" -font $fg 1715 1750 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 1716 -variable [itcl::scope _ widget(-volumeopacity)] \1751 -variable [itcl::scope _settings($this-transp)] \ 1717 1752 -width 10 \ 1718 -showvalue off -command [itcl::code $this AdjustSetting -volumeopacity]1753 -showvalue off -command [itcl::code $this AdjustSetting transp] 1719 1754 label $inner.plastic -text "Opaque" -font $fg 1720 1755 1721 # Tooth thickness 1756 label $inner.clear -text "Clear" -font $fg 1757 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1758 -variable [itcl::scope _settings($this-opacity)] \ 1759 -width 10 \ 1760 -showvalue off -command [itcl::code $this AdjustSetting opacity] 1761 label $inner.opaque -text "Opaque" -font $fg 1762 1722 1763 label $inner.thin -text "Thin" -font $fg 1723 1764 ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \ 1724 -variable [itcl::scope _settings( -thickness)] \1765 -variable [itcl::scope _settings($this-thickness)] \ 1725 1766 -width 10 \ 1726 -showvalue off -command [itcl::code $this AdjustSetting -thickness]1767 -showvalue off -command [itcl::code $this AdjustSetting thickness] 1727 1768 label $inner.thick -text "Thick" -font $fg 1728 1769 1729 # Colormap 1730 label $inner.colormap_l -text "Colormap" -font $fg 1770 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1731 1771 itk_component add colormap { 1732 1772 Rappture::Combobox $inner.colormap -width 10 -editable no 1733 1773 } 1734 1774 1735 $inner.colormap choices insert end [GetColormapList -includeDefault -includeNone] 1775 $inner.colormap choices insert end \ 1776 "BCGYR" "BCGYR" \ 1777 "BGYOR" "BGYOR" \ 1778 "blue" "blue" \ 1779 "blue-to-brown" "blue-to-brown" \ 1780 "blue-to-orange" "blue-to-orange" \ 1781 "blue-to-grey" "blue-to-grey" \ 1782 "green-to-magenta" "green-to-magenta" \ 1783 "greyscale" "greyscale" \ 1784 "nanohub" "nanohub" \ 1785 "rainbow" "rainbow" \ 1786 "spectral" "spectral" \ 1787 "ROYGB" "ROYGB" \ 1788 "RYGCB" "RYGCB" \ 1789 "brown-to-blue" "brown-to-blue" \ 1790 "grey-to-blue" "grey-to-blue" \ 1791 "orange-to-blue" "orange-to-blue" \ 1792 "none" "none" 1793 1794 $itk_component(colormap) value "BCGYR" 1736 1795 bind $inner.colormap <<Value>> \ 1737 [itcl::code $this AdjustSetting -colormap] 1738 $itk_component(colormap) value "default" 1739 set _settings(-colormap) "default" 1740 1741 # Component 1742 label $inner.volcomponents_l -text "Component" -font $fg 1743 itk_component add volcomponents { 1744 Rappture::Combobox $inner.volcomponents -editable no 1745 } 1746 bind $inner.volcomponents <<Value>> \ 1747 [itcl::code $this AdjustSetting -current] 1796 [itcl::code $this AdjustSetting colormap] 1748 1797 1749 1798 blt::table $inner \ 1750 0,0 $inner.volcomponents_l -anchor e -cspan 2 \ 1751 0,2 $inner.volcomponents -cspan 3 -fill x \ 1799 0,0 $inner.vol -cspan 4 -anchor w -pady 2 \ 1752 1800 1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \ 1753 1801 2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \ 1754 3,0 $inner.visibility -cspan 4 -anchor w -pady 2 \ 1755 4,0 $inner.dim -anchor e -pady 2 \ 1756 4,1 $inner.light -cspan 2 -pady 2 -fill x \ 1757 4,3 $inner.bright -anchor w -pady 2 \ 1758 5,0 $inner.fog -anchor e -pady 2 \ 1759 5,1 $inner.transp -cspan 2 -pady 2 -fill x \ 1760 5,3 $inner.plastic -anchor w -pady 2 \ 1761 6,0 $inner.thin -anchor e -pady 2 \ 1762 6,1 $inner.thickness -cspan 2 -pady 2 -fill x\ 1763 6,3 $inner.thick -anchor w -pady 2 1802 3,0 $inner.dim -anchor e -pady 2 \ 1803 3,1 $inner.light -cspan 2 -pady 2 -fill x \ 1804 3,3 $inner.bright -anchor w -pady 2 \ 1805 4,0 $inner.fog -anchor e -pady 2 \ 1806 4,1 $inner.transp -cspan 2 -pady 2 -fill x \ 1807 4,3 $inner.plastic -anchor w -pady 2 \ 1808 5,0 $inner.thin -anchor e -pady 2 \ 1809 5,1 $inner.thickness -cspan 2 -pady 2 -fill x\ 1810 5,3 $inner.thick -anchor w -pady 2 1764 1811 1765 1812 blt::table configure $inner c0 c1 c3 r* -resize none 1766 blt::table configure $inner r 7-resize expand1813 blt::table configure $inner r6 -resize expand 1767 1814 } 1768 1815 … … 1773 1820 $inner configure -borderwidth 4 1774 1821 1775 checkbutton $inner.visible \1776 -text "Show Cutplanes" \1777 -variable [itcl::scope _settings(-cutplanesvisible)] \1778 -command [itcl::code $this AdjustSetting -cutplanesvisible] \1779 -font "Arial 9"1780 1781 1822 # X-value slicer... 1782 1823 itk_component add xCutButton { … … 1784 1825 -onimage [Rappture::icon x-cutplane] \ 1785 1826 -offimage [Rappture::icon x-cutplane] \ 1786 -command [itcl::code $this AdjustSetting -xcutplanevisible] \1787 -variable [itcl::scope _settings( -xcutplanevisible)]1827 -command [itcl::code $this AdjustSetting xcutplane] \ 1828 -variable [itcl::scope _settings($this-xcutplane)] 1788 1829 } 1789 1830 Rappture::Tooltip::for $itk_component(xCutButton) \ 1790 1831 "Toggle the X cut plane on/off" 1791 $itk_component(xCutButton) select1792 1832 1793 1833 itk_component add xCutScale { … … 1796 1836 -borderwidth 1 -highlightthickness 0 \ 1797 1837 -command [itcl::code $this Slice move x] \ 1798 -variable [itcl::scope _settings( -xcutplaneposition)]1838 -variable [itcl::scope _settings($this-xcutposition)] 1799 1839 } { 1800 1840 usual … … 1812 1852 -onimage [Rappture::icon y-cutplane] \ 1813 1853 -offimage [Rappture::icon y-cutplane] \ 1814 -command [itcl::code $this AdjustSetting -ycutplanevisible] \1815 -variable [itcl::scope _settings( -ycutplanevisible)]1854 -command [itcl::code $this AdjustSetting ycutplane] \ 1855 -variable [itcl::scope _settings($this-ycutplane)] 1816 1856 } 1817 1857 Rappture::Tooltip::for $itk_component(yCutButton) \ 1818 1858 "Toggle the Y cut plane on/off" 1819 $itk_component(yCutButton) select1820 1859 1821 1860 itk_component add yCutScale { … … 1824 1863 -borderwidth 1 -highlightthickness 0 \ 1825 1864 -command [itcl::code $this Slice move y] \ 1826 -variable [itcl::scope _settings( -ycutplaneposition)]1865 -variable [itcl::scope _settings($this-ycutposition)] 1827 1866 } { 1828 1867 usual … … 1840 1879 -onimage [Rappture::icon z-cutplane] \ 1841 1880 -offimage [Rappture::icon z-cutplane] \ 1842 -command [itcl::code $this AdjustSetting -zcutplanevisible] \1843 -variable [itcl::scope _settings( -zcutplanevisible)]1881 -command [itcl::code $this AdjustSetting zcutplane] \ 1882 -variable [itcl::scope _settings($this-zcutplane)] 1844 1883 } 1845 1884 Rappture::Tooltip::for $itk_component(zCutButton) \ 1846 1885 "Toggle the Z cut plane on/off" 1847 $itk_component(zCutButton) select1848 1886 1849 1887 itk_component add zCutScale { … … 1852 1890 -borderwidth 1 -highlightthickness 0 \ 1853 1891 -command [itcl::code $this Slice move z] \ 1854 -variable [itcl::scope _settings( -zcutplaneposition)]1892 -variable [itcl::scope _settings($this-zcutposition)] 1855 1893 } { 1856 1894 usual … … 1859 1897 $itk_component(zCutScale) set 50 1860 1898 $itk_component(zCutScale) configure -state disabled 1899 #$itk_component(zCutScale) configure -state disabled 1861 1900 Rappture::Tooltip::for $itk_component(zCutScale) \ 1862 1901 "@[itcl::code $this SlicerTip z]" 1863 1902 1864 1903 blt::table $inner \ 1865 0,1 $inner.visible -anchor w -pady 2 -cspan 4 \ 1866 1,1 $itk_component(xCutScale) \ 1867 1,2 $itk_component(yCutScale) \ 1868 1,3 $itk_component(zCutScale) \ 1869 2,1 $itk_component(xCutButton) \ 1870 2,2 $itk_component(yCutButton) \ 1871 2,3 $itk_component(zCutButton) 1872 1873 blt::table configure $inner r0 r1 r2 c* -resize none 1874 blt::table configure $inner r3 c4 -resize expand 1904 1,1 $itk_component(xCutButton) \ 1905 1,2 $itk_component(yCutButton) \ 1906 1,3 $itk_component(zCutButton) \ 1907 0,1 $itk_component(xCutScale) \ 1908 0,2 $itk_component(yCutScale) \ 1909 0,3 $itk_component(zCutScale) 1910 1911 blt::table configure $inner r0 r1 c* -resize none 1912 blt::table configure $inner r2 c4 -resize expand 1875 1913 blt::table configure $inner c0 -width 2 1876 1914 blt::table configure $inner c1 c2 c3 -padx 2 … … 1895 1933 0,0 $inner.view_l -anchor e -pady 2 \ 1896 1934 0,1 $inner.view -anchor w -pady 2 1897 blt::table configure $inner r0 -resize none1898 1935 1899 1936 set row 1 … … 1902 1939 label $inner.${tag}label -text $tag -font "Arial 9" 1903 1940 entry $inner.${tag} -font "Arial 9" -bg white \ 1904 -textvariable [itcl::scope _settings( -$tag)]1941 -textvariable [itcl::scope _settings($this-$tag)] 1905 1942 bind $inner.${tag} <Return> \ 1906 [itcl::code $this camera set -${tag}]1943 [itcl::code $this camera set ${tag}] 1907 1944 bind $inner.${tag} <KP_Enter> \ 1908 [itcl::code $this camera set -${tag}]1945 [itcl::code $this camera set ${tag}] 1909 1946 blt::table $inner \ 1910 1947 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1914 1951 } 1915 1952 1916 blt::table configure $inner c* -resize none1953 blt::table configure $inner c* r* -resize none 1917 1954 blt::table configure $inner c2 -resize expand 1918 1955 blt::table configure $inner r$row -resize expand … … 1955 1992 itcl::body Rappture::NanovisViewer::SlicerTip {axis} { 1956 1993 set val [$itk_component(${axis}CutScale) get] 1994 # set val [expr {0.01*($val-50) 1995 # *($_limits(${axis}max)-$_limits(${axis}min)) 1996 # + 0.5*($_limits(${axis}max)+$_limits(${axis}min))}] 1957 1997 return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%" 1958 1998 } … … 1975 2015 } 1976 2016 1977 itcl::body Rappture::NanovisViewer::EventuallyRe drawLegend {} {2017 itcl::body Rappture::NanovisViewer::EventuallyResizeLegend {} { 1978 2018 if { !$_resizeLegendPending } { 1979 2019 $_dispatcher event -idle !legend … … 1990 2030 } 1991 2031 "set" { 1992 set wh at[lindex $args 0]1993 set x $_settings($ what)2032 set who [lindex $args 0] 2033 set x $_settings($this-$who) 1994 2034 set code [catch { string is double $x } result] 1995 2035 if { $code != 0 || !$result } { 1996 set _settings($ what) $_view($what)2036 set _settings($this-$who) $_view($who) 1997 2037 return 1998 2038 } 1999 switch -- $wh at{2000 " -xpan" - "-ypan" {2001 set _view($wh at) $_settings($what)2039 switch -- $who { 2040 "xpan" - "ypan" { 2041 set _view($who) $_settings($this-$who) 2002 2042 PanCamera 2003 2043 } 2004 " -qx" - "-qy" - "-qz" - "-qw" {2005 set _view($wh at) $_settings($what)2006 set q [ ViewToQuaternion]2044 "qx" - "qy" - "qz" - "qw" { 2045 set _view($who) $_settings($this-$who) 2046 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2007 2047 $_arcball quaternion $q 2008 2048 SendCmd "camera orient $q" 2009 2049 } 2010 " -zoom" {2011 set _view($wh at) $_settings($what)2012 SendCmd "camera zoom $_view( $what)"2050 "zoom" { 2051 set _view($who) $_settings($this-$who) 2052 SendCmd "camera zoom $_view(zoom)" 2013 2053 } 2014 2054 } … … 2050 2090 array set info $vol 2051 2091 set name $info(name) 2052 if { ![info exists _settings( -volumevisible-$name)] } {2053 set _settings( -volumevisible-$name) $info(hide)2092 if { ![info exists _settings($this-volume-$name)] } { 2093 set _settings($this-volume-$name) $info(hide) 2054 2094 } 2055 2095 checkbutton $inner.vol$row -text $info(label) \ 2056 -variable [itcl::scope _settings( -volumevisible-$name)] \2096 -variable [itcl::scope _settings($this-volume-$name)] \ 2057 2097 -onvalue 0 -offvalue 1 \ 2058 -command [itcl::code $this ToggleVolume $key $name] \2098 -command [itcl::code $this volume $key $name] \ 2059 2099 -font "Arial 9" 2060 2100 Rappture::Tooltip::for $inner.vol$row $info(description) 2061 2101 blt::table $inner $row,0 $inner.vol$row -anchor w 2062 if { !$_settings( -volume-$name) } {2102 if { !$_settings($this-volume-$name) } { 2063 2103 $inner.vol$row select 2064 2104 } … … 2071 2111 } 2072 2112 2073 itcl::body Rappture::NanovisViewer:: ToggleVolume { tag name } {2074 set bool $_settings( -volumevisible-$name)2075 SendCmd "volume stat e $bool $name"2113 itcl::body Rappture::NanovisViewer::volume { tag name } { 2114 set bool $_settings($this-volume-$name) 2115 SendCmd "volume statue $bool $name" 2076 2116 } 2077 2117 … … 2085 2125 bottom "0.707107 0.707107 0 0" 2086 2126 } 2087 foreach name { -qw -qx -qy -qz } value $positions($side) {2127 foreach name { qw qx qy qz } value $positions($side) { 2088 2128 set _view($name) $value 2089 2129 } 2090 set q [ ViewToQuaternion]2130 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2091 2131 $_arcball quaternion $q 2092 2132 SendCmd "camera orient $q" 2093 2133 SendCmd "camera reset" 2094 set _view(-xpan) 0 2095 set _view(-ypan) 0 2096 set _view(-zoom) 1.0 2097 set _settings(-xpan) $_view(-xpan) 2098 set _settings(-ypan) $_view(-ypan) 2099 set _settings(-zoom) $_view(-zoom) 2100 } 2101 2102 2103 # 2104 # InitComponentSettings -- 2105 # 2106 # Initializes the volume settings for a specific component. This should 2107 # match what's used as global settings above. This is called the first 2108 # time we try to switch to a given component in SwitchComponent below. 2109 # 2110 itcl::body Rappture::NanovisViewer::InitComponentSettings { cname } { 2111 foreach {key value} { 2112 -colormap "default" 2113 -light 40 2114 -light2side 1 2115 -thickness 350 2116 -volumeopacity 1.0 2117 -volumevisible 1 2118 } { 2119 if { ![info exists _settings($cname${key})] } { 2120 # Don't override existing component settings 2121 set _settings($cname${key}) $value 2122 } 2123 } 2124 } 2125 2126 # 2127 # SwitchComponent -- 2128 # 2129 # This is called when the current component is changed by the dropdown 2130 # menu in the volume tab. It synchronizes the global volume settings 2131 # with the settings of the new current component. 2132 # 2133 itcl::body Rappture::NanovisViewer::SwitchComponent { cname } { 2134 if { ![info exists _settings($cname-light)] } { 2135 InitComponentSettings $cname 2136 } 2137 if { $_settings(-colormap) != $_settings($cname-colormap) } { 2138 set _settings(-colormap) $_settings($cname-colormap) 2139 EventuallyRedrawLegend 2140 } 2141 # _settings variables change widgets, except for colormap 2142 set _settings(-light) $_settings($cname-light) 2143 set _settings(-light2side) $_settings($cname-light2side) 2144 set _settings(-volumeopacity) $_settings($cname-volumeopacity) 2145 set _settings(-thickness) $_settings($cname-thickness) 2146 set _settings(-volumevisible) $_settings($cname-volumevisible) 2147 $itk_component(colormap) value $_settings($cname-colormap) 2148 2149 set _widget(-volumeopacity) [expr $_settings(-volumeopacity) * 100.0] 2150 2151 set _current $cname; # Reset the current component 2152 } 2153 2154 # 2155 # BuildVolumeComponents -- 2156 # 2157 # This is called from the "scale" method which is called when a new 2158 # dataset is added or deleted. It repopulates the dropdown menu of 2159 # volume component names. It sets the current component to the first 2160 # component in the list (of components found). Finally, if there is 2161 # only one component, don't display the label or the combobox in the 2162 # volume settings tab. 2163 # 2164 itcl::body Rappture::NanovisViewer::BuildVolumeComponents {} { 2165 $itk_component(volcomponents) choices delete 0 end 2166 foreach name $_componentsList { 2167 $itk_component(volcomponents) choices insert end $name $name 2168 } 2169 set _current [lindex $_componentsList 0] 2170 $itk_component(volcomponents) value $_current 2171 set parent [winfo parent $itk_component(volcomponents)] 2172 if { [llength $_componentsList] <= 1 } { 2173 # Unpack the components label and dropdown if there's only one 2174 # component. 2175 blt::table forget $parent.volcomponents_l $parent.volcomponents 2176 } else { 2177 # Pack the components label and dropdown into the table there's 2178 # more than one component to select. 2179 blt::table $parent \ 2180 0,0 $parent.volcomponents_l -anchor e -cspan 2 \ 2181 0,2 $parent.volcomponents -cspan 3 -fill x 2182 } 2183 } 2184 2185 # 2186 # GetDatasetsWithComponents -- 2187 # 2188 # Returns a list of all the datasets (known by the combination of their 2189 # data object and component name) that match the given component name. 2190 # For example, this is used where we want to change the settings of 2191 # volumes that have the current component. 2192 # 2193 itcl::body Rappture::NanovisViewer::GetDatasetsWithComponent { cname } { 2194 if { ![info exists _volcomponents($cname)] } { 2195 return "" 2196 } 2197 set list "" 2198 foreach tag $_volcomponents($cname) { 2199 if { ![info exists _serverDatasets($tag)] } { 2200 continue 2201 } 2202 lappend list $tag 2203 } 2204 return $list 2205 } 2206 2207 # 2208 # HideAllMarkers -- 2209 # 2210 # Hide all the markers in all the transfer functions. Can't simply 2211 # delete and recreate markers from the <style> since the user may have 2212 # created, deleted, or moved markers. 2213 # 2214 itcl::body Rappture::NanovisViewer::HideAllMarkers {} { 2215 foreach cname [array names _transferFunctionEditors] { 2216 $_transferFunctionEditors($cname) hideMarkers 2217 } 2218 } 2219 2220 itcl::body Rappture::NanovisViewer::GetColormap { cname color } { 2221 if { $color == "default" } { 2222 return $_cname2defaultcolormap($cname) 2223 } 2224 return [ColorsToColormap $color] 2225 } 2226 2227 itcl::body Rappture::NanovisViewer::GetAlphamap { cname name } { 2228 if { $name == "default" } { 2229 return $_cname2defaultalphamap($cname) 2230 } 2231 return [NameToAlphamap $name] 2232 } 2233 2234 itcl::body Rappture::NanovisViewer::ResetColormap { cname color } { 2235 # Get the current transfer function 2236 if { ![info exists _cname2transferFunction($cname)] } { 2237 return 2238 } 2239 foreach { cmap wmap } $_cname2transferFunction($cname) break 2240 set cmap [GetColormap $cname $color] 2241 set _cname2transferFunction($cname) [list $cmap $wmap] 2242 SendCmd [list transfunc define $cname $cmap $wmap] 2243 EventuallyRedrawLegend 2244 } 2245 2246 itcl::body Rappture::NanovisViewer::ComputeAlphamap { cname } { 2247 if { ![info exists _transferFunctionEditors($cname)] } { 2248 return [list 0.0 0.0 1.0 1.0] 2249 } 2250 if { ![info exists _settings($cname-light)] } { 2251 InitComponentSettings $cname 2252 } 2253 2254 set isovalues [$_transferFunctionEditors($cname) values] 2255 2256 # Transfer function should be normalized with [0,1] range 2257 # The volume shading opacity setting is used to scale opacity 2258 # in the volume shader. 2259 set max 1.0 2260 2261 # Use the component-wise thickness setting from the slider 2262 # settings widget 2263 # Scale values between 0.00001 and 0.01000 2264 set delta [expr {double($_settings($cname-thickness)) * 0.0001}] 2265 2266 set first [lindex $isovalues 0] 2267 set last [lindex $isovalues end] 2268 set wmap "" 2269 if { $first == "" || $first != 0.0 } { 2270 lappend wmap 0.0 0.0 2271 } 2272 foreach x $isovalues { 2273 set x1 [expr {$x-$delta-0.00001}] 2274 set x2 [expr {$x-$delta}] 2275 set x3 [expr {$x+$delta}] 2276 set x4 [expr {$x+$delta+0.00001}] 2277 if { $x1 < 0.0 } { 2278 set x1 0.0 2279 } elseif { $x1 > 1.0 } { 2280 set x1 1.0 2281 } 2282 if { $x2 < 0.0 } { 2283 set x2 0.0 2284 } elseif { $x2 > 1.0 } { 2285 set x2 1.0 2286 } 2287 if { $x3 < 0.0 } { 2288 set x3 0.0 2289 } elseif { $x3 > 1.0 } { 2290 set x3 1.0 2291 } 2292 if { $x4 < 0.0 } { 2293 set x4 0.0 2294 } elseif { $x4 > 1.0 } { 2295 set x4 1.0 2296 } 2297 # add spikes in the middle 2298 lappend wmap $x1 0.0 2299 lappend wmap $x2 $max 2300 lappend wmap $x3 $max 2301 lappend wmap $x4 0.0 2302 } 2303 if { $last == "" || $last != 1.0 } { 2304 lappend wmap 1.0 0.0 2305 } 2306 return $wmap 2307 } 2308 2309 itcl::body Rappture::NanovisViewer::NameToAlphamap { name } { 2310 switch -- $name { 2311 "ramp-up" { 2312 set wmap { 2313 0.0 0.0 2314 1.0 1.0 2315 } 2316 } 2317 "ramp-down" { 2318 set wmap { 2319 0.0 1.0 2320 1.0 0.0 2321 } 2322 } 2323 "vee" { 2324 set wmap { 2325 0.0 1.0 2326 0.5 0.0 2327 1.0 1.0 2328 } 2329 } 2330 "tent-1" { 2331 set wmap { 2332 0.0 0.0 2333 0.5 1.0 2334 1.0 0.0 2335 } 2336 } 2337 "tent-2" { 2338 set wmap { 2339 0.0 0.0 2340 0.25 1.0 2341 0.5 0.0 2342 0.75 1.0 2343 1.0 0.0 2344 } 2345 } 2346 "tent-3" { 2347 set wmap { 2348 0.0 0.0 2349 0.16666 1.0 2350 0.33333 0.0 2351 0.5 1.0 2352 0.66666 0.0 2353 0.83333 1.0 2354 1.0 0.0 2355 } 2356 } 2357 "tent-4" { 2358 set wmap { 2359 0.0 0.0 2360 0.125 1.0 2361 0.25 0.0 2362 0.375 1.0 2363 0.5 0.0 2364 0.625 1.0 2365 0.75 0.0 2366 0.875 1.0 2367 1.0 0.0 2368 } 2369 } 2370 "sinusoid-1" { 2371 set wmap { 2372 0.0 0.000 0.600 0.800 2373 0.14285714285714285 0.400 0.900 1.000 2374 0.2857142857142857 0.600 1.000 1.000 2375 0.42857142857142855 0.800 1.000 1.000 2376 0.5714285714285714 0.900 0.900 0.900 2377 0.7142857142857143 0.600 0.600 0.600 2378 0.8571428571428571 0.400 0.400 0.400 2379 1.0 0.200 0.200 0.200 2380 } 2381 } 2382 "sinusoid-2" { 2383 set wmap { 2384 0.0 0.900 1.000 1.000 2385 0.1111111111111111 0.800 0.983 1.000 2386 0.2222222222222222 0.700 0.950 1.000 2387 0.3333333333333333 0.600 0.900 1.000 2388 0.4444444444444444 0.500 0.833 1.000 2389 0.5555555555555556 0.400 0.750 1.000 2390 0.6666666666666666 0.300 0.650 1.000 2391 0.7777777777777778 0.200 0.533 1.000 2392 0.8888888888888888 0.100 0.400 1.000 2393 1.0 0.000 0.250 1.000 2394 } 2395 } 2396 "sinusoid-6" { 2397 set wmap { 2398 0.0 0.200 0.100 0.000 2399 0.09090909090909091 0.400 0.187 0.000 2400 0.18181818181818182 0.600 0.379 0.210 2401 0.2727272727272727 0.800 0.608 0.480 2402 0.36363636363636365 0.850 0.688 0.595 2403 0.45454545454545453 0.950 0.855 0.808 2404 0.5454545454545454 0.800 0.993 1.000 2405 0.6363636363636364 0.600 0.973 1.000 2406 0.7272727272727273 0.400 0.940 1.000 2407 0.8181818181818182 0.200 0.893 1.000 2408 0.9090909090909091 0.000 0.667 0.800 2409 1.0 0.000 0.480 0.600 2410 } 2411 } 2412 "sinusoid-10" { 2413 set wmap { 2414 0.0 0.000 0.480 0.600 2415 0.09090909090909091 0.000 0.667 0.800 2416 0.18181818181818182 0.200 0.893 1.000 2417 0.2727272727272727 0.400 0.940 1.000 2418 0.36363636363636365 0.600 0.973 1.000 2419 0.45454545454545453 0.800 0.993 1.000 2420 0.5454545454545454 0.950 0.855 0.808 2421 0.6363636363636364 0.850 0.688 0.595 2422 0.7272727272727273 0.800 0.608 0.480 2423 0.8181818181818182 0.600 0.379 0.210 2424 0.9090909090909091 0.400 0.187 0.000 2425 1.0 0.200 0.100 0.000 2426 } 2427 } 2428 "step-2" { 2429 set wmap { 2430 0.0 0.000 0.167 1.000 2431 0.09090909090909091 0.100 0.400 1.000 2432 0.18181818181818182 0.200 0.600 1.000 2433 0.2727272727272727 0.400 0.800 1.000 2434 0.36363636363636365 0.600 0.933 1.000 2435 0.45454545454545453 0.800 1.000 1.000 2436 0.5454545454545454 1.000 1.000 0.800 2437 0.6363636363636364 1.000 0.933 0.600 2438 0.7272727272727273 1.000 0.800 0.400 2439 0.8181818181818182 1.000 0.600 0.200 2440 0.9090909090909091 1.000 0.400 0.100 2441 1.0 1.000 0.167 0.000 2442 } 2443 } 2444 "step-5" { 2445 set wmap { 2446 0.0 1.000 0.167 0.000 2447 0.09090909090909091 1.000 0.400 0.100 2448 0.18181818181818182 1.000 0.600 0.200 2449 0.2727272727272727 1.000 0.800 0.400 2450 0.36363636363636365 1.000 0.933 0.600 2451 0.45454545454545453 1.000 1.000 0.800 2452 0.5454545454545454 0.800 1.000 1.000 2453 0.6363636363636364 0.600 0.933 1.000 2454 0.7272727272727273 0.400 0.800 1.000 2455 0.8181818181818182 0.200 0.600 1.000 2456 0.9090909090909091 0.100 0.400 1.000 2457 1.0 0.000 0.167 1.000 2458 } 2459 } 2460 "step-12" { 2461 set wmap { 2462 "#EE82EE" 2463 "#4B0082" 2464 "blue" 2465 "#008000" 2466 "yellow" 2467 "#FFA500" 2468 "red" 2469 } 2470 } 2471 default { 2472 } 2473 } 2474 return "" 2475 } 2476 2477 itcl::body Rappture::NanovisViewer::SetObjectStyle { dataobj cname } { 2478 array set styles { 2479 -opacity 0.5 2480 } 2481 array set styles [lindex [$dataobj components -style $cname] 0] 2482 set _settings($cname-volumeopacity) $styles(-opacity) 2483 set tag $dataobj-$cname 2484 SendCmd "volume shading opacity $_settings($cname-volumeopacity) $tag" 2485 NameTransferFunction $dataobj $cname 2486 } 2134 set _view(xpan) 0 2135 set _view(ypan) 0 2136 set _view(zoom) 1.0 2137 set _settings($this-xpan) $_view(xpan) 2138 set _settings($this-ypan) $_view(ypan) 2139 set _settings($this-zoom) $_view(zoom) 2140 } 2141 -
branches/1.3/gui/scripts/vtkglyphviewer.tcl
r4768 r4848 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 3 # ---------------------------------------------------------------------- 3 4 # COMPONENT: vtkglyphviewer - Vtk 3D glyphs object viewer … … 7 8 # ====================================================================== 8 9 # AUTHOR: Michael McLennan, Purdue University 9 # Copyright (c) 2004-20 14 HUBzero Foundation, LLC10 # Copyright (c) 2004-2005 Purdue Research Foundation 10 11 # 11 12 # See the file "license.terms" for information on usage and … … 57 58 public method get {args} 58 59 public method isconnected {} 60 public method limits { colormap } 59 61 public method parameters {title args} { 60 62 # do nothing … … 62 64 public method scale {args} 63 65 66 protected method Connect {} 67 protected method CurrentDatasets {args} 68 protected method Disconnect {} 69 protected method DoResize {} 70 protected method DoRotate {} 71 protected method AdjustSetting {what {value ""}} 72 protected method InitSettings { args } 73 protected method Pan {option x y} 74 protected method Pick {x y} 75 protected method Rebuild {} 76 protected method ReceiveDataset { args } 77 protected method ReceiveImage { args } 78 protected method ReceiveLegend { colormap title vmin vmax size } 79 protected method Rotate {option x y} 80 protected method Zoom {option} 81 64 82 # The following methods are only used by this class. 65 private method AdjustSetting {what {value ""}}66 83 private method BuildAxisTab {} 67 84 private method BuildCameraTab {} … … 72 89 private method DrawLegend {} 73 90 private method Combo { option } 74 private method Connect {}75 private method CurrentDatasets {args}76 private method Disconnect {}77 private method DoResize {}78 private method DoRotate {}79 91 private method EnterLegend { x y } 80 92 private method EventuallyResize { w h } … … 84 96 private method GetImage { args } 85 97 private method GetVtkData { args } 86 private method InitSettings { args }87 98 private method IsValidObject { dataobj } 88 99 private method LeaveLegend {} 89 100 private method MotionLegend { x y } 90 private method Pan {option x y}91 101 private method PanCamera {} 92 private method Pick {x y}93 private method QuaternionToView { q } {94 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break95 }96 private method Rebuild {}97 private method ReceiveDataset { args }98 private method ReceiveImage { args }99 private method ReceiveLegend { colormap title vmin vmax size }100 102 private method RequestLegend {} 101 private method Rotate {option x y}102 103 private method SetLegendTip { x y } 103 104 private method SetObjectStyle { dataobj comp } … … 105 106 private method SetCurrentColormap { color } 106 107 private method SetOrientation { side } 107 private method ViewToQuaternion {} {108 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]109 }110 private method Zoom {option}111 108 112 109 private variable _arcball "" … … 122 119 # heightmaps displayed. 123 120 private variable _currentColormap "" 121 private variable _currentOpacity "" 124 122 125 123 private variable _dataset2style ;# maps dataobj-component to transfunc … … 148 146 private variable _legendPending 0 149 147 private variable _field "" 150 private variable _colorMode "vmag"; 148 private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar) 151 149 private variable _fieldNames {} 152 150 private variable _fields … … 186 184 $_dispatcher register !xcutplane 187 185 $_dispatcher dispatch $this !xcutplane \ 188 "[itcl::code $this AdjustSetting -cutplanexposition]; list"186 "[itcl::code $this AdjustSetting cutplaneXPosition]; list" 189 187 190 188 # Y-Cutplane event 191 189 $_dispatcher register !ycutplane 192 190 $_dispatcher dispatch $this !ycutplane \ 193 "[itcl::code $this AdjustSetting -cutplaneyposition]; list"191 "[itcl::code $this AdjustSetting cutplaneYPosition]; list" 194 192 195 193 # Z-Cutplane event 196 194 $_dispatcher register !zcutplane 197 195 $_dispatcher dispatch $this !zcutplane \ 198 "[itcl::code $this AdjustSetting -cutplanezposition]; list"196 "[itcl::code $this AdjustSetting cutplaneZPosition]; list" 199 197 200 198 # … … 207 205 # Initialize the view to some default parameters. 208 206 array set _view { 209 -ortho 0210 -qw 0.853553211 -qx -0.353553212 -qy 0.353553213 -qz 0.146447214 -xpan 0215 -ypan 0216 -zoom 1.0207 qw 0.853553 208 qx -0.353553 209 qy 0.353553 210 qz 0.146447 211 zoom 1.0 212 xpan 0 213 ypan 0 214 ortho 0 217 215 } 218 216 set _arcball [blt::arcball create 100 100] 219 $_arcball quaternion [ViewToQuaternion] 217 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 218 $_arcball quaternion $q 220 219 221 220 array set _settings [subst { 222 -axesvisible 1 223 -axislabels 1 224 -axisminorticks 1 225 -axismode "static" 226 -background black 227 -colormap BCGYR 228 -colormapvisible 1 229 -cutplaneedges 0 230 -cutplanelighting 1 231 -cutplanepreinterp 1 232 -cutplaneopacity 100 233 -cutplanevisible 0 234 -cutplanewireframe 0 235 -cutplanexposition 50 236 -cutplanexvisible 1 237 -cutplaneyposition 50 238 -cutplaneyvisible 1 239 -cutplanezposition 50 240 -cutplanezvisible 1 241 -field "Default" 242 -glyphedges 0 243 -glyphlighting 1 244 -glyphnormscale 1 245 -glyphopacity 100 246 -glyphorient 1 247 -glyphoutline 0 248 -glyphscale 1 249 -glyphscalemode "vmag" 250 -glyphshape "arrow" 251 -glyphvisible 1 252 -glyphwireframe 0 253 -legendvisible 1 254 -saveglyphopacity 100 255 -xgrid 0 256 -ygrid 0 257 -zgrid 0 221 background black 222 colormap BCGYR 223 colormapVisible 1 224 field "Default" 225 axesVisible 1 226 axisLabelsVisible 1 227 axisXGrid 0 228 axisYGrid 0 229 axisZGrid 0 230 cutplaneEdges 0 231 cutplaneLighting 1 232 cutplanePreinterp 1 233 cutplaneOpacity 100 234 cutplaneVisible 0 235 cutplaneWireframe 0 236 cutplaneXPosition 50 237 cutplaneXVisible 1 238 cutplaneYPosition 50 239 cutplaneYVisible 1 240 cutplaneZPosition 50 241 cutplaneZVisible 1 242 glyphEdges 0 243 glyphLighting 1 244 glyphOpacity 100 245 saveGlyphOpacity 100 246 glyphOutline 0 247 glyphVisible 1 248 glyphWireframe 0 249 legendVisible 1 258 250 }] 259 251 array set _changed { 260 -colormap0261 -glyphopacity0252 glyphOpacity 0 253 colormap 0 262 254 } 263 255 … … 339 331 -onimage [Rappture::icon volume-on] \ 340 332 -offimage [Rappture::icon volume-off] \ 341 -variable [itcl::scope _settings( -glyphvisible)] \342 -command [itcl::code $this AdjustSetting -glyphvisible]333 -variable [itcl::scope _settings(glyphVisible)] \ 334 -command [itcl::code $this AdjustSetting glyphVisible] 343 335 } 344 336 $itk_component(glyphs) select … … 352 344 -onimage [Rappture::icon cutbutton] \ 353 345 -offimage [Rappture::icon cutbutton] \ 354 -variable [itcl::scope _settings( -cutplanevisible)] \355 -command [itcl::code $this AdjustSetting -cutplanevisible]346 -variable [itcl::scope _settings(cutplaneVisible)] \ 347 -command [itcl::code $this AdjustSetting cutplaneVisible] 356 348 } 357 349 Rappture::Tooltip::for $itk_component(cutplane) \ … … 443 435 eval itk_initialize $args 444 436 Connect 437 update 445 438 } 446 439 … … 470 463 471 464 itcl::body Rappture::VtkGlyphViewer::DoRotate {} { 472 SendCmd "camera orient [ViewToQuaternion]" 465 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 466 SendCmd "camera orient $q" 473 467 set _rotatePending 0 474 468 } … … 494 488 495 489 itcl::body Rappture::VtkGlyphViewer::EventuallyRotate { q } { 496 QuaternionToView $q490 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 497 491 if { !$_rotatePending } { 498 492 set _rotatePending 1 … … 549 543 } 550 544 545 551 546 # ---------------------------------------------------------------------- 552 547 # USAGE: delete ?<dataobj1> <dataobj2> ...? 553 548 # 554 # Clients use this to delete a dataobj from the plot. If no dataobjs555 # are specified, then all dataobjs are deleted. No data objects are556 # deleted. They are only removed from the display list.549 # Clients use this to delete a dataobj from the plot. If no dataobjs 550 # are specified, then all dataobjs are deleted. No data objects are 551 # deleted. They are only removed from the display list. 557 552 # 558 553 # ---------------------------------------------------------------------- … … 804 799 # isconnected -- 805 800 # 806 # Indicates if we are currently connected to the visualization server.801 # Indicates if we are currently connected to the visualization server. 807 802 # 808 803 itcl::body Rappture::VtkGlyphViewer::isconnected {} { … … 821 816 # Disconnect -- 822 817 # 823 # Clients use this method to disconnect from the current rendering824 # server.818 # Clients use this method to disconnect from the current rendering 819 # server. 825 820 # 826 821 itcl::body Rappture::VtkGlyphViewer::Disconnect {} { … … 839 834 array unset _data 840 835 array unset _colormaps 836 array unset _seeds 841 837 array unset _dataset2style 842 838 array unset _obj2datasets … … 860 856 if { $info(-type) == "image" } { 861 857 if 0 { 862 set f [open "last.ppm" "w"] 863 fconfigure $f -encoding binary 864 puts -nonewline $f $bytes 858 set f [open "last.ppm" "w"] 859 puts $f $bytes 865 860 close $f 866 861 } … … 950 945 # Reset the camera and other view parameters 951 946 # 952 $_arcball quaternion [ViewToQuaternion] 953 if {$_view(-ortho)} { 947 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 948 $_arcball quaternion $q 949 if {$_view(ortho)} { 954 950 SendCmd "camera mode ortho" 955 951 } else { … … 959 955 PanCamera 960 956 set _first "" 961 InitSettings -xgrid -ygrid -zgrid -axismode \ 962 -axesvisible -axislabels -axisminorticks 963 #SendCmd "axis lformat all %g" 957 InitSettings axisXGrid axisYGrid axisZGrid axisMode \ 958 axesVisible axisLabelsVisible 959 foreach axis { x y z } { 960 SendCmd "axis lformat $axis %g" 961 } 964 962 StopBufferingCommands 965 963 SendCmd "imgflush" … … 977 975 if { ![info exists _datasets($tag)] } { 978 976 set bytes [$dataobj vtkdata $comp] 979 if 0 { 980 set f [open "/tmp/glyph.vtk" "w"] 981 fconfigure $f -translation binary -encoding binary 982 puts -nonewline $f $bytes 983 close $f 977 if 0 { 978 set f [open "/tmp/glyph.vtk" "w"] 979 puts $f $bytes 980 close $f 984 981 } 985 982 set length [string length $bytes] … … 996 993 SendCmd "clientinfo [list $info]" 997 994 } 998 SendCmd "dataset add $tag data follows $length"995 append _outbuf "dataset add $tag data follows $length\n" 999 996 append _outbuf $bytes 1000 997 set _datasets($tag) 1 … … 1005 1002 # Setting dataset visible enables outline 1006 1003 # and glyphs 1007 1004 SendCmd "dataset visible 1 $tag" 1008 1005 } 1009 1006 } … … 1011 1008 1012 1009 if { $_first != "" } { 1013 1014 1015 1010 $itk_component(field) choices delete 0 end 1011 $itk_component(fieldmenu) delete 0 end 1012 array unset _fields 1016 1013 set _curFldName "" 1017 1014 foreach cname [$_first components] { … … 1039 1036 $itk_component(field) value $_curFldLabel 1040 1037 } 1041 InitSettings -glyphoutline1042 # -cutplanevisible1038 InitSettings glyphOutline 1039 #cutplaneVisible 1043 1040 if { $_reset } { 1044 1041 # These are settings that rely on a dataset being loaded. 1045 1042 InitSettings \ 1046 -field \ 1047 -glyphedges -glyphlighting -glyphopacity \ 1048 -glyphwireframe 1049 1050 #-cutplanexposition -cutplaneyposition -cutplanezposition \ 1051 -cutplanexvisible -cutplaneyvisible -cutplanezvisible \ 1052 -cutplanepreinterp 1043 glyphLighting \ 1044 field \ 1045 glyphEdges glyphLighting glyphOpacity \ 1046 glyphWireframe 1047 1048 #cutplaneXPosition cutplaneYPosition cutplaneZPosition \ 1049 cutplaneXVisible cutplaneYVisible cutplaneZVisible \ 1050 cutplanePreinterp 1053 1051 1054 1052 Zoom reset 1055 1053 foreach axis { x y z } { 1056 1054 # Another problem fixed by a <view>. We looking into a data 1057 1055 # object for the name of the axes. This should be global to 1058 1056 # the viewer itself. 1059 1060 1057 set label [$_first hints ${axis}label] 1058 if { $label == "" } { 1061 1059 set label [string toupper $axis] 1062 1063 1064 1060 } 1061 # May be a space in the axis label. 1062 SendCmd [list axis name $axis $label] 1065 1063 } 1066 1064 if { [array size _fields] < 2 } { 1067 catch {blt::table forget $itk_component(field) $itk_component(field_l)}1065 blt::table forget $itk_component(field) $itk_component(field_l) 1068 1066 } 1069 1067 set _reset 0 … … 1133 1131 switch -- $option { 1134 1132 "in" { 1135 set _view( -zoom) [expr {$_view(-zoom)*1.25}]1136 SendCmd "camera zoom $_view( -zoom)"1133 set _view(zoom) [expr {$_view(zoom)*1.25}] 1134 SendCmd "camera zoom $_view(zoom)" 1137 1135 } 1138 1136 "out" { 1139 set _view( -zoom) [expr {$_view(-zoom)*0.8}]1140 SendCmd "camera zoom $_view( -zoom)"1137 set _view(zoom) [expr {$_view(zoom)*0.8}] 1138 SendCmd "camera zoom $_view(zoom)" 1141 1139 } 1142 1140 "reset" { 1143 1141 array set _view { 1144 -qw0.8535531145 -qx-0.3535531146 -qy0.3535531147 -qz0.1464471148 -xpan01149 -ypan01150 -zoom 1.01142 qw 0.853553 1143 qx -0.353553 1144 qy 0.353553 1145 qz 0.146447 1146 zoom 1.0 1147 xpan 0 1148 ypan 0 1151 1149 } 1152 1150 if { $_first != "" } { … … 1156 1154 } 1157 1155 } 1158 $_arcball quaternion [ViewToQuaternion] 1156 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1157 $_arcball quaternion $q 1159 1158 DoRotate 1160 1159 SendCmd "camera reset" … … 1164 1163 1165 1164 itcl::body Rappture::VtkGlyphViewer::PanCamera {} { 1166 set x $_view( -xpan)1167 set y $_view( -ypan)1165 set x $_view(xpan) 1166 set y $_view(ypan) 1168 1167 SendCmd "camera pan $x $y" 1169 1168 } 1169 1170 1170 1171 1171 # ---------------------------------------------------------------------- … … 1223 1223 itcl::body Rappture::VtkGlyphViewer::Pick {x y} { 1224 1224 foreach tag [CurrentDatasets -visible] { 1225 SendCmd "dataset getscalar pixel $x $y $tag"1225 SendCmdNoSplash "dataset getscalar pixel $x $y $tag" 1226 1226 } 1227 1227 } … … 1242 1242 set x [expr $x / double($w)] 1243 1243 set y [expr $y / double($h)] 1244 set _view( -xpan) [expr $_view(-xpan) + $x]1245 set _view( -ypan) [expr $_view(-ypan) + $y]1244 set _view(xpan) [expr $_view(xpan) + $x] 1245 set _view(ypan) [expr $_view(ypan) + $y] 1246 1246 PanCamera 1247 1247 return … … 1265 1265 set _click(x) $x 1266 1266 set _click(y) $y 1267 set _view( -xpan) [expr $_view(-xpan) - $dx]1268 set _view( -ypan) [expr $_view(-ypan) - $dy]1267 set _view(xpan) [expr $_view(xpan) - $dx] 1268 set _view(ypan) [expr $_view(ypan) - $dy] 1269 1269 PanCamera 1270 1270 } … … 1288 1288 itcl::body Rappture::VtkGlyphViewer::InitSettings { args } { 1289 1289 foreach spec $args { 1290 if { [info exists _settings($_first ${spec})] } {1290 if { [info exists _settings($_first-$spec)] } { 1291 1291 # Reset global setting with dataobj specific setting 1292 set _settings($spec) $_settings($_first ${spec})1292 set _settings($spec) $_settings($_first-$spec) 1293 1293 } 1294 1294 AdjustSetting $spec … … 1299 1299 # AdjustSetting -- 1300 1300 # 1301 # Changes/updates a specific setting in the widget. There are1302 # usually user-setable option. Commands are sent to the render1303 # server.1301 # Changes/updates a specific setting in the widget. There are 1302 # usually user-setable option. Commands are sent to the render 1303 # server. 1304 1304 # 1305 1305 itcl::body Rappture::VtkGlyphViewer::AdjustSetting {what {value ""}} { … … 1308 1308 } 1309 1309 switch -- $what { 1310 " -background" {1310 "background" { 1311 1311 set bgcolor [$itk_component(background) value] 1312 1313 1314 1315 "grey""black"1316 1312 array set fgcolors { 1313 "black" "white" 1314 "white" "black" 1315 "grey" "black" 1316 } 1317 1317 configure -plotbackground $bgcolor \ 1318 1319 1320 1321 } 1322 " -axesvisible" {1323 set bool $_settings( $what)1318 -plotforeground $fgcolors($bgcolor) 1319 $itk_component(view) delete "legend" 1320 DrawLegend 1321 } 1322 "axesVisible" { 1323 set bool $_settings(axesVisible) 1324 1324 SendCmd "axis visible all $bool" 1325 1325 } 1326 " -axislabels" {1327 set bool $_settings( $what)1326 "axisLabelsVisible" { 1327 set bool $_settings(axisLabelsVisible) 1328 1328 SendCmd "axis labels all $bool" 1329 1329 } 1330 "-axisminorticks" { 1331 set bool $_settings($what) 1332 SendCmd "axis minticks all $bool" 1333 } 1334 "-xgrid" - "-ygrid" - "-zgrid" { 1335 set axis [string tolower [string range $what 1 1]] 1330 "axisXGrid" - "axisYGrid" - "axisZGrid" { 1331 set axis [string tolower [string range $what 4 4]] 1336 1332 set bool $_settings($what) 1337 1333 SendCmd "axis grid $axis $bool" 1338 1334 } 1339 " -axismode" {1335 "axisMode" { 1340 1336 set mode [$itk_component(axisMode) value] 1341 1337 set mode [$itk_component(axisMode) translate $mode] … … 1343 1339 SendCmd "axis flymode $mode" 1344 1340 } 1345 " -cutplaneedges" {1341 "cutplaneEdges" { 1346 1342 set bool $_settings($what) 1347 1343 SendCmd "cutplane edges $bool" 1348 1344 } 1349 " -cutplanevisible" {1345 "cutplaneVisible" { 1350 1346 set bool $_settings($what) 1351 SendCmd "cutplane visible 0" 1352 if { $bool } { 1353 foreach tag [CurrentDatasets -visible] { 1354 SendCmd "cutplane visible $bool $tag" 1355 } 1356 } 1357 } 1358 "-cutplanewireframe" { 1347 SendCmd "cutplane visible $bool" 1348 } 1349 "cutplaneWireframe" { 1359 1350 set bool $_settings($what) 1360 1351 SendCmd "cutplane wireframe $bool" 1361 1352 } 1362 " -cutplanelighting" {1353 "cutplaneLighting" { 1363 1354 set bool $_settings($what) 1364 1355 SendCmd "cutplane lighting $bool" 1365 1356 } 1366 " -cutplaneopacity" {1357 "cutplaneOpacity" { 1367 1358 set val $_settings($what) 1368 1359 set sval [expr { 0.01 * double($val) }] 1369 1360 SendCmd "cutplane opacity $sval" 1370 1361 } 1371 " -cutplanepreinterp" {1362 "cutplanePreinterp" { 1372 1363 set bool $_settings($what) 1373 1364 SendCmd "cutplane preinterp $bool" 1374 1365 } 1375 " -cutplanexvisible" - "-cutplaneyvisible" - "-cutplanezvisible" {1376 set axis [string tolower [string range $what 9 9]]1366 "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" { 1367 set axis [string tolower [string range $what 8 8]] 1377 1368 set bool $_settings($what) 1378 1369 if { $bool } { … … 1383 1374 -troughcolor grey82 1384 1375 } 1385 1386 } 1387 " -cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" {1388 set axis [string tolower [string range $what 9 9]]1376 SendCmd "cutplane axis $axis $bool" 1377 } 1378 "cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" { 1379 set axis [string tolower [string range $what 8 8]] 1389 1380 set pos [expr $_settings($what) * 0.01] 1390 1381 SendCmd "cutplane slice ${axis} ${pos}" 1391 1382 set _cutplanePending 0 1392 1383 } 1393 " -colormap" {1394 set _changed( $what) 11384 "colormap" { 1385 set _changed(colormap) 1 1395 1386 StartBufferingCommands 1396 1387 set color [$itk_component(colormap) value] 1397 set _settings( $what) $color1398 1399 if { $_settings(-colormapvisible) } {1400 1401 set _settings(-colormapvisible) 01402 1403 1404 if { !$_settings(-colormapvisible) } {1405 1406 set _settings(-colormapvisible) 11407 1408 1409 1388 set _settings(colormap) $color 1389 if { $color == "none" } { 1390 if { $_settings(colormapVisible) } { 1391 SendCmd "glyphs colormode constant {}" 1392 set _settings(colormapVisible) 0 1393 } 1394 } else { 1395 if { !$_settings(colormapVisible) } { 1396 SendCmd "glyphs colormode $_colorMode $_curFldName" 1397 set _settings(colormapVisible) 1 1398 } 1399 SetCurrentColormap $color 1400 } 1410 1401 StopBufferingCommands 1411 EventuallyRequestLegend 1412 } 1413 "-glyphwireframe" { 1414 set bool $_settings($what) 1415 SendCmd "glyphs wireframe $bool" 1416 } 1417 "-glyphvisible" { 1418 set bool $_settings($what) 1419 SendCmd "glyphs visible 0" 1420 if { $bool } { 1421 foreach tag [CurrentDatasets -visible] { 1422 SendCmd "glyphs visible $bool $tag" 1423 } 1424 } 1402 EventuallyRequestLegend 1403 } 1404 "glyphWireframe" { 1405 set bool $_settings(glyphWireframe) 1406 SendCmd "glyphs wireframe $bool" 1407 } 1408 "glyphVisible" { 1409 set bool $_settings(glyphVisible) 1410 SendCmd "glyphs visible $bool" 1425 1411 if { $bool } { 1426 1412 Rappture::Tooltip::for $itk_component(glyphs) \ … … 1430 1416 "Show the glyph" 1431 1417 } 1432 DrawLegend 1433 } 1434 "-glyphlighting" { 1435 set bool $_settings($what) 1436 SendCmd "glyphs lighting $bool" 1437 } 1438 "-glyphedges" { 1439 set bool $_settings($what) 1440 SendCmd "glyphs edges $bool" 1441 } 1442 "-glyphoutline" { 1443 set bool $_settings($what) 1444 SendCmd "outline visible 0" 1445 if { $bool } { 1446 foreach tag [CurrentDatasets -visible] { 1447 SendCmd "outline visible $bool $tag" 1448 } 1449 } 1450 } 1451 "-glyphopacity" { 1452 set val $_settings($what) 1418 DrawLegend 1419 } 1420 "glyphLighting" { 1421 set bool $_settings(glyphLighting) 1422 SendCmd "glyphs lighting $bool" 1423 } 1424 "glyphEdges" { 1425 set bool $_settings(glyphEdges) 1426 SendCmd "glyphs edges $bool" 1427 } 1428 "glyphOutline" { 1429 set bool $_settings(glyphOutline) 1430 SendCmd "outline visible $bool" 1431 } 1432 "glyphOpacity" { 1433 set val $_settings(glyphOpacity) 1453 1434 set sval [expr { 0.01 * double($val) }] 1454 SendCmd "glyphs opacity $sval" 1455 } 1456 "-glyphnormscale" { 1457 set bool $_settings($what) 1458 SendCmd "glyphs normscale $bool" 1459 } 1460 "-glyphorient" { 1461 set bool $_settings($what) 1462 SendCmd "glyphs gorient $bool {}" 1463 } 1464 "-glyphscale" { 1465 set val $_settings($what) 1466 if { [string is double $val] } { 1467 SendCmd "glyphs gscale $val" 1468 } 1469 } 1470 "-glyphscalemode" { 1471 set label [$itk_component(scaleMode) value] 1472 set mode [$itk_component(scaleMode) translate $label] 1473 set _settings($what) $mode 1474 SendCmd "glyphs smode $mode {}" 1475 } 1476 "-glyphshape" { 1477 set label [$itk_component(gshape) value] 1478 set shape [$itk_component(gshape) translate $label] 1479 set _settings($what) $shape 1480 SendCmd "glyphs shape $shape" 1481 } 1482 "-field" { 1435 SendCmd "glyphs opacity $sval" 1436 } 1437 "field" { 1483 1438 set label [$itk_component(field) value] 1484 1439 set fname [$itk_component(field) translate $label] 1485 set _settings( $what) $fname1440 set _settings(field) $fname 1486 1441 if { [info exists _fields($fname)] } { 1487 1442 foreach { label units components } $_fields($fname) break … … 1497 1452 return 1498 1453 } 1499 #if { ![info exists _limits($_curFldName)] } { 1500 # SendCmd "dataset maprange all" 1501 #} else { 1502 # SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 1503 #} 1454 #SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 1504 1455 #SendCmd "cutplane colormode $_colorMode $_curFldName" 1505 1456 SendCmd "glyphs colormode $_colorMode $_curFldName" 1506 1457 DrawLegend 1507 1458 } 1508 " -legendvisible" {1509 if { !$_settings( $what) } {1459 "legendVisible" { 1460 if { !$_settings(legendVisible) } { 1510 1461 $itk_component(view) delete legend 1511 1512 1462 } 1463 DrawLegend 1513 1464 } 1514 1465 default { … … 1518 1469 } 1519 1470 1471 1520 1472 # 1521 1473 # RequestLegend -- 1522 1474 # 1523 # Request a new legend from the server. The size of the legend1524 # is determined from the height of the canvas.1475 # Request a new legend from the server. The size of the legend 1476 # is determined from the height of the canvas. 1525 1477 # 1526 1478 # This should be called when 1527 # 1528 # 1529 # 1530 # 1531 # 1479 # 1. A new current colormap is set. 1480 # 2. Window is resized. 1481 # 3. The limits of the data have changed. (Just need a redraw). 1482 # 4. Number of glyph have changed. (Just need a redraw). 1483 # 5. Legend becomes visible (Just need a redraw). 1532 1484 # 1533 1485 itcl::body Rappture::VtkGlyphViewer::RequestLegend {} { 1534 1486 set _legendPending 0 1487 if { ![info exists _fields($_curFldName)] } { 1488 return 1489 } 1490 set fname $_curFldName 1535 1491 set font "Arial 8" 1492 set lineht [font metrics $font -linespace] 1536 1493 set w 12 1537 set lineht [font metrics $font -linespace]1538 # color ramp height = (canvas height) - (min and max value lines) - 21539 1494 set h [expr {$_height - 2 * ($lineht + 2)}] 1540 1541 set fname $_curFldName 1495 if { $h < 1 } { 1496 return 1497 } 1542 1498 if { [string match "component*" $fname] } { 1543 1499 set title "" 1544 1500 } else { 1545 1546 1547 1548 1549 1550 1551 1552 1501 if { [info exists _fields($fname)] } { 1502 foreach { title units } $_fields($fname) break 1503 if { $units != "" } { 1504 set title [format "%s (%s)" $title $units] 1505 } 1506 } else { 1507 set title $fname 1508 } 1553 1509 } 1554 1510 # If there's a title too, substract one more line … … 1556 1512 incr h -$lineht 1557 1513 } 1558 if { $h < 1 } {1559 return1560 }1561 1514 # Set the legend on the first heightmap dataset. 1562 1515 if { $_currentColormap != "" } { 1563 1564 1516 set cmap $_currentColormap 1517 SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0" 1565 1518 } 1566 1519 } … … 1582 1535 if { [isconnected] } { 1583 1536 set rgb [Color2RGB $itk_option(-plotforeground)] 1584 1537 SendCmd "axis color all $rgb" 1585 1538 SendCmd "outline color $rgb" 1586 1539 #SendCmd "cutplane color $rgb" 1587 1540 } 1541 } 1542 1543 itcl::body Rappture::VtkGlyphViewer::limits { dataobj } { 1544 foreach { limits(xmin) limits(xmax) } [$dataobj limits x] break 1545 foreach { limits(ymin) limits(ymax) } [$dataobj limits y] break 1546 foreach { limits(zmin) limits(zmax) } [$dataobj limits z] break 1547 foreach { limits(vmin) limits(vmax) } [$dataobj limits v] break 1548 return [array get limits] 1588 1549 } 1589 1550 … … 1600 1561 checkbutton $inner.glyphs \ 1601 1562 -text "Glyphs" \ 1602 -variable [itcl::scope _settings( -glyphvisible)] \1603 -command [itcl::code $this AdjustSetting -glyphvisible] \1563 -variable [itcl::scope _settings(glyphVisible)] \ 1564 -command [itcl::code $this AdjustSetting glyphVisible] \ 1604 1565 -font "Arial 9" 1605 1606 label $inner.gshape_l -text "Glyph shape" -font "Arial 9"1607 itk_component add gshape {1608 Rappture::Combobox $inner.gshape -width 10 -editable no1609 }1610 $inner.gshape choices insert end \1611 "arrow" "arrow" \1612 "cone" "cone" \1613 "cube" "cube" \1614 "cylinder" "cylinder" \1615 "dodecahedron" "dodecahedron" \1616 "icosahedron" "icosahedron" \1617 "line" "line" \1618 "octahedron" "octahedron" \1619 "point" "point" \1620 "sphere" "sphere" \1621 "tetrahedron" "tetrahedron"1622 1623 $itk_component(gshape) value $_settings(-glyphshape)1624 bind $inner.gshape <<Value>> [itcl::code $this AdjustSetting -glyphshape]1625 1626 label $inner.scaleMode_l -text "Scale by" -font "Arial 9"1627 itk_component add scaleMode {1628 Rappture::Combobox $inner.scaleMode -width 10 -editable no1629 }1630 $inner.scaleMode choices insert end \1631 "scalar" "Scalar" \1632 "vmag" "Vector magnitude" \1633 "vcomp" "Vector components" \1634 "off" "Constant size"1635 1636 $itk_component(scaleMode) value "[$itk_component(scaleMode) label $_settings(-glyphscalemode)]"1637 bind $inner.scaleMode <<Value>> [itcl::code $this AdjustSetting -glyphscalemode]1638 1639 checkbutton $inner.normscale \1640 -text "Normalize scaling" \1641 -variable [itcl::scope _settings(-glyphnormscale)] \1642 -command [itcl::code $this AdjustSetting -glyphnormscale] \1643 -font "Arial 9"1644 Rappture::Tooltip::for $inner.normscale "If enabled, field values are normalized to \[0,1\] before scaling and scale factor is relative to a default size"1645 1646 checkbutton $inner.gorient \1647 -text "Orient" \1648 -variable [itcl::scope _settings(-glyphorient)] \1649 -command [itcl::code $this AdjustSetting -glyphorient] \1650 -font "Arial 9"1651 Rappture::Tooltip::for $inner.gorient "Orient glyphs by vector field directions"1652 1566 1653 1567 checkbutton $inner.wireframe \ 1654 1568 -text "Wireframe" \ 1655 -variable [itcl::scope _settings( -glyphwireframe)] \1656 -command [itcl::code $this AdjustSetting -glyphwireframe] \1569 -variable [itcl::scope _settings(glyphWireframe)] \ 1570 -command [itcl::code $this AdjustSetting glyphWireframe] \ 1657 1571 -font "Arial 9" 1658 1572 1659 1573 checkbutton $inner.lighting \ 1660 1574 -text "Enable Lighting" \ 1661 -variable [itcl::scope _settings( -glyphlighting)] \1662 -command [itcl::code $this AdjustSetting -glyphlighting] \1575 -variable [itcl::scope _settings(glyphLighting)] \ 1576 -command [itcl::code $this AdjustSetting glyphLighting] \ 1663 1577 -font "Arial 9" 1664 1578 1665 1579 checkbutton $inner.edges \ 1666 1580 -text "Edges" \ 1667 -variable [itcl::scope _settings( -glyphedges)] \1668 -command [itcl::code $this AdjustSetting -glyphedges] \1581 -variable [itcl::scope _settings(glyphEdges)] \ 1582 -command [itcl::code $this AdjustSetting glyphEdges] \ 1669 1583 -font "Arial 9" 1670 1584 1671 1585 checkbutton $inner.outline \ 1672 1586 -text "Outline" \ 1673 -variable [itcl::scope _settings( -glyphoutline)] \1674 -command [itcl::code $this AdjustSetting -glyphoutline] \1587 -variable [itcl::scope _settings(glyphOutline)] \ 1588 -command [itcl::code $this AdjustSetting glyphOutline] \ 1675 1589 -font "Arial 9" 1676 1590 1677 1591 checkbutton $inner.legend \ 1678 1592 -text "Legend" \ 1679 -variable [itcl::scope _settings( -legendvisible)] \1680 -command [itcl::code $this AdjustSetting -legendvisible] \1593 -variable [itcl::scope _settings(legendVisible)] \ 1594 -command [itcl::code $this AdjustSetting legendVisible] \ 1681 1595 -font "Arial 9" 1682 1596 … … 1690 1604 "grey" "grey" 1691 1605 1692 $itk_component(background) value $_settings( -background)1693 bind $inner.background <<Value>> [itcl::code $this AdjustSetting -background]1606 $itk_component(background) value $_settings(background) 1607 bind $inner.background <<Value>> [itcl::code $this AdjustSetting background] 1694 1608 1695 1609 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1696 1610 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1697 -variable [itcl::scope _settings( -glyphopacity)] \1611 -variable [itcl::scope _settings(glyphOpacity)] \ 1698 1612 -width 10 \ 1699 1613 -showvalue off \ 1700 -command [itcl::code $this AdjustSetting -glyphopacity] 1701 1702 label $inner.gscale_l -text "Scale factor" -font "Arial 9" 1703 if {0} { 1704 ::scale $inner.gscale -from 1 -to 100 -orient horizontal \ 1705 -variable [itcl::scope _settings(-glyphscale)] \ 1614 -command [itcl::code $this AdjustSetting glyphOpacity] 1615 1616 label $inner.scale_l -text "Scale" -font "Arial 9" 1617 ::scale $inner.scale -from 1 -to 100 -orient horizontal \ 1618 -variable [itcl::scope _settings(glyphs-scale)] \ 1706 1619 -width 10 \ 1707 1620 -showvalue off \ 1708 -command [itcl::code $this AdjustSetting -glyphscale] 1709 } else { 1710 itk_component add gscale { 1711 entry $inner.gscale -font "Arial 9" -bg white \ 1712 -textvariable [itcl::scope _settings(-glyphscale)] 1713 } { 1714 ignore -font -background 1715 } 1716 bind $inner.gscale <Return> \ 1717 [itcl::code $this AdjustSetting -glyphscale] 1718 bind $inner.gscale <KP_Enter> \ 1719 [itcl::code $this AdjustSetting -glyphscale] 1720 } 1721 Rappture::Tooltip::for $inner.gscale "Set scaling multiplier (or constant size)" 1621 -command [itcl::code $this AdjustSetting glyphs-scale] 1722 1622 1723 1623 itk_component add field_l { … … 1730 1630 } 1731 1631 bind $inner.field <<Value>> \ 1732 [itcl::code $this AdjustSetting -field]1632 [itcl::code $this AdjustSetting field] 1733 1633 1734 1634 label $inner.colormap_l -text "Colormap" -font "Arial 9" … … 1736 1636 Rappture::Combobox $inner.colormap -width 10 -editable no 1737 1637 } 1738 1739 $inner.colormap choices insert end [GetColormapList] 1638 $inner.colormap choices insert end \ 1639 "BCGYR" "BCGYR" \ 1640 "BGYOR" "BGYOR" \ 1641 "blue" "blue" \ 1642 "blue-to-brown" "blue-to-brown" \ 1643 "blue-to-orange" "blue-to-orange" \ 1644 "blue-to-grey" "blue-to-grey" \ 1645 "green-to-magenta" "green-to-magenta" \ 1646 "greyscale" "greyscale" \ 1647 "nanohub" "nanohub" \ 1648 "rainbow" "rainbow" \ 1649 "spectral" "spectral" \ 1650 "ROYGB" "ROYGB" \ 1651 "RYGCB" "RYGCB" \ 1652 "brown-to-blue" "brown-to-blue" \ 1653 "grey-to-blue" "grey-to-blue" \ 1654 "orange-to-blue" "orange-to-blue" 1655 1740 1656 $itk_component(colormap) value "BCGYR" 1741 1657 bind $inner.colormap <<Value>> \ 1742 [itcl::code $this AdjustSetting -colormap]1658 [itcl::code $this AdjustSetting colormap] 1743 1659 1744 1660 blt::table $inner \ 1745 0,0 $inner.field_l 1746 0,1 $inner.field 1747 1,0 $inner.colormap_l 1748 1,1 $inner.colormap 1749 1750 3,1 $inner.background-anchor w -pady 2 -fill x \1751 5,0 $inner.wireframe 1752 6,0 $inner.lighting 1753 7,0 $inner.edges 1754 8,0 $inner.outline 1755 9,0 $inner.legend 1756 10,0 $inner.opacity_l 1757 10,1 $inner.opacity 1661 0,0 $inner.field_l -anchor w -pady 2 \ 1662 0,1 $inner.field -anchor w -pady 2 -fill x \ 1663 1,0 $inner.colormap_l -anchor w -pady 2 \ 1664 1,1 $inner.colormap -anchor w -pady 2 -fill x \ 1665 3,0 $inner.background_l -anchor w -pady 2 \ 1666 3,1 $inner.background -anchor w -pady 2 -fill x \ 1667 5,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \ 1668 6,0 $inner.lighting -anchor w -pady 2 -cspan 2 \ 1669 7,0 $inner.edges -anchor w -pady 2 -cspan 2 \ 1670 8,0 $inner.outline -anchor w -pady 2 -cspan 2 \ 1671 9,0 $inner.legend -anchor w -pady 2 \ 1672 10,0 $inner.opacity_l -anchor w -pady 2 \ 1673 10,1 $inner.opacity -fill x -pady 2 -fill x \ 1758 1674 1759 1675 blt::table configure $inner r* c* -resize none … … 1772 1688 1773 1689 checkbutton $inner.visible \ 1774 -text " Axes" \1775 -variable [itcl::scope _settings( -axesvisible)] \1776 -command [itcl::code $this AdjustSetting -axesvisible] \1690 -text "Show Axes" \ 1691 -variable [itcl::scope _settings(axesVisible)] \ 1692 -command [itcl::code $this AdjustSetting axesVisible] \ 1777 1693 -font "Arial 9" 1778 1694 1779 1695 checkbutton $inner.labels \ 1780 -text " Axis Labels" \1781 -variable [itcl::scope _settings( -axislabels)] \1782 -command [itcl::code $this AdjustSetting -axislabels] \1696 -text "Show Axis Labels" \ 1697 -variable [itcl::scope _settings(axisLabelsVisible)] \ 1698 -command [itcl::code $this AdjustSetting axisLabelsVisible] \ 1783 1699 -font "Arial 9" 1784 label $inner.grid_l -text "Grid" -font "Arial 9" 1785 checkbutton $inner. xgrid\1786 -text " X" \1787 -variable [itcl::scope _settings( -xgrid)] \1788 -command [itcl::code $this AdjustSetting -xgrid] \1700 1701 checkbutton $inner.gridx \ 1702 -text "Show X Grid" \ 1703 -variable [itcl::scope _settings(axisXGrid)] \ 1704 -command [itcl::code $this AdjustSetting axisXGrid] \ 1789 1705 -font "Arial 9" 1790 checkbutton $inner. ygrid\1791 -text " Y" \1792 -variable [itcl::scope _settings( -ygrid)] \1793 -command [itcl::code $this AdjustSetting -ygrid] \1706 checkbutton $inner.gridy \ 1707 -text "Show Y Grid" \ 1708 -variable [itcl::scope _settings(axisYGrid)] \ 1709 -command [itcl::code $this AdjustSetting axisYGrid] \ 1794 1710 -font "Arial 9" 1795 checkbutton $inner.zgrid \ 1796 -text "Z" \ 1797 -variable [itcl::scope _settings(-zgrid)] \ 1798 -command [itcl::code $this AdjustSetting -zgrid] \ 1799 -font "Arial 9" 1800 checkbutton $inner.minorticks \ 1801 -text "Minor Ticks" \ 1802 -variable [itcl::scope _settings(-axisminorticks)] \ 1803 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1711 checkbutton $inner.gridz \ 1712 -text "Show Z Grid" \ 1713 -variable [itcl::scope _settings(axisZGrid)] \ 1714 -command [itcl::code $this AdjustSetting axisZGrid] \ 1804 1715 -font "Arial 9" 1805 1716 … … 1814 1725 "furthest_triad" "farthest" \ 1815 1726 "outer_edges" "outer" 1816 $itk_component(axisMode) value $_settings(-axismode)1817 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]1727 $itk_component(axisMode) value "static" 1728 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisMode] 1818 1729 1819 1730 blt::table $inner \ 1820 0,0 $inner.visible -anchor w -cspan 4 \ 1821 1,0 $inner.labels -anchor w -cspan 4 \ 1822 2,0 $inner.minorticks -anchor w -cspan 4 \ 1823 4,0 $inner.grid_l -anchor w \ 1824 4,1 $inner.xgrid -anchor w \ 1825 4,2 $inner.ygrid -anchor w \ 1826 4,3 $inner.zgrid -anchor w \ 1827 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1828 5,1 $inner.mode -fill x -cspan 3 1731 0,0 $inner.visible -anchor w -cspan 2 \ 1732 1,0 $inner.labels -anchor w -cspan 2 \ 1733 2,0 $inner.gridx -anchor w -cspan 2 \ 1734 3,0 $inner.gridy -anchor w -cspan 2 \ 1735 4,0 $inner.gridz -anchor w -cspan 2 \ 1736 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1737 6,0 $inner.mode -fill x -cspan 2 1829 1738 1830 1739 blt::table configure $inner r* c* -resize none 1831 blt::table configure $inner r7 c 6-resize expand1832 blt::table configure $inner r3 -height 0.125i 1833 } 1740 blt::table configure $inner r7 c1 -resize expand 1741 } 1742 1834 1743 1835 1744 itcl::body Rappture::VtkGlyphViewer::BuildCameraTab {} { … … 1851 1760 0,0 $inner.view_l -anchor e -pady 2 \ 1852 1761 0,1 $inner.view -anchor w -pady 2 1853 blt::table configure $inner r0 -resize none1854 1762 1855 1763 set labels { qx qy qz qw xpan ypan zoom } … … 1858 1766 label $inner.${tag}label -text $tag -font "Arial 9" 1859 1767 entry $inner.${tag} -font "Arial 9" -bg white \ 1860 -textvariable [itcl::scope _view(-$tag)] 1861 bind $inner.${tag} <Return> \ 1862 [itcl::code $this camera set -${tag}] 1863 bind $inner.${tag} <KP_Enter> \ 1864 [itcl::code $this camera set -${tag}] 1768 -textvariable [itcl::scope _view($tag)] 1769 bind $inner.${tag} <KeyPress-Return> \ 1770 [itcl::code $this camera set ${tag}] 1865 1771 blt::table $inner \ 1866 1772 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1871 1777 checkbutton $inner.ortho \ 1872 1778 -text "Orthographic Projection" \ 1873 -variable [itcl::scope _view( -ortho)] \1874 -command [itcl::code $this camera set -ortho] \1779 -variable [itcl::scope _view(ortho)] \ 1780 -command [itcl::code $this camera set ortho] \ 1875 1781 -font "Arial 9" 1876 1782 blt::table $inner \ … … 1879 1785 incr row 1880 1786 1881 blt::table configure $inner c* -resize none1787 blt::table configure $inner c* r* -resize none 1882 1788 blt::table configure $inner c2 -resize expand 1883 1789 blt::table configure $inner r$row -resize expand … … 1896 1802 checkbutton $inner.visible \ 1897 1803 -text "Cutplanes" \ 1898 -variable [itcl::scope _settings( -cutplanevisible)] \1899 -command [itcl::code $this AdjustSetting -cutplanevisible] \1804 -variable [itcl::scope _settings(cutplaneVisible)] \ 1805 -command [itcl::code $this AdjustSetting cutplaneVisible] \ 1900 1806 -font "Arial 9" 1901 1807 1902 1808 checkbutton $inner.wireframe \ 1903 1809 -text "Wireframe" \ 1904 -variable [itcl::scope _settings( -cutplanewireframe)] \1905 -command [itcl::code $this AdjustSetting -cutplanewireframe] \1810 -variable [itcl::scope _settings(cutplaneWireframe)] \ 1811 -command [itcl::code $this AdjustSetting cutplaneWireframe] \ 1906 1812 -font "Arial 9" 1907 1813 1908 1814 checkbutton $inner.lighting \ 1909 1815 -text "Enable Lighting" \ 1910 -variable [itcl::scope _settings( -cutplanelighting)] \1911 -command [itcl::code $this AdjustSetting -cutplanelighting] \1816 -variable [itcl::scope _settings(cutplaneLighting)] \ 1817 -command [itcl::code $this AdjustSetting cutplaneLighting] \ 1912 1818 -font "Arial 9" 1913 1819 1914 1820 checkbutton $inner.edges \ 1915 1821 -text "Edges" \ 1916 -variable [itcl::scope _settings( -cutplaneedges)] \1917 -command [itcl::code $this AdjustSetting -cutplaneedges] \1822 -variable [itcl::scope _settings(cutplaneEdges)] \ 1823 -command [itcl::code $this AdjustSetting cutplaneEdges] \ 1918 1824 -font "Arial 9" 1919 1825 1920 1826 checkbutton $inner.preinterp \ 1921 1827 -text "Interpolate Scalars" \ 1922 -variable [itcl::scope _settings( -cutplanepreinterp)] \1923 -command [itcl::code $this AdjustSetting -cutplanepreinterp] \1828 -variable [itcl::scope _settings(cutplanePreinterp)] \ 1829 -command [itcl::code $this AdjustSetting cutplanePreinterp] \ 1924 1830 -font "Arial 9" 1925 1831 1926 1832 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1927 1833 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1928 -variable [itcl::scope _settings( -cutplaneopacity)] \1834 -variable [itcl::scope _settings(cutplaneOpacity)] \ 1929 1835 -width 10 \ 1930 1836 -showvalue off \ 1931 -command [itcl::code $this AdjustSetting -cutplaneopacity]1932 $inner.opacity set $_settings( -cutplaneopacity)1837 -command [itcl::code $this AdjustSetting cutplaneOpacity] 1838 $inner.opacity set $_settings(cutplaneOpacity) 1933 1839 1934 1840 # X-value slicer... … … 1937 1843 -onimage [Rappture::icon x-cutplane-red] \ 1938 1844 -offimage [Rappture::icon x-cutplane-red] \ 1939 -command [itcl::code $this AdjustSetting -cutplanexvisible] \1940 -variable [itcl::scope _settings( -cutplanexvisible)] \1845 -command [itcl::code $this AdjustSetting cutplaneXVisible] \ 1846 -variable [itcl::scope _settings(cutplaneXVisible)] \ 1941 1847 } 1942 1848 Rappture::Tooltip::for $itk_component(xbutton) \ … … 1948 1854 -borderwidth 1 -highlightthickness 0 \ 1949 1855 -command [itcl::code $this EventuallySetCutplane x] \ 1950 -variable [itcl::scope _settings( -cutplanexposition)] \1951 1856 -variable [itcl::scope _settings(cutplaneXPosition)] \ 1857 -foreground red2 -font "Arial 9 bold" 1952 1858 } { 1953 1859 usual … … 1965 1871 -onimage [Rappture::icon y-cutplane-green] \ 1966 1872 -offimage [Rappture::icon y-cutplane-green] \ 1967 -command [itcl::code $this AdjustSetting -cutplaneyvisible] \1968 -variable [itcl::scope _settings( -cutplaneyvisible)] \1873 -command [itcl::code $this AdjustSetting cutplaneYVisible] \ 1874 -variable [itcl::scope _settings(cutplaneYVisible)] \ 1969 1875 } 1970 1876 Rappture::Tooltip::for $itk_component(ybutton) \ … … 1977 1883 -borderwidth 1 -highlightthickness 0 \ 1978 1884 -command [itcl::code $this EventuallySetCutplane y] \ 1979 -variable [itcl::scope _settings( -cutplaneyposition)] \1980 1885 -variable [itcl::scope _settings(cutplaneYPosition)] \ 1886 -foreground green3 -font "Arial 9 bold" 1981 1887 } { 1982 1888 usual … … 1994 1900 -onimage [Rappture::icon z-cutplane-blue] \ 1995 1901 -offimage [Rappture::icon z-cutplane-blue] \ 1996 -command [itcl::code $this AdjustSetting -cutplanezvisible] \1997 -variable [itcl::scope _settings( -cutplanezvisible)] \1902 -command [itcl::code $this AdjustSetting cutplaneZVisible] \ 1903 -variable [itcl::scope _settings(cutplaneZVisible)] \ 1998 1904 } { 1999 2000 1905 usual 1906 ignore -foreground 2001 1907 } 2002 1908 Rappture::Tooltip::for $itk_component(zbutton) \ … … 2009 1915 -borderwidth 1 -highlightthickness 0 \ 2010 1916 -command [itcl::code $this EventuallySetCutplane z] \ 2011 -variable [itcl::scope _settings( -cutplanezposition)] \2012 1917 -variable [itcl::scope _settings(cutplaneZPosition)] \ 1918 -foreground blue3 -font "Arial 9 bold" 2013 1919 } { 2014 1920 usual … … 2021 1927 2022 1928 blt::table $inner \ 2023 0,0 $inner.visible -anchor w -pady 2 -cspan 3 \ 2024 1,0 $inner.lighting -anchor w -pady 2 -cspan 3 \ 2025 2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \ 2026 3,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 2027 4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \ 2028 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 2029 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 2030 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 2031 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 2032 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 2033 6,1 $inner.xval -fill y -rspan 4 \ 2034 6,2 $inner.yval -fill y -rspan 4 \ 2035 6,3 $inner.zval -fill y -rspan 4 \ 1929 0,0 $inner.visible -anchor w -pady 2 -cspan 3 \ 1930 1,0 $inner.lighting -anchor w -pady 2 -cspan 3 \ 1931 2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \ 1932 3,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 1933 4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \ 1934 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 1935 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 1936 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 1937 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 1938 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 1939 6,1 $inner.xval -fill y -rspan 4 \ 1940 6,2 $inner.yval -fill y -rspan 4 \ 1941 6,3 $inner.zval -fill y -rspan 4 \ 1942 2036 1943 2037 1944 blt::table configure $inner r* c* -resize none 2038 1945 blt::table configure $inner r9 c4 -resize expand 2039 1946 } 1947 1948 2040 1949 2041 1950 # … … 2048 1957 } 2049 1958 "set" { 2050 set wh at[lindex $args 0]2051 set x $_view($wh at)1959 set who [lindex $args 0] 1960 set x $_view($who) 2052 1961 set code [catch { string is double $x } result] 2053 1962 if { $code != 0 || !$result } { 2054 1963 return 2055 1964 } 2056 switch -- $wh at{2057 " -ortho" {2058 if {$_view( $what)} {1965 switch -- $who { 1966 "ortho" { 1967 if {$_view(ortho)} { 2059 1968 SendCmd "camera mode ortho" 2060 1969 } else { … … 2062 1971 } 2063 1972 } 2064 " -xpan" - "-ypan" {1973 "xpan" - "ypan" { 2065 1974 PanCamera 2066 1975 } 2067 " -qx" - "-qy" - "-qz" - "-qw" {2068 set q [ ViewToQuaternion]1976 "qx" - "qy" - "qz" - "qw" { 1977 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2069 1978 $_arcball quaternion $q 2070 1979 EventuallyRotate $q 2071 1980 } 2072 " -zoom" {2073 SendCmd "camera zoom $_view( $what)"1981 "zoom" { 1982 SendCmd "camera zoom $_view(zoom)" 2074 1983 } 2075 1984 } … … 2189 2098 # the code to handle aberrant cases. 2190 2099 2191 if { $_changed( -glyphopacity) } {2192 set style(-opacity) [expr $_settings(-glyphopacity) * 0.01]2193 } 2194 if { $_changed( -colormap) } {2195 set style(-color) $_settings( -colormap)2100 if { $_changed(glyphOpacity) } { 2101 set style(-opacity) $_settings(glyphOpacity) 2102 } 2103 if { $_changed(colormap) } { 2104 set style(-color) $_settings(colormap) 2196 2105 } 2197 2106 if { $_currentColormap == "" } { 2198 2107 $itk_component(colormap) value $style(-color) 2199 2108 } 2200 2109 set _currentOpacity $style(-opacity) 2110 SendCmd "glyphs add $style(-shape) $tag" 2111 SendCmd "glyphs edges $style(-edges) $tag" 2112 # normscale=1 and gscale=1 are defaults 2113 if {$style(-normscale) != 1} { 2114 SendCmd "glyphs normscale $style(-normscale) $tag" 2115 } 2116 if {$style(-gscale) != 1} { 2117 SendCmd "glyphs gscale $style(-gscale) $tag" 2118 } 2201 2119 SendCmd "outline add $tag" 2202 2120 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2203 2121 SendCmd "outline visible $style(-outline) $tag" 2204 set _settings(-glyphoutline) $style(-outline) 2205 2206 SendCmd "glyphs add $style(-shape) $tag" 2207 set _settings(-glyphshape) $style(-shape) 2208 $itk_component(gshape) value $style(-shape) 2209 SendCmd "glyphs edges $style(-edges) $tag" 2210 set _settings(-glyphedges) $style(-edges) 2211 2212 # normscale=1 and gscale=1 are defaults 2213 if {$style(-normscale) != 1} { 2214 SendCmd "glyphs normscale $style(-normscale) $tag" 2215 } 2216 if {$style(-gscale) != 1} { 2217 SendCmd "glyphs gscale $style(-gscale) $tag" 2218 } 2219 set _settings(-glyphnormscale) $style(-normscale) 2220 set _settings(-glyphscale) $style(-gscale) 2221 2122 set _settings(glyphOutline) $style(-outline) 2123 set _settings(glyphEdges) $style(-edges) 2222 2124 # constant color only used if colormode set to constant 2223 2125 SendCmd "glyphs color [Color2RGB $itk_option(-plotforeground)] $tag" … … 2225 2127 # defaults to active scalars or vectors depending on mode 2226 2128 SendCmd "glyphs gorient $style(-orientGlyphs) {} $tag" 2227 set _settings(-glyphorient) $style(-orientGlyphs)2228 2129 SendCmd "glyphs smode $style(-scaleMode) {} $tag" 2229 set _settings(-glyphscalemode) $style(-scaleMode)2230 $itk_component(scaleMode) value "[$itk_component(scaleMode) label $style(-scaleMode)]"2231 2130 SendCmd "glyphs quality $style(-quality) $tag" 2232 2131 SendCmd "glyphs lighting $style(-lighting) $tag" 2233 set _settings( -glyphlighting) $style(-lighting)2132 set _settings(glyphLighting) $style(-lighting) 2234 2133 SendCmd "glyphs linecolor [Color2RGB $style(-edgecolor)] $tag" 2235 2134 SendCmd "glyphs linewidth $style(-linewidth) $tag" 2236 2135 SendCmd "glyphs ptsize $style(-ptsize) $tag" 2237 SendCmd "glyphs opacity $ style(-opacity)$tag"2238 set _settings( -glyphopacity) [expr $style(-opacity) * 100.0]2136 SendCmd "glyphs opacity $_currentOpacity $tag" 2137 set _settings(glyphOpacity) $style(-opacity) 2239 2138 SetCurrentColormap $style(-color) 2240 2139 SendCmd "glyphs wireframe $style(-wireframe) $tag" 2241 set _settings(-glyphwireframe) $style(-wireframe) 2140 set _settings(glyphWireframe) $style(-wireframe) 2141 set _settings(glyphOpacity) [expr $style(-opacity) * 100.0] 2242 2142 } 2243 2143 … … 2293 2193 2294 2194 if { [string match "component*" $fname] } { 2295 2195 set title "" 2296 2196 } else { 2297 2298 2299 2300 2301 2302 2303 2304 2197 if { [info exists _fields($fname)] } { 2198 foreach { title units } $_fields($fname) break 2199 if { $units != "" } { 2200 set title [format "%s (%s)" $title $units] 2201 } 2202 } else { 2203 set title $fname 2204 } 2305 2205 } 2306 2206 # If there's a legend title, increase the offset by the line height. … … 2334 2234 } 2335 2235 2236 2336 2237 # ---------------------------------------------------------------------- 2337 2238 # USAGE: Slice move x|y|z <newval> … … 2367 2268 # ReceiveLegend -- 2368 2269 # 2369 # 2370 # 2371 # 2270 # Invoked automatically whenever the "legend" command comes in from 2271 # the rendering server. Indicates that binary image data with the 2272 # specified <size> will follow. 2372 2273 # 2373 2274 itcl::body Rappture::VtkGlyphViewer::ReceiveLegend { colormap title min max size } { … … 2383 2284 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2384 2285 if { [catch {DrawLegend} errs] != 0 } { 2385 2386 2286 global errorInfo 2287 puts stderr "errs=$errs errorInfo=$errorInfo" 2387 2288 } 2388 2289 } … … 2392 2293 # DrawLegend -- 2393 2294 # 2394 # Draws the legend in the own canvas on the right side of the plot area.2295 # Draws the legend in the own canvas on the right side of the plot area. 2395 2296 # 2396 2297 itcl::body Rappture::VtkGlyphViewer::DrawLegend {} { … … 2403 2304 2404 2305 if { [string match "component*" $fname] } { 2405 2306 set title "" 2406 2307 } else { 2407 2408 2409 2410 2411 2412 2413 2414 2308 if { [info exists _fields($fname)] } { 2309 foreach { title units } $_fields($fname) break 2310 if { $units != "" } { 2311 set title [format "%s (%s)" $title $units] 2312 } 2313 } else { 2314 set title $fname 2315 } 2415 2316 } 2416 2317 set x [expr $w - 2] 2417 if { !$_settings( -legendvisible) } {2418 2419 2318 if { !$_settings(legendVisible) } { 2319 $c delete legend 2320 return 2420 2321 } 2421 2322 if { [$c find withtag "legend"] == "" } { 2422 2423 2323 set y 2 2324 # If there's a legend title, create a text item for the title. 2424 2325 $c create text $x $y \ 2425 -anchor ne \ 2426 -fill $itk_option(-plotforeground) -tags "title legend" \ 2427 -font $font 2428 if { $title != "" } { 2429 incr y $lineht 2430 } 2431 $c create text $x $y \ 2432 -anchor ne \ 2433 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2434 -font $font 2435 incr y $lineht 2436 $c create image $x $y \ 2437 -anchor ne \ 2438 -image $_image(legend) -tags "colormap legend" 2439 $c create rectangle $x $y 1 1 \ 2440 -fill "" -outline "" -tags "sensor legend" 2441 $c create text $x [expr {$h-2}] \ 2442 -anchor se \ 2443 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2444 -font $font 2445 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2446 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2447 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2326 -anchor ne \ 2327 -fill $itk_option(-plotforeground) -tags "title legend" \ 2328 -font $font 2329 incr y $lineht 2330 $c create text $x $y \ 2331 -anchor ne \ 2332 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2333 -font $font 2334 incr y $lineht 2335 $c create image $x $y \ 2336 -anchor ne \ 2337 -image $_image(legend) -tags "colormap legend" 2338 $c create rectangle $x $y 1 1 \ 2339 -fill "" -outline "" -tags "sensor legend" 2340 $c create text $x [expr {$h-2}] \ 2341 -anchor se \ 2342 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2343 -font $font 2344 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2345 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2346 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2448 2347 } 2449 2348 set x2 $x … … 2459 2358 if { [info exists _limits($_curFldName)] } { 2460 2359 foreach { vmin vmax } $_limits($_curFldName) break 2461 2462 2360 $c itemconfigure vmin -text [format %g $vmin] 2361 $c itemconfigure vmax -text [format %g $vmax] 2463 2362 } 2464 2363 set y 2 … … 2466 2365 if { $title != "" } { 2467 2366 $c itemconfigure title -text $title 2468 2469 2367 $c coords title $x $y 2368 incr y $lineht 2470 2369 $c raise title 2471 2370 } … … 2509 2408 invoke { 2510 2409 $itk_component(field) value $_curFldLabel 2511 AdjustSetting -field2410 AdjustSetting field 2512 2411 } 2513 2412 default { … … 2533 2432 # BuildColormap -- 2534 2433 # 2535 # Build the designated colormap on the server.2434 # Build the designated colormap on the server. 2536 2435 # 2537 2436 itcl::body Rappture::VtkGlyphViewer::BuildColormap { name } { … … 2553 2452 bottom "0.707107 0.707107 0 0" 2554 2453 } 2555 foreach name { -qw -qx -qy -qz } value $positions($side) {2454 foreach name { qw qx qy qz } value $positions($side) { 2556 2455 set _view($name) $value 2557 } 2558 set q [ ViewToQuaternion]2456 } 2457 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2559 2458 $_arcball quaternion $q 2560 2459 SendCmd "camera orient $q" 2561 2460 SendCmd "camera reset" 2562 set _view(-xpan) 0 2563 set _view(-ypan) 0 2564 set _view(-zoom) 1.0 2565 } 2461 set _view(xpan) 0 2462 set _view(ypan) 0 2463 set _view(zoom) 1.0 2464 } 2465 -
branches/1.3/gui/scripts/vtkheightmapviewer.tcl
r4770 r4848 7 7 # ====================================================================== 8 8 # AUTHOR: Michael McLennan, Purdue University 9 # Copyright (c) 2004-201 4HUBzero Foundation, LLC9 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 # 11 11 # See the file "license.terms" for information on usage and … … 58 58 public method get {args} 59 59 public method isconnected {} 60 public method limits3 { dataobj } 60 61 public method parameters {title args} { 61 62 # do nothing … … 63 64 public method scale {args} 64 65 66 protected method CameraReset {} 67 protected method Connect {} 68 protected method CurrentDatasets {args} 69 protected method Disconnect {} 70 protected method DoResize {} 71 protected method DoRotate {} 72 protected method AdjustSetting {what {value ""}} 73 protected method AdjustMode {} 74 protected method InitSettings { args } 75 protected method Pan {option x y} 76 protected method Pick {x y} 77 protected method Rebuild {} 78 protected method ReceiveDataset { args } 79 protected method ReceiveImage { args } 80 protected method ReceiveLegend { colormap title min max size } 81 protected method Rotate {option x y} 82 protected method Zoom {option} 83 65 84 # The following methods are only used by this class. 66 private method AdjustSetting {what {value ""}}67 85 private method BuildAxisTab {} 68 86 private method BuildCameraTab {} … … 70 88 private method BuildContourTab {} 71 89 private method BuildDownloadPopup { widget command } 72 private method CameraReset {}73 90 private method Combo { option } 74 private method Connect {}75 private method CurrentDatasets {args}76 private method Disconnect {}77 private method DoResize {}78 private method DoRotate {}79 91 private method DrawLegend {} 80 92 private method EnterLegend { x y } 81 93 private method EventuallyRequestLegend {} 82 94 private method EventuallyResize { w h } 83 private method EventuallyRotate { q } 84 private method GetHeightmapScale {} 95 private method EventuallyRotate { q } 85 96 private method GetImage { args } 86 97 private method GetVtkData { args } 87 private method InitSettings { args }88 98 private method IsValidObject { dataobj } 89 99 private method LeaveLegend {} 90 100 private method MotionLegend { x y } 91 private method Pan {option x y}92 101 private method PanCamera {} 93 private method Pick {x y}94 private method QuaternionToView { q } {95 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break96 }97 private method Rebuild {}98 private method ReceiveDataset { args }99 private method ReceiveImage { args }100 private method ReceiveLegend { colormap title min max size }101 102 private method RequestLegend {} 102 private method ResetAxes {}103 private method Rotate {option x y}104 103 private method SetCurrentColormap { color } 105 104 private method SetLegendTip { x y } 106 105 private method SetObjectStyle { dataobj comp } 106 private method GetHeightmapScale {} 107 private method ResetAxes {} 107 108 private method SetOrientation { side } 108 109 private method UpdateContourList {} 109 private method ViewToQuaternion {} {110 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]111 }112 private method Zoom {option}113 110 114 111 private variable _arcball "" … … 126 123 private variable _currentColormap "" 127 124 private variable _currentNumIsolines -1 125 private variable _currentOpacity "" 128 126 129 127 private variable _maxScale 100; # This is the # of times the x-axis … … 205 203 # Initialize the view to some default parameters. 206 204 array set _view { 207 -ortho 0208 -qw 0.36209 -qx 0.25210 -qy 0.50211 -qz 0.70212 -xpan0213 -ypan0214 -zoom 1.0205 qw 0.36 206 qx 0.25 207 qy 0.50 208 qz 0.70 209 zoom 1.0 210 xpan 0 211 ypan 0 212 ortho 0 215 213 } 216 214 set _arcball [blt::arcball create 100 100] 217 $_arcball quaternion [ViewToQuaternion] 215 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 216 $_arcball quaternion $q 218 217 219 218 array set _settings { 220 -axisflymode "static" 221 -axislabels 1 222 -axisminorticks 1 223 -axisvisible 1 224 -colormap BCGYR 225 -colormapdiscrete 0 226 -colormapvisible 1 227 -edges 0 228 -field "Default" 229 -heightmapscale 50 230 -isheightmap 0 231 -isolinecolor black 232 -isolinesvisible 1 233 -legendvisible 1 234 -lighting 1 235 -numisolines 10 236 -opacity 100 237 -outline 0 238 -savelighting 1 239 -saveopacity 100 240 -saveoutline 0 241 -stretchtofit 0 242 -wireframe 0 243 -xgrid 0 244 -ygrid 0 245 -zgrid 0 219 axisFlymode "static" 220 axisMinorTicks 1 221 stretchToFit 0 222 axisLabels 1 223 axisVisible 1 224 axisXGrid 0 225 axisYGrid 0 226 axisZGrid 0 227 colormapVisible 1 228 colormapDiscrete 0 229 edges 0 230 field "Default" 231 heightmapScale 50 232 isHeightmap 0 233 isolineColor black 234 isolinesVisible 1 235 legendVisible 1 236 lighting 1 237 saveLighting 1 238 numIsolines 10 239 opacity 100 240 outline 0 241 wireframe 0 242 saveOpacity 100 243 saveOutline 0 246 244 } 247 245 array set _changed { 248 -colormap0249 -numisolines0250 -opacity0246 opacity 0 247 colormap 0 248 numIsolines 0 251 249 } 252 250 itk_component add view { … … 327 325 -onimage [Rappture::icon surface] \ 328 326 -offimage [Rappture::icon surface] \ 329 -variable [itcl::scope _settings( -isheightmap)] \330 -command [itcl::code $this AdjustSetting -isheightmap] \327 -variable [itcl::scope _settings(isHeightmap)] \ 328 -command [itcl::code $this AdjustSetting isHeightmap] \ 331 329 } 332 330 Rappture::Tooltip::for $itk_component(mode) \ … … 338 336 -onimage [Rappture::icon stretchtofit] \ 339 337 -offimage [Rappture::icon stretchtofit] \ 340 -variable [itcl::scope _settings( -stretchtofit)] \341 -command [itcl::code $this AdjustSetting -stretchtofit] \338 -variable [itcl::scope _settings(stretchToFit)] \ 339 -command [itcl::code $this AdjustSetting stretchToFit] \ 342 340 } 343 341 Rappture::Tooltip::for $itk_component(stretchtofit) \ … … 444 442 445 443 itcl::body Rappture::VtkHeightmapViewer::DoRotate {} { 446 SendCmd "camera orient [ViewToQuaternion]" 444 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 445 SendCmd "camera orient $q" 447 446 set _rotatePending 0 448 447 } … … 468 467 469 468 itcl::body Rappture::VtkHeightmapViewer::EventuallyRotate { q } { 470 QuaternionToView $q469 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 471 470 if { !$_rotatePending } { 472 471 set _rotatePending 1 … … 667 666 } 668 667 if { [array size found] > 1 } { 669 set _settings( -stretchtofit) 1668 set _settings(stretchToFit) 1 670 669 } else { 671 670 # Check if the range of the x and y axes requires that we stretch … … 676 675 if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) || 677 676 ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } { 678 set _settings( -stretchtofit) 1677 set _settings(stretchToFit) 1 679 678 } 680 679 } … … 843 842 if { $info(-type) == "image" } { 844 843 if 0 { 845 set f [open "last.ppm" "w"] 846 fconfigure $f -encoding binary 847 puts -nonewline $f $bytes 844 set f [open "last.ppm" "w"] 845 puts $f $bytes 848 846 close $f 849 847 } … … 930 928 $_arcball resize $w $h 931 929 DoResize 932 if { $_settings( -stretchtofit) } {933 AdjustSetting -stretchtofit930 if { $_settings(stretchToFit) } { 931 AdjustSetting stretchToFit 934 932 } 935 933 } … … 938 936 # Reset the camera and other view parameters 939 937 # 940 InitSettings -isheightmap -background 941 942 # Setting a custom exponent and label format for axes is causing 943 # a problem with rounding. Near zero ticks aren't rounded by 944 # the %g format. The VTK CubeAxes seem to currently work best 945 # when allowed to automatically set the exponent and precision 946 # based on the axis ranges. This does tend to result in less 947 # visual clutter, so I think it is best to use the automatic 948 # settings by default. We can test more fine-grained 949 # controls on the axis settings tab if necessary. 950 # -Leif 951 #SendCmd "axis exp 0 0 0 1" 938 InitSettings isHeightmap background 939 940 # Let's see how this goes. I think it's preferable to overloading the 941 # axis title with the exponent. 942 SendCmd "axis exp 0 0 0 1" 952 943 953 944 SendCmd "axis lrot z 90" 954 $_arcball quaternion [ViewToQuaternion] 955 if {$_settings(-isheightmap) } { 956 if { $_view(-ortho)} { 945 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 946 $_arcball quaternion $q 947 if {$_settings(isHeightmap) } { 948 if { $_view(ortho)} { 957 949 SendCmd "camera mode ortho" 958 950 } else { … … 983 975 if 0 { 984 976 set f [open /tmp/vtkheightmap.vtk "w"] 985 fconfigure $f -translation binary -encoding binary 986 puts -nonewline $f $bytes 977 puts $f $bytes 987 978 close $f 988 979 } … … 998 989 lappend info "dataset_size" $length 999 990 lappend info "dataset_tag" $tag 1000 SendCmd "clientinfo [list $info]"991 SendCmd [list "clientinfo" $info] 1001 992 } 1002 993 SendCmd "dataset add $tag data follows $length" … … 1047 1038 $itk_component(field) value $_curFldLabel 1048 1039 } 1049 InitSettings -stretchtofit -outline1040 InitSettings stretchToFit outline 1050 1041 1051 1042 if { $_reset } { 1052 1043 SendCmd "axis tickpos outside" 1053 #SendCmd "axis lformat all %g" 1044 foreach axis { x y z } { 1045 SendCmd "axis lformat $axis %g" 1046 } 1054 1047 1055 1048 foreach axis { x y z } { … … 1074 1067 1075 1068 if {$axis == "z" && [$_first hints ${axis}units] == ""} { 1076 if {$_curFldName != ""} { 1077 set units [lindex $_fields($_curFldName) 1] 1078 } 1069 set units [lindex $_fields($_curFldName) 1] 1079 1070 } else { 1080 1071 set units [$_first hints ${axis}units] … … 1089 1080 # 1090 1081 ResetAxes 1091 $_arcball quaternion [ViewToQuaternion] 1092 if {$_settings(-isheightmap) } { 1093 if { $_view(-ortho)} { 1082 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1083 $_arcball quaternion $q 1084 if {$_settings(isHeightmap) } { 1085 if { $_view(ortho)} { 1094 1086 SendCmd "camera mode ortho" 1095 1087 } else { … … 1100 1092 } 1101 1093 PanCamera 1102 InitSettings -xgrid -ygrid -zgrid \1103 -axisvisible -axislabels -heightmapscale -field -isheightmap \1104 -numisolines1094 InitSettings axisXGrid axisYGrid axisZGrid \ 1095 axisVisible axisLabels heightmapScale field isHeightmap \ 1096 numIsolines 1105 1097 if { [array size _fields] < 2 } { 1106 catch {blt::table forget $itk_component(field) $itk_component(field_l)}1098 blt::table forget $itk_component(field) $itk_component(field_l) 1107 1099 } 1108 1100 RequestLegend … … 1166 1158 itcl::body Rappture::VtkHeightmapViewer::CameraReset {} { 1167 1159 array set _view { 1168 -qw 0.361169 -qx 0.251170 -qy 0.501171 -qz 0.701172 -xpan01173 -ypan 01174 -zoom 1.01160 qw 0.36 1161 qx 0.25 1162 qy 0.50 1163 qz 0.70 1164 zoom 1.0 1165 xpan 0 1166 ypan 0 1175 1167 } 1176 1168 if { $_first != "" } { … … 1180 1172 } 1181 1173 } 1182 $_arcball quaternion [ViewToQuaternion] 1183 if {$_settings(-isheightmap) } { 1174 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1175 $_arcball quaternion $q 1176 if {$_settings(isHeightmap) } { 1184 1177 DoRotate 1185 1178 } … … 1198 1191 switch -- $option { 1199 1192 "in" { 1200 set _view( -zoom) [expr {$_view(-zoom)*1.25}]1201 SendCmd "camera zoom $_view( -zoom)"1193 set _view(zoom) [expr {$_view(zoom)*1.25}] 1194 SendCmd "camera zoom $_view(zoom)" 1202 1195 } 1203 1196 "out" { 1204 set _view( -zoom) [expr {$_view(-zoom)*0.8}]1205 SendCmd "camera zoom $_view( -zoom)"1197 set _view(zoom) [expr {$_view(zoom)*0.8}] 1198 SendCmd "camera zoom $_view(zoom)" 1206 1199 } 1207 1200 "reset" { 1208 1201 array set _view { 1209 -xpan01210 -ypan 01211 -zoom 1.01202 zoom 1.0 1203 xpan 0 1204 ypan 0 1212 1205 } 1213 1206 SendCmd "camera reset" … … 1217 1210 1218 1211 itcl::body Rappture::VtkHeightmapViewer::PanCamera {} { 1219 set x $_view( -xpan)1220 set y $_view( -ypan)1212 set x $_view(xpan) 1213 set y $_view(ypan) 1221 1214 SendCmd "camera pan $x $y" 1222 1215 } … … 1296 1289 set x [expr $x / double($w)] 1297 1290 set y [expr $y / double($h)] 1298 set _view( -xpan) [expr $_view(-xpan) + $x]1299 set _view( -ypan) [expr $_view(-ypan) + $y]1291 set _view(xpan) [expr $_view(xpan) + $x] 1292 set _view(ypan) [expr $_view(ypan) + $y] 1300 1293 PanCamera 1301 1294 return … … 1319 1312 set _click(x) $x 1320 1313 set _click(y) $y 1321 set _view( -xpan) [expr $_view(-xpan) - $dx]1322 set _view( -ypan) [expr $_view(-ypan) - $dy]1314 set _view(xpan) [expr $_view(xpan) - $dx] 1315 set _view(ypan) [expr $_view(ypan) - $dy] 1323 1316 PanCamera 1324 1317 } … … 1342 1335 itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } { 1343 1336 foreach spec $args { 1344 if { [info exists _settings($_first ${spec})] } {1337 if { [info exists _settings($_first-$spec)] } { 1345 1338 # Reset global setting with dataobj specific setting 1346 set _settings($spec) $_settings($_first ${spec})1339 set _settings($spec) $_settings($_first-$spec) 1347 1340 } 1348 1341 AdjustSetting $spec … … 1362 1355 } 1363 1356 switch -- $what { 1364 " -axisflymode" {1357 "axisFlymode" { 1365 1358 set mode [$itk_component(axisflymode) value] 1366 1359 set mode [$itk_component(axisflymode) translate $mode] … … 1368 1361 SendCmd "axis flymode $mode" 1369 1362 } 1370 "-axislabels" { 1363 "axisLabels" { 1364 set bool $_settings(axisLabels) 1365 SendCmd "axis labels all $bool" 1366 } 1367 "axisMinorTicks" { 1368 set bool $_settings(axisMinorTicks) 1369 foreach axis { x y z } { 1370 SendCmd "axis minticks ${axis} $bool" 1371 } 1372 } 1373 "axisVisible" { 1374 set bool $_settings(axisVisible) 1375 SendCmd "axis visible all $bool" 1376 } 1377 "axisXGrid" - "axisYGrid" - "axisZGrid" { 1378 set axis [string tolower [string range $what 4 4]] 1371 1379 set bool $_settings($what) 1372 SendCmd "axis labels all $bool" 1373 } 1374 "-axisminorticks" { 1375 set bool $_settings($what) 1376 SendCmd "axis minticks all $bool" 1377 } 1378 "-axisvisible" { 1379 set bool $_settings($what) 1380 SendCmd "axis visible all $bool" 1381 } 1382 "-background" { 1380 SendCmd "axis grid $axis $bool" 1381 } 1382 "background" { 1383 1383 set bg [$itk_component(background) value] 1384 1384 array set fgcolors { … … 1395 1395 DrawLegend 1396 1396 } 1397 " -colormap" {1398 set _changed( $what) 11397 "colormap" { 1398 set _changed(colormap) 1 1399 1399 StartBufferingCommands 1400 1400 set color [$itk_component(colormap) value] 1401 set _settings( $what) $color1401 set _settings(colormap) $color 1402 1402 if { $color == "none" } { 1403 if { $_settings( -colormapvisible) } {1403 if { $_settings(colormapVisible) } { 1404 1404 SendCmd "heightmap surface 0" 1405 set _settings( -colormapvisible) 01405 set _settings(colormapVisible) 0 1406 1406 } 1407 1407 } else { 1408 if { !$_settings( -colormapvisible) } {1408 if { !$_settings(colormapVisible) } { 1409 1409 SendCmd "heightmap surface 1" 1410 set _settings( -colormapvisible) 11410 set _settings(colormapVisible) 1 1411 1411 } 1412 1412 SetCurrentColormap $color 1413 if {$_settings( -colormapdiscrete)} {1414 set numColors [expr $_settings( -numisolines) + 1]1413 if {$_settings(colormapDiscrete)} { 1414 set numColors [expr $_settings(numIsolines) + 1] 1415 1415 SendCmd "colormap res $numColors $color" 1416 1416 } … … 1419 1419 EventuallyRequestLegend 1420 1420 } 1421 " -colormapvisible" {1421 "colormapVisible" { 1422 1422 set bool $_settings($what) 1423 1423 SendCmd "heightmap surface $bool" 1424 1424 } 1425 " -colormapdiscrete" {1425 "colormapDiscrete" { 1426 1426 set bool $_settings($what) 1427 set numColors [expr $_settings( -numisolines) + 1]1427 set numColors [expr $_settings(numIsolines) + 1] 1428 1428 StartBufferingCommands 1429 1429 if {$bool} { … … 1439 1439 EventuallyRequestLegend 1440 1440 } 1441 " -edges" {1442 set bool $_settings( $what)1441 "edges" { 1442 set bool $_settings(edges) 1443 1443 SendCmd "heightmap edges $bool" 1444 1444 } 1445 " -field" {1445 "field" { 1446 1446 set label [$itk_component(field) value] 1447 1447 set fname [$itk_component(field) translate $label] 1448 set _settings( $what) $fname1448 set _settings(field) $fname 1449 1449 if { [info exists _fields($fname)] } { 1450 1450 foreach { label units components } $_fields($fname) break … … 1488 1488 DrawLegend 1489 1489 } 1490 " -heightmapscale" {1491 if { $_settings( -isheightmap) } {1490 "heightmapScale" { 1491 if { $_settings(isHeightmap) } { 1492 1492 set scale [GetHeightmapScale] 1493 1493 # Have to set the datasets individually because we are … … 1500 1500 } 1501 1501 } 1502 " -isheightmap" {1503 set bool $_settings( $what)1502 "isHeightmap" { 1503 set bool $_settings(isHeightmap) 1504 1504 set c $itk_component(view) 1505 1505 StartBufferingCommands 1506 1506 # Fix heightmap scale: 0 for contours, 1 for heightmaps. 1507 1507 if { $bool } { 1508 set _settings( -heightmapscale) 501509 set _settings( -opacity) $_settings(-saveopacity)1510 set _settings( -lighting) $_settings(-savelighting)1511 set _settings( -outline) 01508 set _settings(heightmapScale) 50 1509 set _settings(opacity) $_settings(saveOpacity) 1510 set _settings(lighting) $_settings(saveLighting) 1511 set _settings(outline) 0 1512 1512 } else { 1513 set _settings(-heightmapscale) 0 1514 set _settings(-lighting) 0 1515 set _settings(-opacity) 100 1516 set _settings(-outline) $_settings(-saveoutline) 1517 } 1518 InitSettings -lighting -opacity -outline 1513 set _settings(heightmapScale) 0 1514 set _settings(lighting) 0 1515 set _settings(opacity) 100 1516 set _settings(outline) $_settings(saveOutline) 1517 } 1518 AdjustSetting lighting 1519 AdjustSetting opacity 1520 AdjustSetting outline 1519 1521 set scale [GetHeightmapScale] 1520 1522 # Have to set the datasets individually because we are … … 1531 1533 $itk_component(scale_l) configure -state normal 1532 1534 $itk_component(outline) configure -state disabled 1533 if {$_view( -ortho)} {1535 if {$_view(ortho)} { 1534 1536 SendCmd "camera mode ortho" 1535 1537 } else { … … 1545 1547 SendCmd "camera mode image" 1546 1548 } 1547 if {$_settings( -stretchtofit)} {1549 if {$_settings(stretchToFit)} { 1548 1550 if {$scale == 0} { 1549 1551 SendCmd "camera aspect window" … … 1554 1556 ResetAxes 1555 1557 if { $bool } { 1556 set q [ ViewToQuaternion]1558 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1557 1559 $_arcball quaternion $q 1558 1560 SendCmd "camera orient $q" … … 1576 1578 StopBufferingCommands 1577 1579 } 1578 " -isolinecolor" {1580 "isolineColor" { 1579 1581 set color [$itk_component(isolinecolor) value] 1580 1582 if { $color == "none" } { 1581 if { $_settings( -isolinesvisible) } {1583 if { $_settings(isolinesVisible) } { 1582 1584 SendCmd "heightmap isolines 0" 1583 set _settings( -isolinesvisible) 01585 set _settings(isolinesVisible) 0 1584 1586 } 1585 1587 } else { 1586 if { !$_settings( -isolinesvisible) } {1588 if { !$_settings(isolinesVisible) } { 1587 1589 SendCmd "heightmap isolines 1" 1588 set _settings( -isolinesvisible) 11590 set _settings(isolinesVisible) 1 1589 1591 } 1590 1592 SendCmd "heightmap isolinecolor [Color2RGB $color]" … … 1592 1594 DrawLegend 1593 1595 } 1594 " -isolinesvisible" {1596 "isolinesVisible" { 1595 1597 set bool $_settings($what) 1596 1598 SendCmd "heightmap isolines $bool" 1597 1599 DrawLegend 1598 1600 } 1599 " -legendvisible" {1601 "legendVisible" { 1600 1602 if { !$_settings($what) } { 1601 1603 $itk_component(view) delete legend … … 1603 1605 DrawLegend 1604 1606 } 1605 " -lighting" {1606 if { $_settings( -isheightmap) } {1607 set _settings( -savelighting) $_settings($what)1607 "lighting" { 1608 if { $_settings(isHeightmap) } { 1609 set _settings(saveLighting) $_settings(lighting) 1608 1610 set bool $_settings($what) 1609 1611 SendCmd "heightmap lighting $bool" … … 1612 1614 } 1613 1615 } 1614 " -numisolines" {1615 set _settings( $what) [$itk_component(numisolines) value]1616 set _currentNumIsolines $_settings( $what)1616 "numIsolines" { 1617 set _settings(numIsolines) [$itk_component(numisolines) value] 1618 set _currentNumIsolines $_settings(numIsolines) 1617 1619 UpdateContourList 1618 set _changed( $what) 11620 set _changed(numIsolines) 1 1619 1621 SendCmd "heightmap contourlist [list $_contourList]" 1620 if {$_settings( -colormapdiscrete)} {1621 set numColors [expr $_settings( $what) + 1]1622 if {$_settings(colormapDiscrete)} { 1623 set numColors [expr $_settings(numIsolines) + 1] 1622 1624 SendCmd "colormap res $numColors" 1623 1625 EventuallyRequestLegend … … 1626 1628 } 1627 1629 } 1628 "-opacity" { 1629 set _changed($what) 1 1630 set val [expr $_settings($what) * 0.01] 1631 if { $_settings(-isheightmap) } { 1632 set _settings(-saveopacity) $_settings($what) 1633 SendCmd "heightmap opacity $val" 1630 "opacity" { 1631 set _changed(opacity) 1 1632 if { $_settings(isHeightmap) } { 1633 set _settings(saveOpacity) $_settings(opacity) 1634 set val $_settings(opacity) 1635 set sval [expr { 0.01 * double($val) }] 1636 SendCmd "heightmap opacity $sval" 1634 1637 } else { 1635 SendCmd "heightmap opacity 1 .0"1636 } 1637 } 1638 " -outline" {1639 if { $_settings( -isheightmap) } {1638 SendCmd "heightmap opacity 1" 1639 } 1640 } 1641 "outline" { 1642 if { $_settings(isHeightmap) } { 1640 1643 SendCmd "outline visible 0" 1641 1644 } else { 1642 set _settings( -saveoutline) $_settings($what)1643 set bool $_settings( $what)1645 set _settings(saveOutline) $_settings(outline) 1646 set bool $_settings(outline) 1644 1647 SendCmd "outline visible $bool" 1645 1648 } 1646 1649 } 1647 " -stretchtofit" {1650 "stretchToFit" { 1648 1651 set bool $_settings($what) 1649 1652 if { $bool } { … … 1659 1662 Zoom reset 1660 1663 } 1661 " -wireframe" {1664 "wireframe" { 1662 1665 set bool $_settings($what) 1663 1666 SendCmd "heightmap wireframe $bool" 1664 }1665 "-xgrid" - "-ygrid" - "-zgrid" {1666 set axis [string tolower [string range $what 1 1]]1667 set bool $_settings($what)1668 SendCmd "axis grid $axis $bool"1669 1667 } 1670 1668 default { … … 1719 1717 if { $_currentColormap != "" } { 1720 1718 set cmap $_currentColormap 1721 #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0" 1722 SendCmd "legend2 $cmap $w $h" 1719 SendCmd "legend $cmap scalar $_curFldName {} $w $h 0" 1723 1720 } 1724 1721 } … … 1780 1777 } 1781 1778 1779 1782 1780 # 1783 1781 # BuildColormap -- … … 1800 1798 switch -- $itk_option(-mode) { 1801 1799 "heightmap" { 1802 set _settings( -isheightmap) 11800 set _settings(isHeightmap) 1 1803 1801 } 1804 1802 "contour" { 1805 set _settings( -isheightmap) 01803 set _settings(isHeightmap) 0 1806 1804 } 1807 1805 default { … … 1810 1808 } 1811 1809 if { !$_reset } { 1812 AdjustSetting -isheightmap1810 AdjustSetting isHeightmap 1813 1811 } 1814 1812 } … … 1834 1832 set rgb [Color2RGB $itk_option(-plotforeground)] 1835 1833 if { !$_reset } { 1834 SendCmd "outline color $rgb" 1836 1835 SendCmd "axis color all $rgb" 1837 SendCmd "outline color $rgb" 1838 } 1839 } 1836 } 1837 } 1838 } 1839 1840 itcl::body Rappture::VtkHeightmapViewer::limits3 { dataobj } { 1841 lappend limits x [$dataobj limits x] 1842 lappend limits y [$dataobj limits y] 1843 if { [catch { $dataobj limits $_curFldName } vlim] != 0 } { 1844 set vlim [$dataobj limits v] 1845 } 1846 lappend limits v $vlim 1847 return $limits 1840 1848 } 1841 1849 … … 1852 1860 checkbutton $inner.legend \ 1853 1861 -text "Legend" \ 1854 -variable [itcl::scope _settings( -legendvisible)] \1855 -command [itcl::code $this AdjustSetting -legendvisible] \1862 -variable [itcl::scope _settings(legendVisible)] \ 1863 -command [itcl::code $this AdjustSetting legendVisible] \ 1856 1864 -font "Arial 9" 1857 1865 1858 1866 checkbutton $inner.wireframe \ 1859 1867 -text "Wireframe" \ 1860 -variable [itcl::scope _settings( -wireframe)] \1861 -command [itcl::code $this AdjustSetting -wireframe] \1868 -variable [itcl::scope _settings(wireframe)] \ 1869 -command [itcl::code $this AdjustSetting wireframe] \ 1862 1870 -font "Arial 9" 1863 1871 … … 1865 1873 checkbutton $inner.lighting \ 1866 1874 -text "Enable Lighting" \ 1867 -variable [itcl::scope _settings( -lighting)] \1868 -command [itcl::code $this AdjustSetting -lighting] \1875 -variable [itcl::scope _settings(lighting)] \ 1876 -command [itcl::code $this AdjustSetting lighting] \ 1869 1877 -font "Arial 9" 1870 1878 } { … … 1873 1881 checkbutton $inner.edges \ 1874 1882 -text "Edges" \ 1875 -variable [itcl::scope _settings( -edges)] \1876 -command [itcl::code $this AdjustSetting -edges] \1883 -variable [itcl::scope _settings(edges)] \ 1884 -command [itcl::code $this AdjustSetting edges] \ 1877 1885 -font "Arial 9" 1878 1886 … … 1880 1888 checkbutton $inner.outline \ 1881 1889 -text "Outline" \ 1882 -variable [itcl::scope _settings( -outline)] \1883 -command [itcl::code $this AdjustSetting -outline] \1890 -variable [itcl::scope _settings(outline)] \ 1891 -command [itcl::code $this AdjustSetting outline] \ 1884 1892 -font "Arial 9" 1885 1893 } { … … 1888 1896 checkbutton $inner.stretch \ 1889 1897 -text "Stretch to fit" \ 1890 -variable [itcl::scope _settings( -stretchtofit)] \1891 -command [itcl::code $this AdjustSetting -stretchtofit] \1898 -variable [itcl::scope _settings(stretchToFit)] \ 1899 -command [itcl::code $this AdjustSetting stretchToFit] \ 1892 1900 -font "Arial 9" 1893 1901 1894 1902 checkbutton $inner.isolines \ 1895 1903 -text "Isolines" \ 1896 -variable [itcl::scope _settings( -isolinesvisible)] \1897 -command [itcl::code $this AdjustSetting -isolinesvisible] \1904 -variable [itcl::scope _settings(isolinesVisible)] \ 1905 -command [itcl::code $this AdjustSetting isolinesVisible] \ 1898 1906 -font "Arial 9" 1899 1907 1900 1908 checkbutton $inner.colormapDiscrete \ 1901 1909 -text "Discrete Colormap" \ 1902 -variable [itcl::scope _settings( -colormapdiscrete)] \1903 -command [itcl::code $this AdjustSetting -colormapdiscrete] \1910 -variable [itcl::scope _settings(colormapDiscrete)] \ 1911 -command [itcl::code $this AdjustSetting colormapDiscrete] \ 1904 1912 -font "Arial 9" 1905 1913 … … 1913 1921 } 1914 1922 bind $inner.field <<Value>> \ 1915 [itcl::code $this AdjustSetting -field]1923 [itcl::code $this AdjustSetting field] 1916 1924 1917 1925 label $inner.colormap_l -text "Colormap" -font "Arial 9" … … 1919 1927 Rappture::Combobox $inner.colormap -width 10 -editable no 1920 1928 } 1921 $inner.colormap choices insert end [GetColormapList -includeNone] 1922 $itk_component(colormap) value $_settings(-colormap) 1929 $inner.colormap choices insert end \ 1930 "BCGYR" "BCGYR" \ 1931 "BGYOR" "BGYOR" \ 1932 "blue" "blue" \ 1933 "blue-to-brown" "blue-to-brown" \ 1934 "blue-to-orange" "blue-to-orange" \ 1935 "blue-to-grey" "blue-to-grey" \ 1936 "green-to-magenta" "green-to-magenta" \ 1937 "greyscale" "greyscale" \ 1938 "nanohub" "nanohub" \ 1939 "rainbow" "rainbow" \ 1940 "spectral" "spectral" \ 1941 "ROYGB" "ROYGB" \ 1942 "RYGCB" "RYGCB" \ 1943 "brown-to-blue" "brown-to-blue" \ 1944 "grey-to-blue" "grey-to-blue" \ 1945 "orange-to-blue" "orange-to-blue" \ 1946 "none" "none" 1947 1948 $itk_component(colormap) value "BCGYR" 1923 1949 bind $inner.colormap <<Value>> \ 1924 [itcl::code $this AdjustSetting -colormap]1950 [itcl::code $this AdjustSetting colormap] 1925 1951 1926 1952 label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9" … … 1940 1966 "none" "none" 1941 1967 1942 $itk_component(isolinecolor) value $_settings(-isolinecolor)1968 $itk_component(isolinecolor) value "black" 1943 1969 bind $inner.isolinecolor <<Value>> \ 1944 [itcl::code $this AdjustSetting -isolinecolor]1970 [itcl::code $this AdjustSetting isolineColor] 1945 1971 1946 1972 label $inner.background_l -text "Background Color" -font "Arial 9" … … 1954 1980 1955 1981 $itk_component(background) value "white" 1956 bind $inner.background <<Value>> \ 1957 [itcl::code $this AdjustSetting -background] 1982 bind $inner.background <<Value>> [itcl::code $this AdjustSetting background] 1958 1983 1959 1984 itk_component add opacity_l { … … 1964 1989 itk_component add opacity { 1965 1990 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1966 -variable [itcl::scope _settings( -opacity)] \1991 -variable [itcl::scope _settings(opacity)] \ 1967 1992 -showvalue off \ 1968 -command [itcl::code $this AdjustSetting -opacity]1993 -command [itcl::code $this AdjustSetting opacity] 1969 1994 } 1970 1995 itk_component add scale_l { … … 1975 2000 itk_component add scale { 1976 2001 ::scale $inner.scale -from 0 -to 100 -orient horizontal \ 1977 -variable [itcl::scope _settings( -heightmapscale)] \2002 -variable [itcl::scope _settings(heightmapScale)] \ 1978 2003 -showvalue off \ 1979 -command [itcl::code $this AdjustSetting -heightmapscale]2004 -command [itcl::code $this AdjustSetting heightmapScale] 1980 2005 } 1981 2006 label $inner.numisolines_l -text "Number of Isolines" -font "Arial 9" … … 1984 2009 -min 0 -max 50 -font "arial 9" 1985 2010 } 1986 $itk_component(numisolines) value $_settings( -numisolines)2011 $itk_component(numisolines) value $_settings(numIsolines) 1987 2012 bind $itk_component(numisolines) <<Value>> \ 1988 [itcl::code $this AdjustSetting -numisolines]2013 [itcl::code $this AdjustSetting numIsolines] 1989 2014 1990 2015 frame $inner.separator1 -height 2 -relief sunken -bd 1 … … 2033 2058 checkbutton $inner.visible \ 2034 2059 -text "Axes" \ 2035 -variable [itcl::scope _settings( -axisvisible)] \2036 -command [itcl::code $this AdjustSetting -axisvisible] \2060 -variable [itcl::scope _settings(axisVisible)] \ 2061 -command [itcl::code $this AdjustSetting axisVisible] \ 2037 2062 -font "Arial 9" 2038 2063 checkbutton $inner.labels \ 2039 2064 -text "Axis Labels" \ 2040 -variable [itcl::scope _settings( -axislabels)] \2041 -command [itcl::code $this AdjustSetting -axislabels] \2065 -variable [itcl::scope _settings(axisLabels)] \ 2066 -command [itcl::code $this AdjustSetting axisLabels] \ 2042 2067 -font "Arial 9" 2043 2068 label $inner.grid_l -text "Grid" -font "Arial 9" 2044 2069 checkbutton $inner.xgrid \ 2045 2070 -text "X" \ 2046 -variable [itcl::scope _settings( -xgrid)] \2047 -command [itcl::code $this AdjustSetting -xgrid] \2071 -variable [itcl::scope _settings(axisXGrid)] \ 2072 -command [itcl::code $this AdjustSetting axisXGrid] \ 2048 2073 -font "Arial 9" 2049 2074 checkbutton $inner.ygrid \ 2050 2075 -text "Y" \ 2051 -variable [itcl::scope _settings( -ygrid)] \2052 -command [itcl::code $this AdjustSetting -ygrid] \2076 -variable [itcl::scope _settings(axisYGrid)] \ 2077 -command [itcl::code $this AdjustSetting axisYGrid] \ 2053 2078 -font "Arial 9" 2054 2079 checkbutton $inner.zgrid \ 2055 2080 -text "Z" \ 2056 -variable [itcl::scope _settings( -zgrid)] \2057 -command [itcl::code $this AdjustSetting -zgrid] \2081 -variable [itcl::scope _settings(axisZGrid)] \ 2082 -command [itcl::code $this AdjustSetting axisZGrid] \ 2058 2083 -font "Arial 9" 2059 2084 checkbutton $inner.minorticks \ 2060 2085 -text "Minor Ticks" \ 2061 -variable [itcl::scope _settings( -axisminorticks)] \2062 -command [itcl::code $this AdjustSetting -axisminorticks] \2086 -variable [itcl::scope _settings(axisMinorTicks)] \ 2087 -command [itcl::code $this AdjustSetting axisMinorTicks] \ 2063 2088 -font "Arial 9" 2089 2064 2090 2065 2091 label $inner.mode_l -text "Mode" -font "Arial 9" … … 2073 2099 "furthest_triad" "farthest" \ 2074 2100 "outer_edges" "outer" 2075 $itk_component(axisflymode) value $_settings(-axisflymode)2076 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]2101 $itk_component(axisflymode) value "static" 2102 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlymode] 2077 2103 2078 2104 blt::table $inner \ … … 2092 2118 } 2093 2119 2120 2094 2121 itcl::body Rappture::VtkHeightmapViewer::BuildCameraTab {} { 2095 2122 set inner [$itk_component(main) insert end \ … … 2110 2137 0,0 $inner.view_l -anchor e -pady 2 \ 2111 2138 0,1 $inner.view -anchor w -pady 2 2112 blt::table configure $inner r0 -resize none2113 2139 2114 2140 set labels { qx qy qz qw xpan ypan zoom } … … 2117 2143 label $inner.${tag}label -text $tag -font "Arial 9" 2118 2144 entry $inner.${tag} -font "Arial 9" -bg white \ 2119 -textvariable [itcl::scope _view( -$tag)]2145 -textvariable [itcl::scope _view($tag)] 2120 2146 bind $inner.${tag} <Return> \ 2121 [itcl::code $this camera set -${tag}]2147 [itcl::code $this camera set ${tag}] 2122 2148 bind $inner.${tag} <KP_Enter> \ 2123 [itcl::code $this camera set -${tag}]2149 [itcl::code $this camera set ${tag}] 2124 2150 blt::table $inner \ 2125 2151 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 2130 2156 checkbutton $inner.ortho \ 2131 2157 -text "Orthographic Projection" \ 2132 -variable [itcl::scope _view( -ortho)] \2133 -command [itcl::code $this camera set -ortho] \2158 -variable [itcl::scope _view(ortho)] \ 2159 -command [itcl::code $this camera set ortho] \ 2134 2160 -font "Arial 9" 2135 2161 blt::table $inner \ … … 2138 2164 incr row 2139 2165 2140 blt::table configure $inner c* -resize none2166 blt::table configure $inner c* r* -resize none 2141 2167 blt::table configure $inner c2 -resize expand 2142 2168 blt::table configure $inner r$row -resize expand … … 2152 2178 } 2153 2179 "set" { 2154 set wh at[lindex $args 0]2155 set x $_view($wh at)2180 set who [lindex $args 0] 2181 set x $_view($who) 2156 2182 set code [catch { string is double $x } result] 2157 2183 if { $code != 0 || !$result } { 2158 2184 return 2159 2185 } 2160 switch -- $wh at{2161 " -ortho" {2162 if {$_view( $what)} {2186 switch -- $who { 2187 "ortho" { 2188 if {$_view(ortho)} { 2163 2189 SendCmd "camera mode ortho" 2164 2190 } else { … … 2166 2192 } 2167 2193 } 2168 " -xpan" - "-ypan" {2194 "xpan" - "ypan" { 2169 2195 PanCamera 2170 2196 } 2171 " -qx" - "-qy" - "-qz" - "-qw" {2172 set q [ ViewToQuaternion]2197 "qx" - "qy" - "qz" - "qw" { 2198 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2173 2199 $_arcball quaternion $q 2174 2200 EventuallyRotate $q 2175 2201 } 2176 " -zoom" {2177 SendCmd "camera zoom $_view( $what)"2202 "zoom" { 2203 SendCmd "camera zoom $_view(zoom)" 2178 2204 } 2179 2205 } … … 2259 2285 array set style { 2260 2286 -color BCGYR 2287 -opacity 100 2261 2288 -levels 10 2262 -opacity 1.02263 2289 } 2264 2290 set stylelist [$dataobj style $comp] … … 2275 2301 # the code to handle aberrant cases. 2276 2302 2277 if { $_changed( -opacity) } {2278 set style(-opacity) [expr $_settings(-opacity) * 0.01]2279 } 2280 if { $_changed( -numisolines) } {2281 set style(-levels) $_settings( -numisolines)2282 } 2283 if { $_changed( -colormap) } {2284 set style(-color) $_settings( -colormap)2303 if { $_changed(opacity) } { 2304 set style(-opacity) $_settings(opacity) 2305 } 2306 if { $_changed(numIsolines) } { 2307 set style(-levels) $_settings(numIsolines) 2308 } 2309 if { $_changed(colormap) } { 2310 set style(-color) $_settings(colormap) 2285 2311 } 2286 2312 if { $_currentColormap == "" } { … … 2288 2314 } 2289 2315 if { [info exists style(-stretchtofit)] } { 2290 set _settings(-stretchtofit) $style(-stretchtofit) 2291 AdjustSetting -stretchtofit 2292 } 2316 set _settings(stretchToFit) $style(-stretchtofit) 2317 AdjustSetting stretchToFit 2318 } 2319 set _currentOpacity $style(-opacity) 2293 2320 if { $_currentNumIsolines != $style(-levels) } { 2294 2321 set _currentNumIsolines $style(-levels) 2295 set _settings( -numisolines) $_currentNumIsolines2322 set _settings(numIsolines) $_currentNumIsolines 2296 2323 $itk_component(numisolines) value $_currentNumIsolines 2297 2324 UpdateContourList … … 2300 2327 SendCmd "outline add $tag" 2301 2328 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2302 SendCmd "outline visible $_settings( -outline) $tag"2329 SendCmd "outline visible $_settings(outline) $tag" 2303 2330 set scale [GetHeightmapScale] 2304 2331 SendCmd "[list heightmap add contourlist $_contourList $scale $tag]" 2305 set _comp2scale($tag) $_settings( -heightmapscale)2306 SendCmd "heightmap edges $_settings( -edges) $tag"2307 SendCmd "heightmap wireframe $_settings( -wireframe) $tag"2308 SetCurrentColormap $style(-color) 2332 set _comp2scale($tag) $_settings(heightmapScale) 2333 SendCmd "heightmap edges $_settings(edges) $tag" 2334 SendCmd "heightmap wireframe $_settings(wireframe) $tag" 2335 SetCurrentColormap $style(-color) 2309 2336 set color [$itk_component(isolinecolor) value] 2310 2337 SendCmd "heightmap isolinecolor [Color2RGB $color] $tag" 2311 SendCmd "heightmap lighting $_settings(-isheightmap) $tag" 2312 SendCmd "heightmap isolines $_settings(-isolinesvisible) $tag" 2313 SendCmd "heightmap surface $_settings(-colormapvisible) $tag" 2314 SendCmd "heightmap opacity $style(-opacity) $tag" 2315 set _settings(-opacity) [expr $style(-opacity) * 100.0] 2338 SendCmd "heightmap lighting $_settings(isHeightmap) $tag" 2339 SendCmd "heightmap isolines $_settings(isolinesVisible) $tag" 2340 SendCmd "heightmap surface $_settings(colormapVisible) $tag" 2316 2341 } 2317 2342 … … 2372 2397 } 2373 2398 set x [expr $w - 2] 2374 if { !$_settings( -legendvisible) } {2399 if { !$_settings(legendVisible) } { 2375 2400 $c delete legend 2376 2401 return … … 2380 2405 # If there's a legend title, create a text item for the title. 2381 2406 $c create text $x $y \ 2382 -anchor ne \ 2383 -fill $itk_option(-plotforeground) -tags "title legend" \ 2384 -font $font 2385 if { $title != "" } { 2386 incr y $lineht 2387 } 2407 -anchor ne \ 2408 -fill $itk_option(-plotforeground) -tags "title legend" \ 2409 -font $font 2388 2410 $c create text $x $y \ 2389 2390 2391 2392 2411 -anchor ne \ 2412 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2413 -font $font 2414 incr y $lineht 2393 2415 $c create image $x $y \ 2394 2416 -anchor ne \ … … 2414 2436 array unset _isolines 2415 2437 if { $color != "none" && [info exists _limits($_curFldName)] && 2416 $_settings( -isolinesvisible) && $_currentNumIsolines > 0 } {2438 $_settings(isolinesVisible) && $_currentNumIsolines > 0 } { 2417 2439 2418 2440 foreach { vmin vmax } $_limits($_curFldName) break … … 2581 2603 invoke { 2582 2604 $itk_component(field) value $_curFldLabel 2583 AdjustSetting -field2605 AdjustSetting field 2584 2606 } 2585 2607 default { … … 2590 2612 2591 2613 itcl::body Rappture::VtkHeightmapViewer::GetHeightmapScale {} { 2592 if { $_settings( -isheightmap) } {2593 set val $_settings( -heightmapscale)2614 if { $_settings(isHeightmap) } { 2615 set val $_settings(heightmapScale) 2594 2616 set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }] 2595 2617 return $sval … … 2607 2629 bottom "0 1 0 0" 2608 2630 } 2609 foreach name { -qw -qx -qy -qz } value $positions($side) {2631 foreach name { qw qx qy qz } value $positions($side) { 2610 2632 set _view($name) $value 2611 2633 } 2612 set q [ ViewToQuaternion]2634 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2613 2635 $_arcball quaternion $q 2614 2636 SendCmd "camera orient $q" 2615 2637 SendCmd "camera reset" 2616 set _view( -xpan) 02617 set _view( -ypan) 02618 set _view( -zoom) 1.02638 set _view(xpan) 0 2639 set _view(ypan) 0 2640 set _view(zoom) 1.0 2619 2641 } 2620 2642 -
branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl
r4772 r4848 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 # COMPONENT: vtk streamlinesviewer - Vtk streamlinesobject viewer3 # COMPONENT: vtkviewer - Vtk drawing object viewer 4 4 # 5 5 # It connects to the Vtk server running on a rendering farm, … … 7 7 # ====================================================================== 8 8 # AUTHOR: Michael McLennan, Purdue University 9 # Copyright (c) 2004-201 4HUBzero Foundation, LLC9 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 # 11 11 # See the file "license.terms" for information on usage and … … 62 62 public method scale {args} 63 63 64 protected method Connect {} 65 protected method CurrentDatasets {args} 66 protected method Disconnect {} 67 protected method DoResize {} 68 protected method DoReseed {} 69 protected method DoRotate {} 70 protected method AdjustSetting {what {value ""}} 71 protected method InitSettings { args } 72 protected method Pan {option x y} 73 protected method Pick {x y} 74 protected method Rebuild {} 75 protected method ReceiveDataset { args } 76 protected method ReceiveImage { args } 77 protected method ReceiveLegend { colormap title vmin vmax size } 78 protected method Rotate {option x y} 79 protected method Zoom {option} 80 64 81 # The following methods are only used by this class. 65 private method AdjustSetting {what {value ""}}66 82 private method BuildAxisTab {} 67 83 private method BuildCameraTab {} … … 73 89 private method DrawLegend {} 74 90 private method Combo { option } 75 private method Connect {}76 private method CurrentDatasets {args}77 private method Disconnect {}78 private method DoResize {}79 private method DoReseed {}80 private method DoRotate {}81 91 private method EnterLegend { x y } 82 92 private method EventuallyResize { w h } … … 86 96 private method GetImage { args } 87 97 private method GetVtkData { args } 88 private method InitSettings { args }89 98 private method IsValidObject { dataobj } 90 99 private method LeaveLegend {} 91 100 private method MotionLegend { x y } 92 private method Pan {option x y}93 101 private method PanCamera {} 94 private method Pick {x y}95 private method QuaternionToView { q } {96 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break97 }98 private method Rebuild {}99 private method ReceiveDataset { args }100 private method ReceiveImage { args }101 private method ReceiveLegend { colormap title vmin vmax size }102 102 private method RequestLegend {} 103 private method Rotate {option x y}104 103 private method SetColormap { dataobj comp } 105 104 private method ChangeColormap { dataobj comp color } … … 108 107 private method Slice {option args} 109 108 private method SetOrientation { side } 110 private method ViewToQuaternion {} {111 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]112 }113 private method Zoom {option}114 109 115 110 private variable _arcball "" … … 194 189 $_dispatcher register !xcutplane 195 190 $_dispatcher dispatch $this !xcutplane \ 196 "[itcl::code $this AdjustSetting -cutplanexposition]; list"191 "[itcl::code $this AdjustSetting cutplaneXPosition]; list" 197 192 198 193 # Y-Cutplane event 199 194 $_dispatcher register !ycutplane 200 195 $_dispatcher dispatch $this !ycutplane \ 201 "[itcl::code $this AdjustSetting -cutplaneyposition]; list"196 "[itcl::code $this AdjustSetting cutplaneYPosition]; list" 202 197 203 198 # Z-Cutplane event 204 199 $_dispatcher register !zcutplane 205 200 $_dispatcher dispatch $this !zcutplane \ 206 "[itcl::code $this AdjustSetting -cutplanezposition]; list"201 "[itcl::code $this AdjustSetting cutplaneZPosition]; list" 207 202 208 203 # … … 215 210 # Initialize the view to some default parameters. 216 211 array set _view { 217 -ortho 0218 -qw 0.853553219 -qx -0.353553220 -qy 0.353553221 -qz 0.146447222 -xpan 0223 -ypan 0224 -zoom 1.0212 qw 0.853553 213 qx -0.353553 214 qy 0.353553 215 qz 0.146447 216 zoom 1.0 217 xpan 0 218 ypan 0 219 ortho 0 225 220 } 226 221 set _arcball [blt::arcball create 100 100] 227 $_arcball quaternion [ViewToQuaternion] 222 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 223 $_arcball quaternion $q 228 224 229 225 array set _settings [subst { 230 -axesvisible 1 231 -axislabelsvisible 1 232 -axisminorticks 1 233 -axismode "static" 234 -cutplaneedges 0 235 -cutplanelighting 1 236 -cutplaneopacity 100 237 -cutplanevisible 0 238 -cutplanewireframe 0 239 -cutplanexposition 50 240 -cutplanexvisible 1 241 -cutplaneyposition 50 242 -cutplaneyvisible 1 243 -cutplanezposition 50 244 -cutplanezvisible 1 245 -legendvisible 1 246 -streamlineslighting 1 247 -streamlinesmode lines 248 -streamlinesnumseeds 200 249 -streamlinesopacity 100 250 -streamlinesscale 1 251 -streamlinesseedsvisible 0 252 -streamlinesvisible 1 253 -volumeedges 0 254 -volumelighting 1 255 -volumeopacity 40 256 -volumevisible 1 257 -volumewireframe 0 258 -xgrid 0 259 -ygrid 0 260 -zgrid 0 226 axesVisible 1 227 axisLabelsVisible 1 228 axisXGrid 0 229 axisYGrid 0 230 axisZGrid 0 231 cutplaneEdges 0 232 cutplaneLighting 1 233 cutplaneOpacity 100 234 cutplaneVisible 0 235 cutplaneWireframe 0 236 cutplaneXPosition 50 237 cutplaneXVisible 1 238 cutplaneYPosition 50 239 cutplaneYVisible 1 240 cutplaneZPosition 50 241 cutplaneZVisible 1 242 legendVisible 1 243 streamlinesLighting 1 244 streamlinesMode lines 245 streamlinesNumSeeds 200 246 streamlinesOpacity 100 247 streamlinesScale 1 248 streamlinesSeedsVisible 0 249 streamlinesVisible 1 250 volumeEdges 0 251 volumeLighting 1 252 volumeOpacity 40 253 volumeVisible 1 254 volumeWireframe 0 261 255 }] 262 256 … … 337 331 -onimage [Rappture::icon volume-on] \ 338 332 -offimage [Rappture::icon volume-off] \ 339 -variable [itcl::scope _settings( -volumevisible)] \340 -command [itcl::code $this AdjustSetting -volumevisible]333 -variable [itcl::scope _settings(volumeVisible)] \ 334 -command [itcl::code $this AdjustSetting volumeVisible] 341 335 } 342 336 $itk_component(volume) select … … 349 343 -onimage [Rappture::icon streamlines-on] \ 350 344 -offimage [Rappture::icon streamlines-off] \ 351 -variable [itcl::scope _settings( -streamlinesvisible)] \352 -command [itcl::code $this AdjustSetting -streamlinesvisible] \345 -variable [itcl::scope _settings(streamlinesVisible)] \ 346 -command [itcl::code $this AdjustSetting streamlinesVisible] \ 353 347 } 354 348 $itk_component(streamlines) select … … 361 355 -onimage [Rappture::icon cutbutton] \ 362 356 -offimage [Rappture::icon cutbutton] \ 363 -variable [itcl::scope _settings( -cutplanevisible)] \364 -command [itcl::code $this AdjustSetting -cutplanevisible]357 -variable [itcl::scope _settings(cutplaneVisible)] \ 358 -command [itcl::code $this AdjustSetting cutplaneVisible] 365 359 } 366 360 Rappture::Tooltip::for $itk_component(cutplane) \ … … 405 399 bind $itk_component(view) <ButtonRelease-1> \ 406 400 [itcl::code $this Rotate release %x %y] 407 401 bind $itk_component(view) <Configure> \ 402 [itcl::code $this EventuallyResize %w %h] 403 404 if 0 { 405 bind $itk_component(view) <Configure> \ 406 [itcl::code $this EventuallyResize %w %h] 407 } 408 408 # Bindings for panning via mouse 409 409 bind $itk_component(view) <ButtonPress-2> \ … … 453 453 eval itk_initialize $args 454 454 Connect 455 update 455 456 } 456 457 … … 480 481 481 482 itcl::body Rappture::VtkStreamlinesViewer::DoRotate {} { 482 SendCmd "camera orient [ViewToQuaternion]" 483 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 484 SendCmd "camera orient $q" 483 485 set _rotatePending 0 484 486 } … … 514 516 515 517 itcl::body Rappture::VtkStreamlinesViewer::EventuallyRotate { q } { 516 QuaternionToView $q518 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 517 519 if { !$_rotatePending } { 518 520 set _rotatePending 1 … … 786 788 if { $_reportClientInfo } { 787 789 # Tell the server the viewer, hub, user and session. 788 # Do this immediately on connect before buff ering any commands790 # Do this immediately on connect before buffing any commands 789 791 global env 790 792 … … 876 878 if { $info(-type) == "image" } { 877 879 if 0 { 878 set f [open "last.ppm" "w"] 879 fconfigure $f -encoding binary 880 puts -nonewline $f $bytes 880 set f [open "last.ppm" "w"] 881 puts $f $bytes 881 882 close $f 882 883 } … … 969 970 $_arcball resize $w $h 970 971 DoResize 971 InitSettings -xgrid -ygrid -zgrid -axismode \972 -axesvisible -axislabelsvisible -axisminorticks972 InitSettings axisXGrid axisYGrid axisZGrid axis-mode \ 973 axesVisible axisLabelsVisible 973 974 # This "imgflush" is to force an image returned before vtkvis starts 974 975 # reading a (big) dataset. This will display an empty plot with axes … … 992 993 set f [open /tmp/vtkstreamlines.vtk "w"] 993 994 fconfigure $f -translation binary -encoding binary 994 puts -nonewline$f $bytes995 puts $f $bytes 995 996 close $f 996 997 } … … 1026 1027 set label [$_first hints ${axis}label] 1027 1028 if { $label != "" } { 1028 SendCmd [list axis name $axis $label]1029 SendCmd "axis name $axis $label" 1029 1030 } 1030 1031 set units [$_first hints ${axis}units] 1031 1032 if { $units != "" } { 1032 SendCmd [list axis units $axis $units]1033 SendCmd "axis units $axis $units" 1033 1034 } 1034 1035 } … … 1063 1064 1064 1065 if { $_reset } { 1065 InitSettings -streamlinesseedsvisible -streamlinesopacity \1066 -streamlinesvisible -streamlinescolormap \1067 -streamlineslighting \1068 -streamlinescolormap -field \1069 -volumevisible -volumeedges -volumelighting -volumeopacity \1070 -volumewireframe \1071 -cutplanevisible \1072 -cutplanexposition -cutplaneyposition -cutplanezposition \1073 -cutplanexvisible -cutplaneyvisible -cutplanezvisible1066 InitSettings streamlinesSeedsVisible streamlinesOpacity \ 1067 streamlinesVisible streamlinesColormap \ 1068 streamlinesLighting \ 1069 streamlinesColormap field \ 1070 volumeVisible volumeEdges volumeLighting volumeOpacity \ 1071 volumeWireframe \ 1072 cutplaneVisible \ 1073 cutplaneXPosition cutplaneYPosition cutplaneZPosition \ 1074 cutplaneXVisible cutplaneYVisible cutplaneZVisible 1074 1075 1075 1076 # Reset the camera and other view parameters 1076 $_arcball quaternion [ViewToQuaternion] 1077 if {$_view(-ortho)} { 1077 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1078 $_arcball quaternion $q 1079 if {$_view(ortho)} { 1078 1080 SendCmd "camera mode ortho" 1079 1081 } else { … … 1149 1151 switch -- $option { 1150 1152 "in" { 1151 set _view( -zoom) [expr {$_view(-zoom)*1.25}]1152 SendCmd "camera zoom $_view( -zoom)"1153 set _view(zoom) [expr {$_view(zoom)*1.25}] 1154 SendCmd "camera zoom $_view(zoom)" 1153 1155 } 1154 1156 "out" { 1155 set _view( -zoom) [expr {$_view(-zoom)*0.8}]1156 SendCmd "camera zoom $_view( -zoom)"1157 set _view(zoom) [expr {$_view(zoom)*0.8}] 1158 SendCmd "camera zoom $_view(zoom)" 1157 1159 } 1158 1160 "reset" { 1159 1161 array set _view { 1160 -qw 0.8535531161 -qx -0.3535531162 -qy 0.3535531163 -qz 0.1464471164 -xpan01165 -ypan 01166 -zoom 1.01162 qw 0.853553 1163 qx -0.353553 1164 qy 0.353553 1165 qz 0.146447 1166 zoom 1.0 1167 xpan 0 1168 ypan 0 1167 1169 } 1168 1170 if { $_first != "" } { … … 1172 1174 } 1173 1175 } 1174 $_arcball quaternion [ViewToQuaternion] 1176 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1177 $_arcball quaternion $q 1175 1178 DoRotate 1176 1179 SendCmd "camera reset" … … 1180 1183 1181 1184 itcl::body Rappture::VtkStreamlinesViewer::PanCamera {} { 1182 set x $_view( -xpan)1183 set y $_view( -ypan)1185 set x $_view(xpan) 1186 set y $_view(ypan) 1184 1187 SendCmd "camera pan $x $y" 1185 1188 } 1189 1186 1190 1187 1191 # ---------------------------------------------------------------------- … … 1258 1262 set x [expr $x / double($w)] 1259 1263 set y [expr $y / double($h)] 1260 set _view( -xpan) [expr $_view(-xpan) + $x]1261 set _view( -ypan) [expr $_view(-ypan) + $y]1264 set _view(xpan) [expr $_view(xpan) + $x] 1265 set _view(ypan) [expr $_view(ypan) + $y] 1262 1266 PanCamera 1263 1267 return … … 1281 1285 set _click(x) $x 1282 1286 set _click(y) $y 1283 set _view( -xpan) [expr $_view(-xpan) - $dx]1284 set _view( -ypan) [expr $_view(-ypan) - $dy]1287 set _view(xpan) [expr $_view(xpan) - $dx] 1288 set _view(ypan) [expr $_view(ypan) - $dy] 1285 1289 PanCamera 1286 1290 } … … 1304 1308 itcl::body Rappture::VtkStreamlinesViewer::InitSettings { args } { 1305 1309 foreach spec $args { 1306 if { [info exists _settings($_first ${spec})] } {1310 if { [info exists _settings($_first-$spec)] } { 1307 1311 # Reset global setting with dataobj specific setting 1308 set _settings($spec) $_settings($_first ${spec})1312 set _settings($spec) $_settings($_first-$spec) 1309 1313 } 1310 1314 AdjustSetting $spec … … 1324 1328 } 1325 1329 switch -- $what { 1326 "-axesvisible" { 1330 "volumeOpacity" { 1331 set val $_settings(volumeOpacity) 1332 set sval [expr { 0.01 * double($val) }] 1333 SendCmd "polydata opacity $sval" 1334 } 1335 "volumeWireframe" { 1336 set bool $_settings(volumeWireframe) 1337 SendCmd "polydata wireframe $bool" 1338 } 1339 "volumeVisible" { 1340 set bool $_settings(volumeVisible) 1341 SendCmd "polydata visible $bool" 1342 if { $bool } { 1343 Rappture::Tooltip::for $itk_component(volume) \ 1344 "Hide the volume" 1345 } else { 1346 Rappture::Tooltip::for $itk_component(volume) \ 1347 "Show the volume" 1348 } 1349 } 1350 "volumeLighting" { 1351 set bool $_settings(volumeLighting) 1352 SendCmd "polydata lighting $bool" 1353 } 1354 "volumeEdges" { 1355 set bool $_settings(volumeEdges) 1356 SendCmd "polydata edges $bool" 1357 } 1358 "axesVisible" { 1359 set bool $_settings(axesVisible) 1360 SendCmd "axis visible all $bool" 1361 } 1362 "axisLabelsVisible" { 1363 set bool $_settings(axisLabelsVisible) 1364 SendCmd "axis labels all $bool" 1365 } 1366 "axisXGrid" - "axisYGrid" - "axisZGrid" { 1367 set axis [string tolower [string range $what 4 4]] 1327 1368 set bool $_settings($what) 1328 SendCmd "axis visible all $bool" 1329 } 1330 "-axislabelsvisible" { 1331 set bool $_settings($what) 1332 SendCmd "axis labels all $bool" 1333 } 1334 "-axisminorticks" { 1335 set bool $_settings($what) 1336 SendCmd "axis minticks all $bool" 1337 } 1338 "-axismode" { 1369 SendCmd "axis grid $axis $bool" 1370 } 1371 "axis-mode" { 1339 1372 set mode [$itk_component(axismode) value] 1340 1373 set mode [$itk_component(axismode) translate $mode] … … 1342 1375 SendCmd "axis flymode $mode" 1343 1376 } 1344 " -cutplaneedges" {1377 "cutplaneEdges" { 1345 1378 set bool $_settings($what) 1346 1379 SendCmd "cutplane edges $bool" 1347 1380 } 1348 " -cutplanevisible" {1381 "cutplaneVisible" { 1349 1382 set bool $_settings($what) 1350 1383 SendCmd "cutplane visible $bool" 1351 1384 } 1352 " -cutplanewireframe" {1385 "cutplaneWireframe" { 1353 1386 set bool $_settings($what) 1354 1387 SendCmd "cutplane wireframe $bool" 1355 1388 } 1356 " -cutplanelighting" {1389 "cutplaneLighting" { 1357 1390 set bool $_settings($what) 1358 1391 SendCmd "cutplane lighting $bool" 1359 1392 } 1360 " -cutplaneopacity" {1393 "cutplaneOpacity" { 1361 1394 set val $_settings($what) 1362 1395 set sval [expr { 0.01 * double($val) }] 1363 1396 SendCmd "cutplane opacity $sval" 1364 1397 } 1365 " -cutplanexvisible" - "-cutplaneyvisible" - "-cutplanezvisible" {1366 set axis [string range $what 9 9]1398 "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" { 1399 set axis [string tolower [string range $what 8 8]] 1367 1400 set bool $_settings($what) 1368 1401 if { $bool } { … … 1375 1408 SendCmd "cutplane axis $axis $bool" 1376 1409 } 1377 " -cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" {1378 set axis [string range $what 9 9]1410 "cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" { 1411 set axis [string tolower [string range $what 8 8]] 1379 1412 set pos [expr $_settings($what) * 0.01] 1380 1413 SendCmd "cutplane slice ${axis} ${pos}" 1381 1414 set _cutplanePending 0 1382 1415 } 1383 "-field" { 1384 set label [$itk_component(field) value] 1385 set fname [$itk_component(field) translate $label] 1386 set _settings($what) $fname 1387 if { [info exists _fields($fname)] } { 1388 foreach { label units components } $_fields($fname) break 1389 if { $components > 1 } { 1390 set _colorMode vmag 1391 } else { 1392 set _colorMode scalar 1393 } 1394 set _curFldName $fname 1395 set _curFldLabel $label 1396 } else { 1397 puts stderr "unknown field \"$fname\"" 1398 return 1399 } 1400 # Get the new limits because the field changed. 1401 if { ![info exists _limits($_curFldName)] } { 1402 SendCmd "dataset maprange all" 1403 } else { 1404 SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 1405 } 1406 SendCmd "streamlines colormode $_colorMode $_curFldName" 1407 SendCmd "cutplane colormode $_colorMode $_curFldName" 1408 DrawLegend 1409 } 1410 "-streamlinesseedsvisible" { 1416 "streamlinesSeedsVisible" { 1411 1417 set bool $_settings($what) 1412 1418 SendCmd "streamlines seed visible $bool" 1413 1419 } 1414 " -streamlinesnumseeds" {1420 "streamlinesNumSeeds" { 1415 1421 set density $_settings($what) 1416 1422 EventuallyReseed $density 1417 1423 } 1418 " -streamlinesvisible" {1424 "streamlinesVisible" { 1419 1425 set bool $_settings($what) 1420 1426 SendCmd "streamlines visible $bool" … … 1427 1433 } 1428 1434 } 1429 " -streamlinesmode" {1435 "streamlinesMode" { 1430 1436 set mode [$itk_component(streammode) value] 1431 set _settings( $what) $mode1437 set _settings(streamlinesMode) $mode 1432 1438 switch -- $mode { 1433 1439 "lines" { … … 1442 1448 } 1443 1449 } 1444 " -streamlinescolormap" {1450 "streamlinesColormap" { 1445 1451 set colormap [$itk_component(colormap) value] 1446 set _settings( $what) $colormap1452 set _settings(streamlinesColormap) $colormap 1447 1453 foreach dataset [CurrentDatasets -visible $_first] { 1448 1454 foreach {dataobj comp} [split $dataset -] break … … 1451 1457 set _legendPending 1 1452 1458 } 1453 " -streamlinesopacity" {1454 set val $_settings( $what)1459 "streamlinesOpacity" { 1460 set val $_settings(streamlinesOpacity) 1455 1461 set sval [expr { 0.01 * double($val) }] 1456 1462 SendCmd "streamlines opacity $sval" 1457 1463 } 1458 " -streamlinesscale" {1459 set val $_settings( $what)1464 "streamlinesScale" { 1465 set val $_settings(streamlinesScale) 1460 1466 set sval [expr { 0.01 * double($val) }] 1461 1467 SendCmd "streamlines scale $sval $sval $sval" 1462 1468 } 1463 " -streamlineslighting" {1464 set bool $_settings( $what)1469 "streamlinesLighting" { 1470 set bool $_settings(streamlinesLighting) 1465 1471 SendCmd "streamlines lighting $bool" 1466 1472 } 1467 "-volumeopacity" { 1468 set val $_settings($what) 1469 set sval [expr { 0.01 * double($val) }] 1470 SendCmd "polydata opacity $sval" 1471 } 1472 "-volumewireframe" { 1473 set bool $_settings($what) 1474 SendCmd "polydata wireframe $bool" 1475 } 1476 "-volumevisible" { 1477 set bool $_settings($what) 1478 SendCmd "polydata visible $bool" 1479 if { $bool } { 1480 Rappture::Tooltip::for $itk_component(volume) \ 1481 "Hide the volume" 1473 "field" { 1474 set label [$itk_component(field) value] 1475 set fname [$itk_component(field) translate $label] 1476 set _settings(field) $fname 1477 if { [info exists _fields($fname)] } { 1478 foreach { label units components } $_fields($fname) break 1479 if { $components > 1 } { 1480 set _colorMode vmag 1481 } else { 1482 set _colorMode scalar 1483 } 1484 set _curFldName $fname 1485 set _curFldLabel $label 1482 1486 } else { 1483 Rappture::Tooltip::for $itk_component(volume) \ 1484 "Show the volume" 1485 } 1486 } 1487 "-volumelighting" { 1488 set bool $_settings($what) 1489 SendCmd "polydata lighting $bool" 1490 } 1491 "-volumeedges" { 1492 set bool $_settings($what) 1493 SendCmd "polydata edges $bool" 1494 } 1495 "-xgrid" - "-ygrid" - "-zgrid" { 1496 set axis [string range $what 1 1] 1497 set bool $_settings($what) 1498 SendCmd "axis grid $axis $bool" 1487 puts stderr "unknown field \"$fname\"" 1488 return 1489 } 1490 # Get the new limits because the field changed. 1491 SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 1492 SendCmd "streamlines colormode $_colorMode $_curFldName" 1493 SendCmd "cutplane colormode $_colorMode $_curFldName" 1494 DrawLegend 1499 1495 } 1500 1496 default { … … 1514 1510 set font "Arial 8" 1515 1511 set lineht [font metrics $font -linespace] 1512 set c $itk_component(legend) 1516 1513 set w 12 1517 1514 set h [expr {$_height - 3 * ($lineht + 2)}] 1518 if { $h < 1 1515 if { $h < 1} { 1519 1516 return 1520 1517 } … … 1581 1578 } 1582 1579 1580 1583 1581 # 1584 1582 # BuildColormap -- … … 1590 1588 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1591 1589 } 1592 if { ![info exists _settings( -volumeopacity)] } {1593 set _settings( -volumeopacity) $style(-opacity)1594 } 1595 set max $_settings( -volumeopacity)1590 if { ![info exists _settings(volumeOpacity)] } { 1591 set _settings(volumeOpacity) $style(-opacity) 1592 } 1593 set max $_settings(volumeOpacity) 1596 1594 1597 1595 set wmap "0.0 1.0 1.0 1.0" … … 1604 1602 itcl::configbody Rappture::VtkStreamlinesViewer::plotbackground { 1605 1603 if { [isconnected] } { 1606 set rgb [Color2RGB $itk_option(-plotbackground)]1607 SendCmd "screen bgcolor $r gb"1604 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break 1605 SendCmd "screen bgcolor $r $g $b" 1608 1606 } 1609 1607 } … … 1614 1612 itcl::configbody Rappture::VtkStreamlinesViewer::plotforeground { 1615 1613 if { [isconnected] } { 1616 set rgb [Color2RGB $itk_option(-plotforeground)] 1617 SendCmd "axis color all $rgb" 1618 SendCmd "outline color $rgb" 1619 SendCmd "cutplane color $rgb" 1614 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1615 #fix this! 1616 #SendCmd "color background $r $g $b" 1620 1617 } 1621 1618 } … … 1633 1630 checkbutton $inner.volume \ 1634 1631 -text "Show Volume" \ 1635 -variable [itcl::scope _settings( -volumevisible)] \1636 -command [itcl::code $this AdjustSetting -volumevisible] \1632 -variable [itcl::scope _settings(volumeVisible)] \ 1633 -command [itcl::code $this AdjustSetting volumeVisible] \ 1637 1634 -font "Arial 9" 1638 1635 1639 1636 checkbutton $inner.wireframe \ 1640 1637 -text "Show Wireframe" \ 1641 -variable [itcl::scope _settings( -volumewireframe)] \1642 -command [itcl::code $this AdjustSetting -volumewireframe] \1638 -variable [itcl::scope _settings(volumeWireframe)] \ 1639 -command [itcl::code $this AdjustSetting volumeWireframe] \ 1643 1640 -font "Arial 9" 1644 1641 1645 1642 checkbutton $inner.lighting \ 1646 1643 -text "Enable Lighting" \ 1647 -variable [itcl::scope _settings( -volumelighting)] \1648 -command [itcl::code $this AdjustSetting -volumelighting] \1644 -variable [itcl::scope _settings(volumeLighting)] \ 1645 -command [itcl::code $this AdjustSetting volumeLighting] \ 1649 1646 -font "Arial 9" 1650 1647 1651 1648 checkbutton $inner.edges \ 1652 1649 -text "Show Edges" \ 1653 -variable [itcl::scope _settings( -volumeedges)] \1654 -command [itcl::code $this AdjustSetting -volumeedges] \1650 -variable [itcl::scope _settings(volumeEdges)] \ 1651 -command [itcl::code $this AdjustSetting volumeEdges] \ 1655 1652 -font "Arial 9" 1656 1653 1657 1654 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1658 1655 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1659 -variable [itcl::scope _settings( -volumeopacity)] \1656 -variable [itcl::scope _settings(volumeOpacity)] \ 1660 1657 -width 10 \ 1661 1658 -showvalue off \ 1662 -command [itcl::code $this AdjustSetting -volumeopacity]1659 -command [itcl::code $this AdjustSetting volumeOpacity] 1663 1660 1664 1661 blt::table $inner \ … … 1673 1670 } 1674 1671 1672 1675 1673 itcl::body Rappture::VtkStreamlinesViewer::BuildStreamsTab {} { 1676 1674 … … 1685 1683 checkbutton $inner.streamlines \ 1686 1684 -text "Show Streamlines" \ 1687 -variable [itcl::scope _settings( -streamlinesvisible)] \1688 -command [itcl::code $this AdjustSetting -streamlinesvisible] \1685 -variable [itcl::scope _settings(streamlinesVisible)] \ 1686 -command [itcl::code $this AdjustSetting streamlinesVisible] \ 1689 1687 -font "Arial 9" 1690 1688 1691 1689 checkbutton $inner.lighting \ 1692 1690 -text "Enable Lighting" \ 1693 -variable [itcl::scope _settings( -streamlineslighting)] \1694 -command [itcl::code $this AdjustSetting -streamlineslighting] \1691 -variable [itcl::scope _settings(streamlinesLighting)] \ 1692 -command [itcl::code $this AdjustSetting streamlinesLighting] \ 1695 1693 -font "Arial 9" 1696 1694 1697 1695 checkbutton $inner.seeds \ 1698 1696 -text "Show Seeds" \ 1699 -variable [itcl::scope _settings( -streamlinesseedsvisible)] \1700 -command [itcl::code $this AdjustSetting -streamlinesseedsvisible] \1697 -variable [itcl::scope _settings(streamlinesSeedsVisible)] \ 1698 -command [itcl::code $this AdjustSetting streamlinesSeedsVisible] \ 1701 1699 -font "Arial 9" 1702 1700 … … 1709 1707 "ribbons" "ribbons" \ 1710 1708 "tubes" "tubes" 1711 $itk_component(streammode) value $_settings( -streamlinesmode)1712 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -streamlinesmode]1709 $itk_component(streammode) value $_settings(streamlinesMode) 1710 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting streamlinesMode] 1713 1711 1714 1712 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1715 1713 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1716 -variable [itcl::scope _settings( -streamlinesopacity)] \1714 -variable [itcl::scope _settings(streamlinesOpacity)] \ 1717 1715 -width 10 \ 1718 1716 -showvalue off \ 1719 -command [itcl::code $this AdjustSetting -streamlinesopacity]1717 -command [itcl::code $this AdjustSetting streamlinesOpacity] 1720 1718 1721 1719 label $inner.density_l -text "No. Seeds" -font "Arial 9" 1722 1720 ::scale $inner.density -from 1 -to 1000 -orient horizontal \ 1723 -variable [itcl::scope _settings( -streamlinesnumseeds)] \1721 -variable [itcl::scope _settings(streamlinesNumSeeds)] \ 1724 1722 -width 10 \ 1725 1723 -showvalue on \ 1726 -command [itcl::code $this AdjustSetting -streamlinesnumseeds]1724 -command [itcl::code $this AdjustSetting streamlinesNumSeeds] 1727 1725 1728 1726 label $inner.scale_l -text "Scale" -font "Arial 9" 1729 1727 ::scale $inner.scale -from 1 -to 100 -orient horizontal \ 1730 -variable [itcl::scope _settings( -streamlinesscale)] \1728 -variable [itcl::scope _settings(streamlinesScale)] \ 1731 1729 -width 10 \ 1732 1730 -showvalue off \ 1733 -command [itcl::code $this AdjustSetting -streamlinesscale]1731 -command [itcl::code $this AdjustSetting streamlinesScale] 1734 1732 1735 1733 label $inner.field_l -text "Color by" -font "Arial 9" … … 1738 1736 } 1739 1737 bind $inner.field <<Value>> \ 1740 [itcl::code $this AdjustSetting -field]1738 [itcl::code $this AdjustSetting field] 1741 1739 1742 1740 label $inner.colormap_l -text "Colormap" -font "Arial 9" … … 1744 1742 Rappture::Combobox $inner.colormap -width 10 -editable no 1745 1743 } 1746 $inner.colormap choices insert end [GetColormapList] 1744 $inner.colormap choices insert end \ 1745 "BCGYR" "BCGYR" \ 1746 "BGYOR" "BGYOR" \ 1747 "blue" "blue" \ 1748 "blue-to-brown" "blue-to-brown" \ 1749 "blue-to-orange" "blue-to-orange" \ 1750 "blue-to-grey" "blue-to-grey" \ 1751 "green-to-magenta" "green-to-magenta" \ 1752 "greyscale" "greyscale" \ 1753 "nanohub" "nanohub" \ 1754 "rainbow" "rainbow" \ 1755 "spectral" "spectral" \ 1756 "ROYGB" "ROYGB" \ 1757 "RYGCB" "RYGCB" \ 1758 "brown-to-blue" "brown-to-blue" \ 1759 "grey-to-blue" "grey-to-blue" \ 1760 "orange-to-blue" "orange-to-blue" 1747 1761 1748 1762 $itk_component(colormap) value "BCGYR" 1749 1763 bind $inner.colormap <<Value>> \ 1750 [itcl::code $this AdjustSetting -streamlinescolormap]1764 [itcl::code $this AdjustSetting streamlinesColormap] 1751 1765 1752 1766 blt::table $inner \ … … 1775 1789 set inner [$itk_component(main) insert end \ 1776 1790 -title "Axis Settings" \ 1777 -icon [Rappture::icon axis 2]]1791 -icon [Rappture::icon axis1]] 1778 1792 $inner configure -borderwidth 4 1779 1793 1780 1794 checkbutton $inner.visible \ 1781 -text " Axes" \1782 -variable [itcl::scope _settings( -axesvisible)] \1783 -command [itcl::code $this AdjustSetting -axesvisible] \1795 -text "Show Axes" \ 1796 -variable [itcl::scope _settings(axesVisible)] \ 1797 -command [itcl::code $this AdjustSetting axesVisible] \ 1784 1798 -font "Arial 9" 1785 1799 1786 1800 checkbutton $inner.labels \ 1787 -text " Axis Labels" \1788 -variable [itcl::scope _settings( -axislabelsvisible)] \1789 -command [itcl::code $this AdjustSetting -axislabelsvisible] \1801 -text "Show Axis Labels" \ 1802 -variable [itcl::scope _settings(axisLabelsVisible)] \ 1803 -command [itcl::code $this AdjustSetting axisLabelsVisible] \ 1790 1804 -font "Arial 9" 1791 label $inner.grid_l -text "Grid" -font "Arial 9" 1805 1792 1806 checkbutton $inner.xgrid \ 1793 -text " X" \1794 -variable [itcl::scope _settings( -xgrid)] \1795 -command [itcl::code $this AdjustSetting -xgrid] \1807 -text "Show X Grid" \ 1808 -variable [itcl::scope _settings(axisXGrid)] \ 1809 -command [itcl::code $this AdjustSetting axisXGrid] \ 1796 1810 -font "Arial 9" 1797 1811 checkbutton $inner.ygrid \ 1798 -text " Y" \1799 -variable [itcl::scope _settings( -ygrid)] \1800 -command [itcl::code $this AdjustSetting -ygrid] \1812 -text "Show Y Grid" \ 1813 -variable [itcl::scope _settings(axisYGrid)] \ 1814 -command [itcl::code $this AdjustSetting axisYGrid] \ 1801 1815 -font "Arial 9" 1802 1816 checkbutton $inner.zgrid \ 1803 -text "Z" \ 1804 -variable [itcl::scope _settings(-zgrid)] \ 1805 -command [itcl::code $this AdjustSetting -zgrid] \ 1806 -font "Arial 9" 1807 checkbutton $inner.minorticks \ 1808 -text "Minor Ticks" \ 1809 -variable [itcl::scope _settings(-axisminorticks)] \ 1810 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1817 -text "Show Z Grid" \ 1818 -variable [itcl::scope _settings(axisZGrid)] \ 1819 -command [itcl::code $this AdjustSetting axisZGrid] \ 1811 1820 -font "Arial 9" 1812 1821 … … 1819 1828 "static_triad" "static" \ 1820 1829 "closest_triad" "closest" \ 1821 "furthest_triad" "f arthest" \1830 "furthest_triad" "furthest" \ 1822 1831 "outer_edges" "outer" 1823 $itk_component(axismode) value $_settings(-axismode)1824 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]1832 $itk_component(axismode) value "static" 1833 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode] 1825 1834 1826 1835 blt::table $inner \ 1827 0,0 $inner.visible -anchor w -cspan 4 \ 1828 1,0 $inner.labels -anchor w -cspan 4 \ 1829 2,0 $inner.minorticks -anchor w -cspan 4 \ 1830 4,0 $inner.grid_l -anchor w \ 1831 4,1 $inner.xgrid -anchor w \ 1832 4,2 $inner.ygrid -anchor w \ 1833 4,3 $inner.zgrid -anchor w \ 1834 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1835 5,1 $inner.mode -fill x -cspan 3 1836 0,0 $inner.visible -anchor w -cspan 2 \ 1837 1,0 $inner.labels -anchor w -cspan 2 \ 1838 2,0 $inner.xgrid -anchor w -cspan 2 \ 1839 3,0 $inner.ygrid -anchor w -cspan 2 \ 1840 4,0 $inner.zgrid -anchor w -cspan 2 \ 1841 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1842 6,0 $inner.mode -fill x -cspan 2 1836 1843 1837 1844 blt::table configure $inner r* c* -resize none 1838 blt::table configure $inner r7 c 6-resize expand1839 blt::table configure $inner r3 -height 0.125i 1840 } 1845 blt::table configure $inner r7 c1 -resize expand 1846 } 1847 1841 1848 1842 1849 itcl::body Rappture::VtkStreamlinesViewer::BuildCameraTab {} { … … 1858 1865 0,0 $inner.view_l -anchor e -pady 2 \ 1859 1866 0,1 $inner.view -anchor w -pady 2 1860 blt::table configure $inner r0 -resize none1861 1867 1862 1868 set labels { qx qy qz qw xpan ypan zoom } … … 1865 1871 label $inner.${tag}label -text $tag -font "Arial 9" 1866 1872 entry $inner.${tag} -font "Arial 9" -bg white \ 1867 -textvariable [itcl::scope _view(-$tag)] 1868 bind $inner.${tag} <Return> \ 1869 [itcl::code $this camera set -${tag}] 1870 bind $inner.${tag} <KP_Enter> \ 1871 [itcl::code $this camera set -${tag}] 1873 -textvariable [itcl::scope _view($tag)] 1874 bind $inner.${tag} <KeyPress-Return> \ 1875 [itcl::code $this camera set ${tag}] 1872 1876 blt::table $inner \ 1873 1877 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1878 1882 checkbutton $inner.ortho \ 1879 1883 -text "Orthographic Projection" \ 1880 -variable [itcl::scope _view( -ortho)] \1881 -command [itcl::code $this camera set -ortho] \1884 -variable [itcl::scope _view(ortho)] \ 1885 -command [itcl::code $this camera set ortho] \ 1882 1886 -font "Arial 9" 1883 1887 blt::table $inner \ … … 1886 1890 incr row 1887 1891 1888 blt::table configure $inner c* -resize none1892 blt::table configure $inner c* r* -resize none 1889 1893 blt::table configure $inner c2 -resize expand 1890 1894 blt::table configure $inner r$row -resize expand … … 1903 1907 checkbutton $inner.visible \ 1904 1908 -text "Show Cutplanes" \ 1905 -variable [itcl::scope _settings( -cutplanevisible)] \1906 -command [itcl::code $this AdjustSetting -cutplanevisible] \1909 -variable [itcl::scope _settings(cutplaneVisible)] \ 1910 -command [itcl::code $this AdjustSetting cutplaneVisible] \ 1907 1911 -font "Arial 9" 1908 1912 1909 1913 checkbutton $inner.wireframe \ 1910 1914 -text "Show Wireframe" \ 1911 -variable [itcl::scope _settings( -cutplanewireframe)] \1912 -command [itcl::code $this AdjustSetting -cutplanewireframe] \1915 -variable [itcl::scope _settings(cutplaneWireframe)] \ 1916 -command [itcl::code $this AdjustSetting cutplaneWireframe] \ 1913 1917 -font "Arial 9" 1914 1918 1915 1919 checkbutton $inner.lighting \ 1916 1920 -text "Enable Lighting" \ 1917 -variable [itcl::scope _settings( -cutplanelighting)] \1918 -command [itcl::code $this AdjustSetting -cutplanelighting] \1921 -variable [itcl::scope _settings(cutplaneLighting)] \ 1922 -command [itcl::code $this AdjustSetting cutplaneLighting] \ 1919 1923 -font "Arial 9" 1920 1924 1921 1925 checkbutton $inner.edges \ 1922 1926 -text "Show Edges" \ 1923 -variable [itcl::scope _settings( -cutplaneedges)] \1924 -command [itcl::code $this AdjustSetting -cutplaneedges] \1927 -variable [itcl::scope _settings(cutplaneEdges)] \ 1928 -command [itcl::code $this AdjustSetting cutplaneEdges] \ 1925 1929 -font "Arial 9" 1926 1930 1927 1931 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1928 1932 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1929 -variable [itcl::scope _settings( -cutplaneopacity)] \1933 -variable [itcl::scope _settings(cutplaneOpacity)] \ 1930 1934 -width 10 \ 1931 1935 -showvalue off \ 1932 -command [itcl::code $this AdjustSetting -cutplaneopacity]1933 $inner.opacity set $_settings( -cutplaneopacity)1936 -command [itcl::code $this AdjustSetting cutplaneOpacity] 1937 $inner.opacity set $_settings(cutplaneOpacity) 1934 1938 1935 1939 # X-value slicer... … … 1938 1942 -onimage [Rappture::icon x-cutplane-red] \ 1939 1943 -offimage [Rappture::icon x-cutplane-red] \ 1940 -command [itcl::code $this AdjustSetting -cutplanexvisible] \1941 -variable [itcl::scope _settings( -cutplanexvisible)]1944 -command [itcl::code $this AdjustSetting cutplaneXVisible] \ 1945 -variable [itcl::scope _settings(cutplaneXVisible)] 1942 1946 } 1943 1947 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 1950 1954 -borderwidth 1 -highlightthickness 0 \ 1951 1955 -command [itcl::code $this EventuallySetCutplane x] \ 1952 -variable [itcl::scope _settings( -cutplanexposition)] \1956 -variable [itcl::scope _settings(cutplaneXPosition)] \ 1953 1957 -foreground red3 -font "Arial 9 bold" 1954 1958 } { … … 1967 1971 -onimage [Rappture::icon y-cutplane-green] \ 1968 1972 -offimage [Rappture::icon y-cutplane-green] \ 1969 -command [itcl::code $this AdjustSetting -cutplaneyvisible] \1970 -variable [itcl::scope _settings( -cutplaneyvisible)]1973 -command [itcl::code $this AdjustSetting cutplaneYVisible] \ 1974 -variable [itcl::scope _settings(cutplaneYVisible)] 1971 1975 } 1972 1976 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 1979 1983 -borderwidth 1 -highlightthickness 0 \ 1980 1984 -command [itcl::code $this EventuallySetCutplane y] \ 1981 -variable [itcl::scope _settings( -cutplaneyposition)] \1985 -variable [itcl::scope _settings(cutplaneYPosition)] \ 1982 1986 -foreground green3 -font "Arial 9 bold" 1983 1987 } { … … 1996 2000 -onimage [Rappture::icon z-cutplane-blue] \ 1997 2001 -offimage [Rappture::icon z-cutplane-blue] \ 1998 -command [itcl::code $this AdjustSetting -cutplanezvisible] \1999 -variable [itcl::scope _settings( -cutplanezvisible)]2002 -command [itcl::code $this AdjustSetting cutplaneZVisible] \ 2003 -variable [itcl::scope _settings(cutplaneZVisible)] 2000 2004 } 2001 2005 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 2008 2012 -borderwidth 1 -highlightthickness 0 \ 2009 2013 -command [itcl::code $this EventuallySetCutplane z] \ 2010 -variable [itcl::scope _settings( -cutplanezposition)] \2014 -variable [itcl::scope _settings(cutplaneZPosition)] \ 2011 2015 -foreground blue3 -font "Arial 9 bold" 2012 2016 } { … … 2045 2049 } 2046 2050 "set" { 2047 set wh at[lindex $args 0]2048 set x $_view($wh at)2051 set who [lindex $args 0] 2052 set x $_view($who) 2049 2053 set code [catch { string is double $x } result] 2050 2054 if { $code != 0 || !$result } { 2051 2055 return 2052 2056 } 2053 switch -- $wh at{2054 " -ortho" {2055 if {$_view( $what)} {2057 switch -- $who { 2058 "ortho" { 2059 if {$_view(ortho)} { 2056 2060 SendCmd "camera mode ortho" 2057 2061 } else { … … 2059 2063 } 2060 2064 } 2061 " -xpan" - "-ypan" {2065 "xpan" - "ypan" { 2062 2066 PanCamera 2063 2067 } 2064 " -qx" - "-qy" - "-qz" - "-qw" {2065 set q [ ViewToQuaternion]2068 "qx" - "qy" - "qz" - "qw" { 2069 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2066 2070 $_arcball quaternion $q 2067 2071 EventuallyRotate $q 2068 2072 } 2069 " -zoom" {2070 SendCmd "camera zoom $_view( $what)"2073 "zoom" { 2074 SendCmd "camera zoom $_view(zoom)" 2071 2075 } 2072 2076 } … … 2158 2162 } 2159 2163 array set settings $style 2160 StartBufferingCommands2161 2164 SendCmd "streamlines add $tag" 2162 2165 SendCmd "streamlines seed visible off $tag" … … 2165 2168 set length [string length $seeds] 2166 2169 SendCmd "streamlines seed fmesh 200 data follows $length $tag" 2167 append _outbuf $seeds2170 SendCmd "$seeds" 2168 2171 set _seeds($dataobj) 1 2169 2172 } … … 2171 2174 SendCmd "polydata add $tag" 2172 2175 SendCmd "polydata colormode constant {} $tag" 2173 set _settings(-volumeedges) $settings(-edges) 2174 set _settings(-volumelighting) $settings(-lighting) 2175 set _settings(-volumeopacity) $settings(-opacity) 2176 set _settings(-volumewireframe) $settings(-wireframe) 2177 set _settings(-volumeopacity) [expr $settings(-opacity) * 100.0] 2178 StopBufferingCommands 2176 set _settings(volumeEdges) $settings(-edges) 2177 set _settings(volumeLighting) $settings(-lighting) 2178 set _settings(volumeOpacity) $settings(-opacity) 2179 set _settings(volumeWireframe) $settings(-wireframe) 2180 set _settings(volumeOpacity) [expr $settings(-opacity) * 100.0] 2179 2181 SetColormap $dataobj $comp 2180 2182 } … … 2233 2235 set title $fname 2234 2236 } 2235 if { $_settings( -legendvisible) } {2237 if { $_settings(legendVisible) } { 2236 2238 set x [expr $w - 2] 2237 2239 if { [$c find withtag "legend"] == "" } { … … 2364 2366 "move" { 2365 2367 set axis [lindex $args 0] 2368 set oldval $_settings(axis-${axis}position) 2366 2369 set newval [lindex $args 1] 2367 2370 if {[llength $args] != 2} { … … 2411 2414 invoke { 2412 2415 $itk_component(field) value $_curFldLabel 2413 AdjustSetting -field2416 AdjustSetting field 2414 2417 } 2415 2418 default { … … 2428 2431 bottom "0.707107 0.707107 0 0" 2429 2432 } 2430 foreach name { -qw -qx -qy -qz } value $positions($side) {2433 foreach name { qw qx qy qz } value $positions($side) { 2431 2434 set _view($name) $value 2432 2435 } 2433 set q [ ViewToQuaternion]2436 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2434 2437 $_arcball quaternion $q 2435 2438 SendCmd "camera orient $q" 2436 2439 SendCmd "camera reset" 2437 set _view( -xpan) 02438 set _view( -ypan) 02439 set _view( -zoom) 1.02440 } 2440 set _view(xpan) 0 2441 set _view(ypan) 0 2442 set _view(zoom) 1.0 2443 } -
branches/1.3/gui/scripts/vtkviewer.tcl
r4775 r4848 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 3 # ---------------------------------------------------------------------- 3 4 # COMPONENT: vtkviewer - Vtk drawing object viewer … … 7 8 # ====================================================================== 8 9 # AUTHOR: Michael McLennan, Purdue University 9 # Copyright (c) 2004-201 4HUBzero Foundation, LLC10 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 11 # 11 12 # See the file "license.terms" for information on usage and … … 57 58 public method get {args} 58 59 public method isconnected {} 59 public method limits { dataobj}60 public method limits { colormap } 60 61 public method parameters {title args} { 61 62 # do nothing … … 63 64 public method scale {args} 64 65 66 protected method Connect {} 67 protected method CurrentDatasets {args} 68 protected method Disconnect {} 69 protected method DoResize {} 70 protected method DoRotate {} 71 protected method AdjustSetting {what {value ""}} 72 protected method FixSettings { args } 73 protected method Pan {option x y} 74 protected method Pick {x y} 75 protected method Rebuild {} 76 protected method ReceiveDataset { args } 77 protected method ReceiveImage { args } 78 protected method ReceiveLegend { colormap title vmin vmax size } 79 protected method Rotate {option x y} 80 protected method Zoom {option} 81 65 82 # The following methods are only used by this class. 66 private method AdjustSetting {what {value ""}}67 83 private method BuildAxisTab {} 68 84 private method BuildCameraTab {} … … 70 86 private method BuildCutawayTab {} 71 87 private method BuildDownloadPopup { widget command } 72 private method BuildGlyphsTab {}73 88 private method BuildMoleculeTab {} 74 89 private method BuildPolydataTab {} 75 90 private method ChangeColormap { dataobj comp color } 76 private method Connect {}77 private method CurrentDatasets {args}78 private method Disconnect {}79 private method DoResize {}80 private method DoRotate {}81 91 private method DrawLegend {} 82 92 private method EnterLegend { x y } 83 private method EventuallyResize { w h }84 private method EventuallyRotate { q }85 93 private method EventuallySetAtomScale { args } 86 94 private method EventuallySetBondScale { args } 87 private method EventuallySetGlyphsOpacity { args }88 95 private method EventuallySetMoleculeOpacity { args } 89 96 private method EventuallySetMoleculeQuality { args } 90 97 private method EventuallySetPolydataOpacity { args } 98 private method EventuallyResize { w h } 99 private method EventuallyRotate { q } 91 100 private method GetImage { args } 92 101 private method GetVtkData { args } 93 private method InitSettings { args }94 102 private method IsValidObject { dataobj } 95 103 private method LeaveLegend {} 96 104 private method MotionLegend { x y } 97 private method Pan {option x y}98 105 private method PanCamera {} 99 private method Pick {x y}100 private method QuaternionToView { q } {101 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break102 }103 private method Rebuild {}104 private method ReceiveDataset { args }105 private method ReceiveImage { args }106 private method ReceiveLegend { colormap title vmin vmax size }107 106 private method RequestLegend {} 108 private method Rotate {option x y}109 107 private method SetAtomScale {} 110 108 private method SetBondScale {} 111 109 private method SetColormap { dataobj comp } 112 private method SetGlyphsOpacity {}113 110 private method SetLegendTip { x y } 114 111 private method SetMoleculeOpacity {} … … 119 116 private method SetPolydataOpacity {} 120 117 private method Slice {option args} 121 private method ViewToQuaternion {} {122 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]123 }124 private method Zoom {option}125 118 126 119 private variable _arcball "" … … 164 157 private variable _polydataOpacityPending 0 165 158 private variable _glyphsOpacityPending 0 159 private variable _updatePending 0; 166 160 private variable _rotateDelay 150 167 161 private variable _scaleDelay 100 … … 187 181 $_dispatcher register !resize 188 182 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 183 184 # Update state event 185 $_dispatcher register !update 186 $_dispatcher dispatch $this !update "[itcl::code $this DoUpdate]; list" 189 187 190 188 # Rotate event … … 216 214 $_dispatcher dispatch $this !polydataOpacity \ 217 215 "[itcl::code $this SetPolydataOpacity]; list" 218 219 # Glyphs opacity event220 $_dispatcher register !glyphsOpacity221 $_dispatcher dispatch $this !glyphsOpacity \222 "[itcl::code $this SetGlyphsOpacity]; list"223 224 216 # 225 217 # Populate parser with commands handle incoming requests 226 218 # 227 $_parser alias image [itcl::code $this ReceiveImage]228 $_parser alias dataset [itcl::code $this ReceiveDataset]229 $_parser alias legend [itcl::code $this ReceiveLegend]219 $_parser alias image [itcl::code $this ReceiveImage] 220 $_parser alias dataset [itcl::code $this ReceiveDataset] 221 $_parser alias legend [itcl::code $this ReceiveLegend] 230 222 231 223 # Initialize the view to some default parameters. 232 224 array set _view { 233 -ortho 0234 -qw 0.853553235 -qx -0.353553236 -qy 0.353553237 -qz 0.146447238 -xpan 0239 -ypan 0240 -zoom 1.0225 qw 0.853553 226 qx -0.353553 227 qy 0.353553 228 qz 0.146447 229 zoom 1.0 230 xpan 0 231 ypan 0 232 ortho 0 241 233 } 242 234 set _arcball [blt::arcball create 100 100] 243 $_arcball quaternion [ViewToQuaternion] 235 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 236 $_arcball quaternion $q 244 237 245 238 set _limits(zmin) 0.0 … … 247 240 248 241 array set _axis [subst { 249 labels 1250 minorticks 1251 visible 1252 242 xgrid 0 253 243 ygrid 0 … … 262 252 ydirection -1 263 253 zdirection -1 254 visible 1 255 labels 1 264 256 }] 265 257 array set _settings [subst { 266 glyphs-edges 0 267 glyphs-lighting 1 258 legend 1 268 259 glyphs-opacity 100 269 glyphs-outline 0270 glyphs-palette BCGYR271 glyphs-visible 1272 260 glyphs-wireframe 0 273 legend 1 274 molecule-atoms-visible 1 261 polydata-edges 0 262 polydata-lighting 1 263 polydata-opacity 100 264 polydata-palette rainbow 265 polydata-visible 1 266 polydata-wireframe 0 275 267 molecule-atomscale 0.3 276 molecule-bonds-visible 1277 268 molecule-bondscale 0.075 278 269 molecule-bondstyle "cylinder" 270 molecule-atoms-visible 1 271 molecule-bonds-visible 1 279 272 molecule-edges 0 280 273 molecule-labels 0 281 274 molecule-lighting 1 282 275 molecule-opacity 100 283 molecule-outline 0284 276 molecule-palette elementDefault 285 277 molecule-quality 1.0 … … 288 280 molecule-visible 1 289 281 molecule-wireframe 0 290 polydata-edges 0291 polydata-lighting 1292 polydata-opacity 100293 polydata-outline 0294 polydata-palette BCGYR295 polydata-visible 1296 polydata-wireframe 0297 282 }] 298 283 itk_component add view { … … 362 347 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 363 348 364 if { [catch { 365 BuildAxisTab 366 #BuildCutawayTab 367 BuildCameraTab 368 } errs] != 0 } { 369 puts stderr errs=$errs 370 } 349 BuildAxisTab 350 #BuildCutawayTab 351 BuildCameraTab 371 352 372 353 # Legend 354 373 355 set _image(legend) [image create photo] 374 356 itk_component add legend { … … 396 378 bind $itk_component(view) <ButtonRelease-1> \ 397 379 [itcl::code $this Rotate release %x %y] 380 bind $itk_component(view) <Configure> \ 381 [itcl::code $this EventuallyResize %w %h] 398 382 399 383 # Bindings for panning via mouse … … 473 457 474 458 itcl::body Rappture::VtkViewer::DoRotate {} { 475 SendCmd "camera orient [ViewToQuaternion]" 459 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 460 SendCmd "camera orient $q" 476 461 set _rotatePending 0 477 462 } … … 488 473 489 474 itcl::body Rappture::VtkViewer::EventuallyRotate { q } { 490 QuaternionToView $q475 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 491 476 if { !$_rotatePending } { 492 477 set _rotatePending 1 … … 521 506 } 522 507 523 itcl::body Rappture::VtkViewer::SetGlyphsOpacity {} {524 set _glyphsOpacityPending 0525 foreach dataset [CurrentDatasets -visible $_first] {526 foreach { dataobj comp } [split $dataset -] break527 if { [$dataobj type $comp] == "glyphs" } {528 SetOpacity $dataset529 }530 }531 }532 533 508 itcl::body Rappture::VtkViewer::SetPolydataOpacity {} { 534 509 set _polydataOpacityPending 0 … … 573 548 set _polydataOpacityPending 1 574 549 $_dispatcher event -after $_scaleDelay !polydataOpacity 575 }576 }577 578 itcl::body Rappture::VtkViewer::EventuallySetGlyphsOpacity { args } {579 if { !$_glyphsOpacityPending } {580 set _glyphsOpacityPending 1581 $_dispatcher event -after $_scaleDelay !glyphsOpacity582 550 } 583 551 } … … 748 716 } 749 717 array set bounds [limits $dataobj] 750 if { [info exists bounds(xmin)] && (![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin))} {718 if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} { 751 719 set _limits(xmin) $bounds(xmin) 752 720 } 753 if { [info exists bounds(xmax)] && (![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax))} {721 if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} { 754 722 set _limits(xmax) $bounds(xmax) 755 723 } 756 724 757 if { [info exists bounds(ymin)] && (![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin))} {725 if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} { 758 726 set _limits(ymin) $bounds(ymin) 759 727 } 760 if { [info exists bounds(ymax)] && (![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax))} {728 if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} { 761 729 set _limits(ymax) $bounds(ymax) 762 730 } 763 731 764 if { [info exists bounds(zmin)] && (![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin))} {732 if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} { 765 733 set _limits(zmin) $bounds(zmin) 766 734 } 767 if { [info exists bounds(zmax)] && (![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax))} {735 if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} { 768 736 set _limits(zmax) $bounds(zmax) 769 }770 }771 if { $_haveGlyphs } {772 if { ![$itk_component(main) exists "Glyphs Settings"] } {773 if { [catch { BuildGlyphsTab } errs ] != 0 } {774 puts stderr "errs=$errs"775 }776 737 } 777 738 } … … 867 828 if { $_reportClientInfo } { 868 829 # Tell the server the viewer, hub, user and session. 869 # Do this immediately on connect before buff ering any commands830 # Do this immediately on connect before buffing any commands 870 831 global env 871 832 … … 924 885 925 886 # disconnected -- no more data sitting on server 926 set _outbuf ""927 887 array unset _datasets 928 888 array unset _data … … 951 911 if { $info(-type) == "image" } { 952 912 if 0 { 953 set f [open "last.ppm" "w"] 913 set f [open "last.ppm" "w"] 954 914 fconfigure $f -encoding binary 955 915 puts -nonewline $f $bytes … … 1037 997 $_arcball resize $w $h 1038 998 DoResize 1039 InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \ 1040 axis-visible axis-labels axis-minorticks 1041 999 FixSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \ 1000 axis-visible axis-labels 1001 1002 if { $_havePolydata } { 1003 FixSettings polydata-edges polydata-lighting polydata-opacity \ 1004 polydata-visible polydata-wireframe 1005 } 1042 1006 StopBufferingCommands 1043 1007 SendCmd "imgflush" … … 1061 1025 if { $bytes == "" } { 1062 1026 continue 1063 }1064 if 0 {1065 set f [open /tmp/vtkviewer.vtk "w"]1066 fconfigure $f -translation binary -encoding binary1067 puts -nonewline $f $bytes1068 close $f1069 1027 } 1070 1028 set length [string length $bytes] … … 1079 1037 lappend info "dataset_size" $length 1080 1038 lappend info "dataset_tag" $tag 1081 SendCmd "clientinfo [list $info]"1039 SendCmd [list "clientinfo" $info] 1082 1040 } 1083 1041 SendCmd "dataset add $tag data follows $length" … … 1087 1045 } 1088 1046 lappend _obj2datasets($dataobj) $tag 1089 set type [$dataobj type $comp]1090 1047 if { [info exists _obj2ovride($dataobj-raise)] } { 1091 SendCmd " $typevisible 1 $tag"1048 SendCmd "dataset visible 1 $tag" 1092 1049 SetOpacity $tag 1093 1050 } … … 1103 1060 set label [$_first hints ${axis}label] 1104 1061 if { $label != "" } { 1105 SendCmd [list axis name $axis $label]1062 SendCmd "axis name $axis $label" 1106 1063 } 1107 1064 set units [$_first hints ${axis}units] 1108 1065 if { $units != "" } { 1109 SendCmd [list axis units $axis $units] 1110 } 1111 } 1112 } 1113 if { $_haveGlyphs } { 1114 InitSettings glyphs-outline 1115 } 1116 if { $_haveMolecules } { 1117 InitSettings molecule-outline 1118 } 1119 if { $_havePolydata } { 1120 InitSettings polydata-outline 1066 SendCmd "axis units $axis $units" 1067 } 1068 } 1121 1069 } 1122 1070 if { $_reset } { 1123 if { $_haveGlyphs } { 1124 InitSettings glyphs-edges glyphs-lighting glyphs-opacity \ 1125 glyphs-visible glyphs-wireframe 1126 } 1127 if { $_havePolydata } { 1128 InitSettings polydata-edges polydata-lighting polydata-opacity \ 1129 polydata-visible polydata-wireframe 1130 } 1131 if { $_haveMolecules } { 1132 InitSettings molecule-edges molecule-lighting molecule-opacity \ 1133 molecule-visible molecule-wireframe molecule-labels 1134 } 1135 1136 $_arcball quaternion [ViewToQuaternion] 1071 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1072 $_arcball quaternion $q 1137 1073 SendCmd "camera reset" 1138 if { $_view( -ortho)} {1074 if { $_view(ortho)} { 1139 1075 SendCmd "camera mode ortho" 1140 1076 } else { … … 1147 1083 1148 1084 if { $_haveMolecules } { 1149 # InitSettings molecule-representation1085 #FixSettings molecule-representation 1150 1086 } 1151 1087 set _reset 0 … … 1217 1153 switch -- $option { 1218 1154 "in" { 1219 set _view( -zoom) [expr {$_view(-zoom)*1.25}]1220 SendCmd "camera zoom $_view( -zoom)"1155 set _view(zoom) [expr {$_view(zoom)*1.25}] 1156 SendCmd "camera zoom $_view(zoom)" 1221 1157 } 1222 1158 "out" { 1223 set _view( -zoom) [expr {$_view(-zoom)*0.8}]1224 SendCmd "camera zoom $_view( -zoom)"1159 set _view(zoom) [expr {$_view(zoom)*0.8}] 1160 SendCmd "camera zoom $_view(zoom)" 1225 1161 } 1226 1162 "reset" { 1227 1163 array set _view { 1228 -qw 0.8535531229 -qx -0.3535531230 -qy 0.3535531231 -qz 0.1464471232 -xpan01233 -ypan 01234 -zoom 1.01164 qw 0.853553 1165 qx -0.353553 1166 qy 0.353553 1167 qz 0.146447 1168 zoom 1.0 1169 xpan 0 1170 ypan 0 1235 1171 } 1236 1172 if { $_first != "" } { … … 1240 1176 } 1241 1177 } 1242 $_arcball quaternion [ViewToQuaternion] 1178 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1179 $_arcball quaternion $q 1243 1180 DoRotate 1244 1181 SendCmd "camera reset" … … 1248 1185 1249 1186 itcl::body Rappture::VtkViewer::PanCamera {} { 1250 set x $_view( -xpan)1251 set y $_view( -ypan)1187 set x $_view(xpan) 1188 set y $_view(ypan) 1252 1189 SendCmd "camera pan $x $y" 1253 1190 } … … 1326 1263 set x [expr $x / double($w)] 1327 1264 set y [expr $y / double($h)] 1328 set _view( -xpan) [expr $_view(-xpan) + $x]1329 set _view( -ypan) [expr $_view(-ypan) + $y]1265 set _view(xpan) [expr $_view(xpan) + $x] 1266 set _view(ypan) [expr $_view(ypan) + $y] 1330 1267 PanCamera 1331 1268 return … … 1349 1286 set _click(x) $x 1350 1287 set _click(y) $y 1351 set _view( -xpan) [expr $_view(-xpan) - $dx]1352 set _view( -ypan) [expr $_view(-ypan) - $dy]1288 set _view(xpan) [expr $_view(xpan) - $dx] 1289 set _view(ypan) [expr $_view(ypan) - $dy] 1353 1290 PanCamera 1354 1291 } … … 1364 1301 1365 1302 # ---------------------------------------------------------------------- 1366 # USAGE: InitSettings <what> ?<value>?1303 # USAGE: FixSettings <what> ?<value>? 1367 1304 # 1368 1305 # Used internally to update rendering settings whenever parameters … … 1370 1307 # to the back end. 1371 1308 # ---------------------------------------------------------------------- 1372 itcl::body Rappture::VtkViewer:: InitSettings { args } {1309 itcl::body Rappture::VtkViewer::FixSettings { args } { 1373 1310 foreach setting $args { 1374 1311 AdjustSetting $setting … … 1388 1325 } 1389 1326 switch -- $what { 1390 "glyphs-opacity" {1391 foreach dataset [CurrentDatasets -visible $_first] {1392 foreach { dataobj comp } [split $dataset -] break1393 if { [$dataobj type $comp] == "glyphs" } {1394 SetOpacity $dataset1395 }1396 }1397 }1398 "glyphs-outline" {1399 set bool $_settings($what)1400 foreach dataset [CurrentDatasets -visible $_first] {1401 foreach { dataobj comp } [split $dataset -] break1402 set type [$dataobj type $comp]1403 if { $type == "glyphs" } {1404 SendCmd "outline visible $bool $dataset"1405 }1406 }1407 }1408 "glyphs-wireframe" {1409 set bool $_settings($what)1410 foreach dataset [CurrentDatasets -visible $_first] {1411 foreach { dataobj comp } [split $dataset -] break1412 set type [$dataobj type $comp]1413 if { $type == "glyphs" } {1414 SendCmd "$type wireframe $bool $dataset"1415 }1416 }1417 }1418 "glyphs-visible" {1419 set bool $_settings($what)1420 foreach dataset [CurrentDatasets -visible $_first] {1421 foreach { dataobj comp } [split $dataset -] break1422 set type [$dataobj type $comp]1423 if { $type == "glyphs" } {1424 SendCmd "$type visible $bool $dataset"1425 }1426 }1427 }1428 "glyphs-lighting" {1429 set bool $_settings($what)1430 foreach dataset [CurrentDatasets -visible $_first] {1431 foreach { dataobj comp } [split $dataset -] break1432 set type [$dataobj type $comp]1433 if { $type == "glyphs" } {1434 SendCmd "$type lighting $bool $dataset"1435 }1436 }1437 }1438 "glyphs-edges" {1439 set bool $_settings($what)1440 foreach dataset [CurrentDatasets -visible $_first] {1441 foreach { dataobj comp } [split $dataset -] break1442 set type [$dataobj type $comp]1443 if { $type == "glyphs" } {1444 SendCmd "$type edges $bool $dataset"1445 }1446 }1447 }1448 "glyphs-palette" {1449 set palette [$itk_component(glyphspalette) value]1450 set _settings($what) $palette1451 foreach dataset [CurrentDatasets -visible $_first] {1452 foreach {dataobj comp} [split $dataset -] break1453 set type [$dataobj type $comp]1454 if { $type == "glyphs" } {1455 ChangeColormap $dataobj $comp $palette1456 # FIXME: fill in current selected fieldname1457 #SendCmd "glyphs colormode scalar {} $dataset"1458 }1459 }1460 set _legendPending 11461 }1462 1327 "polydata-opacity" { 1463 1328 foreach dataset [CurrentDatasets -visible $_first] { … … 1468 1333 } 1469 1334 } 1470 "polydata-outline" {1471 set bool $_settings($what)1472 foreach dataset [CurrentDatasets -visible $_first] {1473 foreach { dataobj comp } [split $dataset -] break1474 set type [$dataobj type $comp]1475 if { $type == "polydata" } {1476 SendCmd "outline visible $bool $dataset"1477 }1478 }1479 }1480 1335 "polydata-wireframe" { 1481 set bool $_settings( $what)1336 set bool $_settings(polydata-wireframe) 1482 1337 foreach dataset [CurrentDatasets -visible $_first] { 1483 1338 foreach { dataobj comp } [split $dataset -] break … … 1489 1344 } 1490 1345 "polydata-visible" { 1491 set bool $_settings( $what)1346 set bool $_settings(polydata-visible) 1492 1347 foreach dataset [CurrentDatasets -visible $_first] { 1493 1348 foreach { dataobj comp } [split $dataset -] break … … 1499 1354 } 1500 1355 "polydata-lighting" { 1501 set bool $_settings( $what)1356 set bool $_settings(polydata-lighting) 1502 1357 foreach dataset [CurrentDatasets -visible $_first] { 1503 1358 foreach { dataobj comp } [split $dataset -] break … … 1509 1364 } 1510 1365 "polydata-edges" { 1511 set bool $_settings( $what)1366 set bool $_settings(polydata-edges) 1512 1367 foreach dataset [CurrentDatasets -visible $_first] { 1513 1368 foreach { dataobj comp } [split $dataset -] break … … 1520 1375 "polydata-palette" { 1521 1376 set palette [$itk_component(meshpalette) value] 1522 set _settings( $what) $palette1377 set _settings(polydata-palette) $palette 1523 1378 foreach dataset [CurrentDatasets -visible $_first] { 1524 1379 foreach {dataobj comp} [split $dataset -] break … … 1533 1388 } 1534 1389 "molecule-opacity" { 1390 set val $_settings(molecule-opacity) 1391 set sval [expr { 0.01 * double($val) }] 1535 1392 foreach dataset [CurrentDatasets -visible $_first] { 1536 1393 foreach { dataobj comp } [split $dataset -] break … … 1540 1397 } 1541 1398 } 1542 "molecule-outline" {1543 set bool $_settings($what)1544 foreach dataset [CurrentDatasets -visible $_first] {1545 foreach { dataobj comp } [split $dataset -] break1546 set type [$dataobj type $comp]1547 if { $type == "molecule" } {1548 SendCmd "outline visible $bool $dataset"1549 }1550 }1551 }1552 1399 "molecule-wireframe" { 1553 set bool $_settings( $what)1400 set bool $_settings(molecule-wireframe) 1554 1401 foreach dataset [CurrentDatasets -visible $_first] { 1555 1402 foreach { dataobj comp } [split $dataset -] break … … 1561 1408 } 1562 1409 "molecule-visible" { 1563 set bool $_settings( $what)1410 set bool $_settings(molecule-visible) 1564 1411 foreach dataset [CurrentDatasets -visible $_first] { 1565 1412 foreach { dataobj comp } [split $dataset -] break … … 1571 1418 } 1572 1419 "molecule-lighting" { 1573 set bool $_settings( $what)1420 set bool $_settings(molecule-lighting) 1574 1421 foreach dataset [CurrentDatasets -visible $_first] { 1575 1422 foreach { dataobj comp } [split $dataset -] break … … 1581 1428 } 1582 1429 "molecule-edges" { 1583 set bool $_settings( $what)1430 set bool $_settings(molecule-edges) 1584 1431 foreach dataset [CurrentDatasets -visible $_first] { 1585 1432 foreach { dataobj comp } [split $dataset -] break … … 1592 1439 "molecule-palette" { 1593 1440 set palette [$itk_component(moleculepalette) value] 1594 set _ settings($what) $palette1441 set _moelculeSettings(palette) $palette 1595 1442 foreach dataset [CurrentDatasets -visible $_first] { 1596 1443 foreach {dataobj comp} [split $dataset -] break … … 1656 1503 set _settings(molecule-atoms-visible) 0 1657 1504 set _settings(molecule-bonds-visible) 1 1658 set _settings(molecule-bondstyle) line1505 set _settings(molecule-bondstyle) cylinder 1659 1506 set _settings(molecule-atomscale) 1.0 1660 1507 set _settings(molecule-bondscale) 1.0 … … 1677 1524 set type [$dataobj type $comp] 1678 1525 if { $type == "molecule" } { 1679 StartBufferingCommands 1680 SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset}] 1681 SendCmd [subst {molecule ascale $_settings(molecule-atomscale) $dataset}] 1682 SendCmd [subst {molecule bscale $_settings(molecule-bondscale) $dataset}] 1683 SendCmd [subst {molecule bstyle $_settings(molecule-bondstyle) $dataset}] 1684 SendCmd [subst {molecule atoms $_settings(molecule-atoms-visible) $dataset}] 1685 SendCmd [subst {molecule bonds $_settings(molecule-bonds-visible) $dataset}] 1686 StopBufferingCommands 1526 SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset 1527 molecule ascale $_settings(molecule-atomscale) $dataset 1528 molecule bscale $_settings(molecule-bondscale) $dataset 1529 molecule bstyle $_settings(molecule-bondstyle) $dataset 1530 molecule atoms $_settings(molecule-atoms-visible) $dataset 1531 molecule bonds $_settings(molecule-bonds-visible) $dataset}] 1687 1532 } 1688 1533 } … … 1691 1536 set value [$itk_component(rscale) value] 1692 1537 set value [$itk_component(rscale) translate $value] 1693 set _settings( $what) $value1538 set _settings(molecule-rscale) $value 1694 1539 foreach dataset [CurrentDatasets -visible $_first] { 1695 1540 foreach {dataobj comp} [split $dataset -] break 1696 1541 set type [$dataobj type $comp] 1697 1542 if { $type == "molecule" } { 1698 SendCmd [subst {molecule rscale $_settings( $what) $dataset}]1543 SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset}] 1699 1544 } 1700 1545 } 1701 1546 } 1702 1547 "molecule-labels" { 1703 set bool $_settings( $what)1548 set bool $_settings(molecule-labels) 1704 1549 foreach dataset [CurrentDatasets -visible $_first] { 1705 1550 foreach { dataobj comp } [split $dataset -] break … … 1717 1562 set bool $_axis(labels) 1718 1563 SendCmd "axis labels all $bool" 1719 }1720 "axis-minorticks" {1721 set bool $_axis(minorticks)1722 SendCmd "axis minticks all $bool"1723 1564 } 1724 1565 "axis-xgrid" { … … 1777 1618 set font "Arial 8" 1778 1619 set lineht [font metrics $font -linespace] 1620 set c $itk_component(legend) 1779 1621 set w 12 1780 1622 set h [expr {$_height - 2 * ($lineht + 2)}] 1781 if { $h < 1 1623 if { $h < 1} { 1782 1624 return 1783 1625 } … … 1885 1727 itcl::configbody Rappture::VtkViewer::plotbackground { 1886 1728 if { [isconnected] } { 1887 set rgb [Color2RGB $itk_option(-plotbackground)]1888 SendCmd "screen bgcolor $r gb"1729 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break 1730 SendCmd "screen bgcolor $r $g $b" 1889 1731 } 1890 1732 } … … 1895 1737 itcl::configbody Rappture::VtkViewer::plotforeground { 1896 1738 if { [isconnected] } { 1897 set rgb [Color2RGB $itk_option(-plotforeground)]1898 SendCmd "axis color all $rgb"1899 SendCmd "outline color $rgb"1739 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1740 #fix this! 1741 #SendCmd "color background $r $g $b" 1900 1742 } 1901 1743 } … … 1930 1772 file delete $tmpfile 1931 1773 set output [$reader GetOutput] 1932 if { $output == "" } {1933 # Invalid VTK file -- loader failed to parse1934 continue1935 }1936 1774 set _limits($tag) [$output GetBounds] 1937 1775 if {$debug} { … … 1992 1830 } 1993 1831 1994 itcl::body Rappture::VtkViewer::Build GlyphsTab {} {1832 itcl::body Rappture::VtkViewer::BuildPolydataTab {} { 1995 1833 1996 1834 set fg [option get $itk_component(hull) font Font] 1997 1835 #set bfg [option get $itk_component(hull) boldFont Font] 1998 1836 1999 set inner [$itk_component(main) insert 0 \ 2000 -title "Glyph Settings" \ 2001 -icon [Rappture::icon volume-on]] 2002 $inner configure -borderwidth 4 2003 2004 checkbutton $inner.glyphs \ 2005 -text "Show Glyphs" \ 2006 -variable [itcl::scope _settings(glyphs-visible)] \ 2007 -command [itcl::code $this AdjustSetting glyphs-visible] \ 2008 -font "Arial 9" -anchor w 2009 2010 checkbutton $inner.outline \ 2011 -text "Show Outline" \ 2012 -variable [itcl::scope _settings(glyphs-outline)] \ 2013 -command [itcl::code $this AdjustSetting glyphs-outline] \ 2014 -font "Arial 9" -anchor w 2015 2016 checkbutton $inner.wireframe \ 2017 -text "Show Wireframe" \ 2018 -variable [itcl::scope _settings(glyphs-wireframe)] \ 2019 -command [itcl::code $this AdjustSetting glyphs-wireframe] \ 2020 -font "Arial 9" -anchor w 2021 2022 checkbutton $inner.lighting \ 2023 -text "Enable Lighting" \ 2024 -variable [itcl::scope _settings(glyphs-lighting)] \ 2025 -command [itcl::code $this AdjustSetting glyphs-lighting] \ 2026 -font "Arial 9" -anchor w 2027 2028 checkbutton $inner.edges \ 2029 -text "Show Edges" \ 2030 -variable [itcl::scope _settings(glyphs-edges)] \ 2031 -command [itcl::code $this AdjustSetting glyphs-edges] \ 2032 -font "Arial 9" -anchor w 2033 2034 label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w 2035 itk_component add glyphspalette { 2036 Rappture::Combobox $inner.palette -width 10 -editable no 2037 } 2038 $inner.palette choices insert end [GetColormapList] 2039 $itk_component(glyphspalette) value "BCGYR" 2040 bind $inner.palette <<Value>> \ 2041 [itcl::code $this AdjustSetting glyphs-palette] 2042 2043 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 2044 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2045 -variable [itcl::scope _settings(glyphs-opacity)] \ 2046 -width 10 \ 2047 -showvalue off \ 2048 -command [itcl::code $this EventuallySetGlyphsOpacity] 2049 $inner.opacity set $_settings(glyphs-opacity) 2050 2051 blt::table $inner \ 2052 0,0 $inner.glyphs -cspan 2 -anchor w -pady 2 \ 2053 1,0 $inner.outline -cspan 2 -anchor w -pady 2 \ 2054 2,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 2055 3,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 2056 4,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 2057 5,0 $inner.opacity_l -anchor w -pady 2 \ 2058 5,1 $inner.opacity -fill x -pady 2 \ 2059 6,0 $inner.palette_l -anchor w -pady 2 \ 2060 6,1 $inner.palette -fill x -pady 2 2061 2062 blt::table configure $inner r* c* -resize none 2063 blt::table configure $inner r8 c1 -resize expand 2064 } 2065 2066 itcl::body Rappture::VtkViewer::BuildPolydataTab {} { 2067 2068 set fg [option get $itk_component(hull) font Font] 2069 #set bfg [option get $itk_component(hull) boldFont Font] 2070 2071 set inner [$itk_component(main) insert 0 \ 1837 set inner [$itk_component(main) insert end \ 2072 1838 -title "Mesh Settings" \ 2073 1839 -icon [Rappture::icon mesh]] … … 2080 1846 -font "Arial 9" -anchor w 2081 1847 2082 checkbutton $inner.outline \2083 -text "Show Outline" \2084 -variable [itcl::scope _settings(polydata-outline)] \2085 -command [itcl::code $this AdjustSetting polydata-outline] \2086 -font "Arial 9" -anchor w2087 2088 1848 checkbutton $inner.wireframe \ 2089 1849 -text "Show Wireframe" \ … … 2108 1868 Rappture::Combobox $inner.palette -width 10 -editable no 2109 1869 } 2110 $inner.palette choices insert end [GetColormapList] 1870 $inner.palette choices insert end \ 1871 "BCGYR" "BCGYR" \ 1872 "BGYOR" "BGYOR" \ 1873 "blue" "blue" \ 1874 "blue-to-brown" "blue-to-brown" \ 1875 "blue-to-orange" "blue-to-orange" \ 1876 "blue-to-grey" "blue-to-grey" \ 1877 "green-to-magenta" "green-to-magenta" \ 1878 "greyscale" "greyscale" \ 1879 "nanohub" "nanohub" \ 1880 "rainbow" "rainbow" \ 1881 "spectral" "spectral" \ 1882 "ROYGB" "ROYGB" \ 1883 "RYGCB" "RYGCB" \ 1884 "brown-to-blue" "brown-to-blue" \ 1885 "grey-to-blue" "grey-to-blue" \ 1886 "orange-to-blue" "orange-to-blue" 1887 2111 1888 $itk_component(meshpalette) value "BCGYR" 2112 1889 bind $inner.palette <<Value>> \ … … 2118 1895 -width 10 \ 2119 1896 -showvalue off \ 2120 -command [itcl::code $this EventuallySetPolydataOpacity]1897 -command [itcl::code $this AdjustSetting polydata-opacity] 2121 1898 $inner.opacity set $_settings(polydata-opacity) 2122 1899 2123 1900 blt::table $inner \ 2124 1901 0,0 $inner.mesh -cspan 2 -anchor w -pady 2 \ 2125 1,0 $inner.outline -cspan 2 -anchor w -pady 2 \ 2126 2,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 2127 3,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 2128 4,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 2129 5,0 $inner.opacity_l -anchor w -pady 2 \ 2130 5,1 $inner.opacity -fill x -pady 2 \ 2131 6,0 $inner.palette_l -anchor w -pady 2 \ 2132 6,1 $inner.palette -fill x -pady 2 1902 1,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 1903 2,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 1904 3,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 1905 4,0 $inner.opacity_l -anchor w -pady 2 \ 1906 4,1 $inner.opacity -fill x -pady 2 \ 1907 5,0 $inner.palette_l -anchor w -pady 2 \ 1908 5,1 $inner.palette -fill x -pady 2 2133 1909 2134 1910 blt::table configure $inner r* c* -resize none 2135 blt::table configure $inner r 8c1 -resize expand1911 blt::table configure $inner r7 c1 -resize expand 2136 1912 } 2137 1913 … … 2143 1919 set inner [$itk_component(main) insert end \ 2144 1920 -title "Axis Settings" \ 2145 -icon [Rappture::icon axis 2]]1921 -icon [Rappture::icon axis1]] 2146 1922 $inner configure -borderwidth 4 2147 1923 2148 1924 checkbutton $inner.visible \ 2149 -text " Axes" \1925 -text "Show Axes" \ 2150 1926 -variable [itcl::scope _axis(visible)] \ 2151 1927 -command [itcl::code $this AdjustSetting axis-visible] \ … … 2153 1929 2154 1930 checkbutton $inner.labels \ 2155 -text " Axis Labels" \1931 -text "Show Axis Labels" \ 2156 1932 -variable [itcl::scope _axis(labels)] \ 2157 1933 -command [itcl::code $this AdjustSetting axis-labels] \ 2158 1934 -font "Arial 9" 2159 label $inner.grid_l -text "Grid" -font "Arial 9" 2160 checkbutton $inner. xgrid\2161 -text " X" \1935 1936 checkbutton $inner.gridx \ 1937 -text "Show X Grid" \ 2162 1938 -variable [itcl::scope _axis(xgrid)] \ 2163 1939 -command [itcl::code $this AdjustSetting axis-xgrid] \ 2164 1940 -font "Arial 9" 2165 checkbutton $inner. ygrid\2166 -text " Y" \1941 checkbutton $inner.gridy \ 1942 -text "Show Y Grid" \ 2167 1943 -variable [itcl::scope _axis(ygrid)] \ 2168 1944 -command [itcl::code $this AdjustSetting axis-ygrid] \ 2169 1945 -font "Arial 9" 2170 checkbutton $inner. zgrid\2171 -text " Z" \1946 checkbutton $inner.gridz \ 1947 -text "Show Z Grid" \ 2172 1948 -variable [itcl::scope _axis(zgrid)] \ 2173 1949 -command [itcl::code $this AdjustSetting axis-zgrid] \ 2174 1950 -font "Arial 9" 2175 checkbutton $inner.minorticks \2176 -text "Minor Ticks" \2177 -variable [itcl::scope _axis(minorticks)] \2178 -command [itcl::code $this AdjustSetting axis-minorticks] \2179 -font "Arial 9"2180 1951 2181 1952 label $inner.mode_l -text "Mode" -font "Arial 9" … … 2187 1958 "static_triad" "static" \ 2188 1959 "closest_triad" "closest" \ 2189 "furthest_triad" "f arthest" \1960 "furthest_triad" "furthest" \ 2190 1961 "outer_edges" "outer" 2191 1962 $itk_component(axismode) value "static" … … 2193 1964 2194 1965 blt::table $inner \ 2195 0,0 $inner.visible -anchor w -cspan 4 \ 2196 1,0 $inner.labels -anchor w -cspan 4 \ 2197 2,0 $inner.minorticks -anchor w -cspan 4 \ 2198 4,0 $inner.grid_l -anchor w \ 2199 4,1 $inner.xgrid -anchor w \ 2200 4,2 $inner.ygrid -anchor w \ 2201 4,3 $inner.zgrid -anchor w \ 2202 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 2203 5,1 $inner.mode -fill x -cspan 3 1966 0,0 $inner.visible -anchor w -cspan 2 \ 1967 1,0 $inner.labels -anchor w -cspan 2 \ 1968 2,0 $inner.gridx -anchor w -cspan 2 \ 1969 3,0 $inner.gridy -anchor w -cspan 2 \ 1970 4,0 $inner.gridz -anchor w -cspan 2 \ 1971 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1972 6,0 $inner.mode -fill x -cspan 2 2204 1973 2205 1974 blt::table configure $inner r* c* -resize none 2206 blt::table configure $inner r7 c6 -resize expand 2207 blt::table configure $inner r3 -height 0.125i 1975 blt::table configure $inner r7 c1 -resize expand 2208 1976 } 2209 1977 … … 2226 1994 0,0 $inner.view_l -anchor e -pady 2 \ 2227 1995 0,1 $inner.view -anchor w -pady 2 2228 blt::table configure $inner r0 -resize none2229 1996 2230 1997 set labels { qx qy qz qw xpan ypan zoom } … … 2233 2000 label $inner.${tag}label -text $tag -font "Arial 9" 2234 2001 entry $inner.${tag} -font "Arial 9" -bg white \ 2235 -textvariable [itcl::scope _view(-$tag)] 2236 bind $inner.${tag} <Return> \ 2237 [itcl::code $this camera set -${tag}] 2238 bind $inner.${tag} <KP_Enter> \ 2239 [itcl::code $this camera set -${tag}] 2002 -textvariable [itcl::scope _view($tag)] 2003 bind $inner.${tag} <KeyPress-Return> \ 2004 [itcl::code $this camera set ${tag}] 2240 2005 blt::table $inner \ 2241 2006 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 2246 2011 checkbutton $inner.ortho \ 2247 2012 -text "Orthographic Projection" \ 2248 -variable [itcl::scope _view( -ortho)] \2249 -command [itcl::code $this camera set -ortho] \2013 -variable [itcl::scope _view(ortho)] \ 2014 -command [itcl::code $this camera set ortho] \ 2250 2015 -font "Arial 9" 2251 2016 blt::table $inner \ … … 2254 2019 incr row 2255 2020 2256 blt::table configure $inner c* -resize none2021 blt::table configure $inner c* r* -resize none 2257 2022 blt::table configure $inner c2 -resize expand 2258 2023 blt::table configure $inner r$row -resize expand … … 2372 2137 $itk_component(zCutScale) set 100 2373 2138 $itk_component(zCutScale) configure -state disabled 2139 #$itk_component(zCutScale) configure -state disabled 2374 2140 Rappture::Tooltip::for $itk_component(zCutScale) \ 2375 2141 "@[itcl::code $this Slice tooltip z]" … … 2403 2169 set fg [option get $itk_component(hull) font Font] 2404 2170 2405 set inner [$itk_component(main) insert 0\2171 set inner [$itk_component(main) insert end \ 2406 2172 -title "Molecule Settings" \ 2407 2173 -icon [Rappture::icon molecule]] … … 2412 2178 -variable [itcl::scope _settings(molecule-visible)] \ 2413 2179 -command [itcl::code $this AdjustSetting molecule-visible] \ 2414 -font "Arial 9"2415 2416 checkbutton $inner.outline \2417 -text "Show Outline" \2418 -variable [itcl::scope _settings(molecule-outline)] \2419 -command [itcl::code $this AdjustSetting molecule-outline] \2420 2180 -font "Arial 9" 2421 2181 … … 2482 2242 Rappture::Combobox $inner.palette -width 10 -editable no 2483 2243 } 2484 $inner.palette choices insert end [GetColormapList -includeElementDefault] 2244 $inner.palette choices insert end \ 2245 "elementDefault" "elementDefault" \ 2246 "BCGYR" "BCGYR" \ 2247 "BGYOR" "BGYOR" \ 2248 "blue" "blue" \ 2249 "blue-to-brown" "blue-to-brown" \ 2250 "blue-to-orange" "blue-to-orange" \ 2251 "blue-to-grey" "blue-to-grey" \ 2252 "green-to-magenta" "green-to-magenta" \ 2253 "greyscale" "greyscale" \ 2254 "nanohub" "nanohub" \ 2255 "rainbow" "rainbow" \ 2256 "spectral" "spectral" \ 2257 "ROYGB" "ROYGB" \ 2258 "RYGCB" "RYGCB" \ 2259 "brown-to-blue" "brown-to-blue" \ 2260 "grey-to-blue" "grey-to-blue" \ 2261 "orange-to-blue" "orange-to-blue" 2262 2485 2263 $itk_component(moleculepalette) value "elementDefault" 2486 2264 bind $inner.palette <<Value>> \ 2487 2265 [itcl::code $this AdjustSetting molecule-palette] 2266 2267 checkbutton $inner.labels -text "Show labels on atoms" \ 2268 -command [itcl::code $this labels update] \ 2269 -variable [itcl::scope _settings(molecule-labels)] \ 2270 -font "Arial 9" 2271 Rappture::Tooltip::for $inner.labels \ 2272 "Display atom symbol and serial number." 2273 2274 checkbutton $inner.rock -text "Rock molecule back and forth" \ 2275 -variable [itcl::scope _settings(molecule-rock)] \ 2276 -font "Arial 9" 2277 Rappture::Tooltip::for $inner.rock \ 2278 "Rotate the object back and forth around the y-axis." 2279 2280 checkbutton $inner.cell -text "Parallelepiped" \ 2281 -font "Arial 9" 2282 $inner.cell select 2488 2283 2489 2284 label $inner.atomscale_l -text "Atom Scale" -font "Arial 9" … … 2526 2321 blt::table $inner \ 2527 2322 0,0 $inner.molecule -anchor w -pady {1 0} \ 2528 1,0 $inner.outline -anchor w -pady {1 0} \ 2529 2,0 $inner.label -anchor w -pady {1 0} \ 2530 3,0 $inner.edges -anchor w -pady {1 0} \ 2531 4,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2532 5,0 $inner.rep -fill x -pady 2 \ 2533 6,0 $inner.rscale_l -anchor w -pady { 2 0 } \ 2534 7,0 $inner.rscale -fill x -pady 2 \ 2535 8,0 $inner.palette_l -anchor w -pady 0 \ 2536 9,0 $inner.palette -fill x -padx 2 \ 2537 10,0 $inner.atomscale_l -anchor w -pady {3 0} \ 2538 11,0 $inner.atomscale -fill x -padx 2 \ 2539 12,0 $inner.bondscale_l -anchor w -pady {3 0} \ 2540 13,0 $inner.bondscale -fill x -padx 2 \ 2541 14,0 $inner.opacity_l -anchor w -pady {3 0} \ 2542 15,0 $inner.opacity -fill x -padx 2 \ 2543 16,0 $inner.quality_l -anchor w -pady {3 0} \ 2544 17,0 $inner.quality -fill x -padx 2 2323 1,0 $inner.label -anchor w -pady {1 0} \ 2324 2,0 $inner.edges -anchor w -pady {1 0} \ 2325 3,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2326 4,0 $inner.rep -fill x -pady 2 \ 2327 5,0 $inner.rscale_l -anchor w -pady { 2 0 } \ 2328 6,0 $inner.rscale -fill x -pady 2 \ 2329 7,0 $inner.palette_l -anchor w -pady 0 \ 2330 8,0 $inner.palette -fill x -padx 2 \ 2331 9,0 $inner.atomscale_l -anchor w -pady {3 0} \ 2332 10,0 $inner.atomscale -fill x -padx 2 \ 2333 11,0 $inner.bondscale_l -anchor w -pady {3 0} \ 2334 12,0 $inner.bondscale -fill x -padx 2 \ 2335 13,0 $inner.opacity_l -anchor w -pady {3 0} \ 2336 14,0 $inner.opacity -fill x -padx 2 \ 2337 15,0 $inner.quality_l -anchor w -pady {3 0} \ 2338 16,0 $inner.quality -fill x -padx 2 2545 2339 2546 2340 blt::table configure $inner r* -resize none 2547 blt::table configure $inner r1 8-resize expand2341 blt::table configure $inner r17 -resize expand 2548 2342 } 2549 2343 … … 2557 2351 } 2558 2352 "set" { 2559 set wh at[lindex $args 0]2560 set x $_view($wh at)2353 set who [lindex $args 0] 2354 set x $_view($who) 2561 2355 set code [catch { string is double $x } result] 2562 2356 if { $code != 0 || !$result } { 2563 2357 return 2564 2358 } 2565 switch -- $wh at{2566 " -ortho" {2567 if {$_view( $what)} {2359 switch -- $who { 2360 "ortho" { 2361 if {$_view(ortho)} { 2568 2362 SendCmd "camera mode ortho" 2569 2363 } else { … … 2571 2365 } 2572 2366 } 2573 " -xpan" - "-ypan" {2367 "xpan" - "ypan" { 2574 2368 PanCamera 2575 2369 } 2576 " -qx" - "-qy" - "-qz" - "-qw" {2577 set q [ ViewToQuaternion]2370 "qx" - "qy" - "qz" - "qw" { 2371 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2578 2372 $_arcball quaternion $q 2579 2373 EventuallyRotate $q 2580 2374 } 2581 " -zoom" {2582 SendCmd "camera zoom $_view( $what)"2375 "zoom" { 2376 SendCmd "camera zoom $_view(zoom)" 2583 2377 } 2584 2378 } … … 2661 2455 "glyphs" { 2662 2456 array set settings { 2663 -color white 2457 -color \#FFFFFF 2458 -gscale 1 2459 -edges 0 2664 2460 -edgecolor black 2665 -edges 0 2666 -gscale 1 2461 -linewidth 1.0 2462 -opacity 1.0 2463 -wireframe 0 2667 2464 -lighting 1 2668 -linewidth 1.02669 -normscale 02670 -opacity 1.02671 -orientGlyphs 02672 -outline 02673 -ptsize 1.02674 -quality 12675 -scaleMode "vcomp"2676 -shape "sphere"2677 2465 -visible 1 2678 -wireframe 02679 }2466 } 2467 set shape [$dataobj shape $comp] 2680 2468 array set settings $style 2681 set shape [$dataobj shape $comp] 2682 if {$shape != ""} { 2683 set settings(-shape) $shape 2684 } 2685 SendCmd "outline add $tag" 2686 SendCmd "outline color [Color2RGB $settings(-color)] $tag" 2687 SendCmd "outline visible $settings(-outline) $tag" 2688 set _settings(glyphs-outline) $settings(-outline) 2689 2690 SendCmd "glyphs add $settings(-shape) $tag" 2691 SendCmd "glyphs normscale $settings(-normscale) $tag" 2469 SendCmd "glyphs add $shape $tag" 2470 SendCmd "glyphs normscale 0 $tag" 2692 2471 SendCmd "glyphs gscale $settings(-gscale) $tag" 2693 2472 SendCmd "glyphs wireframe $settings(-wireframe) $tag" 2694 2473 SendCmd "glyphs color [Color2RGB $settings(-color)] $tag" 2695 2474 #SendCmd "glyphs colormode constant {} $tag" 2696 # Omitting field name for gorient and smode commands 2697 # defaults to active scalars or vectors depending on mode 2698 SendCmd "glyphs gorient $settings(-orientGlyphs) {} $tag" 2699 SendCmd "glyphs smode $settings(-scaleMode) {} $tag" 2700 SendCmd "glyphs edges $settings(-edges) $tag" 2701 SendCmd "glyphs linecolor [Color2RGB $settings(-edgecolor)] $tag" 2702 SendCmd "glyphs linewidth $settings(-linewidth) $tag" 2703 SendCmd "glyphs ptsize $settings(-ptsize) $tag" 2704 SendCmd "glyphs quality $settings(-quality) $tag" 2705 SendCmd "glyphs lighting $settings(-lighting) $tag" 2475 SendCmd "glyphs gorient 0 {} $tag" 2476 SendCmd "glyphs smode vcomp {} $tag" 2706 2477 SendCmd "glyphs opacity $settings(-opacity) $tag" 2707 set _settings(glyphs-opacity) [expr 100.0 * $settings(-opacity)]2708 2478 SendCmd "glyphs visible $settings(-visible) $tag" 2709 2479 set _settings(glyphs-wireframe) $settings(-wireframe) 2710 2480 } 2711 2481 "molecule" { 2482 SendCmd "molecule add $tag" 2483 SendCmd "molecule ascale $_settings(molecule-atomscale) $tag" 2484 SendCmd "molecule bscale $_settings(molecule-bondscale) $tag" 2485 SendCmd "molecule bstyle $_settings(molecule-bondstyle) $tag" 2486 SendCmd "molecule atoms $_settings(molecule-atoms-visible) $tag" 2487 SendCmd "molecule bonds $_settings(molecule-bonds-visible) $tag" 2488 set _haveMolecules 1 2489 } 2490 "polydata" { 2712 2491 array set settings { 2713 -atomscale 0.3 2714 -atomsvisible 1 2715 -bondscale 0.075 2716 -bondstyle "cylinder" 2717 -bondsvisible 1 2718 -color "elementDefault" 2492 -color \#FFFFFF 2493 -edges 1 2719 2494 -edgecolor black 2720 -edges 02721 -labels 02722 -lighting 12723 2495 -linewidth 1.0 2724 2496 -opacity 1.0 2725 -outline 0 2726 -quality 1.0 2727 -representation "" 2728 -rscale "covalent" 2497 -wireframe 0 2498 -lighting 1 2729 2499 -visible 1 2730 -wireframe 02731 2500 } 2732 2501 array set settings $style 2733 2734 SendCmd "outline add $tag"2735 SendCmd "outline color [Color2RGB white] $tag"2736 SendCmd "outline visible $settings(-outline) $tag"2737 set _settings(molecule-outline) $settings(-outline)2738 2739 SendCmd "molecule add $tag"2740 if {$settings(-representation) != ""} {2741 switch -- $settings(-representation) {2742 "ballandstick" {2743 set _settings(molecule-rscale) covalent2744 set _settings(molecule-atoms-visible) 12745 set _settings(molecule-bonds-visible) 12746 set _settings(molecule-bondstyle) cylinder2747 set _settings(molecule-atomscale) 0.32748 set _settings(molecule-bondscale) 0.0752749 }2750 "balls" - "spheres" {2751 set _settings(molecule-rscale) covalent2752 set _settings(molecule-atoms-visible) 12753 set _settings(molecule-bonds-visible) 02754 set _settings(molecule-bondstyle) cylinder2755 set _settings(molecule-atomscale) 0.32756 set _settings(molecule-bondscale) 0.0752757 }2758 "sticks" {2759 set _settings(molecule-rscale) none2760 set _settings(molecule-atoms-visible) 12761 set _settings(molecule-bonds-visible) 12762 set _settings(molecule-bondstyle) cylinder2763 set _settings(molecule-atomscale) 0.0752764 set _settings(molecule-bondscale) 0.0752765 }2766 "spacefilling" {2767 set _settings(molecule-rscale) van_der_waals2768 set _settings(molecule-atoms-visible) 12769 set _settings(molecule-bonds-visible) 02770 set _settings(molecule-bondstyle) cylinder2771 set _settings(molecule-atomscale) 1.02772 set _settings(molecule-bondscale) 0.0752773 }2774 "rods" {2775 set _settings(molecule-rscale) none2776 set _settings(molecule-atoms-visible) 12777 set _settings(molecule-bonds-visible) 12778 set _settings(molecule-bondstyle) cylinder2779 set _settings(molecule-atomscale) 0.12780 set _settings(molecule-bondscale) 0.12781 }2782 "wireframe" - "lines" {2783 set _settings(molecule-rscale) none2784 set _settings(molecule-atoms-visible) 02785 set _settings(molecule-bonds-visible) 12786 set _settings(molecule-bondstyle) line2787 set _settings(molecule-atomscale) 1.02788 set _settings(molecule-bondscale) 1.02789 }2790 default {2791 error "unknown representation $value"2792 }2793 }2794 SendCmd "molecule rscale $_settings(molecule-rscale) $tag"2795 SendCmd "molecule atoms $_settings(molecule-atoms-visible) $tag"2796 SendCmd "molecule bonds $_settings(molecule-bonds-visible) $tag"2797 SendCmd "molecule bstyle $_settings(molecule-bondstyle) $tag"2798 SendCmd "molecule ascale $_settings(molecule-atomscale) $tag"2799 SendCmd "molecule bscale $_settings(molecule-bondscale) $tag"2800 $itk_component(representation) value [$itk_component(representation) label $settings(-representation)]2801 $itk_component(rscale) value [$itk_component(rscale) label $_settings(molecule-rscale)]2802 switch -- $settings(-representation) {2803 "ballandstick" - "balls" - "spheres" {2804 $itk_component(rscale) configure -state normal2805 }2806 default {2807 $itk_component(rscale) configure -state disabled2808 }2809 }2810 } else {2811 SendCmd "molecule rscale $settings(-rscale) $tag"2812 set _settings(molecule-rscale) $settings(-rscale)2813 SendCmd "molecule atoms $settings(-atomsvisible) $tag"2814 set _settings(molecule-atoms-visible) $settings(-atomsvisible)2815 SendCmd "molecule bonds $settings(-bondsvisible) $tag"2816 set _settings(molecule-bonds-visible) $settings(-bondsvisible)2817 SendCmd "molecule bstyle $settings(-bondstyle) $tag"2818 set _settings(molecule-bondstyle) $settings(-bondstyle)2819 SendCmd "molecule ascale $settings(-atomscale) $tag"2820 set _settings(molecule-atomscale) $settings(-atomscale)2821 SendCmd "molecule bscale $settings(-bondscale) $tag"2822 set _settings(molecule-bondscale) $settings(-bondscale)2823 }2824 SendCmd "molecule labels $settings(-labels) $tag"2825 set _settings(molecule-labels) $settings(-labels)2826 SendCmd "molecule linecolor [Color2RGB $settings(-edgecolor)] $tag"2827 SendCmd "molecule linewidth $settings(-linewidth) $tag"2828 SendCmd "molecule edges $settings(-edges) $tag"2829 set _settings(molecule-edges) $settings(-edges)2830 SendCmd "molecule lighting $settings(-lighting) $tag"2831 set _settings(molecule-lighting) $settings(-lighting)2832 SendCmd "molecule aquality $settings(-quality) $tag"2833 SendCmd "molecule bquality $settings(-quality) $tag"2834 set _settings(molecule-quality) $settings(-quality)2835 SendCmd "molecule visible $settings(-visible) $tag"2836 set _settings(molecule-visible) $settings(-visible)2837 set _haveMolecules 12838 }2839 "polydata" {2840 array set settings {2841 -cloudstyle "mesh"2842 -color white2843 -edgecolor black2844 -edges 12845 -lighting 12846 -linewidth 1.02847 -opacity 1.02848 -outline 02849 -visible 12850 -wireframe 02851 }2852 array set settings $style2853 2854 SendCmd "outline add $tag"2855 SendCmd "outline color [Color2RGB $settings(-color)] $tag"2856 SendCmd "outline visible $settings(-outline) $tag"2857 set _settings(polydata-outline) $settings(-outline)2858 2859 2502 SendCmd "polydata add $tag" 2860 2503 SendCmd "polydata visible $settings(-visible) $tag" … … 2862 2505 SendCmd "polydata edges $settings(-edges) $tag" 2863 2506 set _settings(polydata-edges) $settings(-edges) 2864 SendCmd "polydata cloudstyle $settings(-cloudstyle) $tag"2865 2507 SendCmd "polydata color [Color2RGB $settings(-color)] $tag" 2866 2508 #SendCmd "polydata colormode constant {} $tag" … … 3023 2665 "move" { 3024 2666 set axis [lindex $args 0] 2667 set oldval $_axis(${axis}position) 3025 2668 set newval [lindex $args 1] 3026 2669 if {[llength $args] != 2} { … … 3050 2693 bottom "0.707107 0.707107 0 0" 3051 2694 } 3052 foreach name { -qw -qx -qy -qz } value $positions($side) {2695 foreach name { qw qx qy qz } value $positions($side) { 3053 2696 set _view($name) $value 3054 2697 } 3055 set q [ ViewToQuaternion]2698 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 3056 2699 $_arcball quaternion $q 3057 2700 SendCmd "camera orient $q" 3058 2701 SendCmd "camera reset" 3059 set _view( -xpan) 03060 set _view( -ypan) 03061 set _view( -zoom) 1.02702 set _view(xpan) 0 2703 set _view(ypan) 0 2704 set _view(zoom) 1.0 3062 2705 } 3063 2706 -
branches/1.3/gui/scripts/vtkvolumeviewer.tcl
r4774 r4848 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 # ---------------------------------------------------------------------- 3 # COMPONENT: vtkvolumeviewer - Vtk volume viewer 2 3 # ---------------------------------------------------------------------- 4 # COMPONENT: VtkVolumeViewer - Vtk volume viewer 4 5 # 5 6 # It connects to the Vtk server running on a rendering farm, … … 7 8 # ====================================================================== 8 9 # AUTHOR: Michael McLennan, Purdue University 9 # Copyright (c) 2004-201 4HUBzero Foundation, LLC10 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 11 # 11 12 # See the file "license.terms" for information on usage and … … 62 63 public method scale {args} 63 64 64 private method GetDatasetsWithComponent { cname } 65 66 private variable _volcomponents ; # Array of components found 67 private variable _componentsList ; # List of component names 65 protected method Connect {} 66 protected method CurrentDatasets {args} 67 protected method Disconnect {} 68 protected method DoResize {} 69 protected method DoReseed {} 70 protected method DoRotate {} 71 protected method AdjustSetting {what {value ""}} 72 protected method InitSettings { args } 73 protected method Pan {option x y} 74 protected method Pick {x y} 75 protected method Rebuild {} 76 protected method ReceiveDataset { args } 77 protected method ReceiveImage { args } 78 protected method ReceiveLegend { colormap title vmin vmax size } 79 protected method Rotate {option x y} 80 protected method Zoom {option} 68 81 69 82 # The following methods are only used by this class. 70 private method AdjustSetting {what {value ""}}71 83 private method BuildAxisTab {} 72 84 private method BuildCameraTab {} … … 74 86 private method BuildCutplaneTab {} 75 87 private method BuildDownloadPopup { widget command } 76 private method BuildViewTab {}77 88 private method BuildVolumeTab {} 78 89 private method DrawLegend {} 79 private method ChangeColormap { dataobj comp color }80 90 private method Combo { option } 81 private method Connect {}82 private method CurrentDatasets {args}83 private method Disconnect {}84 private method DoResize {}85 private method DoRotate {}86 91 private method EnterLegend { x y } 87 92 private method EventuallyResize { w h } 88 private method EventuallyRe questLegend {}93 private method EventuallyReseed { numPoints } 89 94 private method EventuallyRotate { q } 90 95 private method EventuallySetCutplane { axis args } 91 96 private method GetImage { args } 92 97 private method GetVtkData { args } 93 private method InitSettings { args }94 98 private method IsValidObject { dataobj } 95 99 private method LeaveLegend {} 96 private method MotionLegend { x y } 97 private method Pan {option x y} 100 private method MotionLegend { x y } 98 101 private method PanCamera {} 99 private method Pick {x y}100 private method QuaternionToView { q } {101 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break102 }103 private method Rebuild {}104 private method ReceiveDataset { args }105 private method ReceiveImage { args }106 private method ReceiveLegend { colormap title vmin vmax size }107 102 private method RequestLegend {} 108 103 private method SetColormap { dataobj comp } 109 private method Rotate {option x y}104 private method ChangeColormap { dataobj comp color } 110 105 private method SetLegendTip { x y } 111 106 private method SetObjectStyle { dataobj comp } 112 private method SetOrientation { side }113 107 private method Slice {option args} 114 private method ViewToQuaternion {} {115 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]116 }117 private method Zoom {option}118 108 119 109 private variable _arcball "" … … 139 129 private variable _start 0 140 130 private variable _title "" 131 private variable _seeds 141 132 142 133 common _downloadPopup; # download options from popup … … 145 136 private variable _height 0 146 137 private variable _resizePending 0 138 private variable _reseedPending 0 147 139 private variable _rotatePending 0 148 140 private variable _cutplanePending 0 … … 151 143 private variable _curFldName "" 152 144 private variable _curFldLabel "" 153 private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar) 154 private variable _cutplaneCmd "cutplane" 155 private variable _allowMultiComponent 0 145 private variable _colorMode "vmag";# Mode of colormap (vmag or scalar) 156 146 } 157 147 … … 168 158 set _serverType "vtkvis" 169 159 170 EnableWaitDialog 900171 172 160 # Rebuild event 173 161 $_dispatcher register !rebuild … … 178 166 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 179 167 168 # Reseed event 169 $_dispatcher register !reseed 170 $_dispatcher dispatch $this !reseed "[itcl::code $this DoReseed]; list" 171 180 172 # Rotate event 181 173 $_dispatcher register !rotate … … 189 181 $_dispatcher register !xcutplane 190 182 $_dispatcher dispatch $this !xcutplane \ 191 "[itcl::code $this AdjustSetting -xcutplaneposition]; list"183 "[itcl::code $this AdjustSetting cutplane-xposition]; list" 192 184 193 185 # Y-Cutplane event 194 186 $_dispatcher register !ycutplane 195 187 $_dispatcher dispatch $this !ycutplane \ 196 "[itcl::code $this AdjustSetting -ycutplaneposition]; list"188 "[itcl::code $this AdjustSetting cutplane-yposition]; list" 197 189 198 190 # Z-Cutplane event 199 191 $_dispatcher register !zcutplane 200 192 $_dispatcher dispatch $this !zcutplane \ 201 "[itcl::code $this AdjustSetting -zcutplaneposition]; list"193 "[itcl::code $this AdjustSetting cutplane-zposition]; list" 202 194 203 195 # … … 210 202 # Initialize the view to some default parameters. 211 203 array set _view { 212 -ortho 0213 -qw 0.853553214 -qx -0.353553215 -qy 0.353553216 -qz 0.146447217 -xpan 0218 -ypan 0219 -zoom 1.0204 qw 0.853553 205 qx -0.353553 206 qy 0.353553 207 qz 0.146447 208 zoom 1.0 209 xpan 0 210 ypan 0 211 ortho 0 220 212 } 221 213 set _arcball [blt::arcball create 100 100] 222 $_arcball quaternion [ViewToQuaternion] 214 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 215 $_arcball quaternion $q 223 216 224 217 array set _settings { 225 -axesvisible 1 226 -axisflymode static 227 -axislabels 1 228 -axisminorticks 1 229 -background black 230 -color BCGYR 231 -cutplanelighting 1 232 -cutplaneopacity 100 233 -cutplanesvisible 0 234 -legendvisible 1 235 -volumelighting 1 236 -volumematerial 80 237 -volumeopacity 50 238 -volumeoutline 0 239 -volumequality 80 240 -volumevisible 1 241 -xcutplaneposition 50 242 -xcutplanevisible 1 243 -xgrid 0 244 -ycutplaneposition 50 245 -ycutplanevisible 1 246 -ygrid 0 247 -zcutplaneposition 50 248 -zcutplanevisible 1 249 -zgrid 0 218 axis-xgrid 0 219 axis-ygrid 0 220 axis-zgrid 0 221 axesVisible 1 222 axisLabels 1 223 cutplaneEdges 0 224 cutplane-xvisible 1 225 cutplane-yvisible 1 226 cutplane-zvisible 1 227 cutplane-xposition 50 228 cutplane-yposition 50 229 cutplane-zposition 50 230 cutplaneVisible 0 231 cutplaneLighting 1 232 cutplaneWireframe 0 233 cutplane-opacity 100 234 volumeLighting 1 235 volume-material 80 236 volume-opacity 40 237 volume-quality 50 238 volumeVisible 1 239 legendVisible 1 250 240 } 251 241 … … 326 316 -onimage [Rappture::icon volume-on] \ 327 317 -offimage [Rappture::icon volume-off] \ 328 -variable [itcl::scope _settings( -volumevisible)] \329 -command [itcl::code $this AdjustSetting -volumevisible]318 -variable [itcl::scope _settings(volumeVisible)] \ 319 -command [itcl::code $this AdjustSetting volumeVisible] 330 320 } 331 321 $itk_component(volume) select … … 338 328 -onimage [Rappture::icon cutbutton] \ 339 329 -offimage [Rappture::icon cutbutton] \ 340 -variable [itcl::scope _settings( -cutplanesvisible)] \341 -command [itcl::code $this AdjustSetting -cutplanesvisible]330 -variable [itcl::scope _settings(cutplaneVisible)] \ 331 -command [itcl::code $this AdjustSetting cutplaneVisible] 342 332 } 343 333 Rappture::Tooltip::for $itk_component(cutplane) \ … … 347 337 348 338 if { [catch { 349 BuildViewTab350 339 BuildVolumeTab 351 340 BuildCutplaneTab … … 355 344 puts stderr errs=$errs 356 345 } 357 358 346 # Legend 347 359 348 set _image(legend) [image create photo] 360 349 itk_component add legend { … … 382 371 bind $itk_component(view) <ButtonRelease-1> \ 383 372 [itcl::code $this Rotate release %x %y] 384 373 bind $itk_component(view) <Configure> \ 374 [itcl::code $this EventuallyResize %w %h] 375 376 if 0 { 377 bind $itk_component(view) <Configure> \ 378 [itcl::code $this EventuallyResize %w %h] 379 } 385 380 # Bindings for panning via mouse 386 381 bind $itk_component(view) <ButtonPress-2> \ … … 430 425 eval itk_initialize $args 431 426 Connect 427 update 432 428 } 433 429 … … 457 453 458 454 itcl::body Rappture::VtkVolumeViewer::DoRotate {} { 459 SendCmd "camera orient [ViewToQuaternion]" 455 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 456 SendCmd "camera orient $q" 460 457 set _rotatePending 0 461 458 } … … 471 468 } 472 469 473 itcl::body Rappture::VtkVolumeViewer::EventuallyRequestLegend {} { 474 if { !$_legendPending } { 475 set _legendPending 1 476 $_dispatcher event -idle !legend 470 itcl::body Rappture::VtkVolumeViewer::EventuallyReseed { numPoints } { 471 set _numSeeds $numPoints 472 if { !$_reseedPending } { 473 set _reseedPending 1 474 $_dispatcher event -after 600 !reseed 477 475 } 478 476 } … … 481 479 482 480 itcl::body Rappture::VtkVolumeViewer::EventuallyRotate { q } { 483 QuaternionToView $q481 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 484 482 if { !$_rotatePending } { 485 483 set _rotatePending 1 … … 504 502 # ---------------------------------------------------------------------- 505 503 itcl::body Rappture::VtkVolumeViewer::add {dataobj {settings ""}} { 506 if { ![IsValidObject $dataobj] } {507 return; # Ignore invalid objects.508 }509 504 array set params { 510 505 -color auto … … 649 644 # ---------------------------------------------------------------------- 650 645 itcl::body Rappture::VtkVolumeViewer::scale {args} { 651 array unset _limits652 array unset _volcomponents653 set _componentsList ""654 655 646 foreach dataobj $args { 656 if { ![$dataobj isvalid] } {657 continue; # Object doesn't contain valid data.658 }659 # Determine limits for each axis.660 647 foreach axis { x y z } { 661 648 set lim [$dataobj limits $axis] … … 674 661 set _limits($axis) [list $amin $amax] 675 662 } 676 # Determine limits for each field.677 663 foreach { fname lim } [$dataobj fieldlimits] { 678 664 if { ![info exists _limits($fname)] } { … … 689 675 } 690 676 set _limits($fname) [list $fmin $fmax] 691 }692 # Get limits for each component.693 foreach cname [$dataobj components] {694 if { ![info exists _volcomponents($cname)] } {695 lappend _componentsList $cname696 }697 lappend _volcomponents($cname) $dataobj-$cname698 array unset limits699 array set limits [$dataobj valueLimits $cname]700 if { ![info exists _limits($cname)] } {701 set _limits($cname) $limits(v)702 continue703 }704 foreach {min max} $limits(v) break705 foreach {vmin vmax} $_limits($cname) break706 if { $vmin > $min } {707 set vmin $min708 }709 if { $vmax < $max } {710 set vmax $max711 }712 set _limits($cname) [list $vmin $vmax]713 677 } 714 678 } … … 787 751 if { $_reportClientInfo } { 788 752 # Tell the server the viewer, hub, user and session. 789 # Do this immediately on connect before buff ering any commands753 # Do this immediately on connect before buffing any commands 790 754 global env 791 755 … … 845 809 $_dispatcher cancel !rebuild 846 810 $_dispatcher cancel !resize 811 $_dispatcher cancel !reseed 847 812 $_dispatcher cancel !rotate 848 813 $_dispatcher cancel !xcutplane … … 855 820 array unset _data 856 821 array unset _colormaps 822 array unset _seeds 857 823 array unset _dataset2style 858 824 array unset _obj2datasets 859 860 set _resizePending 0861 set _rotatePending 0862 set _cutplanePending 0863 set _legendPending 0864 set _reset 1865 825 } 866 826 … … 883 843 if { $info(-type) == "image" } { 884 844 if 0 { 885 set f [open "last.ppm" "w"] 886 fconfigure $f -encoding binary 887 puts -nonewline $f $bytes 845 set f [open "last.ppm" "w"] 846 puts $f $bytes 888 847 close $f 889 848 } 890 849 $_image(plot) configure -data $bytes 891 #puts stderr "[clock format [clock seconds]]: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 850 set time [clock seconds] 851 set date [clock format $time] 852 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 892 853 if { $_start > 0 } { 893 854 set finish [clock clicks -milliseconds] … … 954 915 # ---------------------------------------------------------------------- 955 916 itcl::body Rappture::VtkVolumeViewer::Rebuild {} { 917 update 956 918 set w [winfo width $itk_component(view)] 957 919 set h [winfo height $itk_component(view)] 958 959 920 if { $w < 2 || $h < 2 } { 960 921 $_dispatcher event -idle !rebuild … … 969 930 set _legendPending 1 970 931 971 if { $_ width != $w || $_height != $h || $_reset } {932 if { $_reset } { 972 933 set _width $w 973 934 set _height $h 974 935 $_arcball resize $w $h 975 936 DoResize 976 }977 if { $_reset } {978 937 # 979 938 # Reset the camera and other view parameters 980 939 # 981 $_arcball quaternion [ViewToQuaternion] 982 if {$_view(-ortho)} { 940 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 941 $_arcball quaternion $q 942 if {$_view(ortho)} { 983 943 SendCmd "camera mode ortho" 984 944 } else { … … 986 946 } 987 947 DoRotate 948 InitSettings axis-xgrid axis-ygrid axis-zgrid axisFlyMode \ 949 axesVisible axisLabels 988 950 PanCamera 989 set _first "" 990 InitSettings -background \ 991 -xgrid -ygrid -zgrid -axisflymode \ 992 -axesvisible -axislabels -axisminorticks 993 StopBufferingCommands 994 SendCmd "imgflush" 995 StartBufferingCommands 996 } 951 } 952 set _first "" 953 954 SendCmd "imgflush" 997 955 set _first "" 998 956 … … 1007 965 if { ![info exists _datasets($tag)] } { 1008 966 set bytes [$dataobj vtkdata $comp] 1009 if 0 {1010 set f [open /tmp/vtkvolume.vtk "w"]1011 fconfigure $f -translation binary -encoding binary1012 puts -nonewline $f $bytes1013 close $f1014 }1015 967 set length [string length $bytes] 1016 968 if { $_reportClientInfo } { … … 1024 976 lappend info "dataset_size" $length 1025 977 lappend info "dataset_tag" $tag 1026 SendCmd "clientinfo [list $info]"1027 } 1028 SendCmd "dataset add $tag data follows $length"978 SendCmd [list "clientinfo" $info] 979 } 980 append _outbuf "dataset add $tag data follows $length\n" 1029 981 append _outbuf $bytes 1030 982 set _datasets($tag) 1 … … 1033 985 lappend _obj2datasets($dataobj) $tag 1034 986 if { [info exists _obj2ovride($dataobj-raise)] } { 1035 SendCmd " volumevisible 1 $tag"987 SendCmd "dataset visible 1 $tag" 1036 988 } 1037 989 break … … 1047 999 set label [$_first hints ${axis}label] 1048 1000 if { $label != "" } { 1049 SendCmd [list axis name $axis $label]1001 SendCmd "axis name $axis $label" 1050 1002 } 1051 1003 set units [$_first hints ${axis}units] 1052 1004 if { $units != "" } { 1053 SendCmd [list axis units $axis $units]1005 SendCmd "axis units $axis $units" 1054 1006 } 1055 1007 } … … 1066 1018 [$_first fieldinfo $fname] break 1067 1019 # Only scalar fields are valid 1068 if {$ _allowMultiComponent || $components == 1} {1020 if {$components == 1} { 1069 1021 $itk_component(field) choices insert end "$fname" "$label" 1070 1022 $itk_component(fieldmenu) add radiobutton -label "$label" \ … … 1086 1038 } 1087 1039 1088 InitSettings -color \ 1089 -volumematerial \ 1090 -volumelighting -volumeopacity -volumequality -volumeoutline -volumevisible \ 1091 -cutplanesvisible \ 1092 -xcutplaneposition -ycutplaneposition -zcutplaneposition \ 1093 -xcutplanevisible -ycutplanevisible -zcutplanevisible 1040 InitSettings volume-palette volume-material volume-quality volumeVisible \ 1041 cutplaneVisible \ 1042 cutplane-xposition cutplane-yposition cutplane-zposition \ 1043 cutplane-xvisible cutplane-yvisible cutplane-zvisible 1094 1044 1095 1045 if { $_reset } { 1046 InitSettings volumeLighting 1096 1047 Zoom reset 1097 1048 set _reset 0 … … 1160 1111 switch -- $option { 1161 1112 "in" { 1162 set _view( -zoom) [expr {$_view(-zoom)*1.25}]1163 SendCmd "camera zoom $_view( -zoom)"1113 set _view(zoom) [expr {$_view(zoom)*1.25}] 1114 SendCmd "camera zoom $_view(zoom)" 1164 1115 } 1165 1116 "out" { 1166 set _view( -zoom) [expr {$_view(-zoom)*0.8}]1167 SendCmd "camera zoom $_view( -zoom)"1117 set _view(zoom) [expr {$_view(zoom)*0.8}] 1118 SendCmd "camera zoom $_view(zoom)" 1168 1119 } 1169 1120 "reset" { 1170 1121 array set _view { 1171 -qw 0.8535531172 -qx -0.3535531173 -qy 0.3535531174 -qz 0.1464471175 -xpan01176 -ypan01177 -zoom 1.01122 qw 0.853553 1123 qx -0.353553 1124 qy 0.353553 1125 qz 0.146447 1126 zoom 1.0 1127 xpan 0 1128 ypan 0 1178 1129 } 1179 1130 if { $_first != "" } { … … 1183 1134 } 1184 1135 } 1185 $_arcball quaternion [ViewToQuaternion] 1136 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1137 $_arcball quaternion $q 1186 1138 DoRotate 1187 1139 SendCmd "camera reset" … … 1191 1143 1192 1144 itcl::body Rappture::VtkVolumeViewer::PanCamera {} { 1193 set x $_view( -xpan)1194 set y $_view( -ypan)1145 set x $_view(xpan) 1146 set y $_view(ypan) 1195 1147 SendCmd "camera pan $x $y" 1196 1148 } 1149 1197 1150 1198 1151 # ---------------------------------------------------------------------- … … 1269 1222 set x [expr $x / double($w)] 1270 1223 set y [expr $y / double($h)] 1271 set _view( -xpan) [expr $_view(-xpan) + $x]1272 set _view( -ypan) [expr $_view(-ypan) + $y]1224 set _view(xpan) [expr $_view(xpan) + $x] 1225 set _view(ypan) [expr $_view(ypan) + $y] 1273 1226 PanCamera 1274 1227 return … … 1292 1245 set _click(x) $x 1293 1246 set _click(y) $y 1294 set _view( -xpan) [expr $_view(-xpan) - $dx]1295 set _view( -ypan) [expr $_view(-ypan) - $dy]1247 set _view(xpan) [expr $_view(xpan) - $dx] 1248 set _view(ypan) [expr $_view(ypan) - $dy] 1296 1249 PanCamera 1297 1250 } … … 1315 1268 itcl::body Rappture::VtkVolumeViewer::InitSettings { args } { 1316 1269 foreach spec $args { 1317 if { [info exists _settings($_first ${spec})] } {1270 if { [info exists _settings($_first-$spec)] } { 1318 1271 # Reset global setting with dataobj specific setting 1319 set _settings($spec) $_settings($_first ${spec})1272 set _settings($spec) $_settings($_first-$spec) 1320 1273 } 1321 1274 AdjustSetting $spec … … 1335 1288 } 1336 1289 switch -- $what { 1337 "-background" { 1338 set bgcolor [$itk_component(background) value] 1339 set _settings($what) $bgcolor 1340 array set fgcolors { 1341 "black" "white" 1342 "white" "black" 1343 "grey" "black" 1344 } 1345 configure -plotbackground $bgcolor \ 1346 -plotforeground $fgcolors($bgcolor) 1347 $itk_component(view) delete "legend" 1348 DrawLegend 1349 } 1350 "-volumeoutline" { 1351 set bool $_settings($what) 1352 SendCmd "outline visible 0" 1353 foreach tag [CurrentDatasets -visible] { 1354 SendCmd "outline visible $bool $tag" 1355 } 1356 } 1357 "-legendvisible" { 1358 set bool $_settings($what) 1359 } 1360 "-volumevisible" { 1361 set bool $_settings($what) 1362 foreach tag [CurrentDatasets -visible] { 1363 SendCmd "volume visible $bool $tag" 1290 "volumeVisible" { 1291 set bool $_settings(volumeVisible) 1292 foreach dataset [CurrentDatasets -visible] { 1293 SendCmd "volume visible $bool $dataset" 1364 1294 } 1365 1295 if { $bool } { … … 1371 1301 } 1372 1302 } 1373 " -volumematerial" {1374 set val $_settings( $what)1303 "volume-material" { 1304 set val $_settings(volume-material) 1375 1305 set diffuse [expr {0.01*$val}] 1376 1306 set specular [expr {0.01*$val}] 1377 1307 #set power [expr {sqrt(160*$val+1.0)}] 1378 1308 set power [expr {$val+1.0}] 1379 foreach tag[CurrentDatasets -visible] {1380 SendCmd "volume shading diffuse $diffuse $ tag"1381 SendCmd "volume shading specular $specular $power $ tag"1382 } 1383 } 1384 " -volumelighting" {1385 set bool $_settings( $what)1386 foreach tag[CurrentDatasets -visible] {1387 SendCmd "volume lighting $bool $ tag"1388 } 1389 } 1390 " -volumeopacity" {1391 set val $_settings( $what)1309 foreach dataset [CurrentDatasets -visible] { 1310 SendCmd "volume shading diffuse $diffuse $dataset" 1311 SendCmd "volume shading specular $specular $power $dataset" 1312 } 1313 } 1314 "volumeLighting" { 1315 set bool $_settings(volumeLighting) 1316 foreach dataset [CurrentDatasets -visible] { 1317 SendCmd "volume lighting $bool $dataset" 1318 } 1319 } 1320 "volume-quality" { 1321 set val $_settings(volume-quality) 1392 1322 set val [expr {0.01*$val}] 1393 foreach tag [CurrentDatasets -visible] { 1394 SendCmd "volume opacity $val $tag" 1395 } 1396 } 1397 "-volumequality" { 1398 set val $_settings($what) 1399 set val [expr {0.01*$val}] 1400 foreach tag [CurrentDatasets -visible] { 1401 SendCmd "volume quality $val $tag" 1402 } 1403 } 1404 "-axesvisible" { 1405 set bool $_settings($what) 1323 foreach dataset [CurrentDatasets -visible] { 1324 SendCmd "volume quality $val $dataset" 1325 } 1326 } 1327 "axesVisible" { 1328 set bool $_settings(axesVisible) 1406 1329 SendCmd "axis visible all $bool" 1407 1330 } 1408 " -axislabels" {1409 set bool $_settings( $what)1331 "axisLabels" { 1332 set bool $_settings(axisLabels) 1410 1333 SendCmd "axis labels all $bool" 1411 1334 } 1412 "-axisminorticks" { 1413 set bool $_settings($what) 1414 SendCmd "axis minticks all $bool" 1415 } 1416 "-xgrid" - "-ygrid" - "-zgrid" { 1417 set axis [string range $what 1 1] 1335 "axis-xgrid" - "axis-ygrid" - "axis-zgrid" { 1336 set axis [string range $what 5 5] 1418 1337 set bool $_settings($what) 1419 1338 SendCmd "axis grid $axis $bool" 1420 1339 } 1421 " -axisflymode" {1340 "axisFlyMode" { 1422 1341 set mode [$itk_component(axismode) value] 1423 1342 set mode [$itk_component(axismode) translate $mode] … … 1425 1344 SendCmd "axis flymode $mode" 1426 1345 } 1427 " -cutplanesvisible" {1346 "cutplaneEdges" { 1428 1347 set bool $_settings($what) 1429 1348 foreach dataset [CurrentDatasets -visible] { 1430 SendCmd " $_cutplaneCmd visible$bool $dataset"1431 } 1432 } 1433 " -cutplanelighting" {1349 SendCmd "cutplane edges $bool $dataset" 1350 } 1351 } 1352 "cutplaneVisible" { 1434 1353 set bool $_settings($what) 1435 1354 foreach dataset [CurrentDatasets -visible] { 1436 if {$_cutplaneCmd != "imgcutplane"} { 1437 SendCmd "$_cutplaneCmd lighting $bool $dataset" 1438 } else { 1439 if {$bool} { 1440 set ambient 0.0 1441 set diffuse 1.0 1442 } else { 1443 set ambient 1.0 1444 set diffuse 0.0 1445 } 1446 SendCmd "imgcutplane material $ambient $diffuse $dataset" 1447 } 1448 } 1449 } 1450 "-cutplaneopacity" { 1355 SendCmd "cutplane visible $bool $dataset" 1356 } 1357 } 1358 "cutplaneWireframe" { 1359 set bool $_settings($what) 1360 foreach dataset [CurrentDatasets -visible] { 1361 SendCmd "cutplane wireframe $bool $dataset" 1362 } 1363 } 1364 "cutplaneLighting" { 1365 set bool $_settings($what) 1366 foreach dataset [CurrentDatasets -visible] { 1367 SendCmd "cutplane lighting $bool $dataset" 1368 } 1369 } 1370 "cutplane-opacity" { 1451 1371 set val $_settings($what) 1452 1372 set sval [expr { 0.01 * double($val) }] 1453 1373 foreach dataset [CurrentDatasets -visible] { 1454 SendCmd " $_cutplaneCmdopacity $sval $dataset"1455 } 1456 } 1457 " -xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {1458 set axis [string range $what 1 1]1374 SendCmd "cutplane opacity $sval $dataset" 1375 } 1376 } 1377 "cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" { 1378 set axis [string range $what 9 9] 1459 1379 set bool $_settings($what) 1460 1380 if { $bool } { … … 1466 1386 } 1467 1387 foreach dataset [CurrentDatasets -visible] { 1468 SendCmd " $_cutplaneCmdaxis $axis $bool $dataset"1469 } 1470 } 1471 " -xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {1472 set axis [string range $what 1 1]1388 SendCmd "cutplane axis $axis $bool $dataset" 1389 } 1390 } 1391 "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" { 1392 set axis [string range $what 9 9] 1473 1393 set pos [expr $_settings($what) * 0.01] 1474 1394 foreach dataset [CurrentDatasets -visible] { 1475 SendCmd " $_cutplaneCmdslice ${axis} ${pos} $dataset"1395 SendCmd "cutplane slice ${axis} ${pos} $dataset" 1476 1396 } 1477 1397 set _cutplanePending 0 1478 1398 } 1479 " -color" {1480 set color [$itk_component(colormap) value]1481 set _settings( $what) $color1399 "volume-palette" { 1400 set palette [$itk_component(palette) value] 1401 set _settings(volume-palette) $palette 1482 1402 foreach dataset [CurrentDatasets -visible $_first] { 1483 1403 foreach {dataobj comp} [split $dataset -] break 1484 ChangeColormap $dataobj $comp $ color1404 ChangeColormap $dataobj $comp $palette 1485 1405 } 1486 1406 set _legendPending 1 1487 1407 } 1488 "-field" { 1408 "volume-palette" { 1409 set palette [$itk_component(palette) value] 1410 set _settings(volume-palette) $palette 1411 foreach dataset [CurrentDatasets -visible $_first] { 1412 foreach {dataobj comp} [split $dataset -] break 1413 ChangeColormap $dataobj $comp $palette 1414 } 1415 set _legendPending 1 1416 } 1417 "field" { 1489 1418 set label [$itk_component(field) value] 1490 1419 set fname [$itk_component(field) translate $label] 1491 set _settings( $what) $fname1420 set _settings(field) $fname 1492 1421 if { [info exists _fields($fname)] } { 1493 1422 foreach { label units components } $_fields($fname) break 1494 if { !$_allowMultiComponent &&$components > 1 } {1423 if { $components > 1 } { 1495 1424 puts stderr "Can't use a vector field in a volume" 1496 1425 return 1497 1426 } else { 1498 if { $components > 1 } { 1499 set _colorMode vmag 1500 } else { 1501 set _colorMode scalar 1502 } 1427 set _colorMode scalar 1503 1428 } 1504 1429 set _curFldName $fname … … 1509 1434 } 1510 1435 foreach dataset [CurrentDatasets -visible $_first] { 1511 #SendCmd " $_cutplaneCmd colormode $_colorMode $_curFldName$dataset"1512 SendCmd " dataset scalar $_curFldName$dataset"1436 #SendCmd "volume colormode $_colorMode ${fname} $dataset" 1437 SendCmd "cutplane colormode $_colorMode ${fname} $dataset" 1513 1438 } 1514 1439 SendCmd "camera reset" … … 1542 1467 if { [info exists _dataset2style($dataset)] } { 1543 1468 SendCmdNoWait \ 1544 "legend2 $_dataset2style($dataset) $w $h" 1545 #"legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0" 1469 "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0" 1546 1470 break; 1547 1471 } … … 1570 1494 -color BCGYR 1571 1495 -levels 6 1496 -opacity 1.0 1572 1497 } 1573 1498 set tag $dataobj-$comp … … 1586 1511 array set style $_style($tag) 1587 1512 1588 set name "$style(-color):$style(-levels) "1513 set name "$style(-color):$style(-levels):$style(-opacity)" 1589 1514 if { ![info exists _colormaps($name)] } { 1590 1515 BuildColormap $name [array get style] … … 1594 1519 $_dataset2style($tag) != $name } { 1595 1520 SendCmd "volume colormap $name $tag" 1596 SendCmd " $_cutplaneCmdcolormap $name-opaque $tag"1521 SendCmd "cutplane colormap $name-opaque $tag" 1597 1522 set _dataset2style($tag) $name 1598 1523 } … … 1608 1533 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1609 1534 } 1610 set max 1.0 1535 if { ![info exists _settings(volume-opacity)] } { 1536 set _settings(volume-opacity) $style(-opacity) 1537 } 1538 set max $_settings(volume-opacity) 1611 1539 1612 1540 set opaqueWmap "0.0 1.0 1.0 1.0" … … 1623 1551 itcl::configbody Rappture::VtkVolumeViewer::plotbackground { 1624 1552 if { [isconnected] } { 1625 set color $itk_option(-plotbackground) 1626 set rgb [Color2RGB $color] 1627 SendCmd "screen bgcolor $rgb" 1628 $itk_component(legend) configure -background $color 1553 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break 1554 SendCmd "screen bgcolor $r $g $b" 1629 1555 } 1630 1556 } … … 1635 1561 itcl::configbody Rappture::VtkVolumeViewer::plotforeground { 1636 1562 if { [isconnected] } { 1637 set color $itk_option(-plotforeground) 1638 set rgb [Color2RGB $color] 1639 SendCmd "axis color all $rgb" 1640 SendCmd "outline color $rgb" 1641 SendCmd "$_cutplaneCmd color $rgb" 1642 $itk_component(legend) itemconfigure labels -fill $color 1643 $itk_component(legend) itemconfigure limits -fill $color 1644 } 1645 } 1646 1647 itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} { 1563 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1564 #fix this! 1565 #SendCmd "color background $r $g $b" 1566 } 1567 } 1568 1569 itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} { 1570 1648 1571 set fg [option get $itk_component(hull) font Font] 1649 1572 #set bfg [option get $itk_component(hull) boldFont Font] 1650 1651 set inner [$itk_component(main) insert end \1652 -title "View Settings" \1653 -icon [Rappture::icon wrench]]1654 $inner configure -borderwidth 41655 1656 checkbutton $inner.axes \1657 -text "Axes" \1658 -variable [itcl::scope _settings(-axesvisible)] \1659 -command [itcl::code $this AdjustSetting -axesvisible] \1660 -font "Arial 9"1661 1662 checkbutton $inner.outline \1663 -text "Outline" \1664 -variable [itcl::scope _settings(-volumeoutline)] \1665 -command [itcl::code $this AdjustSetting -volumeoutline] \1666 -font "Arial 9"1667 1668 checkbutton $inner.legend \1669 -text "Legend" \1670 -variable [itcl::scope _settings(-legendvisible)] \1671 -command [itcl::code $this AdjustSetting -legendvisible] \1672 -font "Arial 9"1673 1674 checkbutton $inner.volume \1675 -text "Volume" \1676 -variable [itcl::scope _settings(-volumevisible)] \1677 -command [itcl::code $this AdjustSetting -volumevisible] \1678 -font "Arial 9"1679 1680 label $inner.background_l -text "Background" -font "Arial 9"1681 itk_component add background {1682 Rappture::Combobox $inner.background -width 10 -editable no1683 }1684 $inner.background choices insert end \1685 "black" "black" \1686 "white" "white" \1687 "grey" "grey"1688 1689 $itk_component(background) value $_settings(-background)1690 bind $inner.background <<Value>> \1691 [itcl::code $this AdjustSetting -background]1692 1693 blt::table $inner \1694 0,0 $inner.axes -cspan 2 -anchor w \1695 1,0 $inner.outline -cspan 2 -anchor w \1696 2,0 $inner.volume -cspan 2 -anchor w \1697 3,0 $inner.legend -cspan 2 -anchor w \1698 4,0 $inner.background_l -anchor e -pady 2 \1699 4,1 $inner.background -fill x \1700 1701 blt::table configure $inner r* -resize none1702 blt::table configure $inner r5 -resize expand1703 }1704 1705 itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} {1706 set font [option get $itk_component(hull) font Font]1707 #set bfont [option get $itk_component(hull) boldFont Font]1708 1573 1709 1574 set inner [$itk_component(main) insert end \ … … 1712 1577 $inner configure -borderwidth 4 1713 1578 1714 checkbutton $inner.v isibility\1715 -text " Visible" \1716 - font $font\1717 - variable [itcl::scope _settings(-volumevisible)] \1718 - command [itcl::code $this AdjustSetting -volumevisible]1579 checkbutton $inner.volume \ 1580 -text "Show Volume" \ 1581 -variable [itcl::scope _settings(volumeVisible)] \ 1582 -command [itcl::code $this AdjustSetting volumeVisible] \ 1583 -font "Arial 9" 1719 1584 1720 1585 checkbutton $inner.lighting \ 1721 1586 -text "Enable Lighting" \ 1722 - font $font\1723 - variable [itcl::scope _settings(-volumelighting)] \1724 - command [itcl::code $this AdjustSetting -volumelighting]1725 1726 label $inner.dim_l -text "Dim" -font $font1587 -variable [itcl::scope _settings(volumeLighting)] \ 1588 -command [itcl::code $this AdjustSetting volumeLighting] \ 1589 -font "Arial 9" 1590 1591 label $inner.dim_l -text "Dim" -font "Arial 9" 1727 1592 ::scale $inner.material -from 0 -to 100 -orient horizontal \ 1728 -variable [itcl::scope _settings(-volumematerial)] \ 1729 -showvalue off -command [itcl::code $this AdjustSetting -volumematerial] 1730 label $inner.bright_l -text "Bright" -font $font 1731 1732 label $inner.opacity_l -text "Opacity" -font $font 1593 -variable [itcl::scope _settings(volume-material)] \ 1594 -width 10 \ 1595 -showvalue off -command [itcl::code $this AdjustSetting volume-material] 1596 label $inner.bright_l -text "Bright" -font "Arial 9" 1597 1598 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1733 1599 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1734 -variable [itcl::scope _settings(-volumeopacity)] \ 1600 -variable [itcl::scope _settings(volume-opacity)] \ 1601 -width 10 \ 1735 1602 -showvalue off \ 1736 -command [itcl::code $this AdjustSetting -volumeopacity]1737 1738 label $inner.quality_l -text "Quality" -font $font1603 -command [itcl::code $this AdjustSetting volume-opacity] 1604 1605 label $inner.quality_l -text "Quality" -font "Arial 9" 1739 1606 ::scale $inner.quality -from 0 -to 100 -orient horizontal \ 1740 -variable [itcl::scope _settings(-volumequality)] \ 1741 -showvalue off \ 1742 -command [itcl::code $this AdjustSetting -volumequality] 1743 1744 label $inner.field_l -text "Field" -font $font 1607 -variable [itcl::scope _settings(volume-quality)] \ 1608 -width 10 \ 1609 -showvalue off -command [itcl::code $this AdjustSetting volume-quality] 1610 1611 itk_component add field_l { 1612 label $inner.field_l -text "Field" -font "Arial 9" 1613 } { 1614 ignore -font 1615 } 1745 1616 itk_component add field { 1746 Rappture::Combobox $inner.field - editable no1617 Rappture::Combobox $inner.field -width 10 -editable no 1747 1618 } 1748 1619 bind $inner.field <<Value>> \ 1749 [itcl::code $this AdjustSetting -field] 1750 1751 label $inner.colormap_l -text "Colormap" -font $font 1752 itk_component add colormap { 1753 Rappture::Combobox $inner.colormap -editable no 1754 } 1755 $inner.colormap choices insert end [GetColormapList] 1756 bind $inner.colormap <<Value>> \ 1757 [itcl::code $this AdjustSetting -color] 1758 $itk_component(colormap) value $_settings(-color) 1620 [itcl::code $this AdjustSetting field] 1621 1622 label $inner.palette_l -text "Palette" -font "Arial 9" 1623 itk_component add palette { 1624 Rappture::Combobox $inner.palette -width 10 -editable no 1625 } 1626 $inner.palette choices insert end \ 1627 "BCGYR" "BCGYR" \ 1628 "BGYOR" "BGYOR" \ 1629 "blue" "blue" \ 1630 "blue-to-brown" "blue-to-brown" \ 1631 "blue-to-orange" "blue-to-orange" \ 1632 "blue-to-grey" "blue-to-grey" \ 1633 "green-to-magenta" "green-to-magenta" \ 1634 "greyscale" "greyscale" \ 1635 "nanohub" "nanohub" \ 1636 "rainbow" "rainbow" \ 1637 "spectral" "spectral" \ 1638 "ROYGB" "ROYGB" \ 1639 "RYGCB" "RYGCB" \ 1640 "brown-to-blue" "brown-to-blue" \ 1641 "grey-to-blue" "grey-to-blue" \ 1642 "orange-to-blue" "orange-to-blue" 1643 1644 $itk_component(palette) value "BCGYR" 1645 bind $inner.palette <<Value>> \ 1646 [itcl::code $this AdjustSetting volume-palette] 1759 1647 1760 1648 blt::table $inner \ 1761 1649 0,0 $inner.field_l -anchor w -pady 2 \ 1762 0,1 $inner.field - fill x -pady 2 -cspan 3\1763 1,0 $inner.v isibility-anchor w -pady 2 -cspan 4 \1650 0,1 $inner.field -anchor w -pady 2 -cspan 2 \ 1651 1,0 $inner.volume -anchor w -pady 2 -cspan 4 \ 1764 1652 2,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 1765 1653 3,0 $inner.dim_l -anchor e -pady 2 \ 1766 3,1 $inner.material -fill x -pady 2 -cspan 2 \ 1767 3,3 $inner.bright_l -anchor w -pady 2 \ 1768 4,0 $inner.opacity_l -anchor w -pady 2 -cspan 4 \ 1769 5,0 $inner.opacity -fill x -pady 2 -cspan 4 \ 1770 6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \ 1771 7,0 $inner.quality -fill x -pady 2 -cspan 4 \ 1772 8,0 $inner.colormap_l -anchor w -pady 2 \ 1773 8,1 $inner.colormap -fill x -pady 2 -cspan 3 \ 1774 1775 blt::table configure $inner r* c0 c1 c3 -resize none 1776 blt::table configure $inner r9 c2 -resize expand 1654 3,1 $inner.material -fill x -pady 2 \ 1655 3,2 $inner.bright_l -anchor w -pady 2 \ 1656 4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \ 1657 5,0 $inner.quality -fill x -pady 2 -cspan 2 \ 1658 7,0 $inner.palette_l -anchor w -pady 2 \ 1659 7,1 $inner.palette -anchor w -pady 2 -cspan 2 \ 1660 1661 blt::table configure $inner r* c* -resize none 1662 blt::table configure $inner r8 -resize expand 1777 1663 } 1778 1664 1779 1665 itcl::body Rappture::VtkVolumeViewer::BuildAxisTab {} { 1666 1780 1667 set fg [option get $itk_component(hull) font Font] 1781 1668 #set bfg [option get $itk_component(hull) boldFont Font] … … 1783 1670 set inner [$itk_component(main) insert end \ 1784 1671 -title "Axis Settings" \ 1785 -icon [Rappture::icon axis 2]]1672 -icon [Rappture::icon axis1]] 1786 1673 $inner configure -borderwidth 4 1787 1674 1788 1675 checkbutton $inner.visible \ 1789 -text " Axes" \1790 -variable [itcl::scope _settings( -axesvisible)] \1791 -command [itcl::code $this AdjustSetting -axesvisible] \1676 -text "Show Axes" \ 1677 -variable [itcl::scope _settings(axesVisible)] \ 1678 -command [itcl::code $this AdjustSetting axesVisible] \ 1792 1679 -font "Arial 9" 1793 1680 1794 1681 checkbutton $inner.labels \ 1795 -text " Axis Labels" \1796 -variable [itcl::scope _settings( -axislabels)] \1797 -command [itcl::code $this AdjustSetting -axislabels] \1682 -text "Show Axis Labels" \ 1683 -variable [itcl::scope _settings(axisLabels)] \ 1684 -command [itcl::code $this AdjustSetting axisLabels] \ 1798 1685 -font "Arial 9" 1799 label $inner.grid_l -text "Grid" -font "Arial 9" 1800 checkbutton $inner. xgrid\1801 -text " X" \1802 -variable [itcl::scope _settings( -xgrid)] \1803 -command [itcl::code $this AdjustSetting -xgrid] \1686 1687 checkbutton $inner.gridx \ 1688 -text "Show X Grid" \ 1689 -variable [itcl::scope _settings(axis-xgrid)] \ 1690 -command [itcl::code $this AdjustSetting axis-xgrid] \ 1804 1691 -font "Arial 9" 1805 checkbutton $inner. ygrid\1806 -text " Y" \1807 -variable [itcl::scope _settings( -ygrid)] \1808 -command [itcl::code $this AdjustSetting -ygrid] \1692 checkbutton $inner.gridy \ 1693 -text "Show Y Grid" \ 1694 -variable [itcl::scope _settings(axis-ygrid)] \ 1695 -command [itcl::code $this AdjustSetting axis-ygrid] \ 1809 1696 -font "Arial 9" 1810 checkbutton $inner.zgrid \ 1811 -text "Z" \ 1812 -variable [itcl::scope _settings(-zgrid)] \ 1813 -command [itcl::code $this AdjustSetting -zgrid] \ 1814 -font "Arial 9" 1815 checkbutton $inner.minorticks \ 1816 -text "Minor Ticks" \ 1817 -variable [itcl::scope _settings(-axisminorticks)] \ 1818 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1697 checkbutton $inner.gridz \ 1698 -text "Show Z Grid" \ 1699 -variable [itcl::scope _settings(axis-zgrid)] \ 1700 -command [itcl::code $this AdjustSetting axis-zgrid] \ 1819 1701 -font "Arial 9" 1820 1702 … … 1827 1709 "static_triad" "static" \ 1828 1710 "closest_triad" "closest" \ 1829 "furthest_triad" "f arthest" \1711 "furthest_triad" "furthest" \ 1830 1712 "outer_edges" "outer" 1831 $itk_component(axismode) value $_settings(-axisflymode)1832 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]1713 $itk_component(axismode) value "static" 1714 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode] 1833 1715 1834 1716 blt::table $inner \ 1835 0,0 $inner.visible -anchor w -cspan 4 \ 1836 1,0 $inner.labels -anchor w -cspan 4 \ 1837 2,0 $inner.minorticks -anchor w -cspan 4 \ 1838 4,0 $inner.grid_l -anchor w \ 1839 4,1 $inner.xgrid -anchor w \ 1840 4,2 $inner.ygrid -anchor w \ 1841 4,3 $inner.zgrid -anchor w \ 1842 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1843 5,1 $inner.mode -fill x -cspan 3 1717 0,0 $inner.visible -anchor w -cspan 2 \ 1718 1,0 $inner.labels -anchor w -cspan 2 \ 1719 2,0 $inner.gridx -anchor w -cspan 2 \ 1720 3,0 $inner.gridy -anchor w -cspan 2 \ 1721 4,0 $inner.gridz -anchor w -cspan 2 \ 1722 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1723 6,0 $inner.mode -fill x -cspan 2 1844 1724 1845 1725 blt::table configure $inner r* c* -resize none 1846 blt::table configure $inner r7 c 6-resize expand1847 blt::table configure $inner r3 -height 0.125i 1848 } 1726 blt::table configure $inner r7 c1 -resize expand 1727 } 1728 1849 1729 1850 1730 itcl::body Rappture::VtkVolumeViewer::BuildCameraTab {} { … … 1854 1734 $inner configure -borderwidth 4 1855 1735 1856 label $inner.view_l -text "view" -font "Arial 9"1857 set f [frame $inner.view]1858 foreach side { front back left right top bottom } {1859 button $f.$side -image [Rappture::icon view$side] \1860 -command [itcl::code $this SetOrientation $side]1861 Rappture::Tooltip::for $f.$side "Change the view to $side"1862 pack $f.$side -side left1863 }1864 blt::table $inner \1865 0,0 $inner.view_l -anchor e -pady 2 \1866 0,1 $inner.view -anchor w -pady 21867 blt::table configure $inner r0 -resize none1868 1869 set row 11870 1736 set labels { qx qy qz qw xpan ypan zoom } 1737 set row 0 1871 1738 foreach tag $labels { 1872 label $inner.${tag} -label -text $tag -font "Arial 9"1739 label $inner.${tag}label -text $tag -font "Arial 9" 1873 1740 entry $inner.${tag} -font "Arial 9" -bg white \ 1874 -textvariable [itcl::scope _view(-$tag)] 1875 bind $inner.${tag} <Return> \ 1876 [itcl::code $this camera set -${tag}] 1877 bind $inner.${tag} <KP_Enter> \ 1878 [itcl::code $this camera set -${tag}] 1741 -textvariable [itcl::scope _view($tag)] 1742 bind $inner.${tag} <KeyPress-Return> \ 1743 [itcl::code $this camera set ${tag}] 1879 1744 blt::table $inner \ 1880 $row,0 $inner.${tag} -label -anchor e -pady 2 \1745 $row,0 $inner.${tag}label -anchor e -pady 2 \ 1881 1746 $row,1 $inner.${tag} -anchor w -pady 2 1882 1747 blt::table configure $inner r$row -resize none … … 1885 1750 checkbutton $inner.ortho \ 1886 1751 -text "Orthographic Projection" \ 1887 -variable [itcl::scope _view( -ortho)] \1888 -command [itcl::code $this camera set -ortho] \1752 -variable [itcl::scope _view(ortho)] \ 1753 -command [itcl::code $this camera set ortho] \ 1889 1754 -font "Arial 9" 1890 1755 blt::table $inner \ … … 1899 1764 1900 1765 itcl::body Rappture::VtkVolumeViewer::BuildCutplaneTab {} { 1901 set font [option get $itk_component(hull) font Font] 1766 1767 set fg [option get $itk_component(hull) font Font] 1902 1768 1903 1769 set inner [$itk_component(main) insert end \ … … 1909 1775 checkbutton $inner.visible \ 1910 1776 -text "Show Cutplanes" \ 1911 -variable [itcl::scope _settings(-cutplanesvisible)] \ 1912 -command [itcl::code $this AdjustSetting -cutplanesvisible] \ 1777 -variable [itcl::scope _settings(cutplaneVisible)] \ 1778 -command [itcl::code $this AdjustSetting cutplaneVisible] \ 1779 -font "Arial 9" 1780 1781 checkbutton $inner.wireframe \ 1782 -text "Show Wireframe" \ 1783 -variable [itcl::scope _settings(cutplaneWireframe)] \ 1784 -command [itcl::code $this AdjustSetting cutplaneWireframe] \ 1913 1785 -font "Arial 9" 1914 1786 1915 1787 checkbutton $inner.lighting \ 1916 1788 -text "Enable Lighting" \ 1917 -variable [itcl::scope _settings(-cutplanelighting)] \ 1918 -command [itcl::code $this AdjustSetting -cutplanelighting] \ 1789 -variable [itcl::scope _settings(cutplaneLighting)] \ 1790 -command [itcl::code $this AdjustSetting cutplaneLighting] \ 1791 -font "Arial 9" 1792 1793 checkbutton $inner.edges \ 1794 -text "Show Edges" \ 1795 -variable [itcl::scope _settings(cutplaneEdges)] \ 1796 -command [itcl::code $this AdjustSetting cutplaneEdges] \ 1919 1797 -font "Arial 9" 1920 1798 1921 1799 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1922 1800 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1923 -variable [itcl::scope _settings( -cutplaneopacity)] \1801 -variable [itcl::scope _settings(cutplane-opacity)] \ 1924 1802 -width 10 \ 1925 1803 -showvalue off \ 1926 -command [itcl::code $this AdjustSetting -cutplaneopacity]1927 $inner.opacity set $_settings( -cutplaneopacity)1804 -command [itcl::code $this AdjustSetting cutplane-opacity] 1805 $inner.opacity set $_settings(cutplane-opacity) 1928 1806 1929 1807 # X-value slicer... … … 1932 1810 -onimage [Rappture::icon x-cutplane] \ 1933 1811 -offimage [Rappture::icon x-cutplane] \ 1934 -command [itcl::code $this AdjustSetting -xcutplanevisible] \1935 -variable [itcl::scope _settings( -xcutplanevisible)]1812 -command [itcl::code $this AdjustSetting cutplane-xvisible] \ 1813 -variable [itcl::scope _settings(cutplane-xvisible)] 1936 1814 } 1937 1815 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 1944 1822 -borderwidth 1 -highlightthickness 0 \ 1945 1823 -command [itcl::code $this EventuallySetCutplane x] \ 1946 -variable [itcl::scope _settings( -xcutplaneposition)]1824 -variable [itcl::scope _settings(cutplane-xposition)] 1947 1825 } { 1948 1826 usual … … 1960 1838 -onimage [Rappture::icon y-cutplane] \ 1961 1839 -offimage [Rappture::icon y-cutplane] \ 1962 -command [itcl::code $this AdjustSetting -ycutplanevisible] \1963 -variable [itcl::scope _settings( -ycutplanevisible)]1840 -command [itcl::code $this AdjustSetting cutplane-yvisible] \ 1841 -variable [itcl::scope _settings(cutplane-yvisible)] 1964 1842 } 1965 1843 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 1972 1850 -borderwidth 1 -highlightthickness 0 \ 1973 1851 -command [itcl::code $this EventuallySetCutplane y] \ 1974 -variable [itcl::scope _settings( -ycutplaneposition)]1852 -variable [itcl::scope _settings(cutplane-yposition)] 1975 1853 } { 1976 1854 usual … … 1988 1866 -onimage [Rappture::icon z-cutplane] \ 1989 1867 -offimage [Rappture::icon z-cutplane] \ 1990 -command [itcl::code $this AdjustSetting -zcutplanevisible] \1991 -variable [itcl::scope _settings( -zcutplanevisible)]1868 -command [itcl::code $this AdjustSetting cutplane-zvisible] \ 1869 -variable [itcl::scope _settings(cutplane-zvisible)] 1992 1870 } 1993 1871 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 2000 1878 -borderwidth 1 -highlightthickness 0 \ 2001 1879 -command [itcl::code $this EventuallySetCutplane z] \ 2002 -variable [itcl::scope _settings( -zcutplaneposition)]1880 -variable [itcl::scope _settings(cutplane-zposition)] 2003 1881 } { 2004 1882 usual … … 2013 1891 0,0 $inner.visible -anchor w -pady 2 -cspan 4 \ 2014 1892 1,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 2015 2,0 $inner.opacity_l -anchor w -pady 2 -cspan 3 \ 2016 3,0 $inner.opacity -fill x -pady 2 -cspan 3 \ 2017 4,0 $itk_component(xCutButton) -anchor e -padx 2 -pady 2 \ 2018 5,0 $itk_component(xCutScale) -fill y \ 2019 4,1 $itk_component(yCutButton) -anchor e -padx 2 -pady 2 \ 2020 5,1 $itk_component(yCutScale) -fill y \ 2021 4,2 $itk_component(zCutButton) -anchor e -padx 2 -pady 2 \ 2022 5,2 $itk_component(zCutScale) -fill y 1893 2,0 $inner.wireframe -anchor w -pady 2 -cspan 4 \ 1894 3,0 $inner.edges -anchor w -pady 2 -cspan 4 \ 1895 4,0 $inner.opacity_l -anchor w -pady 2 -cspan 3 \ 1896 5,0 $inner.opacity -fill x -pady 2 -cspan 3 \ 1897 6,0 $itk_component(xCutButton) -anchor e -padx 2 -pady 2 \ 1898 7,0 $itk_component(xCutScale) -fill y \ 1899 6,1 $itk_component(yCutButton) -anchor e -padx 2 -pady 2 \ 1900 7,1 $itk_component(yCutScale) -fill y \ 1901 6,2 $itk_component(zCutButton) -anchor e -padx 2 -pady 2 \ 1902 7,2 $itk_component(zCutScale) -fill y \ 2023 1903 2024 1904 blt::table configure $inner r* c* -resize none 2025 blt::table configure $inner r 5c3 -resize expand1905 blt::table configure $inner r7 c3 -resize expand 2026 1906 } 2027 1907 … … 2042 1922 } 2043 1923 switch -- $who { 2044 " -ortho" {2045 if {$_view( -ortho)} {1924 "ortho" { 1925 if {$_view(ortho)} { 2046 1926 SendCmd "camera mode ortho" 2047 1927 } else { … … 2049 1929 } 2050 1930 } 2051 " -xpan" - "-ypan" {1931 "xpan" - "ypan" { 2052 1932 PanCamera 2053 1933 } 2054 " -qx" - "-qy" - "-qz" - "-qw" {2055 set q [ ViewToQuaternion]1934 "qx" - "qy" - "qz" - "qw" { 1935 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2056 1936 $_arcball quaternion $q 2057 1937 EventuallyRotate $q 2058 1938 } 2059 " -zoom" {2060 SendCmd "camera zoom $_view( -zoom)"1939 "zoom" { 1940 SendCmd "camera zoom $_view(zoom)" 2061 1941 } 2062 1942 } … … 2128 2008 } 2129 2009 2130 itcl::body Rappture::VtkVolumeViewer::SetObjectStyle { dataobj c name} {2010 itcl::body Rappture::VtkVolumeViewer::SetObjectStyle { dataobj comp } { 2131 2011 # Parse style string. 2132 set tag $dataobj-$cname 2133 array set styles { 2134 -lighting 1 2135 -opacity 0.5 2136 -outline 0 2137 -visible 1 2138 } 2139 array set styles [$dataobj style $cname] 2140 set _settings(-volumelighting) $styles(-lighting) 2141 set _settings(-volumeopacity) [expr $styles(-opacity) * 100.0] 2142 set _settings(-volumeoutline) $styles(-outline) 2143 set _settings(-volumevisible) $styles(-visible) 2144 2145 SendCmd "outline add $tag" 2146 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2147 SendCmd "outline visible $styles(-outline) $tag" 2148 2149 SendCmd "$_cutplaneCmd add $tag" 2150 SendCmd "$_cutplaneCmd color [Color2RGB $itk_option(-plotforeground)] $tag" 2151 SendCmd "$_cutplaneCmd visible 0 $tag" 2152 2012 set tag $dataobj-$comp 2013 set style [$dataobj style $comp] 2014 array set settings { 2015 -color \#808080 2016 -edges 0 2017 -edgecolor black 2018 -linewidth 1.0 2019 -opacity 0.4 2020 -wireframe 0 2021 -lighting 1 2022 -seeds 1 2023 -seedcolor white 2024 -visible 1 2025 } 2026 if { $dataobj != $_first } { 2027 set settings(-opacity) 1 2028 } 2029 array set settings $style 2153 2030 SendCmd "volume add $tag" 2154 SendCmd "volume lighting $styles(-lighting) $tag" 2155 SendCmd "volume opacity $styles(-opacity) $tag" 2156 SendCmd "volume visible $styles(-visible) $tag" 2157 SetColormap $dataobj $cname 2031 SendCmd "cutplane add $tag" 2032 SendCmd "cutplane visible 0 $tag" 2033 2034 SendCmd "volume lighting $settings(-lighting) $tag" 2035 set _settings(volumeLighting) $settings(-lighting) 2036 SetColormap $dataobj $comp 2158 2037 } 2159 2038 … … 2174 2053 itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title vmin vmax size } { 2175 2054 set _legendPending 0 2176 if { [isconnected] } { 2055 #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size" 2056 if { [IsConnected] } { 2177 2057 set bytes [ReceiveBytes $size] 2178 2058 if { ![info exists _image(legend)] } { … … 2209 2089 set title $fname 2210 2090 } 2211 if { $_settings( -legendvisible) } {2091 if { $_settings(legendVisible) } { 2212 2092 set x [expr $w - 2] 2213 2093 if { [$c find withtag "legend"] == "" } { … … 2346 2226 } 2347 2227 set newpos [expr {0.01*$newval}] 2348 SendCmd " $_cutplaneCmdslice $axis $newpos"2228 SendCmd "cutplane slice $axis $newpos" 2349 2229 } 2350 2230 "tooltip" { … … 2358 2238 } 2359 2239 } 2240 2360 2241 2361 2242 # ---------------------------------------------------------------------- … … 2384 2265 } 2385 2266 deactivate { 2386 $c itemconfigure title -fill $itk_option(-plotforeground)2267 $c itemconfigure title -fill white 2387 2268 } 2388 2269 invoke { 2389 $itk_component(field) value $_curFldLabel2390 AdjustSetting -field2270 $itk_component(field) value _curFldLabel 2271 AdjustSetting field 2391 2272 } 2392 2273 default { … … 2396 2277 } 2397 2278 2398 itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } {2399 array set positions {2400 front "1 0 0 0"2401 back "0 0 1 0"2402 left "0.707107 0 -0.707107 0"2403 right "0.707107 0 0.707107 0"2404 top "0.707107 -0.707107 0 0"2405 bottom "0.707107 0.707107 0 0"2406 }2407 foreach name { -qw -qx -qy -qz } value $positions($side) {2408 set _view($name) $value2409 }2410 set q [ViewToQuaternion]2411 $_arcball quaternion $q2412 SendCmd "camera orient $q"2413 SendCmd "camera reset"2414 set _view(-xpan) 02415 set _view(-ypan) 02416 set _view(-zoom) 1.02417 }2418 2419 #2420 # GetDatasetsWithComponents --2421 #2422 # Returns a list of all the datasets (known by the combination of2423 # their data object and component name) that match the given2424 # component name. For example, this is used where we want to change2425 # the settings of volumes that have the current component.2426 #2427 itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } {2428 if { ![info exists _volcomponents($cname)] } {2429 return ""2430 }2431 return $_volcomponents($cname)2432 }
Note: See TracChangeset
for help on using the changeset viewer.