diff --git a/Common/Context.h b/Common/Context.h index 923ccf946c6d41fcb363224caed28d3334e2e1c8..6b886fae431cc11d8271fa312243e83efefeaeb6 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 746fc053015573b12acb295fae3b82c15a9194fb..c07a907a18134d38a00de72774fcc3c61509eefa 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 979ae7fdd4994b0df09f07090a9d8e64c273fe50..a097d632cc2c66a58f49c793f1875b1012c9ac5e 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 ad1e78744eb55460119f7a38bd73de4118b52a57..f4a0813784dbd74181c832bdd9b6597a9aca39fb 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 a9caa2f0afd5d20d143207573a6f8fe1d1d217cc..fd3d628d70d5232672a898c8de13fa02a517ff24 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 e7011fa84665acae19be8114c63a6ce1fefba654..e16a0dbfafd708e8377504d3841436f601846b4f 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;