Ignore:
Timestamp:
Sep 25, 2005 12:40:17 PM (19 years ago)
Author:
mmc
Message:

Lots of fixes for app-pntoy and other tools:

  • Fixed plotting to recognize "-color name" in the style section, and to use auto colors for overlayed plots.
  • Fixed x-y plotting to keep axes instead of resetting when flipping back and forth between plots.
  • Fixed 1D fields to support new lin/log limits queries, so it plots properly.
  • Added support for <string> output values.
  • Fixed molecular viewer so that 3D rotation is unconstrained and more intuitive.
  • Fixed Rappture::exec to handle newlines properly. Sometimes output would get all mixed together without newlines. Works better now.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/moleculeViewer.tcl

    r54 r64  
    6666    protected method _zoom {option}
    6767    protected method _move {option x y}
    68     protected method _3dView {theta phi}
     68    protected method _3dView {theta phi psi}
    6969    protected method _color2rgb {color}
    7070
     
    120120    set _view(theta) 0
    121121    set _view(phi) 0
     122    set _view(psi) 0
    122123
    123124    itk_component add controls {
     
    344345        reset {
    345346            $this-ren ResetCamera
    346             _3dView 45 45
     347            _3dView 45 45 0
    347348        }
    348349    }
     
    367368            set _click(theta) $_view(theta)
    368369            set _click(phi) $_view(phi)
     370            set _click(psi) $_view(psi)
    369371        }
    370372        drag {
     
    377379                    return
    378380                }
    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                }
    381389
    382390                #
    383391                # Rotate the camera in 3D
    384392                #
     393                if {$_view(psi) > 90 || $_view(psi) < -90} {
     394                    # when psi is flipped around, theta moves backwards
     395                    set dy [expr {-$dy}]
     396                }
    385397                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
    391416                emblems fixPosition
    392417                $_dispatcher event -idle !render
     
    408433
    409434# ----------------------------------------------------------------------
    410 # USAGE: _3dView <theta> <phi>
     435# USAGE: _3dView <theta> <phi> <psi>
    411436#
    412437# Used internally to change the position of the camera for 3D data
     
    415440# Both angles are in degrees.
    416441# ----------------------------------------------------------------------
    417 itcl::body Rappture::MoleculeViewer::_3dView {theta phi} {
     442itcl::body Rappture::MoleculeViewer::_3dView {theta phi psi} {
    418443    set deg2rad 0.0174532927778
    419     set xn [expr {sin($theta*$deg2rad)*cos($phi*$deg2rad)}]
    420     set yn [expr {sin($theta*$deg2rad)*sin($phi*$deg2rad)}]
    421     set zn [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)}]
    422447
    423448    set xm [expr {0.5*($_limits(xmax)+$_limits(xmin))}]
     
    430455
    431456    $cam SetFocalPoint $xm $ym $zm
    432     $cam SetPosition [expr {$xm-$xn}] [expr {$ym-$yn}] [expr {$zm+$zn}]
     457    $cam SetPosition [expr {$xm-$xp}] [expr {$ym-$yp}] [expr {$zm+$zp}]
    433458    $cam ComputeViewPlaneNormal
    434459    $cam SetViewUp 0 0 1  ;# z-dir is up
    435460    $cam OrthogonalizeViewUp
     461    $cam Azimuth $psi
    436462    $this-ren ResetCamera
    437463    $cam SetViewAngle $zoom
     
    442468    set _view(theta) $theta
    443469    set _view(phi) $phi
     470    set _view(psi) $psi
    444471}
    445472
Note: See TracChangeset for help on using the changeset viewer.