Changeset 64 for trunk/gui/scripts/moleculeViewer.tcl
- Timestamp:
- Sep 25, 2005 12:40:17 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/moleculeViewer.tcl
r54 r64 66 66 protected method _zoom {option} 67 67 protected method _move {option x y} 68 protected method _3dView {theta phi }68 protected method _3dView {theta phi psi} 69 69 protected method _color2rgb {color} 70 70 … … 120 120 set _view(theta) 0 121 121 set _view(phi) 0 122 set _view(psi) 0 122 123 123 124 itk_component add controls { … … 344 345 reset { 345 346 $this-ren ResetCamera 346 _3dView 45 45 347 _3dView 45 45 0 347 348 } 348 349 } … … 367 368 set _click(theta) $_view(theta) 368 369 set _click(phi) $_view(phi) 370 set _click(psi) $_view(psi) 369 371 } 370 372 drag { … … 377 379 return 378 380 } 379 set dx [expr {double($x-$_click(x))/$w}] 380 set dy [expr {double($y-$_click(y))/$h}] 381 382 if {[catch { 383 # this fails sometimes for no apparent reason 384 set dx [expr {double($x-$_click(x))/$w}] 385 set dy [expr {double($y-$_click(y))/$h}] 386 }]} { 387 return 388 } 381 389 382 390 # 383 391 # Rotate the camera in 3D 384 392 # 393 if {$_view(psi) > 90 || $_view(psi) < -90} { 394 # when psi is flipped around, theta moves backwards 395 set dy [expr {-$dy}] 396 } 385 397 set theta [expr {$_view(theta) - $dy*180}] 386 if {$theta < 2} { set theta 2 } 387 if {$theta > 178} { set theta 178 } 388 set phi [expr {$_view(phi) - $dx*360}] 389 390 _3dView $theta $phi 398 while {$theta < 0} { set theta [expr {$theta+180}] } 399 while {$theta > 180} { set theta [expr {$theta-180}] } 400 #if {$theta < 2} { set theta 2 } 401 #if {$theta > 178} { set theta 178 } 402 403 if {$theta > 45 && $theta < 135} { 404 set phi [expr {$_view(phi) - $dx*360}] 405 while {$phi < 0} { set phi [expr {$phi+360}] } 406 while {$phi > 360} { set phi [expr {$phi-360}] } 407 set psi $_view(psi) 408 } else { 409 set phi $_view(phi) 410 set psi [expr {$_view(psi) - $dx*360}] 411 while {$psi < -180} { set psi [expr {$psi+360}] } 412 while {$psi > 180} { set psi [expr {$psi-360}] } 413 } 414 415 _3dView $theta $phi $psi 391 416 emblems fixPosition 392 417 $_dispatcher event -idle !render … … 408 433 409 434 # ---------------------------------------------------------------------- 410 # USAGE: _3dView <theta> <phi> 435 # USAGE: _3dView <theta> <phi> <psi> 411 436 # 412 437 # Used internally to change the position of the camera for 3D data … … 415 440 # Both angles are in degrees. 416 441 # ---------------------------------------------------------------------- 417 itcl::body Rappture::MoleculeViewer::_3dView {theta phi } {442 itcl::body Rappture::MoleculeViewer::_3dView {theta phi psi} { 418 443 set deg2rad 0.0174532927778 419 set x n[expr {sin($theta*$deg2rad)*cos($phi*$deg2rad)}]420 set y n[expr {sin($theta*$deg2rad)*sin($phi*$deg2rad)}]421 set z n[expr {cos($theta*$deg2rad)}]444 set xp [expr {sin($theta*$deg2rad)*cos($phi*$deg2rad)}] 445 set yp [expr {sin($theta*$deg2rad)*sin($phi*$deg2rad)}] 446 set zp [expr {cos($theta*$deg2rad)}] 422 447 423 448 set xm [expr {0.5*($_limits(xmax)+$_limits(xmin))}] … … 430 455 431 456 $cam SetFocalPoint $xm $ym $zm 432 $cam SetPosition [expr {$xm-$x n}] [expr {$ym-$yn}] [expr {$zm+$zn}]457 $cam SetPosition [expr {$xm-$xp}] [expr {$ym-$yp}] [expr {$zm+$zp}] 433 458 $cam ComputeViewPlaneNormal 434 459 $cam SetViewUp 0 0 1 ;# z-dir is up 435 460 $cam OrthogonalizeViewUp 461 $cam Azimuth $psi 436 462 $this-ren ResetCamera 437 463 $cam SetViewAngle $zoom … … 442 468 set _view(theta) $theta 443 469 set _view(phi) $phi 470 set _view(psi) $psi 444 471 } 445 472
Note: See TracChangeset
for help on using the changeset viewer.