Changeset 3362 for trunk/gui/scripts
- Timestamp:
- Feb 26, 2013, 1:34:35 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:mergeinfo
set to
/branches/nanovis2 merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/gui/scripts/flowvisviewer.tcl
r3330 r3362 125 125 private method arrows { tag name } 126 126 127 private variable _arcball "" 128 private variable _useArcball 1 127 129 private variable _outbuf ;# buffer for outgoing commands 128 130 … … 220 222 $_parser alias legend [itcl::code $this ReceiveLegend] 221 223 $_parser alias data [itcl::code $this ReceiveData] 224 $_parser alias viserror [itcl::code $this ReceiveError] 222 225 223 226 # Initialize the view to some default parameters. 224 227 array set _view { 228 qw 0.853553 229 qx -0.353553 230 qy 0.353553 231 qz 0.146447 225 232 theta 45 226 233 phi 45 … … 230 237 pan-y 0 231 238 } 239 set _arcball [blt::arcball create 100 100] 240 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 241 $_arcball quaternion $q 242 232 243 set _limits(vmin) 0.0 233 244 set _limits(vmax) 1.0 234 245 235 246 array set _settings [subst { 247 $this-qw $_view(qw) 248 $this-qx $_view(qx) 249 $this-qy $_view(qy) 250 $this-qz $_view(qz) 251 $this-theta $_view(theta) 252 $this-phi $_view(phi) 253 $this-psi $_view(psi) 254 $this-zoom $_view(zoom) 255 $this-pan-x $_view(pan-x) 256 $this-pan-y $_view(pan-y) 236 257 $this-arrows 0 237 258 $this-currenttime 0 238 259 $this-duration 1:00 239 260 $this-loop 0 240 $this-pan-x $_view(pan-x)241 $this-pan-y $_view(pan-y)242 $this-phi $_view(phi)243 261 $this-play 0 244 $this-psi $_view(psi)245 262 $this-speed 500 246 263 $this-step 0 247 264 $this-streams 0 248 $this-theta $_view(theta)249 265 $this-volume 1 250 266 $this-xcutplane 0 … … 254 270 $this-zcutplane 0 255 271 $this-zcutposition 0 256 $this-zoom $_view(zoom)257 272 }] 258 273 … … 554 569 image delete $_image(legend) 555 570 image delete $_image(download) 571 catch { blt::arcball destroy $_arcball } 556 572 array unset _settings $this-* 557 573 } … … 1007 1023 } 1008 1024 1009 # Insure that the global opacity and thickness settings (in the slider1025 # Ensure that the global opacity and thickness settings (in the slider 1010 1026 # settings widgets) are used for the active transfer-function. Update the 1011 1027 # values in the _settings varible. … … 1181 1197 set w [winfo width $itk_component(3dview)] 1182 1198 set h [winfo height $itk_component(3dview)] 1199 $_arcball resize $w $h 1183 1200 EventuallyResize $w $h 1184 1201 … … 1229 1246 array set _view $location 1230 1247 } 1231 } 1248 1249 if 1 { 1250 # Tell the server the name of the tool, the version, and 1251 # dataset that we are rendering. Have to do it here because 1252 # we don't know what data objects are using the renderer until 1253 # be get here. 1254 global env 1255 1256 lappend out "hub" [exec hostname] 1257 lappend out "viewer" "flowvisviewer" 1258 if { [info exists env(USER)] } { 1259 lappend out "user" $env(USER) 1260 } 1261 if { [info exists env(SESSION)] } { 1262 lappend out "session" $env(SESSION) 1263 } 1264 lappend out "tool_id" [$_first hints toolId] 1265 lappend out "tool_name" [$_first hints toolName] 1266 lappend out "tool_version" [$_first hints toolRevision] 1267 lappend out "tool_title" [$_first hints toolTitle] 1268 lappend out "tool_dataset" [$_first hints label] 1269 SendCmd "clientinfo [list $out]" 1270 } 1271 } 1272 set _settings($this-qw) $_view(qw) 1273 set _settings($this-qx) $_view(qx) 1274 set _settings($this-qy) $_view(qy) 1275 set _settings($this-qz) $_view(qz) 1232 1276 set _settings($this-theta) $_view(theta) 1233 1277 set _settings($this-phi) $_view(phi) … … 1237 1281 set _settings($this-zoom) $_view(zoom) 1238 1282 1239 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1240 SendCmd "camera angle $xyz" 1283 if {$_useArcball} { 1284 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1285 $_arcball quaternion $q 1286 SendCmd "camera orient $q" 1287 } else { 1288 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1289 SendCmd "camera angle $xyz" 1290 } 1241 1291 PanCamera 1242 1292 SendCmd "camera zoom $_view(zoom)" … … 1330 1380 "reset" { 1331 1381 array set _view { 1382 qw 0.853553 1383 qx -0.353553 1384 qy 0.353553 1385 qz 0.146447 1332 1386 theta 45 1333 1387 phi 45 … … 1343 1397 } 1344 1398 } 1345 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1346 SendCmd "camera angle $xyz" 1399 if {$_useArcball} { 1400 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1401 $_arcball quaternion $q 1402 SendCmd "camera orient $q" 1403 } else { 1404 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1405 SendCmd "camera angle $xyz" 1406 } 1347 1407 PanCamera 1408 set _settings($this-qw) $_view(qw) 1409 set _settings($this-qx) $_view(qx) 1410 set _settings($this-qy) $_view(qy) 1411 set _settings($this-qz) $_view(qz) 1348 1412 set _settings($this-theta) $_view(theta) 1349 1413 set _settings($this-phi) $_view(phi) … … 1400 1464 } 1401 1465 1402 # 1403 # Rotate the camera in 3D 1404 # 1405 if {$_view(psi) > 90 || $_view(psi) < -90} { 1406 # when psi is flipped around, theta moves backwards 1407 set dy [expr {-$dy}] 1466 if {$_useArcball} { 1467 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1468 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 1469 set _settings($this-qw) $_view(qw) 1470 set _settings($this-qx) $_view(qx) 1471 set _settings($this-qy) $_view(qy) 1472 set _settings($this-qz) $_view(qz) 1473 SendCmd "camera orient $q" 1474 } else { 1475 # 1476 # Rotate the camera in 3D 1477 # 1478 if {$_view(psi) > 90 || $_view(psi) < -90} { 1479 # when psi is flipped around, theta moves backwards 1480 set dy [expr {-$dy}] 1481 } 1482 set theta [expr {$_view(theta) - $dy*180}] 1483 while {$theta < 0} { set theta [expr {$theta+180}] } 1484 while {$theta > 180} { set theta [expr {$theta-180}] } 1485 1486 if {abs($theta) >= 30 && abs($theta) <= 160} { 1487 set phi [expr {$_view(phi) - $dx*360}] 1488 while {$phi < 0} { set phi [expr {$phi+360}] } 1489 while {$phi > 360} { set phi [expr {$phi-360}] } 1490 set psi $_view(psi) 1491 } else { 1492 set phi $_view(phi) 1493 set psi [expr {$_view(psi) - $dx*360}] 1494 while {$psi < -180} { set psi [expr {$psi+360}] } 1495 while {$psi > 180} { set psi [expr {$psi-360}] } 1496 } 1497 1498 set _view(theta) $theta 1499 set _view(phi) $phi 1500 set _view(psi) $psi 1501 set xyz [Euler2XYZ $theta $phi $psi] 1502 set _settings($this-theta) $_view(theta) 1503 set _settings($this-phi) $_view(phi) 1504 set _settings($this-psi) $_view(psi) 1505 SendCmd "camera angle $xyz" 1408 1506 } 1409 set theta [expr {$_view(theta) - $dy*180}] 1410 while {$theta < 0} { set theta [expr {$theta+180}] } 1411 while {$theta > 180} { set theta [expr {$theta-180}] } 1412 1413 if {abs($theta) >= 30 && abs($theta) <= 160} { 1414 set phi [expr {$_view(phi) - $dx*360}] 1415 while {$phi < 0} { set phi [expr {$phi+360}] } 1416 while {$phi > 360} { set phi [expr {$phi-360}] } 1417 set psi $_view(psi) 1418 } else { 1419 set phi $_view(phi) 1420 set psi [expr {$_view(psi) - $dx*360}] 1421 while {$psi < -180} { set psi [expr {$psi+360}] } 1422 while {$psi > 180} { set psi [expr {$psi-360}] } 1423 } 1424 1425 set _view(theta) $theta 1426 set _view(phi) $phi 1427 set _view(psi) $psi 1428 set xyz [Euler2XYZ $theta $phi $psi] 1429 set _settings($this-theta) $_view(theta) 1430 set _settings($this-phi) $_view(phi) 1431 set _settings($this-psi) $_view(psi) 1432 SendCmd "camera angle $xyz" 1507 1433 1508 set _click(x) $x 1434 1509 set _click(y) $y … … 1603 1678 set tag $_first-$comp 1604 1679 set diffuse [expr {0.01*$_settings($this-light)}] 1605 set specular [expr {sqrt($_settings($this-light)+1.0)}] 1606 SendCmd "$tag configure -diffuse $diffuse -specular $specular" 1680 set ambient [expr {1.0 - $diffuse}] 1681 set specularLevel 0.3 1682 set specularExp 90.0 1683 SendCmd "$tag configure -ambient $ambient -diffuse $diffuse -specularLevel $specularLevel -specularExp $specularExp" 1607 1684 } 1608 1685 } … … 1611 1688 set comp [lindex [$_first components] 0] 1612 1689 set tag $_first-$comp 1613 set opacity [expr { 0.2*$_settings($this-transp)+1}]1690 set opacity [expr { 0.01 * double($_settings($this-transp)) }] 1614 1691 SendCmd "$tag configure -opacity $opacity" 1615 1692 } … … 2073 2150 } 2074 2151 2075 2076 2077 2152 itcl::body Rappture::FlowvisViewer::BuildViewTab {} { 2078 2153 foreach { key value } { … … 2186 2261 label $inner.shading -text "Shading:" -font $fg 2187 2262 2188 label $inner.dim -text " Dim" -font $fg2263 label $inner.dim -text "Glow" -font $fg 2189 2264 ::scale $inner.light -from 0 -to 100 -orient horizontal \ 2190 2265 -variable [itcl::scope _settings($this-light)] \ 2191 2266 -width 10 \ 2192 2267 -showvalue off -command [itcl::code $this FixSettings light] 2193 label $inner.bright -text " Bright" -font $fg2194 2195 label $inner.fog -text " Fog" -font $fg2268 label $inner.bright -text "Surface" -font $fg 2269 2270 label $inner.fog -text "Clear" -font $fg 2196 2271 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 2197 2272 -variable [itcl::scope _settings($this-transp)] \ 2198 2273 -width 10 \ 2199 2274 -showvalue off -command [itcl::code $this FixSettings transp] 2200 label $inner.plastic -text " Plastic" -font $fg2275 label $inner.plastic -text "Opaque" -font $fg 2201 2276 2202 2277 label $inner.clear -text "Clear" -font $fg … … 2223 2298 3,1 $inner.transp -columnspan 2 -pady 2 -fill x \ 2224 2299 3,3 $inner.plastic -anchor w -pady 2 \ 2225 4,0 $inner.clear -anchor e -pady 2 \ 2226 4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\ 2227 4,3 $inner.opaque -anchor w -pady 2 \ 2228 5,0 $inner.thin -anchor e -pady 2 \ 2229 5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\ 2230 5,3 $inner.thick -anchor w -pady 2 2300 4,0 $inner.thin -anchor e -pady 2 \ 2301 4,1 $inner.thickness -columnspan 2 -pady 2 -fill x\ 2302 4,3 $inner.thick -anchor w -pady 2 2231 2303 2232 2304 if 0 { … … 2245 2317 } 2246 2318 blt::table configure $inner c0 c1 c3 r* -resize none 2247 blt::table configure $inner r 6-resize expand2319 blt::table configure $inner r5 -resize expand 2248 2320 } 2249 2321 … … 2355 2427 $inner configure -borderwidth 4 2356 2428 2357 set labels { phi theta psi pan-x pan-y zoom } 2429 if {$_useArcball} { 2430 set labels { qw qx qy qz pan-x pan-y zoom } 2431 } else { 2432 set labels { phi theta psi pan-x pan-y zoom } 2433 } 2358 2434 set row 0 2359 2435 foreach tag $labels { … … 2537 2613 set _width $w 2538 2614 set _height $h 2615 $_arcball resize $w $h 2539 2616 if { !$_resizePending } { 2540 2617 $_dispatcher event -after 200 !resize … … 2581 2658 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 2582 2659 SendCmd "camera angle $xyz" 2660 if {$_useArcball} { 2661 $_arcball euler [list [expr {-[lindex $xyz 2]}] [expr {-[lindex $xyz 1]}] [expr {-[lindex $xyz 0]}]] 2662 set q [$_arcball quaternion] 2663 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 2664 set _settings($this-qw) $_view(qw) 2665 set _settings($this-qx) $_view(qx) 2666 set _settings($this-qy) $_view(qy) 2667 set _settings($this-qz) $_view(qz) 2668 } 2669 } 2670 "qx" - "qy" - "qz" - "qw" { 2671 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2672 $_arcball quaternion $q 2673 SendCmd "camera orient $q" 2583 2674 } 2584 2675 "zoom" { -
trunk/gui/scripts/isomarker.tcl
r3330 r3362 116 116 array set limits [$_nvobj limits $_tf] 117 117 if { $limits(vmax) == $limits(vmin) } { 118 set limits( min) 0.0119 set limits( max) 1.0118 set limits(vmin) 0.0 119 set limits(vmax) 1.0 120 120 } 121 121 if { [catch {expr $limits(vmax) - $limits(vmin)} r] != 0 } { -
trunk/gui/scripts/nanovisviewer.tcl
r3339 r3362 120 120 private method SetOrientation {} 121 121 122 private variable _arcball "" 123 private variable _useArcball 1 122 124 private variable _outbuf ;# buffer for outgoing commands 123 125 … … 130 132 ;# in the server. 131 133 private variable _recvdDatasets ;# list of data objs to send to server 132 private variable _ vol2style ;# maps dataobj-component to transfunc134 private variable _dataset2style ;# maps dataobj-component to transfunc 133 135 private variable _style2datasets ;# maps tf back to list of 134 136 # dataobj-components using the tf. … … 199 201 # Initialize the view to some default parameters. 200 202 array set _view { 203 qw 0.853553 204 qx -0.353553 205 qy 0.353553 206 qz 0.146447 201 207 theta 45 202 208 phi 45 … … 206 212 pan-y 0 207 213 } 214 set _arcball [blt::arcball create 100 100] 215 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 216 $_arcball quaternion $q 217 208 218 set _limits(vmin) 0.0 209 219 set _limits(vmax) 1.0 … … 211 221 212 222 array set _settings [subst { 223 $this-qw $_view(qw) 224 $this-qx $_view(qx) 225 $this-qy $_view(qy) 226 $this-qz $_view(qz) 227 $this-theta $_view(theta) 228 $this-phi $_view(phi) 229 $this-psi $_view(psi) 230 $this-zoom $_view(zoom) 213 231 $this-pan-x $_view(pan-x) 214 232 $this-pan-y $_view(pan-y) 215 $this-phi $_view(phi)216 $this-psi $_view(psi)217 $this-theta $_view(theta)218 233 $this-volume 1 219 234 $this-xcutplane 0 … … 223 238 $this-zcutplane 0 224 239 $this-zcutposition 0 225 $this-zoom $_view(zoom)226 240 }] 227 241 … … 379 393 image delete $_image(legend) 380 394 image delete $_image(download) 395 catch { blt::arcball destroy $_arcball } 381 396 array unset _settings $this-* 382 397 } … … 491 506 array unset _limits $dataobj* 492 507 array unset _obj2ovride $dataobj-* 493 array unset _ vol2style $dataobj-*508 array unset _dataset2style $dataobj-* 494 509 set changed 1 495 510 } … … 676 691 # The volume hasn't reached the server yet. How did we get 677 692 # here? 693 puts stderr "Don't have $vol in _serverVols" 678 694 continue 679 695 } 680 if { ![info exists _ vol2style($tag)] } {681 puts stderr " unknownvolume $tag"696 if { ![info exists _dataset2style($tag)] } { 697 puts stderr "Don't have style for volume $tag" 682 698 continue; # How does this happen? 683 699 } 684 set tf $_ vol2style($tag)700 set tf $_dataset2style($tag) 685 701 set _settings($this-$tf-opacity) $opacity 686 702 set _settings($this-$tf-thickness) $thickness … … 819 835 return 820 836 } 837 838 puts stderr "Received volume info: '$args'" 839 821 840 # Arguments from server are name value pairs. Stuff them in an array. 822 841 array set info $args … … 872 891 set w [winfo width $itk_component(3dview)] 873 892 set h [winfo height $itk_component(3dview)] 893 $_arcball resize $w $h 874 894 EventuallyResize $w $h 875 895 … … 894 914 # Reset the camera and other view parameters 895 915 # 896 916 set _settings($this-qw) $_view(qw) 917 set _settings($this-qx) $_view(qx) 918 set _settings($this-qy) $_view(qy) 919 set _settings($this-qz) $_view(qz) 897 920 set _settings($this-theta) $_view(theta) 898 921 set _settings($this-phi) $_view(phi) … … 901 924 set _settings($this-pan-y) $_view(pan-y) 902 925 set _settings($this-zoom) $_view(zoom) 903 904 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 905 SendCmd "camera angle $xyz" 926 927 if {$_useArcball} { 928 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 929 $_arcball quaternion $q 930 SendCmd "camera orient $q" 931 } else { 932 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 933 SendCmd "camera angle $xyz" 934 } 935 906 936 PanCamera 907 937 SendCmd "camera zoom $_view(zoom)" 938 FixSettings light2side 908 939 FixSettings light 909 940 FixSettings transp … … 1021 1052 "reset" { 1022 1053 array set _view { 1054 qw 0.853553 1055 qx -0.353553 1056 qy 0.353553 1057 qz 0.146447 1023 1058 theta 45 1024 1059 phi 45 … … 1034 1069 } 1035 1070 } 1036 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1037 SendCmd "camera angle $xyz" 1071 if {$_useArcball} { 1072 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1073 $_arcball quaternion $q 1074 SendCmd "camera orient $q" 1075 } else { 1076 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1077 SendCmd "camera angle $xyz" 1078 } 1079 1038 1080 PanCamera 1081 set _settings($this-qw) $_view(qw) 1082 set _settings($this-qx) $_view(qx) 1083 set _settings($this-qy) $_view(qy) 1084 set _settings($this-qz) $_view(qz) 1039 1085 set _settings($this-theta) $_view(theta) 1040 1086 set _settings($this-phi) $_view(phi) … … 1092 1138 } 1093 1139 1094 # 1095 # Rotate the camera in 3D 1096 # 1097 if {$_view(psi) > 90 || $_view(psi) < -90} { 1098 # when psi is flipped around, theta moves backwards 1099 set dy [expr {-$dy}] 1140 if {$_useArcball} { 1141 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1142 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 1143 set _settings($this-qw) $_view(qw) 1144 set _settings($this-qx) $_view(qx) 1145 set _settings($this-qy) $_view(qy) 1146 set _settings($this-qz) $_view(qz) 1147 SendCmd "camera orient $q" 1148 } else { 1149 # 1150 # Rotate the camera in 3D 1151 # 1152 if {$_view(psi) > 90 || $_view(psi) < -90} { 1153 # when psi is flipped around, theta moves backwards 1154 set dy [expr {-$dy}] 1155 } 1156 set theta [expr {$_view(theta) - $dy*180}] 1157 while {$theta < 0} { set theta [expr {$theta+180}] } 1158 while {$theta > 180} { set theta [expr {$theta-180}] } 1159 1160 if {abs($theta) >= 30 && abs($theta) <= 160} { 1161 set phi [expr {$_view(phi) - $dx*360}] 1162 while {$phi < 0} { set phi [expr {$phi+360}] } 1163 while {$phi > 360} { set phi [expr {$phi-360}] } 1164 set psi $_view(psi) 1165 } else { 1166 set phi $_view(phi) 1167 set psi [expr {$_view(psi) - $dx*360}] 1168 while {$psi < -180} { set psi [expr {$psi+360}] } 1169 while {$psi > 180} { set psi [expr {$psi-360}] } 1170 } 1171 1172 set _view(theta) $theta 1173 set _view(phi) $phi 1174 set _view(psi) $psi 1175 set xyz [Euler2XYZ $theta $phi $psi] 1176 set _settings($this-theta) $_view(theta) 1177 set _settings($this-phi) $_view(phi) 1178 set _settings($this-psi) $_view(psi) 1179 SendCmd "camera angle $xyz" 1100 1180 } 1101 set theta [expr {$_view(theta) - $dy*180}] 1102 while {$theta < 0} { set theta [expr {$theta+180}] } 1103 while {$theta > 180} { set theta [expr {$theta-180}] } 1104 1105 if {abs($theta) >= 30 && abs($theta) <= 160} { 1106 set phi [expr {$_view(phi) - $dx*360}] 1107 while {$phi < 0} { set phi [expr {$phi+360}] } 1108 while {$phi > 360} { set phi [expr {$phi-360}] } 1109 set psi $_view(psi) 1110 } else { 1111 set phi $_view(phi) 1112 set psi [expr {$_view(psi) - $dx*360}] 1113 while {$psi < -180} { set psi [expr {$psi+360}] } 1114 while {$psi > 180} { set psi [expr {$psi-360}] } 1115 } 1116 1117 set _view(theta) $theta 1118 set _view(phi) $phi 1119 set _view(psi) $psi 1120 set xyz [Euler2XYZ $theta $phi $psi] 1121 set _settings($this-theta) $_view(theta) 1122 set _settings($this-phi) $_view(phi) 1123 set _settings($this-psi) $_view(psi) 1124 SendCmd "camera angle $xyz" 1181 1125 1182 set _click(x) $x 1126 1183 set _click(y) $y … … 1193 1250 if {[isconnected]} { 1194 1251 set val $_settings($this-light) 1195 set sval [expr {0.01*$val}] 1196 SendCmd "volume shading diffuse $sval" 1197 set sval [expr {sqrt($val+1.0)}] 1198 SendCmd "volume shading specular $sval" 1252 set diffuse [expr {0.01*$val}] 1253 set ambient [expr {1.0-$diffuse}] 1254 set specularLevel 0.3 1255 set specularExp 90.0 1256 SendCmd "volume shading ambient $ambient" 1257 SendCmd "volume shading diffuse $diffuse" 1258 SendCmd "volume shading specularLevel $specularLevel" 1259 SendCmd "volume shading specularExp $specularExp" 1260 } 1261 } 1262 light2side { 1263 if {[isconnected]} { 1264 set val $_settings($this-light2side) 1265 SendCmd "volume shading light2side $val" 1199 1266 } 1200 1267 } … … 1202 1269 if {[isconnected]} { 1203 1270 set val $_settings($this-transp) 1204 set sval [expr { 0.2*$val+1}]1271 set sval [expr { 0.01 * double($val) }] 1205 1272 SendCmd "volume shading opacity $sval" 1206 1273 } … … 1217 1284 } 1218 1285 } 1219 1220 1286 thickness { 1221 1287 if {[isconnected] && [array names _activeTfs] > 0 } { … … 1302 1368 if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } { 1303 1369 set tag [lindex [CurrentDatasets] 0] 1304 if { [info exists _ vol2style($tag)] } {1305 SendCmd "legend $_ vol2style($tag) $w $h"1370 if { [info exists _dataset2style($tag)] } { 1371 SendCmd "legend $_dataset2style($tag) $w $h" 1306 1372 } 1307 1373 } else { … … 1333 1399 -levels 6 1334 1400 -opacity 1.0 1401 -markers "" 1335 1402 } 1336 1403 set tag $dataobj-$cname 1337 1404 array set style [lindex [$dataobj components -style $cname] 0] 1338 1405 set tf "$style(-color):$style(-levels):$style(-opacity)" 1339 set _ vol2style($tag) $tf1406 set _dataset2style($tag) $tf 1340 1407 lappend _style2datasets($tf) $tag 1341 1408 return $tf … … 1356 1423 -levels 6 1357 1424 -opacity 1.0 1425 -markers "" 1358 1426 } 1359 1427 foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break 1360 1428 array set style [lindex [$dataobj components -style $cname] 0] 1361 1429 1430 puts stderr "$tf: $style(-color), $style(-levels), $style(-opacity), $style(-markers)" 1362 1431 1363 1432 # We have to parse the style attributes for a volume using this … … 1376 1445 if { ![info exists _isomarkers($tf)] } { 1377 1446 # Have to defer creation of isomarkers until we have data limits 1378 if { [info exists style(-markers)] } { 1447 if { [info exists style(-markers)] && 1448 [llength $style(-markers)] > 0 } { 1379 1449 ParseMarkersOption $tf $style(-markers) 1450 puts stderr "Found markers option" 1380 1451 } else { 1381 1452 ParseLevelsOption $tf $style(-levels) … … 1386 1457 } 1387 1458 set clist [split $style(-color) :] 1388 set cmap "0.0 [Color2RGB white] " 1459 if {[llength $clist] == 1} { 1460 lappend clist [lindex $clist 0] 1461 } 1389 1462 for {set i 0} {$i < [llength $clist]} {incr i} { 1390 set x [expr {double($i +1)/([llength $clist]+1)}]1463 set x [expr {double($i)/([llength $clist]-1)}] 1391 1464 set color [lindex $clist $i] 1392 1465 append cmap "$x [Color2RGB $color] " 1393 1466 } 1394 append cmap "1.0 [Color2RGB $color]"1395 1467 1396 1468 set tag $this-$tf … … 1398 1470 set _settings($tag-opacity) $style(-opacity) 1399 1471 } 1400 set max $_settings($tag-opacity)1472 set max 1.0 ;#$_settings($tag-opacity) 1401 1473 1402 1474 set isovalues {} … … 1408 1480 1409 1481 if { ![info exists _settings($tag-thickness)]} { 1410 set _settings($tag-thickness) 0.0 51482 set _settings($tag-thickness) 0.005 1411 1483 } 1412 1484 set delta $_settings($tag-thickness) … … 1563 1635 } 1564 1636 set tag [lindex [CurrentDatasets] 0] 1565 set tf $_ vol2style($tag)1637 set tf $_dataset2style($tag) 1566 1638 set c $itk_component(legend) 1567 1639 set m [Rappture::IsoMarker \#auto $c $this $tf] … … 1718 1790 itcl::body Rappture::NanovisViewer::BuildVolumeTab {} { 1719 1791 foreach { key value } { 1792 light2side 0 1720 1793 light 40 1721 1794 transp 50 … … 1739 1812 label $inner.shading -text "Shading:" -font $fg 1740 1813 1741 label $inner.dim -text "Dim" -font $fg 1814 checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ 1815 -variable [itcl::scope _settings($this-light2side)] \ 1816 -command [itcl::code $this FixSettings light2side] 1817 1818 label $inner.dim -text "Glow" -font $fg 1742 1819 ::scale $inner.light -from 0 -to 100 -orient horizontal \ 1743 1820 -variable [itcl::scope _settings($this-light)] \ 1744 1821 -width 10 \ 1745 1822 -showvalue off -command [itcl::code $this FixSettings light] 1746 label $inner.bright -text " Bright" -font $fg1747 1748 label $inner.fog -text " Fog" -font $fg1823 label $inner.bright -text "Surface" -font $fg 1824 1825 label $inner.fog -text "Clear" -font $fg 1749 1826 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 1750 1827 -variable [itcl::scope _settings($this-transp)] \ 1751 1828 -width 10 \ 1752 1829 -showvalue off -command [itcl::code $this FixSettings transp] 1753 label $inner.plastic -text " Plastic" -font $fg1830 label $inner.plastic -text "Opaque" -font $fg 1754 1831 1755 1832 label $inner.clear -text "Clear" -font $fg … … 1770 1847 0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \ 1771 1848 1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \ 1772 2,0 $inner.dim -anchor e -pady 2 \ 1773 2,1 $inner.light -columnspan 2 -pady 2 -fill x \ 1774 2,3 $inner.bright -anchor w -pady 2 \ 1775 3,0 $inner.fog -anchor e -pady 2 \ 1776 3,1 $inner.transp -columnspan 2 -pady 2 -fill x \ 1777 3,3 $inner.plastic -anchor w -pady 2 \ 1778 4,0 $inner.clear -anchor e -pady 2 \ 1779 4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\ 1780 4,3 $inner.opaque -anchor w -pady 2 \ 1849 2,0 $inner.light2side -columnspan 4 -anchor w -pady 2 \ 1850 3,0 $inner.dim -anchor e -pady 2 \ 1851 3,1 $inner.light -columnspan 2 -pady 2 -fill x \ 1852 3,3 $inner.bright -anchor w -pady 2 \ 1853 4,0 $inner.fog -anchor e -pady 2 \ 1854 4,1 $inner.transp -columnspan 2 -pady 2 -fill x \ 1855 4,3 $inner.plastic -anchor w -pady 2 \ 1781 1856 5,0 $inner.thin -anchor e -pady 2 \ 1782 1857 5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\ 1783 1858 5,3 $inner.thick -anchor w -pady 2 1859 1860 # 4,0 $inner.clear -anchor e -pady 2 \ 1861 # 4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\ 1862 # 4,3 $inner.opaque -anchor w -pady 2 \ 1863 1784 1864 1785 1865 blt::table configure $inner c0 c1 c3 r* -resize none … … 1894 1974 $inner configure -borderwidth 4 1895 1975 1896 set labels { phi theta psi pan-x pan-y zoom } 1976 if {$_useArcball} { 1977 set labels { qw qx qy qz pan-x pan-y zoom } 1978 } else { 1979 set labels { phi theta psi pan-x pan-y zoom } 1980 } 1897 1981 set row 0 1898 1982 foreach tag $labels { … … 1980 2064 set _width $w 1981 2065 set _height $h 2066 $_arcball resize $w $h 1982 2067 if { !$_resizePending } { 1983 2068 $_dispatcher event -idle !resize … … 2018 2103 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 2019 2104 SendCmd "camera angle $xyz" 2105 if {$_useArcball} { 2106 $_arcball euler [list [expr {-[lindex $xyz 2]}] [expr {-[lindex $xyz 1]}] [expr {-[lindex $xyz 0]}]] 2107 set q [$_arcball quaternion] 2108 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 2109 set _settings($this-qw) $_view(qw) 2110 set _settings($this-qx) $_view(qx) 2111 set _settings($this-qy) $_view(qy) 2112 set _settings($this-qz) $_view(qz) 2113 } 2114 } 2115 "qx" - "qy" - "qz" - "qw" { 2116 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2117 $_arcball quaternion $q 2118 SendCmd "camera orient $q" 2020 2119 } 2021 2120 "zoom" {
Note: See TracChangeset
for help on using the changeset viewer.