diff --git a/Common/Context.cpp b/Common/Context.cpp index 29a92dedc8ef470b70f56865753449d15fe88d00..0b2e1f69880c267d558ca8297f036b996791ef94 100644 --- a/Common/Context.cpp +++ b/Common/Context.cpp @@ -1,4 +1,4 @@ -// $Id: Context.cpp,v 1.55 2005-03-11 08:56:37 geuzaine Exp $ +// $Id: Context.cpp,v 1.56 2005-12-08 20:35:34 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -58,6 +58,14 @@ void Context_T::addQuaternion(double p1x, double p1y, double p2x, double p2y) add_quats(quat, quaternion, quaternion); } +void Context_T::addQuaternionFromAxisAndAngle(double axis[3], double angle) +{ + double a = angle * Pi / 180.; + double quat[4]; + axis_to_quat(axis, a, quat); + add_quats(quat, quaternion, quaternion); +} + void Context_T::setQuaternion(double q0, double q1, double q2, double q3) { quaternion[0] = q0; diff --git a/Common/Context.h b/Common/Context.h index d2835522286ecd7a9cfac056fa99d96b4c8d825b..0854705ba6a2363c207b77fc8bb6b08cef0ea57f 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -253,6 +253,7 @@ public : void buildRotationMatrix(void); void setQuaternion(double p1x, double p1y, double p2x, double p2y); void addQuaternion(double p1x, double p1y, double p2x, double p2y); + void addQuaternionFromAxisAndAngle(double axis[3], double angle); void setQuaternionFromEulerAngles(void); void setEulerAnglesFromRotationMatrix(void); }; diff --git a/Fltk/Bitmaps.h b/Fltk/Bitmaps.h index 562f308315f4e36264837ac583b3a30e0d82bf34..e0876a7e46a3a661b0cc155f2699ea5da8edccd6 100644 --- a/Fltk/Bitmaps.h +++ b/Fltk/Bitmaps.h @@ -89,4 +89,11 @@ static unsigned char persp_bits[] = { 0x7c, 0x08, 0x54, 0x08, 0xf4, 0x0f, 0x44, 0x03, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00 }; +#define rotate_width 12 +#define rotate_height 13 +static unsigned char rotate_bits[] = { + 0x00, 0x00, 0xf0, 0x00, 0x08, 0x01, 0x04, 0x02, 0x02, 0x04, 0x02, 0x04, + 0x02, 0x04, 0x02, 0x04, 0x24, 0x00, 0x68, 0x00, 0xf0, 0x00, 0x60, 0x00, + 0x20, 0x00 }; + #endif diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 69288fc1eb5940b5d2f0c9cf11b94870133d01b4..d797deff2f95d1286750fe562dbd3d37f460c2b6 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.383 2005-12-08 18:14:46 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.384 2005-12-08 20:35:34 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -385,49 +385,53 @@ void status_xyz1p_cb(CALLBACK_ARGS) { char *str = (char*)data; - if(!strcmp(str, "x")){ // X pointing out of the screen (and Z pointing up) - CTX.r[0] = -90.; - CTX.r[1] = 0.; - CTX.r[2] = -90.; - CTX.setQuaternionFromEulerAngles(); + if(!strcmp(str, "r")){ // rotate 90 degress around axis perp to the screen + double axis[3] = {0., 0., 1.}; + if(!Fl::event_state(FL_SHIFT)) + CTX.addQuaternionFromAxisAndAngle(axis, -90.); + else + CTX.addQuaternionFromAxisAndAngle(axis, 90.); Draw(); } - else if(!strcmp(str, "y")){ // Y pointing out of the screen (and Z pointing up) - CTX.r[0] = -90.; - CTX.r[1] = 0.; - CTX.r[2] = 180.; + else if(!strcmp(str, "x")){ // X pointing out or into the screen + if(!Fl::event_state(FL_SHIFT)){ + CTX.r[0] = -90.; + CTX.r[1] = 0.; + CTX.r[2] = -90.; + } + else{ + CTX.r[0] = -90.; + CTX.r[1] = 0.; + CTX.r[2] = 90.; + } CTX.setQuaternionFromEulerAngles(); Draw(); } - else if(!strcmp(str, "z")){ // Z pointing out of the screen + else if(!strcmp(str, "y")){ // Y pointing out or into the screen if(!Fl::event_state(FL_SHIFT)){ - CTX.r[0] = 0.; + CTX.r[0] = -90.; + CTX.r[1] = 0.; + CTX.r[2] = 180.; + } + else{ + CTX.r[0] = -90.; CTX.r[1] = 0.; CTX.r[2] = 0.; } - else - CTX.r[2] += 90.; // little hack for philou CTX.setQuaternionFromEulerAngles(); Draw(); } - else if(!strcmp(str, "nx")){ // look from behind X view - CTX.r[0] = -90.; - CTX.r[1] = 0.; - CTX.r[2] = 90.; - CTX.setQuaternionFromEulerAngles(); - Draw(); - } - else if(!strcmp(str, "ny")){ // look from behind Y view - CTX.r[0] = -90.; - CTX.r[1] = 0.; - CTX.r[2] = 0.; - CTX.setQuaternionFromEulerAngles(); - Draw(); - } - else if(!strcmp(str, "nz")){ // look from behind Z view - CTX.r[0] = 0.; - CTX.r[1] = 180.; - CTX.r[2] = 0.; + else if(!strcmp(str, "z")){ // Z pointing out or into the screen + if(!Fl::event_state(FL_SHIFT)){ + CTX.r[0] = 0.; + CTX.r[1] = 0.; + CTX.r[2] = 0.; + } + else{ + CTX.r[0] = 0.; + CTX.r[1] = 180.; + CTX.r[2] = 0.; + } CTX.setQuaternionFromEulerAngles(); Draw(); } diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 9ce93fb86dfc42f668bc00fa63c0afa1ffa1ff40..66865a9ab04075cee813401b4841b4f52c78bccc 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.470 2005-11-28 15:41:54 geuzaine Exp $ +// $Id: GUI.cpp,v 1.471 2005-12-08 20:35:34 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -658,30 +658,21 @@ int GUI::global_shortcuts(int event) redraw_opengl(); return 1; } - else if(Fl::test_shortcut(FL_ALT + 'x')) { + else if(Fl::test_shortcut(FL_ALT + 'x') || + Fl::test_shortcut(FL_ALT + FL_SHIFT + 'x')) { status_xyz1p_cb(0, (void *)"x"); return 1; } - else if(Fl::test_shortcut(FL_ALT + 'y')) { + else if(Fl::test_shortcut(FL_ALT + 'y') || + Fl::test_shortcut(FL_ALT + FL_SHIFT + 'y')) { status_xyz1p_cb(0, (void *)"y"); return 1; } - else if(Fl::test_shortcut(FL_ALT + 'z')) { + else if(Fl::test_shortcut(FL_ALT + 'z') || + Fl::test_shortcut(FL_ALT + FL_SHIFT + 'z')) { status_xyz1p_cb(0, (void *)"z"); return 1; } - else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'x')) { - status_xyz1p_cb(0, (void *)"nx"); - return 1; - } - else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'y')) { - status_xyz1p_cb(0, (void *)"ny"); - return 1; - } - else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'z')) { - status_xyz1p_cb(0, (void *)"nz"); - return 1; - } else if(Fl::test_shortcut(FL_ALT + 'a')) { opt_general_axes(0, GMSH_SET | GMSH_GUI, opt_general_axes(0, GMSH_GET, 0) + 1); @@ -1345,17 +1336,24 @@ void GUI::create_graphic_window() g_status_butt[0] = new Fl_Button(x, glheight + 2, sw, sh - 4, "X"); x += sw; g_status_butt[0]->callback(status_xyz1p_cb, (void *)"x"); - g_status_butt[0]->tooltip("Set X view (Alt+x)"); + g_status_butt[0]->tooltip("Set +X or -X view (Alt+x or Alt+Shift+x)"); g_status_butt[1] = new Fl_Button(x, glheight + 2, sw, sh - 4, "Y"); x += sw; g_status_butt[1]->callback(status_xyz1p_cb, (void *)"y"); - g_status_butt[1]->tooltip("Set Y view (Alt+y)"); + g_status_butt[1]->tooltip("Set +Y or -Y view (Alt+y or Alt+Shift+y)"); g_status_butt[2] = new Fl_Button(x, glheight + 2, sw, sh - 4, "Z"); x += sw; g_status_butt[2]->callback(status_xyz1p_cb, (void *)"z"); - g_status_butt[2]->tooltip("Set Z view (Alt+z)"); + g_status_butt[2]->tooltip("Set +Z or -Z view (Alt+z or Alt+Shift+z)"); + + g_status_butt[4] = new Fl_Button(x, glheight + 2, sw, sh - 4); + x += sw; + g_status_butt[4]->callback(status_xyz1p_cb, (void *)"r"); + g_status_butt[4]->tooltip("Rotate +90 or -90 degrees"); + rotate_bmp = new Fl_Bitmap(rotate_bits, rotate_width, rotate_height); + rotate_bmp->label(g_status_butt[4]); g_status_butt[3] = new Fl_Button(x, glheight + 2, 2 * fontsize, sh - 4, "1:1"); x += 2 * fontsize; @@ -1363,6 +1361,7 @@ void GUI::create_graphic_window() g_status_butt[3]->tooltip("Set unit scale"); //FIXME: remove this until we do the perspective projection properly + //FIXME: need to change the button number!! //g_status_butt[4] = new Fl_Button(x, glheight + 2, sw, sh - 4); //x += sw; //g_status_butt[4]->callback(status_xyz1p_cb, (void *)"p"); @@ -1394,12 +1393,9 @@ void GUI::create_graphic_window() g_status_butt[7]->deactivate(); for(i = 0; i < 8; i++) { - //FIXME: - if(i != 4){ - g_status_butt[i]->box(FL_FLAT_BOX); - g_status_butt[i]->selection_color(FL_WHITE); - g_status_butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); - } + g_status_butt[i]->box(FL_FLAT_BOX); + g_status_butt[i]->selection_color(FL_WHITE); + g_status_butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); } g_status_label[0] = new Fl_Box(x, glheight + 2, diff --git a/Fltk/GUI.h b/Fltk/GUI.h index 3dc419df432b9292ddcd8acdf7dc1b3b16c7e06b..1617338295bc6980148e943913d9fa676ba57c17 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -126,7 +126,7 @@ class GUI{ Fl_Scroll *m_scroll; // Bitmaps - Fl_Bitmap *abort_bmp, *start_bmp, *stop_bmp, *rewind_bmp ; + Fl_Bitmap *abort_bmp, *start_bmp, *stop_bmp, *rewind_bmp, *rotate_bmp ; void add_post_plugins ( Fl_Menu_Button *button , int iView); void add_multiline_in_browser(Fl_Browser *o, char* prefix, char *str);