Changeset 3485 for trunk/gui/scripts
- Timestamp:
- Mar 11, 2013, 5:56:08 PM (12 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/flowvisviewer.tcl
r3478 r3485 125 125 126 126 private variable _arcball "" 127 private variable _useArcball 1128 127 private variable _dlist "" ;# list of data objects 129 128 private variable _allDataObjs … … 224 223 qy 0.353553 225 224 qz 0.146447 226 theta 45227 phi 45228 psi 0229 225 zoom 1.0 230 226 pan-x 0 … … 244 240 $this-qy $_view(qy) 245 241 $this-qz $_view(qz) 246 $this-theta $_view(theta)247 $this-phi $_view(phi)248 $this-psi $_view(psi)249 242 $this-zoom $_view(zoom) 250 243 $this-pan-x $_view(pan-x) … … 956 949 array set _view $location 957 950 } 958 set _settings($this-theta) $_view(theta) 959 set _settings($this-phi) $_view(phi) 960 set _settings($this-psi) $_view(psi) 951 set _settings($this-qw) $_view(qw) 952 set _settings($this-qx) $_view(qx) 953 set _settings($this-qy) $_view(qy) 954 set _settings($this-qz) $_view(qz) 961 955 set _settings($this-pan-x) $_view(pan-x) 962 956 set _settings($this-pan-y) $_view(pan-y) 963 957 set _settings($this-zoom) $_view(zoom) 964 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 965 SendCmd "camera angle $xyz" 958 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 959 $_arcball quaternion $q 960 SendCmd "camera orient $q" 961 #SendCmd "camera reset" 966 962 PanCamera 967 963 SendCmd "camera zoom $_view(zoom)" … … 1254 1250 set _settings($this-qy) $_view(qy) 1255 1251 set _settings($this-qz) $_view(qz) 1256 set _settings($this-theta) $_view(theta)1257 set _settings($this-phi) $_view(phi)1258 set _settings($this-psi) $_view(psi)1259 1252 set _settings($this-pan-x) $_view(pan-x) 1260 1253 set _settings($this-pan-y) $_view(pan-y) 1261 1254 set _settings($this-zoom) $_view(zoom) 1262 1255 1263 if {$_useArcball} { 1264 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1265 $_arcball quaternion $q 1266 SendCmd "camera orient $q" 1267 } else { 1268 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1269 SendCmd "camera angle $xyz" 1270 } 1256 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1257 $_arcball quaternion $q 1258 SendCmd "camera orient $q" 1259 #SendCmd "camera reset" 1271 1260 PanCamera 1272 1261 SendCmd "camera zoom $_view(zoom)" … … 1352 1341 set _view(zoom) [expr {$_view(zoom)*1.25}] 1353 1342 set _settings($this-zoom) $_view(zoom) 1343 SendCmd "camera zoom $_view(zoom)" 1354 1344 } 1355 1345 "out" { 1356 1346 set _view(zoom) [expr {$_view(zoom)*0.8}] 1357 1347 set _settings($this-zoom) $_view(zoom) 1348 SendCmd "camera zoom $_view(zoom)" 1358 1349 } 1359 1350 "reset" { … … 1363 1354 qy 0.353553 1364 1355 qz 0.146447 1365 theta 451366 phi 451367 psi 01368 1356 zoom 1.0 1369 1357 pan-x 0 … … 1376 1364 } 1377 1365 } 1378 if {$_useArcball} { 1379 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1380 $_arcball quaternion $q 1381 SendCmd "camera orient $q" 1382 } else { 1383 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1384 SendCmd "camera angle $xyz" 1385 } 1386 PanCamera 1366 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1367 $_arcball quaternion $q 1368 SendCmd "camera orient $q" 1369 #SendCmd "camera reset" 1370 SendCmd "camera zoom $_view(zoom)" 1387 1371 set _settings($this-qw) $_view(qw) 1388 1372 set _settings($this-qx) $_view(qx) 1389 1373 set _settings($this-qy) $_view(qy) 1390 1374 set _settings($this-qz) $_view(qz) 1391 set _settings($this-theta) $_view(theta)1392 set _settings($this-phi) $_view(phi)1393 set _settings($this-psi) $_view(psi)1394 1375 set _settings($this-pan-x) $_view(pan-x) 1395 1376 set _settings($this-pan-y) $_view(pan-y) … … 1397 1378 } 1398 1379 } 1399 SendCmd "camera zoom $_view(zoom)"1400 1380 } 1401 1381 … … 1422 1402 set _click(x) $x 1423 1403 set _click(y) $y 1424 set _click(theta) $_view(theta)1425 set _click(phi) $_view(phi)1426 1404 } 1427 1405 drag { … … 1443 1421 } 1444 1422 1445 if {$_useArcball} { 1446 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1447 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 1448 set _settings($this-qw) $_view(qw) 1449 set _settings($this-qx) $_view(qx) 1450 set _settings($this-qy) $_view(qy) 1451 set _settings($this-qz) $_view(qz) 1452 SendCmd "camera orient $q" 1453 } else { 1454 # 1455 # Rotate the camera in 3D 1456 # 1457 if {$_view(psi) > 90 || $_view(psi) < -90} { 1458 # when psi is flipped around, theta moves backwards 1459 set dy [expr {-$dy}] 1460 } 1461 set theta [expr {$_view(theta) - $dy*180}] 1462 while {$theta < 0} { set theta [expr {$theta+180}] } 1463 while {$theta > 180} { set theta [expr {$theta-180}] } 1464 1465 if {abs($theta) >= 30 && abs($theta) <= 160} { 1466 set phi [expr {$_view(phi) - $dx*360}] 1467 while {$phi < 0} { set phi [expr {$phi+360}] } 1468 while {$phi > 360} { set phi [expr {$phi-360}] } 1469 set psi $_view(psi) 1470 } else { 1471 set phi $_view(phi) 1472 set psi [expr {$_view(psi) - $dx*360}] 1473 while {$psi < -180} { set psi [expr {$psi+360}] } 1474 while {$psi > 180} { set psi [expr {$psi-360}] } 1475 } 1476 1477 set _view(theta) $theta 1478 set _view(phi) $phi 1479 set _view(psi) $psi 1480 set xyz [Euler2XYZ $theta $phi $psi] 1481 set _settings($this-theta) $_view(theta) 1482 set _settings($this-phi) $_view(phi) 1483 set _settings($this-psi) $_view(psi) 1484 SendCmd "camera angle $xyz" 1485 } 1423 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1424 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 1425 set _settings($this-qw) $_view(qw) 1426 set _settings($this-qx) $_view(qx) 1427 set _settings($this-qy) $_view(qy) 1428 set _settings($this-qz) $_view(qz) 1429 SendCmd "camera orient $q" 1486 1430 1487 1431 set _click(x) $x … … 2443 2387 $inner configure -borderwidth 4 2444 2388 2445 if {$_useArcball} { 2446 set labels { qw qx qy qz pan-x pan-y zoom } 2447 } else { 2448 set labels { phi theta psi pan-x pan-y zoom } 2449 } 2389 set labels { qw qx qy qz pan-x pan-y zoom } 2450 2390 set row 0 2451 2391 foreach tag $labels { … … 2669 2609 set _view($who) $_settings($this-$who) 2670 2610 PanCamera 2671 }2672 "phi" - "theta" - "psi" {2673 set _view($who) $_settings($this-$who)2674 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]2675 SendCmd "camera angle $xyz"2676 if {$_useArcball} {2677 $_arcball euler [list [expr {-[lindex $xyz 2]}] [expr {-[lindex $xyz 1]}] [expr {-[lindex $xyz 0]}]]2678 set q [$_arcball quaternion]2679 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break2680 set _settings($this-qw) $_view(qw)2681 set _settings($this-qx) $_view(qx)2682 set _settings($this-qy) $_view(qy)2683 set _settings($this-qz) $_view(qz)2684 }2685 2611 } 2686 2612 "qx" - "qy" - "qz" - "qw" { -
trunk/gui/scripts/nanovisviewer.tcl
r3478 r3485 17 17 package require BLT 18 18 package require Img 19 19 20 20 # 21 21 # FIXME: … … 121 121 122 122 private variable _arcball "" 123 private variable _useArcball 1124 123 125 124 private variable _dlist "" ;# list of data objects … … 200 199 qy 0.353553 201 200 qz 0.146447 202 theta 45203 phi 45204 psi 0205 201 zoom 1.0 206 202 pan-x 0 … … 220 216 $this-qy $_view(qy) 221 217 $this-qz $_view(qz) 222 $this-theta $_view(theta)223 $this-phi $_view(phi)224 $this-psi $_view(psi)225 218 $this-zoom $_view(zoom) 226 219 $this-pan-x $_view(pan-x) … … 913 906 set _settings($this-qy) $_view(qy) 914 907 set _settings($this-qz) $_view(qz) 915 set _settings($this-theta) $_view(theta)916 set _settings($this-phi) $_view(phi)917 set _settings($this-psi) $_view(psi)918 908 set _settings($this-pan-x) $_view(pan-x) 919 909 set _settings($this-pan-y) $_view(pan-y) 920 910 set _settings($this-zoom) $_view(zoom) 921 911 922 if {$_useArcball} { 923 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 924 $_arcball quaternion $q 925 SendCmd "camera orient $q" 926 } else { 927 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 928 SendCmd "camera angle $xyz" 929 } 930 912 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 913 $_arcball quaternion $q 914 SendCmd "camera orient $q" 915 #SendCmd "camera reset" 931 916 PanCamera 932 917 SendCmd "camera zoom $_view(zoom)" … … 1012 997 set _view(zoom) [expr {$_view(zoom)*1.25}] 1013 998 set _settings($this-zoom) $_view(zoom) 999 SendCmd "camera zoom $_view(zoom)" 1014 1000 } 1015 1001 "out" { 1016 1002 set _view(zoom) [expr {$_view(zoom)*0.8}] 1017 1003 set _settings($this-zoom) $_view(zoom) 1004 SendCmd "camera zoom $_view(zoom)" 1018 1005 } 1019 1006 "reset" { … … 1023 1010 qy 0.353553 1024 1011 qz 0.146447 1025 theta 451026 phi 451027 psi 01028 1012 zoom 1.0 1029 1013 pan-x 0 … … 1036 1020 } 1037 1021 } 1038 if {$_useArcball} { 1039 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1040 $_arcball quaternion $q 1041 SendCmd "camera orient $q" 1042 } else { 1043 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 1044 SendCmd "camera angle $xyz" 1045 } 1046 1047 PanCamera 1022 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1023 $_arcball quaternion $q 1024 SendCmd "camera orient $q" 1025 #SendCmd "camera reset" 1026 SendCmd "camera zoom $_view(zoom)" 1048 1027 set _settings($this-qw) $_view(qw) 1049 1028 set _settings($this-qx) $_view(qx) 1050 1029 set _settings($this-qy) $_view(qy) 1051 1030 set _settings($this-qz) $_view(qz) 1052 set _settings($this-theta) $_view(theta)1053 set _settings($this-phi) $_view(phi)1054 set _settings($this-psi) $_view(psi)1055 1031 set _settings($this-pan-x) $_view(pan-x) 1056 1032 set _settings($this-pan-y) $_view(pan-y) … … 1058 1034 } 1059 1035 } 1060 SendCmd "camera zoom $_view(zoom)"1061 1036 } 1062 1037 … … 1084 1059 set _click(x) $x 1085 1060 set _click(y) $y 1086 set _click(theta) $_view(theta)1087 set _click(phi) $_view(phi)1088 1061 } 1089 1062 drag { … … 1105 1078 } 1106 1079 1107 if {$_useArcball} { 1108 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1109 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 1110 set _settings($this-qw) $_view(qw) 1111 set _settings($this-qx) $_view(qx) 1112 set _settings($this-qy) $_view(qy) 1113 set _settings($this-qz) $_view(qz) 1114 SendCmd "camera orient $q" 1115 } else { 1116 # 1117 # Rotate the camera in 3D 1118 # 1119 if {$_view(psi) > 90 || $_view(psi) < -90} { 1120 # when psi is flipped around, theta moves backwards 1121 set dy [expr {-$dy}] 1122 } 1123 set theta [expr {$_view(theta) - $dy*180}] 1124 while {$theta < 0} { set theta [expr {$theta+180}] } 1125 while {$theta > 180} { set theta [expr {$theta-180}] } 1126 1127 if {abs($theta) >= 30 && abs($theta) <= 160} { 1128 set phi [expr {$_view(phi) - $dx*360}] 1129 while {$phi < 0} { set phi [expr {$phi+360}] } 1130 while {$phi > 360} { set phi [expr {$phi-360}] } 1131 set psi $_view(psi) 1132 } else { 1133 set phi $_view(phi) 1134 set psi [expr {$_view(psi) - $dx*360}] 1135 while {$psi < -180} { set psi [expr {$psi+360}] } 1136 while {$psi > 180} { set psi [expr {$psi-360}] } 1137 } 1138 1139 set _view(theta) $theta 1140 set _view(phi) $phi 1141 set _view(psi) $psi 1142 set xyz [Euler2XYZ $theta $phi $psi] 1143 set _settings($this-theta) $_view(theta) 1144 set _settings($this-phi) $_view(phi) 1145 set _settings($this-psi) $_view(psi) 1146 SendCmd "camera angle $xyz" 1147 } 1080 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1081 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 1082 set _settings($this-qw) $_view(qw) 1083 set _settings($this-qx) $_view(qx) 1084 set _settings($this-qy) $_view(qy) 1085 set _settings($this-qz) $_view(qz) 1086 SendCmd "camera orient $q" 1148 1087 1149 1088 set _click(x) $x … … 1953 1892 $inner configure -borderwidth 4 1954 1893 1955 if {$_useArcball} { 1956 set labels { qw qx qy qz pan-x pan-y zoom } 1957 } else { 1958 set labels { phi theta psi pan-x pan-y zoom } 1959 } 1894 set labels { qw qx qy qz pan-x pan-y zoom } 1960 1895 set row 0 1961 1896 foreach tag $labels { … … 1974 1909 } 1975 1910 1976 itk_component add orientation {1977 Rappture::Combobox $inner.orientation -width 10 -editable no1978 }1979 $inner.orientation choices insert end \1980 "front" "0 90 0" \1981 "back" "180 90 0" \1982 "top" "0 0 0" \1983 "bottom" "0 180 0" \1984 "left" "270 90 0 " \1985 "right" "90 90 0" \1986 "default" "45 45 0"1987 $itk_component(orientation) value "default"1988 bind $inner.orientation <<Value>> [itcl::code $this SetOrientation]1989 1990 1911 blt::table configure $inner c0 c1 -resize none 1991 1912 blt::table configure $inner c2 -resize expand 1992 1913 blt::table configure $inner r$row -resize expand 1993 1914 } 1994 1995 1915 1996 1916 # ---------------------------------------------------------------------- … … 2060 1980 } 2061 1981 2062 2063 1982 # camera -- 2064 1983 # … … 2080 1999 set _view($who) $_settings($this-$who) 2081 2000 PanCamera 2082 }2083 "phi" - "theta" - "psi" {2084 set _view($who) $_settings($this-$who)2085 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]2086 SendCmd "camera angle $xyz"2087 if {$_useArcball} {2088 $_arcball euler [list [expr {-[lindex $xyz 2]}] [expr {-[lindex $xyz 1]}] [expr {-[lindex $xyz 0]}]]2089 set q [$_arcball quaternion]2090 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break2091 set _settings($this-qw) $_view(qw)2092 set _settings($this-qx) $_view(qx)2093 set _settings($this-qy) $_view(qy)2094 set _settings($this-qz) $_view(qz)2095 }2096 2001 } 2097 2002 "qx" - "qy" - "qz" - "qw" { … … 2167 2072 SendCmd "volume statue $bool $name" 2168 2073 } 2169 2170 2171 itcl::body Rappture::NanovisViewer::SetOrientation {} {2172 set angles [$itk_component(orientation) value]2173 foreach name { theta phi psi } angle $angles {2174 set _view($name) $angle2175 }2176 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]2177 SendCmd "camera angle $xyz"2178 }2179
Note: See TracChangeset
for help on using the changeset viewer.