Changeset 4646 for trunk/gui/scripts/mapviewer.tcl
- Timestamp:
- Oct 8, 2014, 10:27:06 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/mapviewer.tcl
r4637 r4646 70 70 protected method CurrentLayers {args} 71 71 protected method Disconnect {} 72 protected method DoPan {} 72 73 protected method DoResize {} 73 74 protected method DoRotate {} … … 88 89 protected method ReceiveImage { args } 89 90 protected method Rotate {option x y} 91 protected method Select {option x y} 90 92 protected method Zoom {option {x 0} {y 0}} 91 93 … … 96 98 private method BuildTerrainTab {} 97 99 private method ChangeLayerVisibility { dataobj layer } 98 private method EventuallyHandleMotionEvent { x y } 100 private method EventuallyHandleMotionEvent { x y } 101 private method EventuallyPan { dx dy } 99 102 private method EventuallyResize { w h } 100 103 private method EventuallyRotate { dx dy } … … 115 118 private variable _click; # info used for rotate operations 116 119 private variable _view; # view params for 3D view 120 private variable _pan; 121 private variable _rotate; 122 private variable _motion; 117 123 private variable _settings 118 124 private variable _visibility … … 122 128 # needs to be reinitialized. 123 129 private variable _initCamera 1; 124 private variable _haveTerrain 0 130 private variable _haveTerrain 0; 125 131 126 132 private variable _first "" ;# This is the topmost dataset. … … 133 139 private variable _height 0 134 140 private variable _resizePending 0 135 private variable _rotatePending 0136 private variable _rotateDelay 150137 private variable _motion138 141 private variable _sendEarthFile 0 139 142 private variable _useServerManip 0 140 143 private variable _labelCount 0 144 private variable _b1mode "pan" 141 145 } 142 146 … … 161 165 $_dispatcher register !resize 162 166 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 167 168 # Pan event 169 $_dispatcher register !pan 170 $_dispatcher dispatch $this !pan "[itcl::code $this DoPan]; list" 163 171 164 172 # Rotate event … … 187 195 x 0 188 196 y 0 197 } 198 array set _pan { 199 compress 1 200 delay 100 201 pending 0 202 x 0 203 y 0 204 } 205 array set _rotate { 206 azimuth 0 207 compress 1 208 delay 100 209 elevation 0 210 pending 0 189 211 } 190 212 # This array holds the Viewpoint parameters that the … … 366 388 +[itcl::code $this Pin delete %x %y] 367 389 390 bind $itk_component(view) <Shift-ButtonPress-1> \ 391 [itcl::code $this Select click %x %y] 392 bind $itk_component(view) <B1-Motion> \ 393 +[itcl::code $this Select drag %x %y] 394 bind $itk_component(view) <Shift-ButtonRelease-1> \ 395 +[itcl::code $this Select release %x %y] 396 397 if {1} { 368 398 # Bindings for rotation via mouse 369 399 bind $itk_component(view) <ButtonPress-2> \ … … 373 403 bind $itk_component(view) <ButtonRelease-2> \ 374 404 [itcl::code $this Rotate release %x %y] 405 } 375 406 376 407 # Bindings for zoom via mouse … … 473 504 474 505 itcl::body Rappture::MapViewer::DoRotate {} { 475 SendCmd "camera rotate $_view(azimuth) $_view(elevation)" 476 set _rotatePending 0 506 SendCmd "camera rotate $_rotate(azimuth) $_rotate(elevation)" 507 set _rotate(azimuth) 0 508 set _rotate(elevation) 0 509 set _rotate(pending) 0 477 510 } 478 511 … … 486 519 } 487 520 521 itcl::body Rappture::MapViewer::DoPan {} { 522 SendCmd "camera pan $_pan(x) $_pan(y)" 523 set _pan(x) 0 524 set _pan(y) 0 525 set _pan(pending) 0 526 } 527 528 itcl::body Rappture::MapViewer::EventuallyPan { dx dy } { 529 set _pan(x) [expr $_pan(x) + $dx] 530 set _pan(y) [expr $_pan(y) + $dy] 531 if { !$_pan(compress) } { 532 DoPan 533 return 534 } 535 if { !$_pan(pending) } { 536 set _pan(pending) 1 537 $_dispatcher event -after $_pan(delay) !pan 538 } 539 } 540 488 541 itcl::body Rappture::MapViewer::EventuallyRotate { dx dy } { 489 set _view(azimuth) $dx 490 set _view(elevation) $dy 491 if { !$_rotatePending } { 492 set _rotatePending 1 493 $_dispatcher event -after $_rotateDelay !rotate 542 set _rotate(azimuth) [expr $_rotate(azimuth) + $dx] 543 set _rotate(elevation) [expr $_rotate(elevation) + $dy] 544 if { !$_rotate(compress) } { 545 DoRotate 546 return 547 } 548 if { !$_rotate(pending) } { 549 set _rotate(pending) 1 550 $_dispatcher event -after $_rotate(delay) !rotate 494 551 } 495 552 } … … 845 902 VisViewer::Disconnect 846 903 904 $_dispatcher cancel !pan 905 $_dispatcher cancel !motion 847 906 $_dispatcher cancel !rebuild 848 907 $_dispatcher cancel !resize 849 908 $_dispatcher cancel !rotate 850 $_dispatcher cancel !motion851 909 # disconnected -- no more data sitting on server 852 910 array unset _layers … … 1265 1323 set _click(x) $x 1266 1324 set _click(y) $y 1325 set _rotate(azimuth) 0 1326 set _rotate(elevation) 0 1267 1327 } 1268 1328 "drag" { … … 1280 1340 set _click(y) $y 1281 1341 if {[expr (abs($dx) > 0.0 || abs($dy) > 0.0)]} { 1282 SendCmd "camera rotate $dx $dy"1283 #EventuallyRotate $dx $dy1342 #SendCmd "camera rotate $dx $dy" 1343 EventuallyRotate $dx $dy 1284 1344 } 1285 1345 } … … 1292 1352 default { 1293 1353 error "bad option \"$option\": should be click, drag, release" 1354 } 1355 } 1356 } 1357 1358 itcl::body Rappture::MapViewer::Select {option x y} { 1359 switch -- $option { 1360 "click" { 1361 set _click(x) $x 1362 set _click(y) $y 1363 set _b1mode "select" 1364 SendCmd "map box init $x $y" 1365 } 1366 "drag" { 1367 if {$_b1mode == "select"} { 1368 SendCmd "map box update $x $y" 1369 } 1370 } 1371 "release" { 1372 set _b1mode "" 1373 if {$_click(x) == $x && 1374 $_click(y) == $y} { 1375 SendCmd "map box clear" 1376 } 1294 1377 } 1295 1378 } … … 1335 1418 set _click(x) $x 1336 1419 set _click(y) $y 1420 set _pan(x) 0 1421 set _pan(y) 0 1337 1422 $itk_component(view) configure -cursor hand1 1423 set _b1mode "pan" 1338 1424 } 1339 1425 "drag" { 1426 if {$_b1mode != "pan"} { 1427 return 1428 } 1340 1429 if { ![info exists _click(x)] } { 1341 1430 set _click(x) $x … … 1351 1440 set _click(y) $y 1352 1441 if {[expr (abs($dx) > 0.0 || abs($dy) > 0.0)]} { 1353 SendCmd "camera pan $dx $dy" 1442 EventuallyPan $dx $dy 1443 #SendCmd "camera pan $dx $dy" 1354 1444 } 1355 1445 } … … 1357 1447 Pan drag $x $y 1358 1448 $itk_component(view) configure -cursor "" 1449 set _b1mode "" 1359 1450 } 1360 1451 default {
Note: See TracChangeset
for help on using the changeset viewer.