From 168f373acf97ca631207c14b619d2e86c0d57f9c Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 26 Oct 2010 16:24:04 +0000 Subject: [PATCH] separate option for trackball hyperbolic sheet --- Common/Context.h | 2 +- Common/DefaultOptions.h | 2 ++ Common/Options.cpp | 7 +++++++ Common/Options.h | 1 + Graphics/Trackball.cpp | 23 +++++++++-------------- utils/api_demos/mainGlut.cpp | 3 ++- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index 923ccf946c..6b886fae43 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -115,7 +115,7 @@ class CTX { // clipping plane distance factor double clipFactor; // do or do not use the trackball for rotations - int useTrackball; + int useTrackball, trackballHyperbolicSheet; // point around which to rotate the scene double rotationCenter[3]; // rotate around the center of mass instead of rotationCenter[] diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 746fc05301..c07a907a18 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -844,6 +844,8 @@ StringXNumber GeneralOptions_Number[] = { "Show tooltips in the user interface" }, { F|O, "Trackball" , opt_general_trackball , 1. , "Use trackball rotation mode" }, + { F|O, "TrackballHyperbolicSheet" , opt_general_trackball_hyperbolic_sheet , 1. , + "Use hyperbolic sheet away from trackball center for z-rotations" }, { F, "TrackballQuaternion0" , opt_general_quaternion0 , 0.0 , "First trackball quaternion component (used if General.Trackball=1)" }, { F, "TrackballQuaternion1" , opt_general_quaternion1 , 0.0 , diff --git a/Common/Options.cpp b/Common/Options.cpp index 979ae7fdd4..a097d632cc 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -3643,6 +3643,13 @@ double opt_general_trackball(OPT_ARGS_NUM) return CTX::instance()->useTrackball; } +double opt_general_trackball_hyperbolic_sheet(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->trackballHyperbolicSheet = (int)val; + return CTX::instance()->trackballHyperbolicSheet; +} + double opt_general_rotation_center_cg(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index ad1e78744e..f4a0813784 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -345,6 +345,7 @@ double opt_general_arrow_head_radius(OPT_ARGS_NUM); double opt_general_arrow_stem_length(OPT_ARGS_NUM); double opt_general_arrow_stem_radius(OPT_ARGS_NUM); double opt_general_trackball(OPT_ARGS_NUM); +double opt_general_trackball_hyperbolic_sheet(OPT_ARGS_NUM); double opt_general_rotation_center_cg(OPT_ARGS_NUM); double opt_general_zoom_factor(OPT_ARGS_NUM); double opt_general_expert_mode(OPT_ARGS_NUM); diff --git a/Graphics/Trackball.cpp b/Graphics/Trackball.cpp index a9caa2f0af..fd3d628d70 100644 --- a/Graphics/Trackball.cpp +++ b/Graphics/Trackball.cpp @@ -51,7 +51,7 @@ */ /* * Modified for inclusion in Gmsh (rotmatrix as a vector + - * float->double + camera + new trackballsize function) + * float->double + optional use of hyperbolic sheet for z-rotation) */ #include <math.h> #include "Trackball.h" @@ -233,14 +233,7 @@ tb_project_to_sphere(double r, double x, double y) d = sqrt(x*x + y*y); - if (CTX::instance()->camera) { - if (d < r ) { - z = sqrt(r*r - d*d); - } else { - z = 0.; - } - } - else{ + if (CTX::instance()->trackballHyperbolicSheet) { if (d < r * 0.70710678118654752440) { // Inside sphere z = sqrt(r*r - d*d); @@ -250,6 +243,13 @@ tb_project_to_sphere(double r, double x, double y) z = t*t / d; } } + else{ + if (d < r ) { + z = sqrt(r*r - d*d); + } else { + z = 0.; + } + } return z; } @@ -345,8 +345,3 @@ build_rotmatrix(double m[16], double q[4]) m[14] = 0.0; m[15] = 1.0; } - -double trackballsize() -{ - return TRACKBALLSIZE; -} diff --git a/utils/api_demos/mainGlut.cpp b/utils/api_demos/mainGlut.cpp index e7011fa846..e16a0dbfaf 100644 --- a/utils/api_demos/mainGlut.cpp +++ b/utils/api_demos/mainGlut.cpp @@ -419,7 +419,8 @@ int main(int argc, char **argv) GmshSetOption("General", "Stereo", 0.); GmshSetOption("General", "Camera", 1.); GmshSetOption("General", "Orthographic", 0.); - + GmshSetOption("General", "TrackballHyperbolicSheet", 0.); + if (strstr(argv[1],"-s") != NULL){ camera.stereoEnable = true; cout<<"mode STEREO"<<endl; -- GitLab