Changeset 1215


Ignore:
Timestamp:
Nov 13, 2008 3:24:00 PM (11 years ago)
Author:
gah
Message:

changes to allow panning and zooming (via scrollwhell)

Location:
trunk
Files:
9 edited

Legend:

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

    r1120 r1215  
    7373    protected method _rebuild {}
    7474    protected method _zoom {option}
    75     protected method _move {option x y}
     75    protected method _pan {option x y}
     76    protected method _rotate {option x y}
    7677
    7778    protected method _state {comp}
     
    9091    private variable _sendobjs ""  ;# list of data objs to send to server
    9192    private variable _receiveids   ;# list of data responses from the server
    92     private variable _click        ;# info used for _move operations
     93    private variable _click        ;# info used for _rotate operations
    9394    private variable _limits       ;# autoscale min/max for all axes
    9495    private variable _view         ;# view params for 3D view
     
    261262
    262263    # set up bindings for rotation
    263     bind $itk_component(3dview) <ButtonPress> \
    264         [itcl::code $this _move click %x %y]
     264    bind $itk_component(3dview) <ButtonPress-1> \
     265        [itcl::code $this _rotate click %x %y]
    265266    bind $itk_component(3dview) <B1-Motion> \
    266         [itcl::code $this _move drag %x %y]
    267     bind $itk_component(3dview) <ButtonRelease> \
    268         [itcl::code $this _move release %x %y]
     267        [itcl::code $this _rotate drag %x %y]
     268    bind $itk_component(3dview) <ButtonRelease-1> \
     269        [itcl::code $this _rotate release %x %y]
    269270    bind $itk_component(3dview) <Configure> \
    270271        [itcl::code $this _send "screen %w %h"]
     272
     273    bind $itk_component(3dview) <ButtonPress-2> \
     274        [itcl::code $this _pan click %x %y]
     275    bind $itk_component(3dview) <B2-Motion> \
     276        [itcl::code $this _pan drag %x %y]
     277    bind $itk_component(3dview) <ButtonRelease-2> \
     278        [itcl::code $this _pan release %x %y]
     279
     280    if {[string equal "x11" [tk windowingsystem]]} {
     281        bind $itk_component(3dview) <4> [itcl::code $this _zoom out]
     282        bind $itk_component(3dview) <5> [itcl::code $this _zoom in]
     283    }
    271284
    272285    set _image(download) [image create photo]
     
    772785
    773786# ----------------------------------------------------------------------
    774 # USAGE: _move click <x> <y>
    775 # USAGE: _move drag <x> <y>
    776 # USAGE: _move release <x> <y>
     787# USAGE: $this _pan click x y
     788#        $this _pan drag x y
     789#        $this _pan release x y
     790#
     791# Called automatically when the user clicks on one of the zoom
     792# controls for this widget.  Changes the zoom for the current view.
     793# ----------------------------------------------------------------------
     794itcl::body Rappture::HeightmapViewer::_pan {option x y} {
     795    if { $option == "click" } {
     796        $itk_component(3dview) configure -cursor hand1
     797    }
     798    if { $option == "drag" || $option == "release" } {
     799        set _view(x) [expr $_view(x) + $x]
     800        set _view(y) [expr $_view(y) + $y]
     801        _send "camera pan $_view(x) $_view(y) 0"
     802    }
     803    if { $option == "release" } {
     804        $itk_component(3dview) configure -cursor ""
     805    }
     806}
     807
     808# ----------------------------------------------------------------------
     809# USAGE: _rotate click <x> <y>
     810# USAGE: _rotate drag <x> <y>
     811# USAGE: _rotate release <x> <y>
    777812#
    778813# Called automatically when the user clicks/drags/releases in the
    779814# plot area.  Moves the plot according to the user's actions.
    780815# ----------------------------------------------------------------------
    781 itcl::body Rappture::HeightmapViewer::_move {option x y} {
     816itcl::body Rappture::HeightmapViewer::_rotate {option x y} {
    782817    switch -- $option {
    783818        click {
     
    790825        drag {
    791826            if {[array size _click] == 0} {
    792                 _move click $x $y
     827                _rotate click $x $y
    793828            } else {
    794829                set w [winfo width $itk_component(3dview)]
     
    839874        }
    840875        release {
    841             _move drag $x $y
     876            _rotate drag $x $y
    842877            $itk_component(3dview) configure -cursor ""
    843878            catch {unset _click}
  • trunk/gui/scripts/molvisviewer.tcl

    r1142 r1215  
    7171    protected method _update { args }
    7272    protected method _rebuild { }
    73     protected method _zoom {option}
     73    protected method _zoom {option {factor 10}}
     74    protected method _pan {option x y}
    7475    protected method _configure {w h}
    7576    protected method _unmap {}
     
    294295
    295296    # set up bindings for rotation
    296     bind $itk_component(3dview) <ButtonPress> \
     297    bind $itk_component(3dview) <ButtonPress-1> \
    297298        [itcl::code $this _vmouse click %b %s %x %y]
    298299    bind $itk_component(3dview) <B1-Motion> \
    299300        [itcl::code $this _vmouse drag 1 %s %x %y]
    300     bind $itk_component(3dview) <ButtonRelease> \
     301    bind $itk_component(3dview) <ButtonRelease-1> \
    301302        [itcl::code $this _vmouse release %b %s %x %y]
     303
     304    bind $itk_component(3dview) <ButtonPress-2> \
     305        [itcl::code $this _pan click %x %y]
     306    bind $itk_component(3dview) <B2-Motion> \
     307        [itcl::code $this _pan drag %x %y]
     308    bind $itk_component(3dview) <ButtonRelease-2> \
     309        [itcl::code $this _pan release %x %y]
     310
     311    if {[string equal "x11" [tk windowingsystem]]} {
     312        bind $itk_component(3dview) <4> [itcl::code $this _zoom out 2]
     313        bind $itk_component(3dview) <5> [itcl::code $this _zoom in 2]
     314    }
    302315
    303316    # set up bindings to bridge mouse events to server
     
    641654
    642655# ----------------------------------------------------------------------
     656# USAGE: $this _pan click x y
     657#        $this _pan drag x y
     658#        $this _pan release x y
     659#
     660# Called automatically when the user clicks on one of the zoom
     661# controls for this widget.  Changes the zoom for the current view.
     662# ----------------------------------------------------------------------
     663itcl::body Rappture::MolvisViewer::_pan {option x y} {
     664    if { ![info exists _mevent(x)] } {
     665        set option "click"
     666    }
     667    if { $option == "click" } {
     668        $itk_component(3dview) configure -cursor hand1
     669    }
     670    if { $option == "drag" || $option == "release" } {
     671        set dx [expr $x - $_mevent(x)]
     672        set dy [expr $y - $_mevent(y)]
     673        _send "pan $dx $dy"
     674    }
     675    set _mevent(x) $x
     676    set _mevent(y) $y
     677    if { $option == "release" } {
     678        $itk_component(3dview) configure -cursor ""
     679    }
     680}
     681
     682# ----------------------------------------------------------------------
    643683# USAGE: _zoom in
    644684# USAGE: _zoom out
     
    648688# controls for this widget.  Changes the zoom for the current view.
    649689# ----------------------------------------------------------------------
    650 itcl::body Rappture::MolvisViewer::_zoom {option} {
     690itcl::body Rappture::MolvisViewer::_zoom {option {factor 10}} {
    651691    switch -- $option {
    652692        "in" {
    653             _send "zoom 10"
     693            _send "zoom $factor"
    654694        }
    655695        "out" {
    656             _send "zoom -10"
     696            _send "zoom -$factor"
    657697        }
    658698        "reset" {
  • trunk/gui/scripts/nanovisviewer.tcl

    r1141 r1215  
    8282    protected method _currentVolumeIds {{what -all}}
    8383    protected method _zoom {option}
    84     protected method _move {option x y}
     84    protected method _pan {option x y}
     85    protected method _rotate {option x y}
    8586    protected method _slice {option args}
    8687    protected method _slicertip {axis}
     
    113114    private variable _style2ids    ;# maps id => style settings
    114115
    115     private variable _click        ;# info used for _move operations
     116    private variable _click        ;# info used for _rotate operations
    116117    private variable _limits       ;# autoscale min/max for all axes
    117118    private variable _view         ;# view params for 3D view
    118        
     119    private variable _mevent
    119120    private variable _isomarkers    ;# array of isosurface level values 0..1
    120121    private variable _styles
     
    168169        psi     0
    169170        zoom    1.0
    170         xfocus  0
    171         yfocus  0
    172         zfocus  0
     171        x       0
     172        y       0
     173        z       0
    173174    }
    174175    set _obj2id(count) 0
     
    464465
    465466    # set up bindings for rotation
    466     bind $itk_component(3dview) <ButtonPress> \
    467         [itcl::code $this _move click %x %y]
     467    bind $itk_component(3dview) <ButtonPress-1> \
     468        [itcl::code $this _rotate click %x %y]
    468469    bind $itk_component(3dview) <B1-Motion> \
    469         [itcl::code $this _move drag %x %y]
    470     bind $itk_component(3dview) <ButtonRelease> \
    471         [itcl::code $this _move release %x %y]
     470        [itcl::code $this _rotate drag %x %y]
     471    bind $itk_component(3dview) <ButtonRelease-1> \
     472        [itcl::code $this _rotate release %x %y]
    472473    bind $itk_component(3dview) <Configure> \
    473474        [itcl::code $this _send "screen %w %h"]
     475
     476    bind $itk_component(3dview) <ButtonPress-2> \
     477        [itcl::code $this _pan click %x %y]
     478    bind $itk_component(3dview) <B2-Motion> \
     479        [itcl::code $this _pan drag %x %y]
     480    bind $itk_component(3dview) <ButtonRelease-2> \
     481        [itcl::code $this _pan release %x %y]
     482
     483    if {[string equal "x11" [tk windowingsystem]]} {
     484        bind $itk_component(3dview) <4> [itcl::code $this _zoom out]
     485        bind $itk_component(3dview) <5> [itcl::code $this _zoom in]
     486    }
    474487
    475488    set _image(download) [image create photo]
     
    11421155
    11431156# ----------------------------------------------------------------------
    1144 # USAGE: _move click <x> <y>
    1145 # USAGE: _move drag <x> <y>
    1146 # USAGE: _move release <x> <y>
     1157# USAGE: _rotate click <x> <y>
     1158# USAGE: _rotate drag <x> <y>
     1159# USAGE: _rotate release <x> <y>
    11471160#
    11481161# Called automatically when the user clicks/drags/releases in the
    11491162# plot area.  Moves the plot according to the user's actions.
    11501163# ----------------------------------------------------------------------
    1151 itcl::body Rappture::NanovisViewer::_move {option x y} {
     1164itcl::body Rappture::NanovisViewer::_rotate {option x y} {
    11521165    switch -- $option {
    11531166        click {
     
    11601173        drag {
    11611174            if {[array size _click] == 0} {
    1162                 _move click $x $y
     1175                _rotate click $x $y
    11631176            } else {
    11641177                set w [winfo width $itk_component(3dview)]
     
    12111224        }
    12121225        release {
    1213             _move drag $x $y
     1226            _rotate drag $x $y
    12141227            $itk_component(3dview) configure -cursor ""
    12151228            catch {unset _click}
     
    12181231            error "bad option \"$option\": should be click, drag, release"
    12191232        }
     1233    }
     1234}
     1235
     1236# ----------------------------------------------------------------------
     1237# USAGE: $this _pan click x y
     1238#        $this _pan drag x y
     1239#        $this _pan release x y
     1240#
     1241# Called automatically when the user clicks on one of the zoom
     1242# controls for this widget.  Changes the zoom for the current view.
     1243# ----------------------------------------------------------------------
     1244itcl::body Rappture::NanovisViewer::_pan {option x y} {
     1245    if { $option == "click" } {
     1246        $itk_component(3dview) configure -cursor hand1
     1247    }
     1248    if { $option == "drag" || $option == "release" } {
     1249        set _view(x) [expr $_view(x) + $x]
     1250        set _view(y) [expr $_view(y) + $y]
     1251        _send "camera pan $_view(x) $_view(y) 0"
     1252    }
     1253    if { $option == "release" } {
     1254        $itk_component(3dview) configure -cursor ""
    12201255    }
    12211256}
  • trunk/packages/vizservers/nanovis/Command.cpp

    r1194 r1215  
    694694
    695695static int
    696 CameraAimOp(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
    697 {
    698     double x0, y0, z0;
    699     if ((Tcl_GetDoubleFromObj(interp, objv[2], &x0) != TCL_OK) ||
    700         (Tcl_GetDoubleFromObj(interp, objv[3], &y0) != TCL_OK) ||
    701         (Tcl_GetDoubleFromObj(interp, objv[4], &z0) != TCL_OK)) {
    702         return TCL_ERROR;
    703     }
    704     NanoVis::cam->aim(x0, y0, z0);
    705     return TCL_OK;
    706 }
    707 
    708 static int
    709 CameraAngleOp(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
    710 {
    711     double xangle, yangle, zangle;
    712     if ((Tcl_GetDoubleFromObj(interp, objv[2], &xangle) != TCL_OK) ||
    713         (Tcl_GetDoubleFromObj(interp, objv[3], &yangle) != TCL_OK) ||
    714         (Tcl_GetDoubleFromObj(interp, objv[4], &zangle) != TCL_OK)) {
    715         return TCL_ERROR;
    716     }
    717     NanoVis::cam->rotate(xangle, yangle, zangle);
    718     return TCL_OK;
    719 }
     696CameraPanOp(ClientData cdata, Tcl_Interp *interp, int objc,
     697             Tcl_Obj *const *objv)
     698{
     699    double dx, dy, dz;
     700    if ((Tcl_GetDoubleFromObj(interp, objv[2], &dx) != TCL_OK) ||
     701        (Tcl_GetDoubleFromObj(interp, objv[3], &dy) != TCL_OK) ||
     702        (Tcl_GetDoubleFromObj(interp, objv[4], &dz) != TCL_OK)) {
     703        return TCL_ERROR;
     704    }
     705    NanoVis::cam->aim(dx, dy, dz);
     706    NanoVis::cam->x(dx);
     707    NanoVis::cam->y(dy);
     708    NanoVis::cam->z(dz);
     709    return TCL_OK;
     710}
     711
     712static int
     713CameraAimOp(ClientData cdata, Tcl_Interp *interp, int objc,
     714            Tcl_Obj *const *objv)
     715{
     716    double x, y, z;
     717    if ((Tcl_GetDoubleFromObj(interp, objv[2], &x) != TCL_OK) ||
     718        (Tcl_GetDoubleFromObj(interp, objv[3], &y) != TCL_OK) ||
     719        (Tcl_GetDoubleFromObj(interp, objv[4], &z) != TCL_OK)) {
     720        return TCL_ERROR;
     721    }
     722    NanoVis::cam->aim(x, y, z);
     723    return TCL_OK;
     724}
     725
     726static int
     727CameraAngleOp(ClientData cdata, Tcl_Interp *interp, int objc,
     728              Tcl_Obj *const *objv)
     729{
     730    double theta, phi, psi;
     731    if ((Tcl_GetDoubleFromObj(interp, objv[2], &phi) != TCL_OK) ||
     732        (Tcl_GetDoubleFromObj(interp, objv[3], &theta) != TCL_OK) ||
     733        (Tcl_GetDoubleFromObj(interp, objv[4], &psi) != TCL_OK)) {
     734        return TCL_ERROR;
     735    }
     736    NanoVis::cam->rotate(phi, theta, psi);
     737    return TCL_OK;
     738}
     739
    720740
    721741static int
     
    726746        return TCL_ERROR;
    727747    }
    728     NanoVis::zoom(zoom);
     748    NanoVis::cam->z(-2.5 / zoom);
    729749    return TCL_OK;
    730750}
     
    733753    {"aim",     2, CameraAimOp,      5, 5, "x y z",},
    734754    {"angle",   2, CameraAngleOp,    5, 5, "xAngle yAngle zAngle",},
     755    {"pan",     1, CameraPanOp,      5, 5, "x y z",},
    735756    {"zoom",    1, CameraZoomOp,     3, 3, "factor",},
    736757};
     
    21282149
    21292150    // the variables below should be reassigned
    2130     int heightmap_index = 0;
    21312151    int image_width = 512;
    21322152    int image_height = 512;
  • trunk/packages/vizservers/nanovis/NvCamera.cpp

    r953 r1215  
    2020
    2121NvCamera::NvCamera(int startx, int starty, int w, int h,
    22                    double loc_x, double loc_y, double loc_z,
    23                    double target_x, double target_y, double target_z,
    24                    int angle_x, int angle_y, int angle_z):
    25     location(Vector3(loc_x, loc_y, loc_z)),
    26     target(Vector3(target_x, target_y, target_z)),
    27     angle(Vector3(angle_x, angle_y, angle_z)),
    28     width(w),
    29     height(h),
    30     startX(startx),
    31     startY(starty)
     22                   float loc_x, float loc_y, float loc_z,
     23                   float target_x, float target_y, float target_z,
     24                   float angle_x, float angle_y, float angle_z):
     25    location_(Vector3(loc_x, loc_y, loc_z)),
     26    target_(Vector3(target_x, target_y, target_z)),
     27    angle_(Vector3(angle_x, angle_y, angle_z)),
     28    width_(w),
     29    height_(h),
     30    startX_(startx),
     31    startY_(starty)
    3232{
    3333    /*empty*/
    3434}
    3535
    36 NvCamera::~NvCamera()
    37 {
    38     /*empty*/
    39 }       
    40 
    41 void
    42 NvCamera::move(double loc_x, double loc_y, double loc_z)
    43 {
    44     location = Vector3(loc_x, loc_y, loc_z);
    45 }
    46 
    47 void
    48 NvCamera::aim(double target_x, double target_y, double target_z)
    49 {
    50     target = Vector3(target_x, target_y, target_z);
    51 }
    52 
    53 void
    54 NvCamera::rotate(double angle_x, double angle_y, double angle_z)
    55 {
    56     angle = Vector3(angle_x, angle_y, angle_z);
    57 }
    5836
    5937void
     
    6139{
    6240    //fprintf(stderr, "camera: %d, %d\n", width, height);
    63     glViewport(startX, startY, width, height);
     41    glViewport(startX_, startY_, width_, height_);
    6442    glMatrixMode(GL_PROJECTION);
    6543    glLoadIdentity();
    66     gluPerspective(30, (GLdouble)(width - startX)/(GLdouble)(height - startY),
    67         0.1, 50.0);
     44    gluPerspective(30,
     45                   (GLdouble)(width_ - startX_)/(GLdouble)(height_ - startY_),
     46                   0.1, 50.0);
    6847
    6948    glMatrixMode(GL_MODELVIEW);
    7049    glLoadIdentity();
    7150
    72     gluLookAt(location.x, location.y, location.z,
    73               target.x, target.y, target.z,
     51    gluLookAt(location_.x, location_.y, location_.z,
     52              target_.x, target_.y, target_.z,
    7453              0., 1., 0.);
    7554
    76     glRotated(angle.x, 1., 0., 0.);
    77     glRotated(angle.y, 0., 1., 0.);
    78     glRotated(angle.z, 0., 0., 1.);
     55    glRotated(angle_.x, 1., 0., 0.);
     56    glRotated(angle_.y, 0., 1., 0.);
     57    glRotated(angle_.z, 0., 0., 1.);
    7958}
    8059
    81 void
    82 NvCamera::set_screen_size(int sx, int sy, int w, int h)
    83 {
    84     width = w, height = h;
    85     startX = sx, startY = sy;
    86 }
  • trunk/packages/vizservers/nanovis/NvCamera.h

    r953 r1215  
    2222class NvCamera {
    2323
    24 public:
    25     Vector3 location;           //Location of the camera in the scene
    26     Vector3 target;             //Location the camera is looking at. 
     24    Vector3 location_;          //Location of the camera in the scene
     25    Vector3 target_;            //Location the camera is looking at. 
    2726                                //location and target: two points define the
    2827                                //line-of-sight
    29     Vector3 angle;              //rotation angles of camera along x, y, z
    30     int width;                  //screen size
    31     int height;                 //screen size
    32     int startX;
    33     int startY;
     28    Vector3 angle_;             //rotation angles of camera along x, y, z
     29    int width_;                 //screen width
     30    int height_;                //screen height
     31    int startX_;
     32    int startY_;
    3433
    35     ~NvCamera();
     34public:
     35    ~NvCamera(void) {
     36        /*empty*/
     37    }   
    3638    NvCamera(int startx, int starty, int w, int h,
    37              double loc_x, double loc_y, double loc_z,
    38              double target_x, double target_y, double target_z,
    39              int angle_x, int angle_y, int angle_z);
    40     void move(double loc_x, double loc_y, double loc_z); //move location of camera
    41     void aim(double target_x, double target_y, double target_z); //change target point
    42     void rotate(double angle_x, double angle_y, double angle_z); //change target point
    43     void activate(); //make the camera setting active, this has to be called
    44                      //before drawing things.
    45     void set_screen_size(int startx, int starty, int w, int h);
     39             float loc_x, float loc_y, float loc_z,
     40             float target_x, float target_y, float target_z,
     41             float angle_x, float angle_y, float angle_z);
     42
     43    //move location of camera
     44    void x(double loc_x) {
     45        location_.x = loc_x;
     46    }
     47    float x(void) {
     48        return location_.x;
     49    }
     50    void y(double loc_y) {
     51        location_.y = loc_y;
     52    }
     53    float y(void) {
     54        return location_.y;
     55    }
     56    void z(double loc_z) {
     57        location_.z = loc_z;
     58    }
     59    float z(void) {
     60        return location_.z;
     61    }
     62
     63    void aim(double target_x, double target_y, double target_z) {
     64        target_ = Vector3(target_x, target_y, target_z);
     65    }
     66    Vector3 aim(void) {
     67        return target_;
     68    }
     69    void rotate(double angle_x, double angle_y, double angle_z) {
     70        angle_ = Vector3(angle_x, angle_y, angle_z);
     71    }
     72    void rotate(Vector3 angle) {
     73        angle_ = angle;
     74    }
     75    Vector3 rotate(void) {
     76        return angle_;
     77    }
     78    void set_screen_size(int sx, int sy, int w, int h) {
     79        width_ = w, height_ = h;
     80        startX_ = sx, startY_ = sy;
     81    }
     82    void activate(void); //make the camera setting active, this has to be
     83                         //called before drawing things.
    4684};
    4785
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1211 r1215  
    171171
    172172// Object rotation angles
    173 static float live_rot_x = 90.;
    174 static float live_rot_y = 180.;
    175 static float live_rot_z = -135;
     173const float def_rot_x = 90.;
     174const float def_rot_y = 180.;
     175const float def_rot_z = -135;
    176176
    177177// Object translation location from the origin
    178 static float live_obj_x = -0.0;
    179 static float live_obj_y = -0.0;
    180 static float live_obj_z = -2.5;
     178const float def_obj_x = -0.0;
     179const float def_obj_y = -0.0;
     180const float def_obj_z = -2.5;
    181181
    182182
     
    507507    }
    508508    return tf;
    509 }
    510 
    511 void
    512 NanoVis::zoom(double zoom)
    513 {
    514     live_obj_z = -2.5 / zoom;
    515     cam->move(live_obj_x, live_obj_y, live_obj_z);
    516509}
    517510
     
    884877   //create the camera with default setting
    885878   cam = new NvCamera(0, 0, win_width, win_height,
    886                    live_obj_x, live_obj_y, live_obj_z,
    887                    0., 0., 100.,
    888                    (int)live_rot_x, (int)live_rot_y, (int)live_rot_z);
     879                      def_obj_x, def_obj_y, def_obj_z,
     880                      0., 0., 100.,
     881                      def_rot_x, def_rot_y, def_rot_z);
    889882
    890883   glEnable(GL_TEXTURE_2D);
     
    13361329        float y = vert[3*i+1];
    13371330        float z = vert[3*i+2];
    1338 
    1339         float dis = (x-live_obj_x)*(x-live_obj_x) + (y-live_obj_y)*(y-live_obj_y) + (z-live_obj_z)*(z-live_obj_z);
     1331        float dx, dy, dz;
     1332        dx = x - cam->x();
     1333        dy = y - cam->y();
     1334        dz = z - cam->z();
     1335        float dis = (dx * dx) + (dy * dy) + (dz * dz);
    13401336        p[i].x = x;
    13411337        p[i].y = y;
     
    19291925NanoVis::update_rot(int delta_x, int delta_y)
    19301926{
    1931     live_rot_x += delta_x;
    1932     live_rot_y += delta_y;
    1933 
    1934     if (live_rot_x > 360.0) {
    1935         live_rot_x -= 360.0;
    1936     } else if(live_rot_x < -360.0) {
    1937         live_rot_x += 360.0;
    1938     }
    1939     if (live_rot_y > 360.0) {
    1940         live_rot_y -= 360.0;
    1941     } else if(live_rot_y < -360.0) {
    1942         live_rot_y += 360.0;
    1943     }
    1944     cam->rotate(live_rot_x, live_rot_y, live_rot_z);
     1927    Vector3 angle;
     1928
     1929    angle = cam->rotate();
     1930    angle.x += delta.x;
     1931    angle.y += delta.y;
     1932
     1933    if (angle.x > 360.0) {
     1934        angle.x -= 360.0;
     1935    } else if(angle.x < -360.0) {
     1936        angle.x += 360.0;
     1937    }
     1938    if (angle.y > 360.0) {
     1939        angle.y -= 360.0;
     1940    } else if(angle.y < -360.0) {
     1941        angle.y += 360.0;
     1942    }
     1943    cam->rotate(angle);
    19451944}
    19461945
     
    19481947NanoVis::update_trans(int delta_x, int delta_y, int delta_z)
    19491948{
    1950     live_obj_x += delta_x*0.03;
    1951     live_obj_y += delta_y*0.03;
    1952     live_obj_z += delta_z*0.03;
     1949    cam->x(cam->x() + delta_x * 0.03);
     1950    cam->y(cam->y() + delta_y * 0.03);
     1951    cam->z(cam->z() + delta_z * 0.03);
    19531952}
    19541953
     
    19881987       break;
    19891988   case 'w': //zoom out
    1990        live_obj_z-=0.05;
     1989       cam->z(cam->z() - 0.05);
    19911990       log = true;
    1992        cam->move(live_obj_x, live_obj_y, live_obj_z);
    19931991       break;
    19941992   case 's': //zoom in
    1995        live_obj_z+=0.05;
     1993       cam->z(cam->z() + 0.05);
    19961994       log = true;
    1997        cam->move(live_obj_x, live_obj_y, live_obj_z);
    19981995       break;
    19991996   case 'a': //left
    2000        live_obj_x-=0.05;
     1997       cam->x(cam->x() - 0.05);
    20011998       log = true;
    2002        cam->move(live_obj_x, live_obj_y, live_obj_z);
    20031999       break;
    20042000   case 'd': //right
    2005        live_obj_x+=0.05;
     2001       cam->x(cam->x() + 0.05);
    20062002       log = true;
    2007        cam->move(live_obj_x, live_obj_y, live_obj_z);
    20082003       break;
    20092004   case 'i':
     
    20272022#ifdef EVENTLOG
    20282023   if(log){
    2029        float param[3] = {live_obj_x, live_obj_y, live_obj_z};
     2024       float param[3];
     2025       param[0] = cam->x();
     2026       param[1] = cam->y();
     2027       param[2] = cam->z();
    20302028       Event* tmp = new Event(EVENT_MOVE, param, NvGetTimeInterval());
    20312029       tmp->write(event_log);
     
    20702068
    20712069#ifdef EVENTLOG
    2072     float param[3] = {live_rot_x, live_rot_y, live_rot_z};
    2073     Event* tmp = new Event(EVENT_ROTATE, param, NvGetTimeInterval());
     2070    Vector3 angle = cam->rotate();
     2071    Event* tmp = new Event(EVENT_ROTATE, &angle, NvGetTimeInterval());
    20742072    tmp->write(event_log);
    20752073    delete tmp;
  • trunk/packages/vizservers/nanovis/nanovis.h

    r1194 r1215  
    163163    static void update(void);
    164164    static void display_offscreen_buffer();
    165     static void zoom(double zoom);
    166165    static int render_legend(TransferFunction *tf, double min, double max,
    167166        int width, int height, const char* volArg);
  • trunk/packages/vizservers/pymolproxy/pymolproxy.c

    r1213 r1215  
    10871087{
    10881088    double factor = 0.0;
    1089     double zmove = 0.0;
    10901089    PymolProxy *proxyPtr = clientData;
    10911090    int defer = 0, push = 0, arg, varg = 1;
     
    11031102        }
    11041103    }
    1105     zmove = factor * -75;
    1106  
    11071104    proxyPtr->need_update = !defer || push;
    11081105    proxyPtr->immediate_update  |= push;
    11091106    proxyPtr->invalidate_cache = 1;
    1110 
    1111     if (zmove != 0.0)
    1112         Send(proxyPtr,"move z, %f\n", factor);
    1113 
     1107    if (factor != 0.0) {
     1108        Send(proxyPtr,"move z,%f\n", factor);
     1109    }
     1110    return proxyPtr->status;
     1111}
     1112
     1113static int
     1114PanCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     1115        const char *argv[])
     1116{
     1117    PymolProxy *proxyPtr = clientData;
     1118    double x, y;
     1119    int i;
     1120    int defer, push;
     1121
     1122    clear_error(proxyPtr);
     1123    defer = push = FALSE;
     1124    for (i = 1; i < argc; i++) {
     1125        if (strcmp(argv[i],"-defer") == 0) {
     1126            defer = 1;
     1127        } else if (strcmp(argv[i],"-push") == 0) {
     1128            push = 1;
     1129        } else {
     1130            break;
     1131        }
     1132    }
     1133    if ((Tcl_GetDouble(interp, argv[i], &x) != TCL_OK) ||
     1134        (Tcl_GetDouble(interp, argv[i+1], &y) != TCL_OK)) {
     1135        return TCL_ERROR;
     1136    }
     1137    proxyPtr->need_update = !defer || push;
     1138    proxyPtr->immediate_update  |= push;
     1139    proxyPtr->invalidate_cache = 1;
     1140    if (x != 0.0) {
     1141        Send(proxyPtr,"move x,%f\n", x * 0.005);
     1142    }   
     1143    if (y != 0.0) {
     1144        Send(proxyPtr,"move y,%f\n", -y * 0.005);
     1145    }   
    11141146    return proxyPtr->status;
    11151147}
     
    13261358    Tcl_CreateCommand(interp, "disable", DisableCmd,    &proxy, NULL);
    13271359    Tcl_CreateCommand(interp, "enable",  EnableCmd,     &proxy, NULL);
     1360    Tcl_CreateCommand(interp, "pan",     PanCmd,        &proxy, NULL);
    13281361
    13291362    // Main Proxy Loop
     
    13551388        if (!proxy.immediate_update) {
    13561389            status = poll(ufd, 3, timeout);
    1357             trace("result of poll = %d: %s", status, strerror(errno));
    13581390        }
    13591391        if ( status < 0 ) {
     
    14051437                if (nRead <= 0) {
    14061438                    /* It's possible to have already drained the channel in
    1407                      * response to a client command (handled above). Skip
     1439                     * response to a client command handled above. Skip
    14081440                     * it if we're blocking. */
    14091441                    if ((errno == EAGAIN) || (errno == EINTR)) {
Note: See TracChangeset for help on using the changeset viewer.