diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 54bda6242e67cf3099c0737a69125799d876b5dc..a7c9c4c67ea12a7d144ecc259e7054cda2f09fb3 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -374,7 +374,7 @@ StringXNumber GeneralOptions_Number[] = { "Display the axes linked to the model" }, { F, "Clip0" , opt_general_clip0 , 0. , "Enable clipping plane 0 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" }, - { F, "Clip0A" , opt_general_clip0a , 0.0 , + { F, "Clip0A" , opt_general_clip0a , 1.0 , "First coefficient in equation for clipping plane 0 (`A' in `AX+BY+CZ+D=0')" }, { F, "Clip0B" , opt_general_clip0b , 0.0 , "Second coefficient in equation for clipping plane 0 (`B' in `AX+BY+CZ+D=0')" }, @@ -384,7 +384,7 @@ StringXNumber GeneralOptions_Number[] = { "Fourth coefficient in equation for clipping plane 0 (`D' in `AX+BY+CZ+D=0')" }, { F, "Clip1" , opt_general_clip1 , 0., "Enable clipping plane 1 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" }, - { F, "Clip1A" , opt_general_clip1a , 0.0 , + { F, "Clip1A" , opt_general_clip1a , 1.0 , "First coefficient in equation for clipping plane 1" }, { F, "Clip1B" , opt_general_clip1b , 0.0 , "Second coefficient in equation for clipping plane 1" }, @@ -394,7 +394,7 @@ StringXNumber GeneralOptions_Number[] = { "Fourth coefficient in equation for clipping plane 1" }, { F, "Clip2" , opt_general_clip2 , 0., "Enable clipping plane 2 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" }, - { F, "Clip2A" , opt_general_clip2a , 0.0 , + { F, "Clip2A" , opt_general_clip2a , 1.0 , "First coefficient in equation for clipping plane 2" }, { F, "Clip2B" , opt_general_clip2b , 0.0 , "Second coefficient in equation for clipping plane 2" }, @@ -404,7 +404,7 @@ StringXNumber GeneralOptions_Number[] = { "Fourth coefficient in equation for clipping plane 2" }, { F, "Clip3" , opt_general_clip3 , 0., "Enable clipping plane 3 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" }, - { F, "Clip3A" , opt_general_clip3a , 0.0 , + { F, "Clip3A" , opt_general_clip3a , 1.0 , "First coefficient in equation for clipping plane 3" }, { F, "Clip3B" , opt_general_clip3b , 0.0 , "Second coefficient in equation for clipping plane 3" }, @@ -414,7 +414,7 @@ StringXNumber GeneralOptions_Number[] = { "Fourth coefficient in equation for clipping plane 3" }, { F, "Clip4" , opt_general_clip4 , 0., "Enable clipping plane 4 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" }, - { F, "Clip4A" , opt_general_clip4a , 0.0 , + { F, "Clip4A" , opt_general_clip4a , 1.0 , "First coefficient in equation for clipping plane 4" }, { F, "Clip4B" , opt_general_clip4b , 0.0 , "Second coefficient in equation for clipping plane 4" }, @@ -424,7 +424,7 @@ StringXNumber GeneralOptions_Number[] = { "Fourth coefficient in equation for clipping plane 4" }, { F, "Clip5" , opt_general_clip5 , 0., "Enable clipping plane 5 (Geometry=2^0, Mesh=2^1, View[i]=2^(2+i))" }, - { F, "Clip5A" , opt_general_clip5a , 0.0 , + { F, "Clip5A" , opt_general_clip5a , 1.0 , "First coefficient in equation for clipping plane 5" }, { F, "Clip5B" , opt_general_clip5b , 0.0 , "Second coefficient in equation for clipping plane 5" }, @@ -725,13 +725,13 @@ StringXNumber MeshOptions_Number[] = { "Draw the intersection volume layer as a surface" }, { F, "CutPlaneOnlyVolume" , opt_mesh_cut_plane_only_volume , 0 , "Cut only the volume elements" }, - { F, "CutPlaneA" , opt_mesh_cut_planea , 1. , + { F, "CutPlaneA" , opt_mesh_cut_planea , 1.0 , "First cut plane equation coefficient (`A' in `AX+BY+CZ+D=0')" }, - { F, "CutPlaneB" , opt_mesh_cut_planeb , 0. , + { F, "CutPlaneB" , opt_mesh_cut_planeb , 0.0 , "Second cut plane equation coefficient (`B' in `AX+BY+CZ+D=0')" }, - { F, "CutPlaneC" , opt_mesh_cut_planec , 0. , + { F, "CutPlaneC" , opt_mesh_cut_planec , 0.0 , "Third cut plane equation coefficient (`C' in `AX+BY+CZ+D=0')" }, - { F, "CutPlaneD" , opt_mesh_cut_planed , 0. , + { F, "CutPlaneD" , opt_mesh_cut_planed , 0.0 , "Fourth cut plane equation coefficient (`D' in `AX+BY+CZ+D=0')" }, { F|O, "Dual" , opt_mesh_dual , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 7770ed07d3f811dcb9b72ff04185630d2e67c7b6..db2b0460eca2afbeef89e162532a8b55efe51219 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.174 2004-07-23 01:28:57 geuzaine Exp $ +// $Id: Options.cpp,v 1.175 2004-07-23 04:47:41 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -3759,6 +3759,14 @@ double opt_mesh_use_cut_plane(OPT_ARGS_NUM) if(action & GMSH_SET){ if(CTX.mesh.use_cut_plane != (int)val) CTX.mesh.changed = 1; CTX.mesh.use_cut_plane = (int)val; +#if defined(HAVE_FLTK) + if(WID){ + double val1 = CTX.lc; + WID->mesh_value[17]->step(val1/200.); + WID->mesh_value[17]->minimum(-val1); + WID->mesh_value[17]->maximum(val1); + } +#endif } #if defined(HAVE_FLTK) if(WID && (action & GMSH_GUI)) diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index cbaeb50f00268da02282beecbec6ec4fbb1378ab..ef7aa0ad88aa3d9f5e16b52dcf8f2d271e5b1733 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.258 2004-07-23 01:28:57 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.259 2004-07-23 04:47:41 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -243,6 +243,11 @@ void set_changed_cb(CALLBACK_ARGS) w->set_changed(); } +void redraw_cb(CALLBACK_ARGS) +{ + Draw(); +} + // Graphical window void status_xyz1p_cb(CALLBACK_ARGS) @@ -1014,6 +1019,30 @@ void mesh_options_ok_cb(CALLBACK_ARGS) opt_mesh_color_carousel(0, GMSH_SET, WID->mesh_choice[4]->value()); } +void mesh_cut_plane_cb(CALLBACK_ARGS) +{ + if(!CTX.mesh.use_cut_plane) + return; + + int old = CTX.draw_bbox; + CTX.draw_bbox = 1; + if(CTX.fast_redraw){ + CTX.post.draw = 0; + CTX.mesh.draw = 0; + } + + opt_mesh_cut_planea(0, GMSH_SET, WID->mesh_value[14]->value()); + opt_mesh_cut_planeb(0, GMSH_SET, WID->mesh_value[15]->value()); + opt_mesh_cut_planec(0, GMSH_SET, WID->mesh_value[16]->value()); + opt_mesh_cut_planed(0, GMSH_SET, WID->mesh_value[17]->value()); + + Draw(); + + CTX.draw_bbox = old; + CTX.post.draw = 1; + CTX.mesh.draw = 1; +} + // Solver options void solver_options_cb(CALLBACK_ARGS) @@ -1323,19 +1352,15 @@ void clip_num_cb(CALLBACK_ARGS) WID->reset_clip_browser(); } -void clip_reset_cb(CALLBACK_ARGS) +void clip_update_cb(CALLBACK_ARGS) { - for(int i = 0; i < 6; i++){ - CTX.clip[i] = 0; - for(int j = 0; j < 4; j++) - CTX.clip_plane[i][j] = 0.; + int old = CTX.draw_bbox; + CTX.draw_bbox = 1; + if(CTX.fast_redraw){ + CTX.post.draw = 0; + CTX.mesh.draw = 0; } - WID->reset_clip_browser(); - Draw(); -} -void clip_ok_cb(CALLBACK_ARGS) -{ int idx = WID->clip_choice->value(); CTX.clip[idx] = 0; for(int i = 0; i < WID->clip_browser->size(); i++) @@ -1344,6 +1369,22 @@ void clip_ok_cb(CALLBACK_ARGS) for(int i = 0; i < 4; i++) CTX.clip_plane[idx][i] = WID->clip_value[i]->value(); Draw(); + + CTX.draw_bbox = old; + CTX.post.draw = 1; + CTX.mesh.draw = 1; +} + +void clip_reset_cb(CALLBACK_ARGS) +{ + for(int i = 0; i < 6; i++){ + CTX.clip[i] = 0; + CTX.clip_plane[i][0] = 1.; + for(int j = 1; j < 4; j++) + CTX.clip_plane[i][j] = 0.; + } + WID->reset_clip_browser(); + Draw(); } // Help Menu diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h index d505eb064a08e9472a028cf4e6f445388dc56953..0ba13a3a06a8cf9d78c636c1dbf6e5fdee2aedd1 100644 --- a/Fltk/Callbacks.h +++ b/Fltk/Callbacks.h @@ -32,6 +32,7 @@ void ManualPlay(int time, int step); void cancel_cb(CALLBACK_ARGS) ; void color_cb(CALLBACK_ARGS) ; void set_changed_cb(CALLBACK_ARGS); +void redraw_cb(CALLBACK_ARGS); // Graphical window @@ -84,12 +85,14 @@ void general_options_color_scheme_cb(CALLBACK_ARGS) ; void general_options_rotation_center_cb(CALLBACK_ARGS) ; void general_options_rotation_center_select_cb(CALLBACK_ARGS) ; void general_options_ok_cb(CALLBACK_ARGS) ; +void general_arrow_param_cb(CALLBACK_ARGS); void geometry_options_cb(CALLBACK_ARGS) ; void geometry_options_ok_cb(CALLBACK_ARGS) ; void mesh_options_cb(CALLBACK_ARGS) ; void mesh_options_ok_cb(CALLBACK_ARGS) ; +void mesh_cut_plane_cb(CALLBACK_ARGS) ; void solver_options_cb(CALLBACK_ARGS) ; void solver_options_ok_cb(CALLBACK_ARGS) ; @@ -128,6 +131,7 @@ void view_options_timestep_cb(CALLBACK_ARGS) ; void view_options_timestep_decr_cb(CALLBACK_ARGS); void view_options_timestep_incr_cb(CALLBACK_ARGS); void view_options_ok_cb(CALLBACK_ARGS) ; +void view_arrow_param_cb(CALLBACK_ARGS); // Statistics Menu @@ -152,9 +156,9 @@ void visibility_ok_cb(CALLBACK_ARGS) ; // Clipping planes Menu void clip_cb(CALLBACK_ARGS) ; +void clip_update_cb(CALLBACK_ARGS) ; void clip_num_cb(CALLBACK_ARGS) ; void clip_reset_cb(CALLBACK_ARGS) ; -void clip_ok_cb(CALLBACK_ARGS) ; // Help Menu @@ -274,10 +278,5 @@ void solver_kill_cb(CALLBACK_ARGS); void solver_choose_executable_cb(CALLBACK_ARGS); void solver_ok_cb(CALLBACK_ARGS); -// Arrow editor windows - -void general_arrow_param_cb(CALLBACK_ARGS); -void view_arrow_param_cb(CALLBACK_ARGS); - #endif diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 5ec5098e7df39d01a743ded774502288fd350ce0..f795535accf95e2ec8de09272230b8d6a86a2ead 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.327 2004-07-23 01:28:57 geuzaine Exp $ +// $Id: GUI.cpp,v 1.328 2004-07-23 04:47:41 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -61,7 +61,7 @@ #define RADIO_COLOR FL_BLACK #define IW (10*fontsize) // input field width -#define BB (6*fontsize+4) // width of a button with internal label +#define BB (7*fontsize) // width of a button with internal label #define BH (2*fontsize+1) // button height #define WB (6) // window border @@ -1891,6 +1891,10 @@ void GUI::create_option_window() mesh_value[17] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "D"); for(i = 14; i <= 17; i++) { mesh_value[i]->align(FL_ALIGN_RIGHT); + mesh_value[i]->callback(mesh_cut_plane_cb); + mesh_value[i]->step(0.01); + mesh_value[i]->minimum(-1.0); + mesh_value[i]->maximum(1.0); } mesh_butt[22] = new Fl_Check_Button(2 * WB, 2 * WB + 6 * BH, BW, BH, "Draw intersecting volume layer as surface"); @@ -3000,11 +3004,22 @@ void GUI::reset_clip_browser() clip_browser->select(i+1); for(int i = 0; i < 4; i++) clip_value[i]->value(CTX.clip_plane[idx][i]); + + for(int i = 0; i < 3; i++) { + clip_value[i]->step(0.01); + clip_value[i]->minimum(-1.0); + clip_value[i]->maximum(1.0); + } + double val1 = CTX.lc; + clip_value[3]->step(val1/200.); + clip_value[3]->minimum(-val1); + clip_value[3]->maximum(val1); } void GUI::create_clip_window() { if(clip_window) { + reset_clip_browser(); clip_window->show(); return; } @@ -3022,13 +3037,13 @@ void GUI::create_clip_window() int width = 3 * BB + 4 * WB; int height = 6 * BH + 3 * WB; int brw = 105; - int BW = width - brw - 3 * WB - 3 * fontsize / 2; - + int BW = width - brw - 3 * WB - 2 * fontsize; clip_window = new Fl_Window(width, height, "Clipping Planes"); clip_window->box(WINDOW_BOX); clip_browser = new Fl_Multi_Browser(1 * WB, 1 * WB, brw, 5 * BH); + clip_browser->callback(clip_update_cb); clip_choice = new Fl_Choice(2 * WB + brw, 1 * WB + 0 * BH, BW, BH); clip_choice->menu(plane_number); @@ -3038,14 +3053,16 @@ void GUI::create_clip_window() clip_value[1] = new Fl_Value_Input(2 * WB + brw, 1 * WB + 2 * BH, BW, BH, "B"); clip_value[2] = new Fl_Value_Input(2 * WB + brw, 1 * WB + 3 * BH, BW, BH, "C"); clip_value[3] = new Fl_Value_Input(2 * WB + brw, 1 * WB + 4 * BH, BW, BH, "D"); - for(int i = 0; i < 4; i++) + for(int i = 0; i < 4; i++){ clip_value[i]->align(FL_ALIGN_RIGHT); + clip_value[i]->callback(clip_update_cb); + } reset_clip_browser(); { - Fl_Return_Button *o = new Fl_Return_Button(width - 3 * BB - 3 * WB, height - BH - WB, BB, BH, "Apply"); - o->callback(clip_ok_cb); + Fl_Return_Button *o = new Fl_Return_Button(width - 3 * BB - 3 * WB, height - BH - WB, BB, BH, "Redraw"); + o->callback(redraw_cb); } { Fl_Button *o = new Fl_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Reset"); diff --git a/Graphics/Entity.cpp b/Graphics/Entity.cpp index ef2805034471f3aa6cde3875123e3ee2b125ef8a..585870a5e746aba6365fb63749e89ae7290e9f9f 100644 --- a/Graphics/Entity.cpp +++ b/Graphics/Entity.cpp @@ -1,4 +1,4 @@ -// $Id: Entity.cpp,v 1.44 2004-07-22 19:32:02 geuzaine Exp $ +// $Id: Entity.cpp,v 1.45 2004-07-23 04:47:42 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -388,10 +388,15 @@ void Draw_PlaneInBoundingBox(double xmin, double ymin, double zmin, }; point intersect(point &p1, point &p2){ double v1 = val(p1), v2 = val(p2); - if(fabs(v1) < 1.e-12) - return point(p1.x, p1.y, p1.z); - else if(fabs(v2) < 1.e-12) + if(fabs(v1) < 1.e-12){ + if(fabs(v2) < 1.e-12) + return point(); + else + return point(p1.x, p1.y, p1.z); + } + else if(fabs(v2) < 1.e-12){ return point(p2.x, p2.y, p2.z); + } else if(v1 * v2 < 0.){ double coef = - v1 / (v2 - v1); return point(coef * (p2.x - p1.x) + p1.x,