Changeset 4314
- Timestamp:
- Apr 2, 2014, 12:19:53 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/mapviewer.tcl
r4311 r4314 86 86 protected method ReceiveImage { args } 87 87 protected method Rotate {option x y} 88 protected method Zoom {option }88 protected method Zoom {option {x 0} {y 0}} 89 89 90 90 # The following methods are only used by this class. … … 96 96 private method EventuallyHandleMotionEvent { x y } 97 97 private method EventuallyResize { w h } 98 private method EventuallyRotate { q}98 private method EventuallyRotate { dx dy } 99 99 private method GetImage { args } 100 private method PanCamera {}100 private method GetNormalizedMouse { x y } 101 101 private method SetLayerStyle { dataobj layer } 102 102 private method SetTerrainStyle { style } 103 103 private method SetOpacity { dataset } 104 private method SetOrientation { side }105 104 private method UpdateLayerControls {} 106 105 private method EarthFile {} 107 106 108 private variable _arcball ""109 107 private variable _dlist ""; # list of data objects 110 108 private variable _obj2datasets … … 113 111 # layer in the server. 114 112 private variable _click; # info used for rotate operations 115 private variable _limits; # autoscale min/max for all axes116 113 private variable _view; # view params for 3D view 117 114 private variable _settings … … 136 133 private variable _motion 137 134 private variable _sendEarthFile 0 135 private variable _useServerManip 1 138 136 } 139 137 … … 172 170 $_parser alias image [itcl::code $this ReceiveImage] 173 171 $_parser alias dataset [itcl::code $this ReceiveDataset] 174 172 $_parser alias camera [itcl::code $this camera] 173 174 # Settings for mouse motion events: these are required 175 # to update the Lat/Long coordinate display 175 176 array set _motion { 176 177 x 0 … … 180 181 compress 0 181 182 } 182 # Initialize the view to some default parameters. 183 # This array holds the Viewpoint parameters that the 184 # server sends on "camera get". 183 185 array set _view { 184 qw 1.0 185 qx 0.0 186 qy 0.0 187 qz 0.0 188 zoom 1.0 189 xpan 0.0 190 ypan 0.0 191 } 192 set _arcball [blt::arcball create 100 100] 193 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 194 $_arcball quaternion $q 195 196 set _limits(zmin) 0.0 197 set _limits(zmax) 1.0 186 x 0.0 187 y 0.0 188 z 0.0 189 heading 0.0 190 pitch 0.0 191 distance 0.0 192 srs "" 193 verticalDatum "" 194 } 198 195 199 196 array set _settings [subst { … … 235 232 -highlightthickness 0 \ 236 233 -image [Rappture::icon reset-view] \ 237 -command [itcl::code $this Zoomreset]234 -command [itcl::code $this camera reset] 238 235 } { 239 236 usual … … 292 289 blt::table configure $itk_component(plotarea) c1 -resize none 293 290 294 # Bindings for keyboard events295 bind $itk_component(view) <KeyPress> \296 [itcl::code $this KeyPress %N]297 bind $itk_component(view) <KeyRelease> \298 [itcl::code $this KeyRelease %N]299 300 # Bindings for rotation via mouse301 bind $itk_component(view) <ButtonPress-1> \302 [itcl::code $this MouseClick 1 %x %y]303 bind $itk_component(view) <Double-1> \304 [itcl::code $this MouseDoubleClick 1 %x %y]305 bind $itk_component(view) <B1-Motion> \306 [itcl::code $this MouseDrag 1 %x %y]307 bind $itk_component(view) <ButtonRelease-1> \308 [itcl::code $this MouseRelease 1 %x %y]309 291 bind $itk_component(view) <Configure> \ 310 292 [itcl::code $this EventuallyResize %w %h] 311 293 312 # Bindings for panning via mouse 313 bind $itk_component(view) <ButtonPress-2> \ 314 [itcl::code $this MouseClick 2 %x %y] 315 bind $itk_component(view) <Double-2> \ 316 [itcl::code $this MouseDoubleClick 2 %x %y] 317 bind $itk_component(view) <B2-Motion> \ 318 [itcl::code $this MouseDrag 2 %x %y] 319 bind $itk_component(view) <ButtonRelease-2> \ 320 [itcl::code $this MouseRelease 2 %x %y] 321 322 bind $itk_component(view) <ButtonPress-3> \ 323 [itcl::code $this MouseClick 3 %x %y] 324 bind $itk_component(view) <Double-3> \ 325 [itcl::code $this MouseDoubleClick 3 %x %y] 326 bind $itk_component(view) <B3-Motion> \ 327 [itcl::code $this MouseDrag 3 %x %y] 328 bind $itk_component(view) <ButtonRelease-3> \ 329 [itcl::code $this MouseRelease 3 %x %y] 330 331 bind $itk_component(view) <Motion> \ 332 [itcl::code $this EventuallyHandleMotionEvent %x %y] 333 334 if {0} { 335 # Bindings for panning via keyboard 336 bind $itk_component(view) <KeyPress-Left> \ 337 [itcl::code $this Pan set -10 0] 338 bind $itk_component(view) <KeyPress-Right> \ 339 [itcl::code $this Pan set 10 0] 340 bind $itk_component(view) <KeyPress-Up> \ 341 [itcl::code $this Pan set 0 -10] 342 bind $itk_component(view) <KeyPress-Down> \ 343 [itcl::code $this Pan set 0 10] 294 if {$_useServerManip} { 295 # Bindings for keyboard events 296 bind $itk_component(view) <KeyPress> \ 297 [itcl::code $this KeyPress %N] 298 bind $itk_component(view) <KeyRelease> \ 299 [itcl::code $this KeyRelease %N] 300 301 # Bindings for rotation via mouse 302 bind $itk_component(view) <ButtonPress-1> \ 303 [itcl::code $this MouseClick 1 %x %y] 304 bind $itk_component(view) <Double-1> \ 305 [itcl::code $this MouseDoubleClick 1 %x %y] 306 bind $itk_component(view) <B1-Motion> \ 307 [itcl::code $this MouseDrag 1 %x %y] 308 bind $itk_component(view) <ButtonRelease-1> \ 309 [itcl::code $this MouseRelease 1 %x %y] 310 311 # Bindings for panning via mouse 312 bind $itk_component(view) <ButtonPress-2> \ 313 [itcl::code $this MouseClick 2 %x %y] 314 bind $itk_component(view) <Double-2> \ 315 [itcl::code $this MouseDoubleClick 2 %x %y] 316 bind $itk_component(view) <B2-Motion> \ 317 [itcl::code $this MouseDrag 2 %x %y] 318 bind $itk_component(view) <ButtonRelease-2> \ 319 [itcl::code $this MouseRelease 2 %x %y] 320 321 bind $itk_component(view) <ButtonPress-3> \ 322 [itcl::code $this MouseClick 3 %x %y] 323 bind $itk_component(view) <Double-3> \ 324 [itcl::code $this MouseDoubleClick 3 %x %y] 325 bind $itk_component(view) <B3-Motion> \ 326 [itcl::code $this MouseDrag 3 %x %y] 327 bind $itk_component(view) <ButtonRelease-3> \ 328 [itcl::code $this MouseRelease 3 %x %y] 329 330 bind $itk_component(view) <Motion> \ 331 [itcl::code $this EventuallyHandleMotionEvent %x %y] 332 } else { 333 # Bindings for panning via mouse 334 bind $itk_component(view) <ButtonPress-1> \ 335 [itcl::code $this Pan click %x %y] 336 bind $itk_component(view) <B1-Motion> \ 337 [itcl::code $this Pan drag %x %y] 338 bind $itk_component(view) <ButtonRelease-1> \ 339 [itcl::code $this Pan release %x %y] 340 341 # Bindings for rotation via mouse 342 bind $itk_component(view) <ButtonPress-2> \ 343 [itcl::code $this Rotate click %x %y] 344 bind $itk_component(view) <B2-Motion> \ 345 [itcl::code $this Rotate drag %x %y] 346 bind $itk_component(view) <ButtonRelease-2> \ 347 [itcl::code $this Rotate release %x %y] 348 349 # Bindings for zoom via mouse 350 bind $itk_component(view) <ButtonPress-3> \ 351 [itcl::code $this Zoom click %x %y] 352 bind $itk_component(view) <B3-Motion> \ 353 [itcl::code $this Zoom drag %x %y] 354 bind $itk_component(view) <ButtonRelease-3> \ 355 [itcl::code $this Zoom release %x %y] 356 357 # Bindings for panning via keyboard 358 bind $itk_component(view) <KeyPress-Left> \ 359 [itcl::code $this Pan set 10 0] 360 bind $itk_component(view) <KeyPress-Right> \ 361 [itcl::code $this Pan set -10 0] 362 bind $itk_component(view) <KeyPress-Up> \ 363 [itcl::code $this Pan set 0 -10] 364 bind $itk_component(view) <KeyPress-Down> \ 365 [itcl::code $this Pan set 0 10] 366 367 # Send (compressed) motion events to update Lat/Long 368 set _motion(compress) 1 369 bind $itk_component(view) <Motion> \ 370 [itcl::code $this EventuallyHandleMotionEvent %x %y] 371 } 372 344 373 bind $itk_component(view) <Shift-KeyPress-Left> \ 374 [itcl::code $this Pan set 2 0] 375 bind $itk_component(view) <Shift-KeyPress-Right> \ 345 376 [itcl::code $this Pan set -2 0] 346 bind $itk_component(view) <Shift-KeyPress-Right> \347 [itcl::code $this Pan set 2 0]348 377 bind $itk_component(view) <Shift-KeyPress-Up> \ 349 378 [itcl::code $this Pan set 0 -2] 350 379 bind $itk_component(view) <Shift-KeyPress-Down> \ 351 380 [itcl::code $this Pan set 0 2] 352 }353 381 354 382 # Bindings for zoom via keyboard … … 362 390 if {[string equal "x11" [tk windowingsystem]]} { 363 391 # Bindings for zoom via mouse 364 #bind $itk_component(view) <4> [itcl::code $this Zoom out] 365 #bind $itk_component(view) <5> [itcl::code $this Zoom in] 366 bind $itk_component(view) <4> [itcl::code $this MouseScroll up] 367 bind $itk_component(view) <5> [itcl::code $this MouseScroll down] 392 if {$_useServerManip} { 393 bind $itk_component(view) <4> [itcl::code $this MouseScroll up] 394 bind $itk_component(view) <5> [itcl::code $this MouseScroll down] 395 } else { 396 bind $itk_component(view) <4> [itcl::code $this Zoom out] 397 bind $itk_component(view) <5> [itcl::code $this Zoom in] 398 } 368 399 } 369 400 … … 387 418 image delete $_image(plot) 388 419 image delete $_image(download) 389 catch { blt::arcball destroy $_arcball }390 420 } 391 421 … … 408 438 409 439 itcl::body Rappture::MapViewer::DoRotate {} { 410 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 411 SendCmd "camera orient $q" 440 SendCmd "camera rotate $_view(azimuth) $_view(elevation)" 412 441 set _rotatePending 0 413 442 } … … 416 445 set _width $w 417 446 set _height $h 418 $_arcball resize $w $h419 447 if { !$_resizePending } { 420 448 set _resizePending 1 … … 423 451 } 424 452 425 itcl::body Rappture::MapViewer::EventuallyRotate { q } { 426 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 453 itcl::body Rappture::MapViewer::EventuallyRotate { dx dy } { 454 set _view(azimuth) $dx 455 set _view(elevation) $dy 427 456 if { !$_rotatePending } { 428 457 set _rotatePending 1 … … 851 880 set _width $w 852 881 set _height $h 853 $_arcball resize $w $h854 882 DoResize 855 883 … … 901 929 } 902 930 903 set _limits(zmin) ""904 set _limits(zmax) ""905 931 set _first "" 906 932 set count 0 … … 944 970 } 945 971 if { $_reset } { 946 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 947 $_arcball quaternion $q 948 SendCmd "camera reset" 949 DoRotate 950 PanCamera 951 Zoom reset 972 camera reset 952 973 } 953 974 UpdateLayerControls … … 1016 1037 } 1017 1038 1018 itcl::body Rappture::MapViewer::MouseClick {button x y} { 1019 if {0} { 1039 itcl::body Rappture::MapViewer::GetNormalizedMouse {x y} { 1020 1040 set w [winfo width $itk_component(view)] 1021 1041 set h [winfo height $itk_component(view)] 1022 1042 set x [expr {(2.0 * double($x)/$w) - 1.0}] 1023 1043 set y [expr {(2.0 * double($y)/$h) - 1.0}] 1024 } 1044 return [list $x $y] 1045 } 1046 1047 itcl::body Rappture::MapViewer::MouseClick {button x y} { 1025 1048 SendCmd "mouse click $button $x $y" 1026 1049 } 1027 1050 1028 1051 itcl::body Rappture::MapViewer::MouseDoubleClick {button x y} { 1029 if {0} {1030 set w [winfo width $itk_component(view)]1031 set h [winfo height $itk_component(view)]1032 set x [expr {(2.0 * double($x)/$w) - 1.0}]1033 set y [expr {(2.0 * double($y)/$h) - 1.0}]1034 }1035 1052 SendCmd "mouse dblclick $button $x $y" 1036 1053 } 1037 1054 1038 1055 itcl::body Rappture::MapViewer::MouseDrag {button x y} { 1039 if {0} {1040 set w [winfo width $itk_component(view)]1041 set h [winfo height $itk_component(view)]1042 set x [expr {(2.0 * double($x)/$w) - 1.0}]1043 set y [expr {(2.0 * double($y)/$h) - 1.0}]1044 }1045 1056 SendCmd "mouse drag $button $x $y" 1046 1057 } 1047 1058 1048 1059 itcl::body Rappture::MapViewer::MouseRelease {button x y} { 1049 if {0} {1050 set w [winfo width $itk_component(view)]1051 set h [winfo height $itk_component(view)]1052 set x [expr {(2.0 * double($x)/$w) - 1.0}]1053 set y [expr {(2.0 * double($y)/$h) - 1.0}]1054 }1055 1060 SendCmd "mouse release $button $x $y" 1061 } 1062 1063 itcl::body Rappture::MapViewer::MouseMotion {} { 1064 SendCmd "mouse motion $_motion(x) $_motion(y)" 1065 set _motion(pending) 0 1066 } 1067 1068 itcl::body Rappture::MapViewer::MouseScroll {direction} { 1069 switch -- $direction { 1070 "up" { 1071 SendCmd "mouse scroll 1" 1072 } 1073 "down" { 1074 SendCmd "mouse scroll -1" 1075 } 1076 } 1056 1077 } 1057 1078 … … 1076 1097 } 1077 1098 1078 itcl::body Rappture::MapViewer::MouseMotion {} {1079 if {0} {1080 set w [winfo width $itk_component(view)]1081 set h [winfo height $itk_component(view)]1082 set x [expr {(2.0 * double($_motion(x))/$w) - 1.0}]1083 set y [expr {(2.0 * double($_motion(y))/$h) - 1.0}]1084 }1085 SendCmd "mouse motion $_motion(x) $_motion(y)"1086 set _motion(pending) 01087 }1088 1089 itcl::body Rappture::MapViewer::MouseScroll {direction} {1090 switch -- $direction {1091 "up" {1092 SendCmd "mouse scroll 1"1093 }1094 "down" {1095 SendCmd "mouse scroll -1"1096 }1097 }1098 }1099 1100 1099 # ---------------------------------------------------------------------- 1101 1100 # USAGE: Zoom in 1102 1101 # USAGE: Zoom out 1103 1102 # USAGE: Zoom reset 1103 # $this Zoom click x y 1104 # $this Zoom drag x y 1105 # $this Zoom release x y 1104 1106 # 1105 1107 # Called automatically when the user clicks on one of the zoom 1106 1108 # controls for this widget. Changes the zoom for the current view. 1107 # ---------------------------------------------------------------------- 1108 itcl::body Rappture::MapViewer::Zoom {option} { 1109 # Also implements mouse zoom. 1110 # ---------------------------------------------------------------------- 1111 itcl::body Rappture::MapViewer::Zoom {option {x 0} {y 0}} { 1109 1112 switch -- $option { 1110 1113 "in" { 1111 set _view(zoom) [expr {$_view(zoom)*1.25}] 1112 #SendCmd "camera zoom $_view(zoom)" 1114 # z here is normalized mouse Y delta 1113 1115 set z -0.25 1114 1116 SendCmd "camera zoom $z" 1115 1117 } 1116 1118 "out" { 1117 set _view(zoom) [expr {$_view(zoom)*0.8}] 1118 #SendCmd "camera zoom $_view(zoom)" 1119 # z here is normalized mouse Y delta 1119 1120 set z 0.25 1120 1121 SendCmd "camera zoom $z" 1121 1122 } 1122 1123 "reset" { 1123 array set _view { 1124 qw 1.0 1125 qx 0.0 1126 qy 0.0 1127 qz 0.0 1128 zoom 1.0 1129 xpan 0.0 1130 ypan 0.0 1131 } 1132 if { $_first != "" } { 1133 set location [$_first hints camera] 1134 if { $location != "" } { 1135 array set _view $location 1136 } 1137 } 1138 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1139 $_arcball quaternion $q 1140 DoRotate 1141 SendCmd "camera reset" 1142 } 1143 } 1144 } 1145 1146 itcl::body Rappture::MapViewer::PanCamera {} { 1147 set x $_view(xpan) 1148 set y $_view(ypan) 1149 SendCmd "camera pan $x $y" 1124 SendCmd "camera dist $_view(distance)" 1125 } 1126 "click" { 1127 set _click(x) $x 1128 set _click(y) $y 1129 $itk_component(view) configure -cursor hand1 1130 } 1131 "drag" { 1132 if { ![info exists _click(x)] } { 1133 set _click(x) $x 1134 } 1135 if { ![info exists _click(y)] } { 1136 set _click(y) $y 1137 } 1138 set h [winfo height $itk_component(view)] 1139 set dy [expr ($_click(y) - $y)/double($h)] 1140 set _click(x) $x 1141 set _click(y) $y 1142 SendCmd "camera zoom $dy" 1143 } 1144 "release" { 1145 Zoom drag $x $y 1146 $itk_component(view) configure -cursor "" 1147 } 1148 } 1150 1149 } 1151 1150 … … 1174 1173 return 1175 1174 } 1176 1177 if {[catch { 1178 # this fails sometimes for no apparent reason 1179 set dx [expr {double($x-$_click(x))/$w}] 1180 set dy [expr {double($y-$_click(y))/$h}] 1181 }]} { 1182 return 1183 } 1184 if { $dx == 0 && $dy == 0 } { 1185 return 1186 } 1187 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1188 EventuallyRotate $q 1175 set dx [expr ($x - $_click(x))/double($w)] 1176 set dy [expr ($_click(y) - $y)/double($h)] 1189 1177 set _click(x) $x 1190 1178 set _click(y) $y 1179 SendCmd "camera rotate $dx $dy" 1180 #EventuallyRotate $dx $dy 1191 1181 } 1192 1182 } … … 1203 1193 1204 1194 # ---------------------------------------------------------------------- 1205 # USAGE: $this Pan click x y 1195 # USAGE: $this Pan set x y 1196 # $this Pan click x y 1206 1197 # $this Pan drag x y 1207 1198 # $this Pan release x y … … 1217 1208 set x [expr $x / double($w)] 1218 1209 set y [expr $y / double($h)] 1219 set _view(xpan) [expr $_view(xpan) + $x] 1220 set _view(ypan) [expr $_view(ypan) + $y] 1221 PanCamera 1210 SendCmd "camera pan $x $y" 1222 1211 return 1223 1212 } … … 1236 1225 set w [winfo width $itk_component(view)] 1237 1226 set h [winfo height $itk_component(view)] 1238 set dx [expr ($ _click(x) - $x)/double($w)]1227 set dx [expr ($x - $_click(x))/double($w)] 1239 1228 set dy [expr ($_click(y) - $y)/double($h)] 1240 1229 set _click(x) $x 1241 1230 set _click(y) $y 1242 set _view(xpan) [expr $_view(xpan) - $dx] 1243 set _view(ypan) [expr $_view(ypan) - $dy] 1244 PanCamera 1231 SendCmd "camera pan $dx $dy" 1245 1232 } 1246 1233 "release" { … … 1332 1319 itcl::body Rappture::MapViewer::limits { dataobj } { 1333 1320 error "no limits" 1334 foreach layer [$dataobj layers] {1335 set tag $dataobj-$layer1336 1337 foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break1338 if {![info exists limits(xmin)] || $limits(xmin) > $xMin} {1339 set limits(xmin) $xMin1340 }1341 if {![info exists limits(xmax)] || $limits(xmax) < $xMax} {1342 set limits(xmax) $xMax1343 }1344 if {![info exists limits(ymin)] || $limits(ymin) > $yMin} {1345 set limits(ymin) $xMin1346 }1347 if {![info exists limits(ymax)] || $limits(ymax) < $yMax} {1348 set limits(ymax) $yMax1349 }1350 if {![info exists limits(zmin)] || $limits(zmin) > $zMin} {1351 set limits(zmin) $zMin1352 }1353 if {![info exists limits(zmax)] || $limits(zmax) < $zMax} {1354 set limits(zmax) $zMax1355 }1356 }1357 return [array get limits]1358 1321 } 1359 1322 … … 1455 1418 $inner configure -borderwidth 4 1456 1419 1457 label $inner.view_l -text "view" -font "Arial 9" 1458 set f [frame $inner.view] 1459 foreach side { front back left right top bottom } { 1460 button $f.$side -image [Rappture::icon view$side] \ 1461 -command [itcl::code $this SetOrientation $side] 1462 Rappture::Tooltip::for $f.$side "Change the view to $side" 1463 pack $f.$side -side left 1464 } 1465 1466 blt::table $inner \ 1467 0,0 $inner.view_l -anchor e -pady 2 \ 1468 0,1 $inner.view -anchor w -pady 2 1469 1470 set labels { qx qy qz qw xpan ypan zoom } 1471 set row 1 1420 set row 0 1421 1422 set labels { x y z heading pitch distance } 1472 1423 foreach tag $labels { 1473 1424 label $inner.${tag}label -text $tag -font "Arial 9" … … 1482 1433 incr row 1483 1434 } 1484 1485 checkbutton $inner.throw \ 1486 -text "Enable Throw" \ 1487 -font "Arial 9" \ 1488 -variable [itcl::scope _settings(camera-throw)] \ 1489 -command [itcl::code $this AdjustSetting camera-throw] 1490 blt::table $inner \ 1491 $row,0 $inner.throw -anchor w -pady 2 -cspan 2 1492 blt::table configure $inner r$row -resize none 1493 incr row 1435 set labels { srs verticalDatum } 1436 foreach tag $labels { 1437 label $inner.${tag}label -text $tag -font "Arial 9" 1438 entry $inner.${tag} -font "Arial 9" -bg white \ 1439 -textvariable [itcl::scope _view($tag)] 1440 bind $inner.${tag} <KeyPress-Return> \ 1441 [itcl::code $this camera set ${tag}] 1442 blt::table $inner \ 1443 $row,0 $inner.${tag}label -anchor e -pady 2 \ 1444 $row,1 $inner.${tag} -anchor w -pady 2 1445 blt::table configure $inner r$row -resize none 1446 incr row 1447 } 1448 1449 if {$_useServerManip} { 1450 checkbutton $inner.throw \ 1451 -text "Enable Throw" \ 1452 -font "Arial 9" \ 1453 -variable [itcl::scope _settings(camera-throw)] \ 1454 -command [itcl::code $this AdjustSetting camera-throw] 1455 blt::table $inner \ 1456 $row,0 $inner.throw -anchor w -pady 2 -cspan 2 1457 blt::table configure $inner r$row -resize none 1458 incr row 1459 } 1494 1460 1495 1461 blt::table configure $inner c* r* -resize none … … 1501 1467 # camera -- 1502 1468 # 1469 # USAGE: camera get 1470 # This is called by the server to transfer the 1471 # current Viewpoint settings 1472 # USAGE: camera reset 1473 # Reset the camera to the default view 1474 # 1503 1475 itcl::body Rappture::MapViewer::camera {option args} { 1504 1476 switch -- $option { 1505 "show" { 1506 puts [array get _view] 1477 "get" { 1478 # We got the camera settings from the server 1479 foreach name {x y z heading pitch distance srs verticalDatum} value $args { 1480 set _view($name) $value 1481 } 1482 puts stderr "view: $_view(x), $_view(y), $_view(z), $_view(heading), $_view(pitch), $_view(distance), $_view(srs), $_view(verticalDatum)" 1483 } 1484 "reset" { 1485 array set _view { 1486 x 0.0 1487 y 0.0 1488 z 0.0 1489 heading 0.0 1490 pitch 0.0 1491 distance 0.0 1492 srs "" 1493 verticalDatum "" 1494 } 1495 if { $_first != "" } { 1496 # Check if the tool specified a default 1497 set location [$_first hints camera] 1498 if { $location != "" } { 1499 array set _view $location 1500 set duration 0.0 1501 SendCmd [list camera set $_view(x) $_view(y) $_view(z) $_view(heading) $_view(pitch) $_view(distance) $duration $_view(srs) $_view(verticalDatum)] 1502 } else { 1503 SendCmd "camera reset" 1504 # Retrieve the settings 1505 SendCmd "camera get" 1506 } 1507 } else { 1508 SendCmd "camera reset" 1509 # Retrieve the settings 1510 SendCmd "camera get" 1511 } 1507 1512 } 1508 1513 "set" { 1509 1514 set who [lindex $args 0] 1510 set x $_view($who) 1511 set code [catch { string is double $x } result] 1512 if { $code != 0 || !$result } { 1513 return 1515 if {$who != "srs" && $who != "verticalDatum"} { 1516 set val $_view($who) 1517 set code [catch { string is double $val } result] 1518 if { $code != 0 || !$result } { 1519 return 1520 } 1514 1521 } 1515 1522 switch -- $who { 1516 "xpan" - "ypan" { 1517 PanCamera 1518 } 1519 "qx" - "qy" - "qz" - "qw" { 1520 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1521 $_arcball quaternion $q 1522 EventuallyRotate $q 1523 } 1524 "zoom" { 1525 SendCmd "camera zoom $_view(zoom)" 1523 "x" - "y" - "z" - "heading" - "pitch" - "distance" - "srs" - "verticalDatum" { 1524 set duration 0.0 1525 SendCmd [list camera set $_view(x) $_view(y) $_view(z) $_view(heading) $_view(pitch) $_view(distance) $duration $_view(srs) $_view(verticalDatum)] 1526 1526 } 1527 1527 } … … 1704 1704 } 1705 1705 } 1706 }1707 1708 itcl::body Rappture::MapViewer::SetOrientation { side } {1709 array set positions {1710 front "1 0 0 0"1711 back "0 0 1 0"1712 left "0.707107 0 -0.707107 0"1713 right "0.707107 0 0.707107 0"1714 top "0.707107 -0.707107 0 0"1715 bottom "0.707107 0.707107 0 0"1716 }1717 foreach name { qw qx qy qz } value $positions($side) {1718 set _view($name) $value1719 }1720 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1721 $_arcball quaternion $q1722 SendCmd "camera orient $q"1723 #SendCmd "camera reset"1724 set _view(xpan) 01725 set _view(ypan) 01726 set _view(zoom) 1.01727 1706 } 1728 1707
Note: See TracChangeset
for help on using the changeset viewer.