From 35d330a17023c7105f0a6a3462f428d9fae4e53a Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 22 Dec 2000 17:01:39 +0000 Subject: [PATCH] Corrected Trackball settings for X, Y and Z standard positions --- Common/Context.cpp | 15 ++++++++++++--- Unix/CbInput.cpp | 8 +++++++- Unix/CbOptions.cpp | 6 +++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Common/Context.cpp b/Common/Context.cpp index b86349c0da..2b65dc134a 100644 --- a/Common/Context.cpp +++ b/Common/Context.cpp @@ -1,4 +1,4 @@ -/* $Id: Context.cpp,v 1.23 2000-12-20 15:28:42 geuzaine Exp $ */ +/* $Id: Context.cpp,v 1.24 2000-12-22 17:01:37 geuzaine Exp $ */ #include "Gmsh.h" #include "Const.h" @@ -374,6 +374,12 @@ void Context_T::buildRotmatrix(void) rot[3][1] = 0.0 ; rot[3][2] = 0.0 ; rot[3][3] = 1.0 ; + /* + printf("x=%g y=%g z=%g\n", r[0], r[1], r[2]); + printf("[%g %g %g]\n", rot[0][0], rot[0][1], rot[0][2]); + printf("[%g %g %g]\n", rot[1][0], rot[1][1], rot[1][2]); + printf("[%g %g %g]\n", rot[2][0], rot[2][1], rot[2][2]); + */ } } @@ -385,7 +391,10 @@ void Context_T::addQuaternion (float p1x, float p1y, float p2x, float p2y) add_quats(quat, quaternion, quaternion); } -void Context_T::setQuaternion (float p1x, float p1y, float p2x, float p2y) +void Context_T::setQuaternion (float q0, float q1, float q2, float q3) { - trackball(quaternion,p1x,p1y,p2x,p2y); + quaternion[0] = q0; + quaternion[1] = q1; + quaternion[2] = q2; + quaternion[3] = q3; } diff --git a/Unix/CbInput.cpp b/Unix/CbInput.cpp index f323beb916..15463188ad 100644 --- a/Unix/CbInput.cpp +++ b/Unix/CbInput.cpp @@ -1,4 +1,4 @@ -/* $Id: CbInput.cpp,v 1.12 2000-12-20 12:17:13 geuzaine Exp $ */ +/* $Id: CbInput.cpp,v 1.13 2000-12-22 17:01:39 geuzaine Exp $ */ #include "Gmsh.h" #include "GmshUI.h" @@ -230,12 +230,18 @@ void KeyboardAccel(XEvent *event){ Init(); Draw(); break; case XK_x : case XK_X : + if(CTX.useTrackball) + CTX.setQuaternion(0.,-1./sqrt(2.),0.,1./sqrt(2.)); set_r(0,0.); set_r(1,90.);set_r(2,0.); Init(); Draw(); break; case XK_y : case XK_Y : + if(CTX.useTrackball) + CTX.setQuaternion(1./sqrt(2.),0.,1./sqrt(2.),0.); set_r(0,-90.);set_r(1,0.); set_r(2,0.); Init(); Draw(); break; case XK_z : case XK_Z : + if(CTX.useTrackball) + CTX.setQuaternion(0.,0.,0.,0.); set_r(0,0.); set_r(1,0.); set_r(2,0.); Init(); Draw(); break; case XK_a : diff --git a/Unix/CbOptions.cpp b/Unix/CbOptions.cpp index ff03847e04..d97dfff162 100644 --- a/Unix/CbOptions.cpp +++ b/Unix/CbOptions.cpp @@ -1,4 +1,4 @@ -/* $Id: CbOptions.cpp,v 1.15 2000-12-21 08:02:06 geuzaine Exp $ */ +/* $Id: CbOptions.cpp,v 1.16 2000-12-22 17:01:39 geuzaine Exp $ */ #include "Gmsh.h" #include "GmshUI.h" @@ -98,13 +98,13 @@ void OptionsCb (Widget w, XtPointer client_data, XtPointer call_data){ case OPTIONS_SCALEZ_LOCKED : CTX.slock[2] = !CTX.slock[2]; break; case OPTIONS_XVIEW : if(CTX.useTrackball) - CTX.setQuaternion(0.,0.,1.,0.); + CTX.setQuaternion(0.,-1./sqrt(2.),0.,1./sqrt(2.)); set_r(0,0.); set_r(1,90.);set_r(2,0.); Init(); Draw(); break; case OPTIONS_YVIEW : if(CTX.useTrackball) - CTX.setQuaternion(0.,-1.,0.,0.); + CTX.setQuaternion(1./sqrt(2.),0.,1./sqrt(2.),0.); set_r(0,-90.);set_r(1,0.); set_r(2,0.); Init(); Draw(); break; -- GitLab