diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 4027cb49e594daf18dbb6650b494f2d3677dd5d7..e64ff09cfc7b0b9300d40b29d40035b27c611ad3 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -9,8 +9,12 @@ #if defined(HAVE_FLTK) #include <FL/Fl.H> -#if (FL_MAJOR_VERSION != 1) || (FL_MINOR_VERSION != 1) || (FL_PATCH_VERSION < 7) -#error "Gmsh requires FLTK 1.1.7 or above" +#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 1) && (FL_PATCH_VERSION > 6) +// OK +#elif (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3) +// also OK +#else +#error "Gmsh requires FLTK >= 1.1.7 or FLTK 1.3.x" #endif #endif @@ -305,6 +309,13 @@ void Get_Options(int argc, char *argv[]) else Msg::Fatal("Missing number"); } + else if(!strcmp(argv[i] + 1, "nt")) { + i++; + if(argv[i] != NULL) + CTX.num_tiles = atoi(argv[i++]); + else + Msg::Fatal("Missing number"); + } else if(!strcmp(argv[i] + 1, "convert")) { i++; CTX.batch = 1; @@ -618,6 +629,13 @@ void Get_Options(int argc, char *argv[]) else Msg::Fatal("Missing number"); } + else if(!strcmp(argv[i] + 1, "deltafontsize")) { + i++; + if(argv[i] != NULL) + CTX.deltafontsize = atoi(argv[i++]); + else + Msg::Fatal("Missing number"); + } else if(!strcmp(argv[i] + 1, "theme") || !strcmp(argv[i] + 1, "scheme")) { i++; if(argv[i] != NULL) diff --git a/Common/Context.h b/Common/Context.h index 6487202e550f915cd3d66e682ed78c8132d6fc12..1113021b30b5761f731d0ea1163f05c439a5dcea 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -41,7 +41,7 @@ class Context_T { int confirm_overwrite; // confirm overwrite when file->save as const char *display; // forced display host:0.0 under X11 int terminal; // show we print to the terminal console? - int num_windows; // number of graphical windows to create + int num_windows, num_tiles; // number of graphical windows/tiles to create const char *editor; // text editor command (with included '%s') const char *web_browser; // web browser command (with included '%s') char home_dir[256]; // the home directory @@ -49,6 +49,7 @@ class Context_T { int tooltips; // show tootips in GUI? int position[2]; // position of the menu window on the screen int gl_position[2]; // position of the graphic window on the screen + int gl_size[2]; // size of the graphic window on the screen int msg_position[2]; // position of the message window on the screen int msg_size[2]; // size of the message window on the screen int msg_auto_scroll; // scroll automatically to last message @@ -91,7 +92,7 @@ class Context_T { int alpha; // enable alpha blending double zoom_factor; // mouse2 zoom coefficient int bg_gradient; // draw background gradient? - int fontsize; // font size for fltk UI + int fontsize, deltafontsize; // fltk font size (and delta for palettes) const char *gl_font; // font for opengl graphics int gl_font_enum; // font for opengl graphics (fltk enum value) int gl_fontsize; // font size for opengl graphics @@ -125,7 +126,6 @@ class Context_T { double tmp_r[3]; // current Euler angles (in degrees!) double tmp_t[3], tmp_s[3]; // current translation and scale double tmp_quaternion[4]; // current quaternion used for "trackball" rotation - int tmp_viewport[4]; // current viewport // geometry options struct{ diff --git a/Common/CreateFile.cpp b/Common/CreateFile.cpp index 13d477ffc79d3596b90a61f2dba1361606875d9d..552bbc03bc083bb429e1186ca4066d25bb03a4ea 100644 --- a/Common/CreateFile.cpp +++ b/Common/CreateFile.cpp @@ -118,7 +118,7 @@ void CreateOutputFile(const char *filename, int format) #if defined(HAVE_FLTK) int vp[4]; - GetStoredViewport(vp); + GetCurrentOpenglWindowViewport(vp); GLint viewport[4]; for(int i = 0; i < 4; i++) viewport[i] = vp[i]; GLint width = viewport[2] - viewport[0]; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index de16f7afcacb62b67cff432ef825843ab11696b1..174e2ba3c1a4b58c54040043b1ce3f8c9d02cdcf 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -556,13 +556,13 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "GraphicsFontSize" , opt_general_graphics_fontsize , 17. , "Size of the font in the graphic window" }, - { F|S, "GraphicsHeight" , opt_general_viewport3 , 600. , + { F|S, "GraphicsHeight" , opt_general_graphics_size1 , 600. , "Height (in pixels) of the graphic window" }, { F|S, "GraphicsPositionX" , opt_general_graphics_position0 , 50. , "Horizontal position (in pixels) of the upper left corner of the graphic window" }, { F|S, "GraphicsPositionY" , opt_general_graphics_position1 , 50. , "Vertical position (in pixels) of the upper left corner of the graphic window" }, - { F|S, "GraphicsWidth" , opt_general_viewport2 , 600. , + { F|S, "GraphicsWidth" , opt_general_graphics_size0 , 600. , "Width (in pixels) of the graphic window" }, { F|O, "InitialModule", opt_general_initial_context, 0. , @@ -706,7 +706,7 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "PolygonOffsetUnits" , opt_general_polygon_offset_units , 1. , "Polygon offset units (offset = factor * DZ + r * units)" }, - { F|O, "QuadricSubdivisions" , opt_general_quadric_subdivisions, 8. , + { F|O, "QuadricSubdivisions" , opt_general_quadric_subdivisions, 6. , "Number of subdivisions used to draw points or lines as spheres or cylinders" }, { F, "RotationX" , opt_general_rotation0 , 0.0 , @@ -1219,16 +1219,10 @@ StringXNumber ViewOptions_Number[] = { "Use adaptive visualization grid (for high-order elements)?" }, { F|O, "AngleSmoothNormals" , opt_view_angle_smooth_normals , 30.0 , "Threshold angle below which normals are not smoothed" }, - { F|O, "ArrowHeadRadius" , opt_view_arrow_head_radius , 0.12 , - "Relative radius of arrow head" }, { F|O, "ArrowSizeMax" , opt_view_arrow_size_max , 60. , "Maximum display size of arrows (in pixels)" }, { F|O, "ArrowSizeMin" , opt_view_arrow_size_min , 0. , "Minimum display size of arrows (in pixels)" }, - { F|O, "ArrowStemLength" , opt_view_arrow_stem_length , 0.56 , - "Relative length of arrow stem" }, - { F|O, "ArrowStemRadius" , opt_view_arrow_stem_radius , 0.02 , - "Relative radius of arrow stem" }, { F|O, "AutoPosition" , opt_view_auto_position , 1. , "Position the scale or 2D plot automatically" }, { F|O, "Axes" , opt_view_axes , 0 , diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index 2e254ded80b2c2c278a15276cc8f070e4e3b49e1..4d8cdf2a6a57c727fbf73ca375d97631235ec9ca 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -389,6 +389,30 @@ int MergeFile(const char *name, int warn_if_missing) return status; } +void ClearProject() +{ +#if !defined(HAVE_NO_POST) + for(int i = PView::list.size() - 1; i >= 0; i--) + delete PView::list[i]; +#endif +#if !defined(HAVE_NO_PARSER) + gmsh_yysymbols.clear(); +#endif + for(int i = GModel::list.size() - 1; i >= 1; i--) + delete GModel::list[i]; + GModel::current(0); + GModel::current()->destroy(); + GModel::current()->getGEOInternals()->destroy(); +#if defined(HAVE_FLTK) + if(GUI::available()){ + GUI::instance()->resetVisibility(); + GUI::instance()->updateViews(); + GUI::instance()->updateFields(); + GModel::current()->setSelection(0); + } +#endif +} + void OpenProject(const char *name) { if(CTX.threads_lock) { diff --git a/Common/OpenFile.h b/Common/OpenFile.h index 5f765987bc938517281fc18c0cb5f845983fcb3c..2a8da860814e670fe048f333a3ed8e99cf003bb6 100644 --- a/Common/OpenFile.h +++ b/Common/OpenFile.h @@ -11,6 +11,7 @@ void ParseString(const char *str); void OpenProject(const char *filename); void OpenProjectMacFinder(const char *filename); int MergeFile(const char *filename, int warn_if_missing=0); +void ClearProject(); void SetBoundingBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); diff --git a/Common/Options.cpp b/Common/Options.cpp index 11ca77025be5df912f552e4680bf572c18846236..c346ba06b73ef5841bf4fdfd1e1595ac5b478b9e 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -471,7 +471,6 @@ void Init_Options(int num) CTX.output_filename = NULL; CTX.bgm_filename = NULL; CTX.lc = 1.; - CTX.tmp_viewport[0] = CTX.tmp_viewport[1] = 0; // nice 2-D defaults for when adding points in a brand new model CTX.min[0] = CTX.min[1] = CTX.min[2] = CTX.max[2] = 0.; CTX.max[0] = CTX.max[1] = 1.; @@ -495,7 +494,8 @@ void Init_Options(int num) #endif CTX.forced_bbox = 0; CTX.hide_unselected = 0; - CTX.num_windows = 1; + CTX.num_windows = CTX.num_tiles = 1; + CTX.deltafontsize = 0; } void ReInit_Options(int num) @@ -2410,34 +2410,6 @@ double opt_general_graphics_fontsize(OPT_ARGS_NUM) return CTX.gl_fontsize; } -double opt_general_viewport2(OPT_ARGS_NUM) -{ - if(action & GMSH_SET) - CTX.tmp_viewport[2] = (int)val; -#if defined(HAVE_FLTK) - if(GUI::available()){ - if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->viewport[2] = (int)val; - return GUI::instance()->graph[0]->gl->getDrawContext()->viewport[2]; - } -#endif - return CTX.tmp_viewport[2]; -} - -double opt_general_viewport3(OPT_ARGS_NUM) -{ - if(action & GMSH_SET) - CTX.tmp_viewport[3] = (int)val; -#if defined(HAVE_FLTK) - if(GUI::available()){ - if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->viewport[3] = (int)val; - return GUI::instance()->graph[0]->gl->getDrawContext()->viewport[3]; - } -#endif - return CTX.tmp_viewport[3]; -} - double opt_general_polygon_offset_always(OPT_ARGS_NUM) { if(action & GMSH_SET) @@ -2485,6 +2457,34 @@ double opt_general_graphics_position1(OPT_ARGS_NUM) return CTX.gl_position[1]; } +double opt_general_graphics_size0(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.gl_size[0] = (int)val; +#if defined(HAVE_FLTK) + if(GUI::available()){ + if(action & GMSH_SET) + GUI::instance()->graph[0]->win->size + (CTX.gl_size[0], GUI::instance()->graph[0]->bottom->h() + CTX.gl_size[1]); + } +#endif + return CTX.gl_size[0]; +} + +double opt_general_graphics_size1(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.gl_size[1] = (int)val; +#if defined(HAVE_FLTK) + if(GUI::available()){ + if(action & GMSH_SET) + GUI::instance()->graph[0]->win->size + (CTX.gl_size[0], GUI::instance()->graph[0]->bottom->h() + CTX.gl_size[1]); + } +#endif + return CTX.gl_size[1]; +} + double opt_general_menu_position0(OPT_ARGS_NUM) { if(action & GMSH_SET) @@ -2753,8 +2753,8 @@ double opt_general_rotation0(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->r[0] = val; - return GUI::instance()->graph[0]->gl->getDrawContext()->r[0]; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->r[0] = val; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->r[0]; } #endif return CTX.tmp_r[0]; @@ -2767,8 +2767,8 @@ double opt_general_rotation1(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->r[1] = val; - return GUI::instance()->graph[0]->gl->getDrawContext()->r[1]; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->r[1] = val; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->r[1]; } #endif return CTX.tmp_r[1]; @@ -2781,8 +2781,8 @@ double opt_general_rotation2(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->r[2] = val; - return GUI::instance()->graph[0]->gl->getDrawContext()->r[2]; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->r[2] = val; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->r[2]; } #endif return CTX.tmp_r[2]; @@ -2828,10 +2828,10 @@ double opt_general_quaternion0(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[0] = val; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->quaternion[0] = val; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[0]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->quaternion[0]; } #endif return CTX.tmp_quaternion[0]; @@ -2844,10 +2844,10 @@ double opt_general_quaternion1(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[1] = val; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->quaternion[1] = val; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[1]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->quaternion[1]; } #endif return CTX.tmp_quaternion[1]; @@ -2860,10 +2860,10 @@ double opt_general_quaternion2(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[2] = val; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->quaternion[2] = val; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[2]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->quaternion[2]; } #endif return CTX.tmp_quaternion[2]; @@ -2876,10 +2876,10 @@ double opt_general_quaternion3(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[3] = val; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->quaternion[3] = val; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->quaternion[3]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->quaternion[3]; } #endif return CTX.tmp_quaternion[3]; @@ -2892,10 +2892,10 @@ double opt_general_translation0(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->t[0] = val; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->t[0] = val; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->t[0]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->t[0]; } #endif return CTX.tmp_t[0]; @@ -2908,10 +2908,10 @@ double opt_general_translation1(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->t[1] = val; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->t[1] = val; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->t[1]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->t[1]; } #endif return CTX.tmp_t[1]; @@ -2924,10 +2924,10 @@ double opt_general_translation2(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->t[2] = val; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->t[2] = val; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->t[2]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->t[2]; } #endif return CTX.tmp_t[2]; @@ -2940,10 +2940,10 @@ double opt_general_scale0(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->s[0] = val ? val : 1.0; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->s[0] = val ? val : 1.0; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->s[0]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->s[0]; } #endif return CTX.tmp_s[0]; @@ -2956,10 +2956,10 @@ double opt_general_scale1(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->s[1] = val ? val : 1.0; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->s[1] = val ? val : 1.0; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->s[1]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->s[1]; } #endif return CTX.tmp_s[1]; @@ -2972,10 +2972,10 @@ double opt_general_scale2(OPT_ARGS_NUM) #if defined(HAVE_FLTK) if(GUI::available()){ if(action & GMSH_SET) - GUI::instance()->graph[0]->gl->getDrawContext()->s[2] = val ? val : 1.0; + GUI::instance()->graph[0]->gl[0]->getDrawContext()->s[2] = val ? val : 1.0; if(action & GMSH_GUI) GUI::instance()->manip->update(); - return GUI::instance()->graph[0]->gl->getDrawContext()->s[2]; + return GUI::instance()->graph[0]->gl[0]->getDrawContext()->s[2]; } #endif return CTX.tmp_s[2]; @@ -3406,8 +3406,10 @@ double opt_general_quadric_subdivisions(OPT_ARGS_NUM) if(action & GMSH_SET) CTX.quadric_subdivisions = (int)val; #if defined(HAVE_FLTK) - if(GUI::available() && (action & GMSH_GUI)) - GUI::instance()->options->general.value[11]->value(CTX.quadric_subdivisions); + if(GUI::available()){ + if(action & GMSH_GUI) + GUI::instance()->options->general.value[11]->value(CTX.quadric_subdivisions); + } #endif return CTX.quadric_subdivisions; } @@ -3421,7 +3423,8 @@ double opt_general_double_buffer(OPT_ARGS_NUM) int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE); if(CTX.antialiasing) mode |= FL_MULTISAMPLE; for(unsigned int i = 0; i < GUI::instance()->graph.size(); i++) - GUI::instance()->graph[i]->gl->mode(mode); + for(unsigned int j = 0; j < GUI::instance()->graph[i]->gl.size(); j++) + GUI::instance()->graph[i]->gl[j]->mode(mode); } #endif } @@ -3441,7 +3444,8 @@ double opt_general_antialiasing(OPT_ARGS_NUM) int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE); if(CTX.antialiasing) mode |= FL_MULTISAMPLE; for(unsigned int i = 0; i < GUI::instance()->graph.size(); i++) - GUI::instance()->graph[i]->gl->mode(mode); + for(unsigned int j = 0; j < GUI::instance()->graph[i]->gl.size(); j++) + GUI::instance()->graph[i]->gl[j]->mode(mode); } #endif } @@ -4153,11 +4157,11 @@ double opt_general_transform(OPT_ARGS_NUM) if(action & GMSH_SET){ if(CTX.use_transform == 1){ drawTransform *tr = new drawTransformScaled(CTX.transform, CTX.offset); - GUI::instance()->graph[0]->gl->getDrawContext()->setTransform(tr); + GUI::instance()->graph[0]->gl[0]->getDrawContext()->setTransform(tr); } else{ - drawTransform *tr = GUI::instance()->graph[0]->gl->getDrawContext()->getTransform(); - GUI::instance()->graph[0]->gl->getDrawContext()->setTransform(0); + drawTransform *tr = GUI::instance()->graph[0]->gl[0]->getDrawContext()->getTransform(); + GUI::instance()->graph[0]->gl[0]->getDrawContext()->setTransform(0); if(tr) delete tr; } } @@ -4176,7 +4180,7 @@ static double _opt_general_transform(OPT_ARGS_NUM, int ii, int jj, int nn) if(action & GMSH_GUI) GUI::instance()->options->general.value[nn]->value(CTX.transform[ii][jj]); if(action & GMSH_SET){ - drawTransform *tr = GUI::instance()->graph[0]->gl->getDrawContext()->getTransform(); + drawTransform *tr = GUI::instance()->graph[0]->gl[0]->getDrawContext()->getTransform(); if(tr) tr->setMatrix(CTX.transform, CTX.offset); } } @@ -4238,7 +4242,7 @@ static double _opt_general_offset(OPT_ARGS_NUM, int ii, int nn) if(action & GMSH_GUI) GUI::instance()->options->general.value[nn]->value(CTX.offset[ii]); if(action & GMSH_SET){ - drawTransform *tr = GUI::instance()->graph[0]->gl->getDrawContext()->getTransform(); + drawTransform *tr = GUI::instance()->graph[0]->gl[0]->getDrawContext()->getTransform(); if(tr) tr->setMatrix(CTX.transform, CTX.offset); } } @@ -6539,51 +6543,6 @@ double opt_view_arrow_size_max(OPT_ARGS_NUM) #endif } -double opt_view_arrow_head_radius(OPT_ARGS_NUM) -{ -#if !defined(HAVE_NO_POST) - GET_VIEW(0.); - if(action & GMSH_SET){ - if(val < 0.) val = 0.; - if(val > 1.) val = 1.; - opt->ArrowRelHeadRadius = val; - } - return opt->ArrowRelHeadRadius; -#else - return 0.; -#endif -} - -double opt_view_arrow_stem_length(OPT_ARGS_NUM) -{ -#if !defined(HAVE_NO_POST) - GET_VIEW(0.); - if(action & GMSH_SET){ - if(val < 0.) val = 0.; - if(val > 1.) val = 1.; - opt->ArrowRelStemLength = val; - } - return opt->ArrowRelStemLength; -#else - return 0.; -#endif -} - -double opt_view_arrow_stem_radius(OPT_ARGS_NUM) -{ -#if !defined(HAVE_NO_POST) - GET_VIEW(0.); - if(action & GMSH_SET){ - if(val < 0.) val = 0.; - if(val > 1.) val = 1.; - opt->ArrowRelStemRadius = val; - } - return opt->ArrowRelStemRadius; -#else - return 0.; -#endif -} - double opt_view_normals(OPT_ARGS_NUM) { #if !defined(HAVE_NO_POST) diff --git a/Common/Options.h b/Common/Options.h index 69f2b1b2a14bc38ca50d4b3ac492060af6560bd4..da3105052cd0534b554e0e52f0c89d169c27e599 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -216,14 +216,14 @@ double opt_general_fontsize(OPT_ARGS_NUM); double opt_general_graphics_fontsize(OPT_ARGS_NUM); double opt_general_graphics_position0(OPT_ARGS_NUM); double opt_general_graphics_position1(OPT_ARGS_NUM); +double opt_general_graphics_size0(OPT_ARGS_NUM); +double opt_general_graphics_size1(OPT_ARGS_NUM); double opt_general_solver_position0(OPT_ARGS_NUM); double opt_general_solver_position1(OPT_ARGS_NUM); double opt_general_context_position0(OPT_ARGS_NUM); double opt_general_context_position1(OPT_ARGS_NUM); double opt_general_file_chooser_position0(OPT_ARGS_NUM); double opt_general_file_chooser_position1(OPT_ARGS_NUM); -double opt_general_viewport2(OPT_ARGS_NUM); -double opt_general_viewport3(OPT_ARGS_NUM); double opt_general_polygon_offset_always(OPT_ARGS_NUM); double opt_general_polygon_offset_factor(OPT_ARGS_NUM); double opt_general_polygon_offset_units(OPT_ARGS_NUM); @@ -593,9 +593,6 @@ double opt_view_transform21(OPT_ARGS_NUM); double opt_view_transform22(OPT_ARGS_NUM); double opt_view_arrow_size_min(OPT_ARGS_NUM); double opt_view_arrow_size_max(OPT_ARGS_NUM); -double opt_view_arrow_head_radius(OPT_ARGS_NUM); -double opt_view_arrow_stem_length(OPT_ARGS_NUM); -double opt_view_arrow_stem_radius(OPT_ARGS_NUM); double opt_view_normals(OPT_ARGS_NUM); double opt_view_tangents(OPT_ARGS_NUM); double opt_view_displacement_factor(OPT_ARGS_NUM); diff --git a/Fltk/Draw.cpp b/Fltk/Draw.cpp index e73fa6660a1e6571b082b4c0b068cbfb160f40a5..2cad7aa0bcacc577d3069f6c322909f99fca519c 100644 --- a/Fltk/Draw.cpp +++ b/Fltk/Draw.cpp @@ -4,16 +4,6 @@ // bugs and problems to <gmsh@geuz.org>. #include <string.h> -#include <FL/gl.h> - -//FIXME: workaround faulty fltk installs -//#include <FL/glu.h> -#ifdef __APPLE__ -# include <OpenGL/glu.h> -#else -# include <GL/glu.h> -#endif - #include "GUI.h" #include "graphicWindow.h" #include "optionWindow.h" @@ -30,36 +20,14 @@ void Draw() { if(!GUI::available()) return; for(unsigned int i = 0; i < GUI::instance()->graph.size(); i++){ - GUI::instance()->graph[i]->gl->make_current(); - GUI::instance()->graph[i]->gl->redraw(); + for(unsigned int j = 0; j < GUI::instance()->graph[i]->gl.size(); j++){ + GUI::instance()->graph[i]->gl[j]->make_current(); + GUI::instance()->graph[i]->gl[j]->redraw(); + } } GUI::instance()->check(); } -void ClearOpengl() -{ - glClearColor(CTX.UNPACK_RED(CTX.color.bg) / 255., - CTX.UNPACK_GREEN(CTX.color.bg) / 255., - CTX.UNPACK_BLUE(CTX.color.bg) / 255., 0.); - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); -} - -void SetOpenglContext(int index) -{ - if(!GUI::available()) return; - if(index >= 0 && index < GUI::instance()->graph.size()) - GUI::instance()->graph[index]->gl->make_current(); -} - -void Draw2d3d(int index) -{ - if(!GUI::available()) return; - if(index >= 0 && index < GUI::instance()->graph.size()){ - GUI::instance()->graph[index]->gl->getDrawContext()->draw3d(); - GUI::instance()->graph[index]->gl->getDrawContext()->draw2d(); - } -} - void DrawPlugin(void (*draw)(void *context)) { CTX.post.plugin_draw_function = draw; @@ -77,13 +45,25 @@ void DrawPlugin(void (*draw)(void *context)) CTX.mesh.draw = 1; } -void GetStoredViewport(int viewport[4], int index) +void DrawCurrentOpenglWindow(bool make_current) { if(!GUI::available()) return; - if(index >= 0 && index < GUI::instance()->graph.size()){ - for(int i = 0; i < 4; i++) - viewport[i] = GUI::instance()->graph[index]->gl->getDrawContext()->viewport[i]; - } + openglWindow *gl = GUI::instance()->getCurrentOpenglWindow(); + if(make_current) gl->make_current(); + glClearColor(CTX.UNPACK_RED(CTX.color.bg) / 255., + CTX.UNPACK_GREEN(CTX.color.bg) / 255., + CTX.UNPACK_BLUE(CTX.color.bg) / 255., 0.); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + gl->getDrawContext()->draw3d(); + gl->getDrawContext()->draw2d(); +} + +void GetCurrentOpenglWindowViewport(int viewport[4]) +{ + if(!GUI::available()) return; + openglWindow *gl = GUI::instance()->getCurrentOpenglWindow(); + for(int i = 0; i < 4; i++) + viewport[i] = gl->getDrawContext()->viewport[i]; } int GetFontIndex(const char *fontname) diff --git a/Fltk/Draw.h b/Fltk/Draw.h index 551554cb7f7ede815df4743480d6a5fa259b024d..defebfd35d16052d5c467970a0b5d0e4c40ebbaf 100644 --- a/Fltk/Draw.h +++ b/Fltk/Draw.h @@ -8,12 +8,10 @@ #include <string> -void SetOpenglContext(int index=0); -void ClearOpengl(); void Draw(); -void Draw2d3d(int index=0); void DrawPlugin(void (*draw)(void *context)); -void GetStoredViewport(int viewport[4], int index=0); +void DrawCurrentOpenglWindow(bool make_current); +void GetCurrentOpenglWindowViewport(int viewport[4]); int GetFontIndex(const char *fontname); int GetFontEnum(int index); const char *GetFontName(int index); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index ea09bb26a89d320a08049bb3711be45b405160fa..93af50f8e8bd49f37d34e07b37a95f84d53a3a2f 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -80,7 +80,7 @@ GUI::GUI(int argc, char **argv) // since the shortcuts should be valid even for hidden windows, and // we don't want to test for widget existence every time menu = new menuWindow(); - graph.push_back(new graphicWindow()); + graph.push_back(new graphicWindow(CTX.num_tiles)); #if defined(WIN32) graph[0]->win->icon @@ -117,38 +117,36 @@ GUI::GUI(int argc, char **argv) // graphic window should have the initial focus (so we can // e.g. directly loop through time steps with the keyboard) - graph[0]->gl->take_focus(); + graph[0]->gl[0]->take_focus(); // create additional graphic windows for(int i = 1; i < CTX.num_windows; i++){ - graph.push_back(new graphicWindow()); - //double mat[3][3] = {10,0,0,0,1,0,0,0,1}; - //drawTransform *tr = new drawTransformScaled(mat); - //graph.back()->gl->getDrawContext()->setTransform(tr); + graph.push_back(new graphicWindow(CTX.num_tiles)); graph.back()->win->size(400, 400); graph.back()->win->show(); } - options = new optionWindow(); - fields = new fieldWindow(); - plugins = new pluginWindow(); - stats = new statisticsWindow(); - visibility = new visibilityWindow(); - clipping = new clippingWindow(); - messages = new messageWindow(); - manip = new manipWindow(); - geoContext = new geometryContextWindow(); - meshContext = new meshContextWindow(); + options = new optionWindow(CTX.deltafontsize); + fields = new fieldWindow(CTX.deltafontsize); + plugins = new pluginWindow(CTX.deltafontsize); + stats = new statisticsWindow(CTX.deltafontsize); + visibility = new visibilityWindow(CTX.deltafontsize); + clipping = new clippingWindow(CTX.deltafontsize); + messages = new messageWindow(CTX.deltafontsize); + manip = new manipWindow(CTX.deltafontsize); + geoContext = new geometryContextWindow(CTX.deltafontsize); + meshContext = new meshContextWindow(CTX.deltafontsize); about = new aboutWindow(); for(int i = 0; i < MAX_NUM_SOLVERS; i++) - solver.push_back(new solverWindow(i)); + solver.push_back(new solverWindow(i, CTX.deltafontsize)); // init solver plugin stuff callForSolverPlugin(-1); // draw the scene for(unsigned int i = 0; i < graph.size(); i++) - graph[i]->gl->redraw(); + for(unsigned int j = 0; j < graph[i]->gl.size(); j++) + graph[i]->gl[j]->redraw(); } GUI *GUI::_instance = 0; @@ -218,27 +216,32 @@ int GUI::testGlobalShortcuts(int event) } else if(Fl::test_shortcut('e')) { for(unsigned int i = 0; i < graph.size(); i++) - graph[i]->gl->endSelection = 1; + for(unsigned int j = 0; j < graph[i]->gl.size(); j++) + graph[i]->gl[j]->endSelection = 1; status = 0; // trick: do as if we didn't use it } else if(Fl::test_shortcut('u')) { for(unsigned int i = 0; i < graph.size(); i++) - graph[i]->gl->undoSelection = 1; + for(unsigned int j = 0; j < graph[i]->gl.size(); j++) + graph[i]->gl[j]->undoSelection = 1; status = 0; // trick: do as if we didn't use it } else if(Fl::test_shortcut('i')) { for(unsigned int i = 0; i < graph.size(); i++) - graph[i]->gl->invertSelection = 1; + for(unsigned int j = 0; j < graph[i]->gl.size(); j++) + graph[i]->gl[j]->invertSelection = 1; status = 0; // trick: do as if we didn't use it } else if(Fl::test_shortcut('q')) { for(unsigned int i = 0; i < graph.size(); i++) - graph[i]->gl->quitSelection = 1; + for(unsigned int j = 0; j < graph[i]->gl.size(); j++) + graph[i]->gl[j]->quitSelection = 1; status = 0; // trick: do as if we didn't use it } else if(Fl::test_shortcut('-')) { for(unsigned int i = 0; i < graph.size(); i++) - graph[i]->gl->invertSelection = 1; + for(unsigned int j = 0; j < graph[i]->gl.size(); j++) + graph[i]->gl[j]->invertSelection = 1; status = 0; // trick: do as if we didn't use it } else if(Fl::test_shortcut(FL_Escape) || @@ -248,14 +251,16 @@ int GUI::testGlobalShortcuts(int event) Fl::test_shortcut(FL_ALT + FL_Escape)) { bool lasso = false; for(unsigned int i = 0; i < graph.size(); i++) - if(graph[i]->gl->lassoMode) lasso = true; + for(unsigned int j = 0; j < graph[i]->gl.size(); j++) + if(graph[i]->gl[j]->lassoMode) lasso = true; if(lasso){ for(unsigned int i = 0; i < graph.size(); i++) - graph[i]->gl->lassoMode = false; + for(unsigned int j = 0; j < graph[i]->gl.size(); j++) + graph[i]->gl[j]->lassoMode = false; status = 2; } else{ - status_xyz1p_cb(0, (void *)"S"); + status_options_cb(0, (void *)"S"); status = 1; } } @@ -356,7 +361,7 @@ int GUI::testGlobalShortcuts(int event) } else if(Fl::test_shortcut(FL_ALT + 'o') || Fl::test_shortcut(FL_ALT + FL_SHIFT + 'o')) { - status_xyz1p_cb(0, (void *)"p"); + status_options_cb(0, (void *)"p"); status = 1; } else if(Fl::test_shortcut(FL_ALT + 'a')) { @@ -511,11 +516,6 @@ int GUI::testArrowShortcuts() return 0; } -void GUI::setGraphicSize(int w, int h) -{ - graph[0]->win->size(w, h + graph[0]->win->h() - graph[0]->gl->h()); -} - void GUI::setGraphicTitle(const char *str) { // FIXME should use copy_label, but it is broken for Fl_Windows in @@ -549,20 +549,28 @@ void GUI::resetVisibility() visibility_cb(NULL, NULL); } -int GUI::getLastGraphIndex() +openglWindow *GUI::getCurrentOpenglWindow() { - unsigned int index = 0; - if(graph.size() > 1) - for(Fl_Window *w = Fl::first_window(); w; w = Fl::next_window(w)) - for(index = 0; index < graph.size(); index++) - if(w == graph[index]->win || w == graph[index]->gl) - return index; - return 0; + if(openglWindow::getLastHandled()) + return openglWindow::getLastHandled(); + else + return graph[0]->gl[0]; +} + +void GUI::splitCurrentOpenglWindow(char how) +{ + openglWindow *g = getCurrentOpenglWindow(); + for(unsigned int i = 0; i < graph.size(); i++){ + if(graph[i]->tile->find(g) != graph[i]->tile->children()){ + graph[i]->split(g, how); + break; + } + } } char GUI::selectEntity(int type) { - return graph[getLastGraphIndex()]->gl->selectEntity + return getCurrentOpenglWindow()->selectEntity (type, selectedVertices, selectedEdges, selectedFaces, selectedRegions, selectedElements); } @@ -579,17 +587,17 @@ void GUI::setStatus(const char *msg, int num) } } else if(num == 2){ - int index = getLastGraphIndex(); + openglWindow *gl = getCurrentOpenglWindow(); int n = strlen(msg); int i = 0; while(i < n) if(msg[i++] == '\n') break; - graph[index]->gl->screenMessage[0] = std::string(msg); + gl->screenMessage[0] = std::string(msg); if(i) - graph[index]->gl->screenMessage[0].resize(i - 1); + gl->screenMessage[0].resize(i - 1); if(i < n) - graph[index]->gl->screenMessage[1] = std::string(&msg[i]); + gl->screenMessage[1] = std::string(&msg[i]); else - graph[index]->gl->screenMessage[1].clear(); + gl->screenMessage[1].clear(); Draw(); } } @@ -600,6 +608,8 @@ void GUI::storeCurrentWindowsInfo() CTX.position[1] = menu->win->y(); CTX.gl_position[0] = graph[0]->win->x(); CTX.gl_position[1] = graph[0]->win->y(); + CTX.gl_size[0] = graph[0]->win->w(); + CTX.gl_size[1] = (graph[0]->win->h() - graph[0]->bottom->h()); CTX.msg_position[0] = messages->win->x(); CTX.msg_position[1] = messages->win->y(); CTX.msg_size[0] = messages->win->w(); diff --git a/Fltk/GUI.h b/Fltk/GUI.h index 8764a6dd57df2c423cc10d2ce2e46571818c1055..c442ed6244dea5dcb6b7a94167613cca76145743 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -18,6 +18,7 @@ #define WB (7) // window border class graphicWindow; +class openglWindow; class menuWindow; class optionWindow; class fieldWindow; @@ -84,8 +85,6 @@ class GUI{ // navigation). This is necessary since FLTK 1.1. int testArrowShortcuts(); // set the size of the graphic window - void setGraphicSize(int w, int h); - // set the title of the graphic window void setGraphicTitle(const char *str); // update the GUI when views get added or deleted void updateViews(); @@ -95,8 +94,10 @@ class GUI{ void resetVisibility(); // store current window positions and sizes in CTX void storeCurrentWindowsInfo(); - // get the index of the last graphic window that received an event - int getLastGraphIndex(); + // get the last opengl window that received an event + openglWindow *getCurrentOpenglWindow(); + // split the current opengl window + void splitCurrentOpenglWindow(char how); // select an entity in the most recent graphic window char selectEntity(int type); // display status message diff --git a/Fltk/Makefile b/Fltk/Makefile index c3c380adb387592ff61761930a4a99e0a00d66e1..f403a3078588c085518a5c7ba86744af198de6df 100644 --- a/Fltk/Makefile +++ b/Fltk/Makefile @@ -108,11 +108,11 @@ GUI${OBJEXT}: GUI.cpp GUI.h graphicWindow.h openglWindow.h \ ../Mesh/PartitionOptions.h graphicWindow${OBJEXT}: graphicWindow.cpp GUI.h graphicWindow.h openglWindow.h \ ../Graphics/drawContext.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \ - shortcutWindow.h menuWindow.h popupButton.h messageWindow.h \ - manipWindow.h extraDialogs.h Draw.h ../Post/PView.h ../Post/PViewData.h \ - ../Numeric/GmshMatrix.h ../Common/GmshMessage.h ../Common/OS.h \ - ../Common/Options.h ../Post/ColorTable.h ../Common/Context.h \ - ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h + menuWindow.h popupButton.h messageWindow.h manipWindow.h extraDialogs.h \ + Draw.h ../Post/PView.h ../Post/PViewData.h ../Numeric/GmshMatrix.h \ + ../Common/GmshMessage.h ../Common/OS.h ../Common/Options.h \ + ../Post/ColorTable.h ../Common/Context.h ../Geo/CGNSOptions.h \ + ../Mesh/PartitionOptions.h openglWindow${OBJEXT}: openglWindow.cpp openglWindow.h ../Graphics/drawContext.h \ ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h graphicWindow.h manipWindow.h \ contextWindow.h ../Common/GmshDefines.h ../Common/GmshMessage.h \ @@ -131,25 +131,24 @@ openglWindow${OBJEXT}: openglWindow.cpp openglWindow.h ../Graphics/drawContext.h ../Numeric/GmshMatrix.h GUI.h ../Common/VertexArray.h \ ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h menuWindow${OBJEXT}: menuWindow.cpp GUI.h Draw.h menuWindow.h popupButton.h \ - shortcutWindow.h graphicWindow.h openglWindow.h \ - ../Graphics/drawContext.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \ - optionWindow.h spherePositionWidget.h colorbarWindow.h \ - ../Post/ColorTable.h statisticsWindow.h messageWindow.h contextWindow.h \ - visibilityWindow.h clippingWindow.h manipWindow.h fieldWindow.h \ - pluginWindow.h solverWindow.h aboutWindow.h fileDialogs.h \ - partitionDialog.h projectionEditor.h ../Geo/fourierProjectionFace.h \ - ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \ - ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \ - ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \ - ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \ - ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \ - ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \ - ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \ - ../Geo/SBoundingBox3d.h ../Geo/Range.h classificationEditor.h \ - ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \ - ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \ - ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \ - ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \ + dialogWindow.h graphicWindow.h openglWindow.h ../Graphics/drawContext.h \ + ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h optionWindow.h \ + spherePositionWidget.h colorbarWindow.h ../Post/ColorTable.h \ + statisticsWindow.h messageWindow.h contextWindow.h visibilityWindow.h \ + clippingWindow.h manipWindow.h fieldWindow.h pluginWindow.h \ + solverWindow.h aboutWindow.h fileDialogs.h partitionDialog.h \ + projectionEditor.h ../Geo/fourierProjectionFace.h ../Geo/GModel.h \ + ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ + ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \ + ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \ + ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \ + ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \ + ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \ + ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/Range.h \ + classificationEditor.h ../Geo/MElement.h ../Common/GmshDefines.h \ + ../Geo/MVertex.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h \ + ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \ + ../Geo/SVector3.h ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \ ../Numeric/GmshMatrix.h ../Numeric/Gauss.h ../Common/Options.h \ Solvers.h ../Common/CommandLine.h ../Mesh/Generator.h \ ../Mesh/HighOrder.h ../Post/PView.h ../Post/PViewData.h \ @@ -160,7 +159,7 @@ menuWindow${OBJEXT}: menuWindow.cpp GUI.h Draw.h menuWindow.h popupButton.h \ ../Mesh/PartitionOptions.h optionWindow${OBJEXT}: optionWindow.cpp GUI.h optionWindow.h \ spherePositionWidget.h colorbarWindow.h ../Post/ColorTable.h \ - shortcutWindow.h menuWindow.h popupButton.h extraDialogs.h Draw.h \ + dialogWindow.h menuWindow.h popupButton.h extraDialogs.h Draw.h \ ../Common/GmshDefines.h ../Common/GmshMessage.h ../Common/Options.h \ Solvers.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \ ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \ @@ -179,9 +178,9 @@ optionWindow${OBJEXT}: optionWindow.cpp GUI.h optionWindow.h \ colorbarWindow${OBJEXT}: colorbarWindow.cpp colorbarWindow.h \ ../Post/ColorTable.h Draw.h ../Common/Context.h ../Geo/CGNSOptions.h \ ../Mesh/PartitionOptions.h -fieldWindow${OBJEXT}: fieldWindow.cpp GUI.h Draw.h fieldWindow.h \ - shortcutWindow.h fileDialogs.h ../Common/GmshDefines.h ../Geo/GModel.h \ - ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ +fieldWindow${OBJEXT}: fieldWindow.cpp GUI.h Draw.h fieldWindow.h dialogWindow.h \ + fileDialogs.h ../Common/GmshDefines.h ../Geo/GModel.h ../Geo/GVertex.h \ + ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \ ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \ ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \ @@ -193,14 +192,14 @@ fieldWindow${OBJEXT}: fieldWindow.cpp GUI.h Draw.h fieldWindow.h \ ../Common/Options.h ../Post/ColorTable.h ../Common/Context.h \ ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h pluginWindow${OBJEXT}: pluginWindow.cpp GUI.h Draw.h pluginWindow.h \ - shortcutWindow.h ../Post/PView.h ../Geo/SPoint3.h \ + dialogWindow.h ../Post/PView.h ../Geo/SPoint3.h \ ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Common/Options.h \ ../Post/ColorTable.h ../Common/GmshMessage.h ../Post/PViewDataList.h \ ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \ ../Numeric/GmshMatrix.h ../Common/ListUtils.h ../Common/Context.h \ ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h statisticsWindow${OBJEXT}: statisticsWindow.cpp GUI.h Draw.h statisticsWindow.h \ - shortcutWindow.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \ + dialogWindow.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \ ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \ ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \ ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \ @@ -216,7 +215,7 @@ statisticsWindow${OBJEXT}: statisticsWindow.cpp GUI.h Draw.h statisticsWindow.h ../Mesh/Generator.h ../Common/Context.h ../Geo/CGNSOptions.h \ ../Mesh/PartitionOptions.h visibilityWindow${OBJEXT}: visibilityWindow.cpp GUI.h Draw.h visibilityWindow.h \ - shortcutWindow.h contextWindow.h ../Common/GmshDefines.h \ + dialogWindow.h contextWindow.h ../Common/GmshDefines.h \ ../Common/GmshMessage.h ../Geo/GModel.h ../Geo/GVertex.h \ ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \ @@ -233,20 +232,20 @@ visibilityWindow${OBJEXT}: visibilityWindow.cpp GUI.h Draw.h visibilityWindow.h ../Post/ColorTable.h ../Common/Context.h ../Geo/CGNSOptions.h \ ../Mesh/PartitionOptions.h ../Parser/Parser.h clippingWindow${OBJEXT}: clippingWindow.cpp GUI.h Draw.h clippingWindow.h \ - shortcutWindow.h ../Common/GmshDefines.h ../Post/PView.h \ - ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \ - ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/Context.h \ - ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h -messageWindow${OBJEXT}: messageWindow.cpp GUI.h messageWindow.h shortcutWindow.h \ + dialogWindow.h ../Common/GmshDefines.h ../Post/PView.h ../Geo/SPoint3.h \ + ../Post/PViewOptions.h ../Post/ColorTable.h ../Geo/SBoundingBox3d.h \ + ../Geo/SPoint3.h ../Common/Context.h ../Geo/CGNSOptions.h \ + ../Mesh/PartitionOptions.h +messageWindow${OBJEXT}: messageWindow.cpp GUI.h messageWindow.h dialogWindow.h \ fileDialogs.h ../Common/GmshMessage.h ../Common/OS.h \ ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h -manipWindow${OBJEXT}: manipWindow.cpp GUI.h Draw.h manipWindow.h \ - shortcutWindow.h graphicWindow.h openglWindow.h \ - ../Graphics/drawContext.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \ - ../Common/Options.h ../Post/ColorTable.h ../Common/Context.h \ - ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h +manipWindow${OBJEXT}: manipWindow.cpp GUI.h Draw.h manipWindow.h dialogWindow.h \ + graphicWindow.h openglWindow.h ../Graphics/drawContext.h \ + ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/Options.h \ + ../Post/ColorTable.h ../Common/Context.h ../Geo/CGNSOptions.h \ + ../Mesh/PartitionOptions.h contextWindow${OBJEXT}: contextWindow.cpp GUI.h Draw.h contextWindow.h \ - shortcutWindow.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \ + dialogWindow.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \ ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \ ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \ ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \ @@ -256,16 +255,16 @@ contextWindow${OBJEXT}: contextWindow.cpp GUI.h Draw.h contextWindow.h \ ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GeoStringInterface.h \ ../Common/ListUtils.h ../Common/OpenFile.h ../Common/Context.h \ ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h -solverWindow${OBJEXT}: solverWindow.cpp GUI.h solverWindow.h shortcutWindow.h \ +solverWindow${OBJEXT}: solverWindow.cpp GUI.h solverWindow.h dialogWindow.h \ optionWindow.h spherePositionWidget.h colorbarWindow.h \ ../Post/ColorTable.h messageWindow.h fileDialogs.h \ ../Common/GmshMessage.h Solvers.h ../Common/StringUtils.h \ ../Common/Options.h ../Common/OS.h ../Common/Context.h \ ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h -aboutWindow${OBJEXT}: aboutWindow.cpp GUI.h aboutWindow.h shortcutWindow.h \ +aboutWindow${OBJEXT}: aboutWindow.cpp GUI.h aboutWindow.h dialogWindow.h \ ../Common/CommandLine.h ../Common/StringUtils.h ../Common/OS.h \ ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h -fileDialogs${OBJEXT}: fileDialogs.cpp GUI.h shortcutWindow.h \ +fileDialogs${OBJEXT}: fileDialogs.cpp GUI.h dialogWindow.h \ ../Common/GmshDefines.h ../Common/CreateFile.h ../Common/Options.h \ ../Post/ColorTable.h Draw.h ../Geo/GModel.h ../Geo/GVertex.h \ ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ @@ -277,7 +276,7 @@ fileDialogs${OBJEXT}: fileDialogs.cpp GUI.h shortcutWindow.h \ ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \ ../Geo/SBoundingBox3d.h ../Common/Context.h ../Geo/CGNSOptions.h \ ../Mesh/PartitionOptions.h fileChooser.h -extraDialogs${OBJEXT}: extraDialogs.cpp GUI.h shortcutWindow.h \ +extraDialogs${OBJEXT}: extraDialogs.cpp GUI.h dialogWindow.h \ ../Common/GmshDefines.h ../Common/CreateFile.h ../Common/Options.h \ ../Post/ColorTable.h Draw.h ../Geo/GModel.h ../Geo/GVertex.h \ ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ @@ -290,7 +289,7 @@ extraDialogs${OBJEXT}: extraDialogs.cpp GUI.h shortcutWindow.h \ ../Geo/SBoundingBox3d.h ../Common/Context.h ../Geo/CGNSOptions.h \ ../Mesh/PartitionOptions.h projectionEditor${OBJEXT}: projectionEditor.cpp GUI.h projectionEditor.h \ - shortcutWindow.h ../Geo/fourierProjectionFace.h ../Geo/GModel.h \ + dialogWindow.h ../Geo/fourierProjectionFace.h ../Geo/GModel.h \ ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \ ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \ @@ -311,8 +310,8 @@ projectionEditor${OBJEXT}: projectionEditor.cpp GUI.h projectionEditor.h \ ../Geo/MVertex.h ../Common/Context.h ../Geo/CGNSOptions.h \ ../Mesh/PartitionOptions.h classificationEditor${OBJEXT}: classificationEditor.cpp GUI.h \ - classificationEditor.h shortcutWindow.h ../Geo/GModel.h \ - ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ + classificationEditor.h dialogWindow.h ../Geo/GModel.h ../Geo/GVertex.h \ + ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \ ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \ ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \ @@ -331,7 +330,7 @@ classificationEditor${OBJEXT}: classificationEditor.cpp GUI.h \ ../Mesh/meshGFaceDelaunayInsertion.h ../Geo/discreteEdge.h \ ../Geo/GModel.h ../Geo/GEdge.h ../Geo/discreteFace.h ../Geo/GModel.h \ ../Geo/GFace.h -partitionDialog${OBJEXT}: partitionDialog.cpp GUI.h shortcutWindow.h \ +partitionDialog${OBJEXT}: partitionDialog.cpp GUI.h dialogWindow.h \ ../Common/GmshDefines.h ../Common/GmshMessage.h ../Geo/GModel.h \ ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \ ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \ diff --git a/Fltk/aboutWindow.cpp b/Fltk/aboutWindow.cpp index 2c5c011e023a0177b764697d1d81cf8483d39871..d4941ffbfb864df7df2f5878814f6ff53e942fd4 100644 --- a/Fltk/aboutWindow.cpp +++ b/Fltk/aboutWindow.cpp @@ -8,7 +8,7 @@ #include <FL/Fl_Button.H> #include "GUI.h" #include "aboutWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "CommandLine.h" #include "StringUtils.h" #include "OS.h" @@ -51,11 +51,7 @@ aboutWindow::aboutWindow() o->add("@c@.with built-in pre- and post-processing facilities"); o->add(" "); o->add("@c@.Copyright (C) 1997-2009"); -#if defined(__APPLE__) o->add("@c@.Christophe Geuzaine and Jean-Francois Remacle"); -#else - o->add("@c@.Christophe Geuzaine and Jean-François Remacle"); -#endif o->add(" "); o->add("@c@.Please send all questions and bug reports to"); o->add("@c@b@.gmsh@geuz.org"); diff --git a/Fltk/classificationEditor.h b/Fltk/classificationEditor.h index 31dbfff5acfc0ee4ca85ae06078f0b6b9b85df4d..a73905fa1e96223f893250ea03030e425e88e524 100644 --- a/Fltk/classificationEditor.h +++ b/Fltk/classificationEditor.h @@ -9,7 +9,7 @@ #include <vector> #include <FL/Fl_Toggle_Button.H> #include <FL/Fl_Round_Button.H> -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "GModel.h" #include "MElement.h" #include "ColorTable.h" @@ -51,7 +51,7 @@ class classificationEditor { std::vector<edge_angle> edges_detected; std::vector<edge_angle> edges_lonly; classificationEditor(); - void show(){ _window->show();} + void show(){ _window->show(); } std::vector<MTriangle*> &getElements() { return _elements; } Fl_Group *edge_detec, *face_color, *reverse_eng; }; diff --git a/Fltk/clippingWindow.cpp b/Fltk/clippingWindow.cpp index 6dae0a98dd5de587fb29ae0d6a2e7feddcd0fecf..9d0c969dc2fa2619ca9e6f538816bc8f7234f8b5 100644 --- a/Fltk/clippingWindow.cpp +++ b/Fltk/clippingWindow.cpp @@ -8,7 +8,7 @@ #include "GUI.h" #include "Draw.h" #include "clippingWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "GmshDefines.h" #include "PView.h" #include "PViewOptions.h" @@ -145,8 +145,10 @@ static void clip_reset_cb(Fl_Widget *w, void *data) Draw(); } -clippingWindow::clippingWindow() +clippingWindow::clippingWindow(int deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; + static Fl_Menu_Item plane_number[] = { {"Plane 0", 0, 0}, {"Plane 1", 0, 0}, @@ -253,6 +255,8 @@ clippingWindow::clippingWindow() win->position(CTX.clip_position[0], CTX.clip_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } void clippingWindow::resetBrowser() diff --git a/Fltk/clippingWindow.h b/Fltk/clippingWindow.h index ab82ae2cb3bc87a9ac9d591501a15e2e6dcdf11c..5fe02f52d0ef691179fd739229d58d0fe79079ba 100644 --- a/Fltk/clippingWindow.h +++ b/Fltk/clippingWindow.h @@ -22,7 +22,7 @@ class clippingWindow{ Fl_Check_Button *butt[3]; Fl_Group *group[2]; public: - clippingWindow(); + clippingWindow(int deltaFontSize=0); void resetBrowser(); void show(); }; diff --git a/Fltk/contextWindow.cpp b/Fltk/contextWindow.cpp index 6d7f00a727092a5a3e292262b4cef64865fc038a..4650be9b40aa356fad1418cb3fbecf94ed126355 100644 --- a/Fltk/contextWindow.cpp +++ b/Fltk/contextWindow.cpp @@ -8,7 +8,7 @@ #include "GUI.h" #include "Draw.h" #include "contextWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "GModel.h" #include "GeoStringInterface.h" #include "OpenFile.h" @@ -43,8 +43,10 @@ static void con_geometry_snap_cb(Fl_Widget *w, void *data) CTX.geom.snap[2] = GUI::instance()->geoContext->value[2]->value(); } -geometryContextWindow::geometryContextWindow() +geometryContextWindow::geometryContextWindow(int deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; + int width = 31 * FL_NORMAL_SIZE; int height = 5 * WB + 9 * BH; @@ -195,6 +197,8 @@ geometryContextWindow::geometryContextWindow() win->position(CTX.ctx_position[0], CTX.ctx_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } void geometryContextWindow::show(int pane) @@ -205,8 +209,10 @@ void geometryContextWindow::show(int pane) win->show(); } -meshContextWindow::meshContextWindow() +meshContextWindow::meshContextWindow(int deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; + static Fl_Menu menu_transfinite_dir[] = { {"Left", 0, 0, 0}, {"Right", 0, 0, 0}, @@ -276,6 +282,8 @@ meshContextWindow::meshContextWindow() win->position(CTX.ctx_position[0], CTX.ctx_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } void meshContextWindow::show(int pane) diff --git a/Fltk/contextWindow.h b/Fltk/contextWindow.h index 2137e8edecb400603713f2b1c0f1715b42ed0d1e..ce51140304bdeeeb292582ce10a4e14278d35f2c 100644 --- a/Fltk/contextWindow.h +++ b/Fltk/contextWindow.h @@ -19,7 +19,7 @@ class geometryContextWindow{ Fl_Value_Input *value[10]; Fl_Group *group[10]; public: - geometryContextWindow(); + geometryContextWindow(int deltaFontSize=0); void show(int pane); }; @@ -30,7 +30,7 @@ class meshContextWindow{ Fl_Choice *choice[20]; Fl_Group *group[10]; public: - meshContextWindow(); + meshContextWindow(int deltaFontSize=0); void show(int pane); }; diff --git a/Fltk/dialogWindow.h b/Fltk/dialogWindow.h new file mode 100644 index 0000000000000000000000000000000000000000..c0dbea7ee1ed0d39bd0c7198ea31b0c730e7ddcb --- /dev/null +++ b/Fltk/dialogWindow.h @@ -0,0 +1,49 @@ +// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle +// +// See the LICENSE.txt file for license information. Please report all +// bugs and problems to <gmsh@geuz.org>. + +#ifndef _DIALOG_WINDOW_H +#define _DIALOG_WINDOW_H + +#include <FL/Fl.H> +#include <FL/Fl_Double_Window.H> +#include <FL/fl_ask.H> + +// Derive special windows from Fl_Double_Window to correctly process +// the OS-specific shorcuts (Esc & Cmd-w on Mac, Alt+F4 on Windows) +class dialogWindow : public Fl_Double_Window { + private: + int handle(int event) + { + switch (event) { + case FL_SHORTCUT: + case FL_KEYBOARD: +#if defined(__APPLE__) + if(Fl::test_shortcut(FL_META+'w') || Fl::test_shortcut(FL_Escape)){ +#elif defined(WIN32) + if(Fl::test_shortcut(FL_ALT+FL_F+4) || Fl::test_shortcut(FL_Escape)){ +#else + if(Fl::test_shortcut(FL_CTRL+'w') || Fl::test_shortcut(FL_Escape)){ +#endif + do_callback(); + return 1; + } + break; + } + return Fl_Double_Window::handle(event); + } + public: + dialogWindow(int w, int h, int nonmodal=false, const char *l=0) + : Fl_Double_Window(w, h, l) + { + if(nonmodal) set_non_modal(); + } + void show() + { + if(non_modal() && !shown()) Fl_Double_Window::show(); // fix ordering + Fl_Double_Window::show(); + } +}; + +#endif diff --git a/Fltk/extraDialogs.cpp b/Fltk/extraDialogs.cpp index ab03c839a4c826f258d349e35d44d780325bdc2b..633d2611409b9807538ccc5ae1251b52e44952f6 100644 --- a/Fltk/extraDialogs.cpp +++ b/Fltk/extraDialogs.cpp @@ -17,7 +17,7 @@ #include <FL/Fl_Hold_Browser.H> #include <FL/Fl_Box.H> #include "GUI.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "GmshDefines.h" #include "CreateFile.h" #include "Options.h" diff --git a/Fltk/fieldWindow.cpp b/Fltk/fieldWindow.cpp index 6a769ae82d5724a1f9f8e6e47e4abd6be0523ef8..04c3e60a3f2d02bff627b62e156c515e4cdede67 100644 --- a/Fltk/fieldWindow.cpp +++ b/Fltk/fieldWindow.cpp @@ -11,7 +11,7 @@ #include "GUI.h" #include "Draw.h" #include "fieldWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "fileDialogs.h" #include "GmshDefines.h" #include "GModel.h" @@ -119,8 +119,10 @@ static void field_select_node_cb(Fl_Widget *w, void *data) Draw(); } -fieldWindow::fieldWindow() +fieldWindow::fieldWindow(int deltaFontSize) : _deltaFontSize(deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; + int width0 = 34 * FL_NORMAL_SIZE + WB; int height0 = 13 * BH + 5 * WB; int width = (CTX.field_size[0] < width0) ? width0 : CTX.field_size[0]; @@ -206,6 +208,8 @@ fieldWindow::fieldWindow() win->position(CTX.field_position[0], CTX.field_position[1]); win->end(); + FL_NORMAL_SIZE += deltaFontSize; + loadFieldViewList(); editField(NULL); } @@ -352,6 +356,9 @@ void fieldWindow::editField(Field *f) loadFieldList(); return; } + + FL_NORMAL_SIZE -= _deltaFontSize; + selected_id = f->id; editor_group->show(); editor_group->user_data(f); @@ -400,6 +407,9 @@ void fieldWindow::editField(Field *f) yy += WB + BH; } options_scroll->end(); + + FL_NORMAL_SIZE += _deltaFontSize; + loadFieldOptions(); options_scroll->damage(1); put_on_view_btn->activate(); diff --git a/Fltk/fieldWindow.h b/Fltk/fieldWindow.h index c93f3a72db7b306f7ca2ca017fc5312a6c8551d5..05a0548fb1e892e4e4c2c05ff9fd6cb389696371 100644 --- a/Fltk/fieldWindow.h +++ b/Fltk/fieldWindow.h @@ -21,6 +21,8 @@ class Field; class fieldWindow{ + private: + int _deltaFontSize; public: Fl_Window *win; Fl_Hold_Browser *browser; @@ -34,7 +36,7 @@ class fieldWindow{ Fl_Button *delete_btn; int selected_id; public: - fieldWindow(); + fieldWindow(int deltaFontSize=0); void loadFieldViewList(); void loadFieldList(); void saveFieldOptions(); diff --git a/Fltk/fileDialogs.cpp b/Fltk/fileDialogs.cpp index 9a1542babc09d069bb9ead720049006a5565d692..556d7a0ae4999eebfa9aae8358c93c875bd72cc7 100644 --- a/Fltk/fileDialogs.cpp +++ b/Fltk/fileDialogs.cpp @@ -18,7 +18,7 @@ #include <FL/Fl_Round_Button.H> #include <FL/Fl_Choice.H> #include "GUI.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "GmshDefines.h" #include "CreateFile.h" #include "Options.h" diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index 671f10a6c56a7382a680708b38a03864f47ec54b..9d4e8ad1807917bebe1e4ed6bf4ee51581981c82 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -5,9 +5,9 @@ #include <string.h> #include <FL/fl_draw.H> +#include <FL/fl_ask.H> #include "GUI.h" #include "graphicWindow.h" -#include "shortcutWindow.h" #include "menuWindow.h" #include "messageWindow.h" #include "manipWindow.h" @@ -21,17 +21,6 @@ extern Context_T CTX; -// This dummy box class permits to define a box widget that will not -// eat the FL_ENTER/FL_LEAVE events (the new Box widget in fltk > 1.1 -// does that, so that gl->handle() was not called when the mouse -// moved) -class dummyBox : public Fl_Box { - private: - int handle(int){ return 0; } // always! - public: - dummyBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x, y, w, h, l) {} -}; - // Icons for the satus bar #define vv(x,y) fl_vertex(x,y) #define bl fl_begin_loop() @@ -101,71 +90,85 @@ static void gmsh_models(Fl_Color c) #undef bl #undef el -static int findGraphIndex(Fl_Widget *w) +static graphicWindow *getGraphicWindow(Fl_Widget *w) { - if(!w || !w->parent()) return 0; + if(!w || !w->parent()) return GUI::instance()->graph[0]; for(unsigned int i = 0; i < GUI::instance()->graph.size(); i++) if(GUI::instance()->graph[i]->win == w->parent()) - return i; - return 0; + return GUI::instance()->graph[i]; + return GUI::instance()->graph[0]; } void status_xyz1p_cb(Fl_Widget *w, void *data) { const char *str = (const char*)data; - int index = findGraphIndex(w); - drawContext *ctx = GUI::instance()->graph[index]->gl->getDrawContext(); + std::vector<openglWindow*> gls; + if(w) + gls = getGraphicWindow(w)->gl; + else + gls.push_back(GUI::instance()->getCurrentOpenglWindow()); - 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, "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.; + for(unsigned int i = 0; i < gls.size(); i++){ + drawContext *ctx = gls[i]->getDrawContext(); + 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.); } - else{ - ctx->r[0] = -90.; ctx->r[1] = 0.; ctx->r[2] = 90.; + 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(); } - ctx->setQuaternionFromEulerAngles(); - Draw(); - } - else if(!strcmp(str, "y")){ // Y pointing out or into the screen - if(!Fl::event_state(FL_SHIFT)){ - ctx->r[0] = -90.; ctx->r[1] = 0.; ctx->r[2] = 180.; + else if(!strcmp(str, "y")){ // Y pointing out or into the screen + if(!Fl::event_state(FL_SHIFT)){ + 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.; + } + ctx->setQuaternionFromEulerAngles(); } - else{ - ctx->r[0] = -90.; ctx->r[1] = 0.; 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(); } - ctx->setQuaternionFromEulerAngles(); - Draw(); - } - 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 if(!strcmp(str, "1:1")){ // reset translation and scaling + ctx->t[0] = ctx->t[1] = ctx->t[2] = 0.; + ctx->s[0] = ctx->s[1] = ctx->s[2] = 1.; } - else{ - ctx->r[0] = 0.; ctx->r[1] = 180.; ctx->r[2] = 0.; + else if(!strcmp(str, "reset")){ // reset everything + ctx->t[0] = ctx->t[1] = ctx->t[2] = 0.; + ctx->s[0] = ctx->s[1] = ctx->s[2] = 1.; + ctx->r[0] = ctx->r[1] = ctx->r[2] = 0.; + ctx->setQuaternionFromEulerAngles(); } - ctx->setQuaternionFromEulerAngles(); - Draw(); } - else if(!strcmp(str, "1:1")){ // reset translation and scaling - ctx->t[0] = ctx->t[1] = ctx->t[2] = 0.; - ctx->s[0] = ctx->s[1] = ctx->s[2] = 1.; - Draw(); + Draw(); + GUI::instance()->manip->update(); +} + +void status_options_cb(Fl_Widget *w, void *data) +{ + const char *str = (const char*)data; + if(!strcmp(str, "model")){ // model selection + model_chooser(); } - else if(!strcmp(str, "reset")){ // reset everything - ctx->t[0] = ctx->t[1] = ctx->t[2] = 0.; - ctx->s[0] = ctx->s[1] = ctx->s[2] = 1.; - ctx->r[0] = ctx->r[1] = ctx->r[2] = 0.; - ctx->setQuaternionFromEulerAngles(); - Draw(); + else if(!strcmp(str, "?")){ // display options + Print_Options(0, GMSH_FULLRC, 0, 1, NULL); + GUI::instance()->messages->show(); } else if(!strcmp(str, "p")){ // toggle projection mode if(!Fl::event_state(FL_SHIFT)){ @@ -177,23 +180,17 @@ void status_xyz1p_cb(Fl_Widget *w, void *data) } Draw(); } - else if(!strcmp(str, "model")){ // toggle projection mode - model_chooser(); - } - else if(!strcmp(str, "?")){ // display options - Print_Options(0, GMSH_FULLRC, 0, 1, NULL); - GUI::instance()->messages->show(); - } else if(!strcmp(str, "S")){ // mouse selection if(CTX.mouse_selection){ opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 0); - GUI::instance()->graph[index]->gl->cursor - (FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); + for(unsigned int i = 0; i < GUI::instance()->graph.size(); i++) + for(unsigned int j = 0; j < GUI::instance()->graph[i]->gl.size(); j++) + GUI::instance()->graph[i]->gl[j]->cursor + (FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); } else opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 1); } - GUI::instance()->manip->update(); } static int stop_anim, view_in_cycle = -1; @@ -234,7 +231,7 @@ void status_play_manual(int time, int step) static void status_play_cb(Fl_Widget *w, void *data) { static double anim_time; - GUI::instance()->graph[findGraphIndex(w)]->setAnimButtons(0); + getGraphicWindow(w)->setAnimButtons(0); stop_anim = 0; anim_time = GetTimeInSeconds(); while(1) { @@ -251,7 +248,7 @@ static void status_play_cb(Fl_Widget *w, void *data) static void status_pause_cb(Fl_Widget *w, void *data) { stop_anim = 1; - GUI::instance()->graph[findGraphIndex(w)]->setAnimButtons(1); + getGraphicWindow(w)->setAnimButtons(1); } static void status_rewind_cb(Fl_Widget *w, void *data) @@ -278,7 +275,73 @@ static void status_stepforward_cb(Fl_Widget *w, void *data) status_play_manual(!CTX.post.anim_cycle, 1); } -graphicWindow::graphicWindow() +static void remove_graphic_window_cb(Fl_Widget *w, void *data) +{ + if(GUI::instance()->graph.size() == 1){ + file_quit_cb(0, 0); + return; + } + + std::vector<graphicWindow*> graph2; + graphicWindow *deleteMe = 0; + for(unsigned int i = 0; i < GUI::instance()->graph.size(); i++){ + if(GUI::instance()->graph[i]->win == w) + deleteMe = GUI::instance()->graph[i]; + else + graph2.push_back(GUI::instance()->graph[i]); + } + if(deleteMe){ + openglWindow::setLastHandled(0); + GUI::instance()->graph = graph2; + delete deleteMe; + } +} + +// We derive the window from Fl_Window instead of Fl_Double_Window: it +// shows up faster this way (and the opengl subwindow is +// double-buffered on its own anyway) +class normalWindow : public Fl_Window { + private: + int handle(int event) + { + switch (event) { + case FL_SHORTCUT: + case FL_KEYBOARD: +#if defined(__APPLE__) + if(Fl::test_shortcut(FL_META+'w')){ +#elif defined(WIN32) + if(Fl::test_shortcut(FL_ALT+FL_F+4)){ +#else + if(Fl::test_shortcut(FL_CTRL+'w')){ +#endif + if(GUI::instance()->graph.size() == 1){ + if(fl_choice("Do you really want to quit?", "Cancel", "Quit", 0)) + do_callback(); + } + else + do_callback(); + return 1; + } + break; + } + return Fl_Window::handle(event); + } + public: + normalWindow(int w, int h, const char *l=0) : Fl_Window(w, h, l) {} +}; + +// This dummy box class permits to define a box widget that will not +// eat the FL_ENTER/FL_LEAVE events (the new Box widget in fltk > 1.1 +// does that, so that gl->handle() was not called when the mouse +// moved) +class dummyBox : public Fl_Box { + private: + int handle(int){ return 0; } // always! + public: + dummyBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x, y, w, h, l) {} +}; + +graphicWindow::graphicWindow(int numTiles) { static bool first = true; if(first){ @@ -295,17 +358,17 @@ graphicWindow::graphicWindow() int sh = 2 * FL_NORMAL_SIZE - 4; // status bar height int sw = FL_NORMAL_SIZE + 3; // status button width - int width = CTX.tmp_viewport[2] - CTX.tmp_viewport[0]; - int glheight = CTX.tmp_viewport[3] - CTX.tmp_viewport[1]; + int width = CTX.gl_size[0]; + int glheight = CTX.gl_size[1]; int height = glheight + sh; - // the graphic window is a "main" window: it should be a normal - // window (neither modal nor non-modal) - win = new mainWindow(width, height, false); - win->callback(file_quit_cb); - + // the graphic window should be a "normal" window (neither modal nor + // non-modal) + win = new normalWindow(width, height); + win->callback(remove_graphic_window_cb); + // bottom button bar - Fl_Box *bottom = new Fl_Box(0, glheight, width, sh); + bottom = new Fl_Box(0, glheight, width, sh); bottom->box(FL_FLAT_BOX); int x = 2; @@ -313,7 +376,7 @@ graphicWindow::graphicWindow() butt[5] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_models"); x += sw; - butt[5]->callback(status_xyz1p_cb, (void *)"model"); + butt[5]->callback(status_options_cb, (void *)"model"); butt[5]->tooltip("Select active model"); butt[0] = new Fl_Button(x, glheight + 2, sw, sht, "X"); @@ -343,12 +406,12 @@ graphicWindow::graphicWindow() butt[8] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_ortho"); x += sw; - butt[8]->callback(status_xyz1p_cb, (void *)"p"); + butt[8]->callback(status_options_cb, (void *)"p"); butt[8]->tooltip("Toggle projection mode (Alt+o or Alt+Shift+o)"); butt[9] = new Fl_Button(x, glheight + 2, sw, sht, "S"); x += sw; - butt[9]->callback(status_xyz1p_cb, (void *)"S"); + butt[9]->callback(status_options_cb, (void *)"S"); butt[9]->tooltip("Toggle mouse selection ON/OFF (Escape)"); butt[6] = new Fl_Button(x, glheight + 2, sw, sht, "@-1gmsh_rewind"); @@ -395,18 +458,95 @@ graphicWindow::graphicWindow() // dummy resizable box dummyBox *resbox = new dummyBox(x, 0, width - x, glheight); win->resizable(resbox); - - // opengl window - gl = new openglWindow(0, 0, width, glheight); + + // opengl window(s) int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE); if(CTX.antialiasing) mode |= FL_MULTISAMPLE; - gl->mode(mode); - gl->end(); + tile = new Fl_Tile(0, 0, width, glheight); + + int w2 = width / 2, h2 = glheight / 2; + if(numTiles == 2){ + gl.push_back(new openglWindow(0, 0, w2, glheight)); + gl.back()->mode(mode); + gl.back()->end(); + gl.push_back(new openglWindow(w2, 0, width - w2, glheight)); + gl.back()->mode(mode); + gl.back()->end(); + } + else if(numTiles == 3){ + gl.push_back(new openglWindow(0, 0, w2, glheight)); + gl.back()->mode(mode); + gl.back()->end(); + gl.push_back(new openglWindow(w2, 0, width - w2, h2)); + gl.back()->mode(mode); + gl.back()->end(); + gl.push_back(new openglWindow(w2, h2, width - w2, glheight - h2)); + gl.back()->mode(mode); + gl.back()->end(); + } + else{ + gl.push_back(new openglWindow(0, 0, width, glheight)); + gl.back()->mode(mode); + gl.back()->end(); + } + + tile->end(); + win->position(CTX.gl_position[0], CTX.gl_position[1]); win->end(); } +graphicWindow::~graphicWindow() +{ + openglWindow::setLastHandled(0); + tile->clear(); + win->clear(); + Fl::delete_widget(win); +} + +void graphicWindow::split(openglWindow *g, char how) +{ + if(tile->find(g) == tile->children()) return; + + if(how == 'u'){ + // after many tries I cannot figure out how to do this cleanly, so + // let's be brutal :-) + int mode = g->mode(); + openglWindow::setLastHandled(0); + tile->clear(); + gl.clear(); + openglWindow *g2 = new openglWindow(0, 0, tile->w(), tile->h()); + g2->mode(mode); + g2->end(); + gl.push_back(g2); + tile->add(g2); + g2->show(); + return; + } + + int x1 = g->x(); + int y1 = g->y(); + int w1 = (how == 'h') ? g->w() / 2 : g->w(); + int h1 = (how == 'h') ? g->h() : g->h() / 2; + + int x2 = (how == 'h') ? (g->x() + w1) : g->x(); + int y2 = (how == 'h') ? g->y() : (g->y() + h1); + int w2 = (how == 'h') ? (g->w() - w1) : g->w(); + int h2 = (how == 'h') ? g->h() : (g->h() - h1); + + openglWindow *g2 = new openglWindow(0, 0, w2, h2); + g2->mode(g->mode()); + g2->end(); + + gl.push_back(g2); + tile->add(g2); + g2->show(); + + g->resize(x1, y1, w1, h1); + g2->resize(x2, y2, w2, h2); +} + void graphicWindow::setAnimButtons(int mode) { if(mode) { diff --git a/Fltk/graphicWindow.h b/Fltk/graphicWindow.h index fe50991f5b823a2eb0e4b1b9c1fefe2f5422adb1..0e1d0fea447507f9f5e75dd8f222b6f69f64dbd9 100644 --- a/Fltk/graphicWindow.h +++ b/Fltk/graphicWindow.h @@ -6,24 +6,31 @@ #ifndef _GRAPHIC_WINDOW_H_ #define _GRAPHIC_WINDOW_H_ +#include <vector> #include <FL/Fl_Window.H> #include <FL/Fl_Button.H> #include <FL/Fl_Box.H> +#include <FL/Fl_Tile.H> #include "openglWindow.h" class graphicWindow{ public: Fl_Window *win; - openglWindow *gl; + Fl_Tile *tile; + std::vector<openglWindow*> gl; + Fl_Box *bottom; Fl_Button *butt[12]; Fl_Box *label[2]; public: - graphicWindow(); + graphicWindow(int numTiles=1); + ~graphicWindow(); + void split(openglWindow *g, char how); void setAnimButtons(int mode); void checkAnimButtons(); }; void status_xyz1p_cb(Fl_Widget *w, void *data); +void status_options_cb(Fl_Widget *w, void *data); void status_play_manual(int time, int step); #endif diff --git a/Fltk/manipWindow.cpp b/Fltk/manipWindow.cpp index 8109877540f0de86b34336b056bb763ce4645a1e..10ef89af976f78fd6dbf0087ff147e51be72fc9b 100644 --- a/Fltk/manipWindow.cpp +++ b/Fltk/manipWindow.cpp @@ -8,7 +8,7 @@ #include "GUI.h" #include "Draw.h" #include "manipWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "graphicWindow.h" #include "Options.h" #include "Context.h" @@ -22,7 +22,7 @@ void manip_cb(Fl_Widget *w, void *data) static void manip_update_cb(Fl_Widget *w, void *data) { - drawContext *ctx = GUI::instance()->graph[0]->gl->getDrawContext(); + drawContext *ctx = GUI::instance()->getCurrentOpenglWindow()->getDrawContext(); ctx->r[0] = GUI::instance()->manip->value[0]->value(); ctx->r[1] = GUI::instance()->manip->value[1]->value(); ctx->r[2] = GUI::instance()->manip->value[2]->value(); @@ -36,8 +36,9 @@ static void manip_update_cb(Fl_Widget *w, void *data) Draw(); } -manipWindow::manipWindow() +manipWindow::manipWindow(int deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; int width = 4 * BB + 2 * WB; int height = 5 * BH + 3 * WB; @@ -95,6 +96,8 @@ manipWindow::manipWindow() win->position(CTX.manip_position[0], CTX.manip_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } void manipWindow::update(bool force) diff --git a/Fltk/manipWindow.h b/Fltk/manipWindow.h index c1ceb3ef9b2cad1131254e5350deb76fbd22156a..bdb387d9df35801fa0f4d88f9330bb82e6210bea 100644 --- a/Fltk/manipWindow.h +++ b/Fltk/manipWindow.h @@ -14,7 +14,7 @@ class manipWindow{ Fl_Window *win; Fl_Value_Input *value[9]; public: - manipWindow(); + manipWindow(int deltaFontSize); void update(bool force=false); void show(); }; diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 9bd86a912f663e79e756c60b4acf6065ae07cdf4..6215b13ad640f46812b2529d04118ab961902b62 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -11,7 +11,7 @@ #include "GUI.h" #include "Draw.h" #include "menuWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "graphicWindow.h" #include "optionWindow.h" #include "statisticsWindow.h" @@ -71,7 +71,8 @@ static void file_new_cb(Fl_Widget *w, void *data) time(&now); fprintf(fp, "// Gmsh project created on %s", ctime(&now)); fclose(fp); - OpenProject(name.c_str()); + new GModel(); + MergeFile(name.c_str()); Draw(); } } @@ -141,6 +142,35 @@ static void file_merge_cb(Fl_Widget *w, void *data) GUI::instance()->menu->setContext(menu_post, 0); } +static void file_clear_cb(Fl_Widget *w, void *data) +{ + ClearProject(); + Draw(); +} + +static void file_window_cb(Fl_Widget *w, void *data) +{ + std::string str((const char*)data); + if(str == "new"){ + graphicWindow *g1 = GUI::instance()->graph.back(); + graphicWindow *g2 = new graphicWindow(CTX.num_tiles); + GUI::instance()->graph.push_back(g2); + g2->win->label(g1->win->label()); + g2->win->resize(g1->win->x() + 10, g1->win->y() + 10, + g1->win->w(), g1->win->h()); + g2->win->show(); + } + else if(str == "split_h"){ + GUI::instance()->splitCurrentOpenglWindow('h'); + } + else if(str == "split_v"){ + GUI::instance()->splitCurrentOpenglWindow('v'); + } + else if(str == "split_u"){ + GUI::instance()->splitCurrentOpenglWindow('u'); + } +} + static int _save_msh(const char *name){ return msh_dialog(name); } static int _save_pos(const char *name){ return pos_dialog(name); } static int _save_options(const char *name){ return options_dialog(name); } @@ -524,7 +554,8 @@ static void add_new_point() while(1) { for(unsigned int i = 0; i < GUI::instance()->graph.size(); i++) - GUI::instance()->graph[i]->gl->addPointMode = true; + for(unsigned int j = 0; j < GUI::instance()->graph[i]->gl.size(); j++) + GUI::instance()->graph[i]->gl[j]->addPointMode = true; Msg::StatusBar(3, false, "Move mouse and/or enter coordinates\n" "[Press 'Shift' to hold position, 'e' to add point " "or 'q' to abort]"); @@ -540,7 +571,8 @@ static void add_new_point() } if(ib == 'q'){ for(unsigned int i = 0; i < GUI::instance()->graph.size(); i++) - GUI::instance()->graph[i]->gl->addPointMode = false; + for(unsigned int j = 0; j < GUI::instance()->graph[i]->gl.size(); j++) + GUI::instance()->graph[i]->gl[j]->addPointMode = false; break; } } @@ -2100,7 +2132,14 @@ static Fl_Menu_Item bar_table[] = { {"&File", 0, 0, 0, FL_SUBMENU}, {"&New...", FL_CTRL+'n', (Fl_Callback *)file_new_cb, 0}, {"&Open...", FL_CTRL+'o', (Fl_Callback *)file_open_cb, 0}, - {"M&erge...", FL_CTRL+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0, FL_MENU_DIVIDER}, + {"M&erge...", FL_CTRL+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0}, + {"&Clear", 0, (Fl_Callback *)file_clear_cb, 0, FL_MENU_DIVIDER}, + {"New Window", 0, (Fl_Callback *)file_window_cb, (void*)"new"}, + {"Split Window", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU}, + {"Horizontally", 0, (Fl_Callback *)file_window_cb, (void*)"split_h"}, + {"Vertically", 0, (Fl_Callback *)file_window_cb, (void*)"split_v"}, + {"Clear", 0, (Fl_Callback *)file_window_cb, (void*)"split_u"}, + {0}, {"&Rename...", FL_CTRL+'r', (Fl_Callback *)file_rename_cb, 0}, {"Save &As...", FL_CTRL+'s', (Fl_Callback *)file_save_as_cb, 0}, {"Sa&ve Mesh", FL_CTRL+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0, FL_MENU_DIVIDER}, @@ -2120,7 +2159,7 @@ static Fl_Menu_Item bar_table[] = { {"M&ouse Actions", 0, (Fl_Callback *)help_mouse_cb, 0}, {"&Keyboard Shortcuts", 0, (Fl_Callback *)help_short_cb, 0}, {"C&ommand Line Options", 0, (Fl_Callback *)help_command_line_cb, 0}, - {"&Current Options", 0, (Fl_Callback *)status_xyz1p_cb, (void*)"?", FL_MENU_DIVIDER}, + {"&Current Options", 0, (Fl_Callback *)status_options_cb, (void*)"?", FL_MENU_DIVIDER}, {"&About Gmsh...", 0, (Fl_Callback *)help_about_cb, 0}, {0}, {0} @@ -2128,11 +2167,6 @@ static Fl_Menu_Item bar_table[] = { #if defined(__APPLE__) -#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 1) && (FL_PATCH_VERSION <= 6) -#undef FL_META -#define FL_META FL_CTRL -#endif - // Alternative items for the MacOS system menu bar (removed '&' // shortcuts: they would cause spurious menu items to appear on the // menu window; removed File->Quit) @@ -2140,7 +2174,14 @@ static Fl_Menu_Item sysbar_table[] = { {"File", 0, 0, 0, FL_SUBMENU}, {"New...", FL_META+'n', (Fl_Callback *)file_new_cb, 0}, {"Open...", FL_META+'o', (Fl_Callback *)file_open_cb, 0}, - {"Merge...", FL_META+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0, FL_MENU_DIVIDER}, + {"Merge...", FL_META+FL_SHIFT+'o', (Fl_Callback *)file_merge_cb, 0}, + {"Clear", 0, (Fl_Callback *)file_clear_cb, 0, FL_MENU_DIVIDER}, + {"New Window", 0, (Fl_Callback *)file_window_cb, (void*)"new"}, + {"Split Window", 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU}, + {"Horizontally", 0, (Fl_Callback *)file_window_cb, (void*)"split_h"}, + {"Vertically", 0, (Fl_Callback *)file_window_cb, (void*)"split_v"}, + {"Clear", 0, (Fl_Callback *)file_window_cb, (void*)"split_u"}, + {0}, {"Rename...", FL_META+'r', (Fl_Callback *)file_rename_cb, 0}, {"Save As...", FL_META+'s', (Fl_Callback *)file_save_as_cb, 0}, {"Save Mesh", FL_META+FL_SHIFT+'s', (Fl_Callback *)mesh_save_cb, 0}, @@ -2164,7 +2205,7 @@ static Fl_Menu_Item sysbar_table[] = { {"Mouse Actions", 0, (Fl_Callback *)help_mouse_cb, 0}, {"Keyboard Shortcuts", 0, (Fl_Callback *)help_short_cb, 0}, {"Command Line Options", 0, (Fl_Callback *)help_command_line_cb, 0}, - {"Current Options", 0, (Fl_Callback *)status_xyz1p_cb, (void*)"?", FL_MENU_DIVIDER}, + {"Current Options", 0, (Fl_Callback *)status_options_cb, (void*)"?", FL_MENU_DIVIDER}, {"About Gmsh...", 0, (Fl_Callback *)help_about_cb, 0}, {0}, {0} @@ -2400,6 +2441,42 @@ contextItem menu_post[] = { {0} }; +// Derive the main window from Fl_Window (it shows up faster that way) +class mainWindow : public Fl_Window { + private: + int handle(int event) + { + switch (event) { + case FL_SHORTCUT: + case FL_KEYBOARD: +#if defined(__APPLE__) + if(Fl::test_shortcut(FL_META+'w')){ +#elif defined(WIN32) + if(Fl::test_shortcut(FL_ALT+FL_F+4)){ +#else + if(Fl::test_shortcut(FL_CTRL+'w')){ +#endif + if(fl_choice("Do you really want to quit?", "Cancel", "Quit", 0)) + do_callback(); + return 1; + } + break; + } + return Fl_Window::handle(event); + } + public: + mainWindow(int w, int h, bool nonmodal=false, const char *l=0) + : Fl_Window(w, h, l) + { + if(nonmodal) set_non_modal(); + } + void show() + { + if(non_modal() && !shown()) Fl_Window::show(); // fix ordering + Fl_Window::show(); + } +}; + menuWindow::menuWindow() { int width = 14 * FL_NORMAL_SIZE; diff --git a/Fltk/messageWindow.cpp b/Fltk/messageWindow.cpp index d24bd5eae4f00dce0f8717bfea80eb9980c6750c..303a220511c3f3394f238983182ab255d933e4eb 100644 --- a/Fltk/messageWindow.cpp +++ b/Fltk/messageWindow.cpp @@ -9,7 +9,7 @@ #include <FL/fl_ask.H> #include "GUI.h" #include "messageWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "fileDialogs.h" #include "GmshMessage.h" #include "OS.h" @@ -65,8 +65,10 @@ static void message_save_cb(Fl_Widget *w, void *data) } } -messageWindow::messageWindow() +messageWindow::messageWindow(int deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; + int width = CTX.msg_size[0]; int height = CTX.msg_size[1]; @@ -108,6 +110,8 @@ messageWindow::messageWindow() win->position(CTX.msg_position[0], CTX.msg_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } void messageWindow::add(const char *msg) diff --git a/Fltk/messageWindow.h b/Fltk/messageWindow.h index 20faf8df18ca3db34341cdccf6011395a27cabb7..e1696c6614d0e8bcc862054529487de3b90bb3a9 100644 --- a/Fltk/messageWindow.h +++ b/Fltk/messageWindow.h @@ -16,7 +16,7 @@ class messageWindow{ Fl_Browser *browser; Fl_Check_Button *butt; public: - messageWindow(); + messageWindow(int deltaFontSize); void show(bool redrawOnly=false); void add(const char *msg); void save(const char *filename); diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp index 0302e66e6de20365c1c2acaa44c173de368bed8a..accae25c8aee78113e19b0bedbd4727d16f2f635 100644 --- a/Fltk/openglWindow.cpp +++ b/Fltk/openglWindow.cpp @@ -76,7 +76,8 @@ openglWindow::openglWindow(int x, int y, int w, int h, const char *l) _selection = ENT_NONE; _trySelection = 0; for(int i = 0; i < 4; i++) _trySelectionXYWH[i] = 0; - + _lassoXY[0] = _lassoXY[1] = 0; + addPointMode = lassoMode = selectionMode = false; endSelection = undoSelection = invertSelection = quitSelection = 0; } @@ -111,6 +112,30 @@ void openglWindow::drawScreenMessage() } } +void openglWindow::drawBorder() +{ + // draw thin border if the parent group has several children + if(parent()->children() > 1){ + unsigned char r, g, b; + Fl::get_color(color(), r, g, b); + /* would need to redraw all gl's when _lastHandled is changed + if(_lastHandled == this) + Fl::get_color(FL_SELECTION_COLOR, r, g, b); + else + Fl::get_color(FL_BACKGROUND_COLOR, r, g, b); + */ + glColor3ub(r, g, b); + int ww = 1; + glLineWidth(ww); + glBegin(GL_LINE_LOOP); + glVertex2d(_ctx->viewport[0], _ctx->viewport[1]); + glVertex2d(_ctx->viewport[2] - ww, _ctx->viewport[1]); + glVertex2d(_ctx->viewport[2] - ww, _ctx->viewport[3] - ww); + glVertex2d(_ctx->viewport[0], _ctx->viewport[3] - ww); + glEnd(); + } +} + void openglWindow::draw() { static int locked = 0; @@ -121,24 +146,12 @@ void openglWindow::draw() Msg::Debug("openglWindow->draw()"); - if(!valid()) { - valid(1); - _ctx->viewport[0] = 0; - _ctx->viewport[1] = 0; - _ctx->viewport[2] = w(); - _ctx->viewport[3] = h(); - glViewport(_ctx->viewport[0], _ctx->viewport[1], - _ctx->viewport[2], _ctx->viewport[3]); - } - else { - if((w() != _ctx->viewport[2] - _ctx->viewport[0]) || - (h() != _ctx->viewport[3] - _ctx->viewport[1])) { - GUI::instance()->setGraphicSize(_ctx->viewport[2] - _ctx->viewport[0], - _ctx->viewport[3] - _ctx->viewport[1]); - glViewport(_ctx->viewport[0], _ctx->viewport[1], - _ctx->viewport[2], _ctx->viewport[3]); - } - } + _ctx->viewport[0] = 0; + _ctx->viewport[1] = 0; + _ctx->viewport[2] = w(); + _ctx->viewport[3] = h(); + glViewport(_ctx->viewport[0], _ctx->viewport[1], + _ctx->viewport[2], _ctx->viewport[3]); if(lassoMode) { // draw the zoom or selection lasso on top of the current scene @@ -159,19 +172,22 @@ void openglWindow::draw() glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); glEnable(GL_BLEND); glLineWidth(0.2); - for(int i = 0; i < 2; i++){ - glBegin(GL_LINE_STRIP); - glVertex2d(_click.win[0], _ctx->viewport[3] - _click.win[1]); - glVertex2d(_lasso.win[0], _ctx->viewport[3] - _click.win[1]); - glVertex2d(_lasso.win[0], _ctx->viewport[3] - _lasso.win[1]); - glVertex2d(_click.win[0], _ctx->viewport[3] - _lasso.win[1]); - glVertex2d(_click.win[0], _ctx->viewport[3] - _click.win[1]); - glEnd(); - if(!i) _lasso.set(_ctx); - } + glBegin(GL_LINE_LOOP); + glVertex2d(_click.win[0], _ctx->viewport[3] - _click.win[1]); + glVertex2d(_lassoXY[0], _ctx->viewport[3] - _click.win[1]); + glVertex2d(_lassoXY[0], _ctx->viewport[3] - _lassoXY[1]); + glVertex2d(_click.win[0], _ctx->viewport[3] - _lassoXY[1]); + glEnd(); + glBegin(GL_LINE_LOOP); + glVertex2d(_click.win[0], _ctx->viewport[3] - _click.win[1]); + glVertex2d(_curr.win[0], _ctx->viewport[3] - _click.win[1]); + glVertex2d(_curr.win[0], _ctx->viewport[3] - _curr.win[1]); + glVertex2d(_click.win[0], _ctx->viewport[3] - _curr.win[1]); + glEnd(); + _lassoXY[0] = _curr.win[0]; + _lassoXY[1] = _curr.win[1]; glDisable(GL_BLEND); - if(selectionMode && CTX.mouse_selection) - glDisable(GL_LINE_STIPPLE); + glDisable(GL_LINE_STIPPLE); glEnable(GL_DEPTH_TEST); } else if(addPointMode) { @@ -180,7 +196,10 @@ void openglWindow::draw() CTX.mesh.draw = 0; CTX.post.draw = 0; } - ClearOpengl(); + glClearColor(CTX.UNPACK_RED(CTX.color.bg) / 255., + CTX.UNPACK_GREEN(CTX.color.bg) / 255., + CTX.UNPACK_BLUE(CTX.color.bg) / 255., 0.); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); _ctx->draw3d(); glColor4ubv((GLubyte *) & CTX.color.fg); glPointSize(CTX.geom.point_size); @@ -189,15 +208,20 @@ void openglWindow::draw() glEnd(); _ctx->draw2d(); drawScreenMessage(); + drawBorder(); CTX.mesh.draw = 1; CTX.post.draw = 1; } else{ // draw the whole scene - ClearOpengl(); + glClearColor(CTX.UNPACK_RED(CTX.color.bg) / 255., + CTX.UNPACK_GREEN(CTX.color.bg) / 255., + CTX.UNPACK_BLUE(CTX.color.bg) / 255., 0.); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); _ctx->draw3d(); _ctx->draw2d(); drawScreenMessage(); + drawBorder(); } locked = 0; @@ -209,6 +233,8 @@ void openglWindow::draw() // as treated, and is suppressed. If the handle returns 0, the event // is passed to the parent. +openglWindow *openglWindow::_lastHandled = 0; + int openglWindow::handle(int event) { switch (event) { @@ -225,13 +251,15 @@ int openglWindow::handle(int event) return Fl_Gl_Window::handle(event); case FL_PUSH: + _lastHandled = this; take_focus(); // force keyboard focus when we click in the window _curr.set(_ctx); if(Fl::event_button() == 1 && !Fl::event_state(FL_SHIFT) && !Fl::event_state(FL_ALT)) { if(!lassoMode && Fl::event_state(FL_CTRL)) { lassoMode = true; - _lasso.set(_ctx); + _lassoXY[0] = _curr.win[0]; + _lassoXY[1] = _curr.win[1]; } else if(lassoMode) { lassoMode = false; @@ -307,6 +335,7 @@ int openglWindow::handle(int event) return 1; case FL_RELEASE: + _lastHandled = this; _curr.set(_ctx); CTX.draw_rotation_center = 0; if(!lassoMode) { @@ -331,6 +360,7 @@ int openglWindow::handle(int event) return 1; case FL_DRAG: + _lastHandled = this; _curr.set(_ctx); { double dx = _curr.win[0] - _prev.win[0]; @@ -390,7 +420,7 @@ int openglWindow::handle(int event) case FL_MOVE: _curr.set(_ctx); - if(lassoMode) { + if(lassoMode){ redraw(); } else if(addPointMode && !Fl::event_state(FL_SHIFT)){ diff --git a/Fltk/openglWindow.h b/Fltk/openglWindow.h index 79ac3ebb2a5bdd4b6a73b6de5f3a09d58200fc9e..bd72e8cf24b241c5d67266052965a9f6f9596c6c 100644 --- a/Fltk/openglWindow.h +++ b/Fltk/openglWindow.h @@ -44,11 +44,13 @@ class mousePosition { class openglWindow : public Fl_Gl_Window { private: - mousePosition _click, _curr, _prev, _lasso; + static openglWindow *_lastHandled; + mousePosition _click, _curr, _prev; drawContext *_ctx; double _point[3]; - int _selection, _trySelection, _trySelectionXYWH[4]; + int _selection, _trySelection, _trySelectionXYWH[4], _lassoXY[2]; void drawScreenMessage(); + void drawBorder(); bool processSelectionBuffer(int type, bool multipleSelection, bool meshSelection, int x, int y, int w, int h, @@ -70,6 +72,8 @@ class openglWindow : public Fl_Gl_Window { std::vector<GVertex*> &vertices, std::vector<GEdge*> &edges, std::vector<GFace*> &faces, std::vector<GRegion*> ®ions, std::vector<MElement*> &elements); + static openglWindow *getLastHandled(){ return _lastHandled; } + static void setLastHandled(openglWindow *w){ _lastHandled = w; } }; #endif diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 09574364227bef9bf55806c58dd94600df880878..ed7c59a22800b1a811dce6aa7012f43a557e4c5b 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -9,7 +9,7 @@ #include <FL/Fl_Color_Chooser.H> #include "GUI.h" #include "optionWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "menuWindow.h" #include "extraDialogs.h" #include "Draw.h" @@ -530,25 +530,6 @@ static void view_options_timestep_cb(Fl_Widget *w, void *data) Draw(); } -static void view_arrow_param_cb(Fl_Widget *w, void *data) -{ - double a = opt_view_arrow_head_radius - (GUI::instance()->options->view.index, GMSH_GET, 0); - double b = opt_view_arrow_stem_length - (GUI::instance()->options->view.index, GMSH_GET, 0); - double c = opt_view_arrow_stem_radius - (GUI::instance()->options->view.index, GMSH_GET, 0); - while(arrow_editor("Arrow Editor", a, b, c)){ - opt_view_arrow_head_radius - (GUI::instance()->options->view.index, GMSH_SET, a); - opt_view_arrow_stem_length - (GUI::instance()->options->view.index, GMSH_SET, b); - opt_view_arrow_stem_radius - (GUI::instance()->options->view.index, GMSH_SET, c); - Draw(); - } -} - static void view_options_ok_cb(Fl_Widget *w, void *data) { int current = GUI::instance()->options->view.index; @@ -1155,11 +1136,8 @@ static void view_options_max_recursion_cb(Fl_Widget *w, void *data) view_options_ok_cb(0, 0); } -optionWindow::optionWindow() +optionWindow::optionWindow(int deltaFontSize) { - // we should maybe use deltaFontSize==2 on all "palette" windows to - // make them smaller - int deltaFontSize = 0; FL_NORMAL_SIZE -= deltaFontSize; int width = 34 * FL_NORMAL_SIZE + WB; @@ -2950,11 +2928,6 @@ optionWindow::optionWindow() view.choice[2]->align(FL_ALIGN_RIGHT); view.choice[2]->callback(view_options_ok_cb); - view.push[0] = new Fl_Button - (L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 6 * BH, (int)(1.15*BB), BH, - "Edit arrow"); - view.push[0]->callback(view_arrow_param_cb); - view.value[64] = new Fl_Value_Input (L + 2 * WB, 2 * WB + 7 * BH, IW / 2, BH); view.value[64]->minimum(0); diff --git a/Fltk/optionWindow.h b/Fltk/optionWindow.h index 3a2a8f9c8f2490666a8fc78d17eaa39276dc5bca..677b19b8f4a1c624e4f4ce082176b96a8664a916 100644 --- a/Fltk/optionWindow.h +++ b/Fltk/optionWindow.h @@ -84,7 +84,7 @@ class optionWindow{ } view; public: - optionWindow(); + optionWindow(int deltaFontSize=0); void showGroup(int num, bool showWindow=true); void resetBrowser(); void resetExternalViewList(); diff --git a/Fltk/partitionDialog.cpp b/Fltk/partitionDialog.cpp index 8bea759f9d6832aedd2a1b3ea6d7cca6314be524..854b32bf62fb0072e70db2ad916eef840abbc710 100644 --- a/Fltk/partitionDialog.cpp +++ b/Fltk/partitionDialog.cpp @@ -19,7 +19,7 @@ #include <FL/Fl_Group.H> #include <FL/Fl_Box.H> #include "GUI.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "GmshDefines.h" #include "GmshMessage.h" #include "GModel.h" diff --git a/Fltk/pluginWindow.cpp b/Fltk/pluginWindow.cpp index 4e4e1d5c947c94260c030a0159cb262a887efdfe..a5bd75f3c7138be8730ff38e0b818490a09cf445 100644 --- a/Fltk/pluginWindow.cpp +++ b/Fltk/pluginWindow.cpp @@ -10,7 +10,7 @@ #include "GUI.h" #include "Draw.h" #include "pluginWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "PView.h" #include "PluginManager.h" #include "Plugin.h" @@ -222,8 +222,10 @@ void pluginWindow::_createDialogBox(GMSH_Plugin *p, int x, int y, p->dialogBox->group->hide(); } -pluginWindow::pluginWindow() +pluginWindow::pluginWindow(int deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; + int width0 = 34 * FL_NORMAL_SIZE + WB; int height0 = 13 * BH + 5 * WB; @@ -275,6 +277,8 @@ pluginWindow::pluginWindow() win->position(CTX.plugin_position[0], CTX.plugin_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } void pluginWindow::show(int viewIndex) diff --git a/Fltk/pluginWindow.h b/Fltk/pluginWindow.h index c41ff7557b283360088801d33819fe888f98fd41..4e138c5682e8d1132b9867b32dfdacd9f99ef1c8 100644 --- a/Fltk/pluginWindow.h +++ b/Fltk/pluginWindow.h @@ -31,7 +31,7 @@ class pluginWindow{ Fl_Return_Button *run; void _createDialogBox(GMSH_Plugin *p, int x, int y, int width, int height); public: - pluginWindow(); + pluginWindow(int deltaFontSize=0); void show(int viewIndex); void resetViewBrowser(); }; diff --git a/Fltk/projectionEditor.h b/Fltk/projectionEditor.h index 88eafc4e6509dacbac535c64430e99a2092d8572..20363a6655176250e02190d50cb747ea38ba967e 100644 --- a/Fltk/projectionEditor.h +++ b/Fltk/projectionEditor.h @@ -12,7 +12,7 @@ #include <FL/Fl_Round_Button.H> #include <FL/Fl_Value_Input.H> #include <FL/Fl_Hold_Browser.H> -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "fourierProjectionFace.h" #include "GModel.h" #include "ColorTable.h" diff --git a/Fltk/shortcutWindow.h b/Fltk/shortcutWindow.h deleted file mode 100644 index d84dcf8ed8b82c4543d91cd8b84c3f7e56b3db22..0000000000000000000000000000000000000000 --- a/Fltk/shortcutWindow.h +++ /dev/null @@ -1,92 +0,0 @@ -// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle -// -// See the LICENSE.txt file for license information. Please report all -// bugs and problems to <gmsh@geuz.org>. - -#ifndef _SHORTCUT_WINDOW_H -#define _SHORTCUT_WINDOW_H - -#include <FL/Fl.H> -#include <FL/Fl_Window.H> -#include <FL/Fl_Double_Window.H> -#include <FL/fl_ask.H> - -// Derive special windows from Fl_Double_Window to correctly process -// the OS-specific shorcuts (Cmd-w on Mac, Alt+F4 on Windows) - -class dialogWindow : public Fl_Double_Window { - private: - int handle(int event) - { - switch (event) { - case FL_SHORTCUT: - case FL_KEYBOARD: -#if defined(__APPLE__) - if(Fl::test_shortcut(FL_META+'w') || Fl::test_shortcut(FL_Escape)){ -#elif defined(WIN32) - if(Fl::test_shortcut(FL_ALT+FL_F+4) || Fl::test_shortcut(FL_Escape)){ -#else - if(Fl::test_shortcut(FL_CTRL+'w') || Fl::test_shortcut(FL_Escape)){ -#endif - do_callback(); - return 1; - } - break; - } - return Fl_Double_Window::handle(event); - } - public: - dialogWindow(int w, int h, int nonmodal=false, const char *l=0) - : Fl_Double_Window(w, h, l) - { - if(nonmodal) set_non_modal(); - } - void show() - { - if(non_modal() && !shown()) Fl_Double_Window::show(); // fix ordering - Fl_Double_Window::show(); - } -}; - -// Do the same for the main windows, but ask if we really want to quit -// before closing. Also, derive the main windows from Fl_Window: they -// show up faster that way, and they only contain either buttons that -// are recreated each time, or the big (already double-buffered) -// OpenGL area anyway. - -class mainWindow : public Fl_Window { - private: - int handle(int event) - { - switch (event) { - case FL_SHORTCUT: - case FL_KEYBOARD: -#if defined(__APPLE__) - if(Fl::test_shortcut(FL_META+'w')){ -#elif defined(WIN32) - if(Fl::test_shortcut(FL_ALT+FL_F+4)){ -#else - if(Fl::test_shortcut(FL_CTRL+'w')){ -#endif - if(fl_choice("Do you really want to quit?", "Cancel", "Quit", 0)) - do_callback(); - return 1; - } - break; - } - return Fl_Window::handle(event); - } - public: - mainWindow(int w, int h, bool nonmodal=false, const char *l=0) - : Fl_Window(w, h, l) - { - if(nonmodal) set_non_modal(); - } - void show() - { - if(non_modal() && !shown()) Fl_Window::show(); // fix ordering - Fl_Window::show(); - } -}; - -#endif diff --git a/Fltk/solverWindow.cpp b/Fltk/solverWindow.cpp index 44b4e2f537b28c1a79e7fd1448dab7d09d2eaec0..09771ca19bf14010f1cb6885995fda5fa1cd17ed 100644 --- a/Fltk/solverWindow.cpp +++ b/Fltk/solverWindow.cpp @@ -10,7 +10,7 @@ #include <FL/Fl_Browser.H> #include "GUI.h" #include "solverWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "optionWindow.h" #include "messageWindow.h" #include "fileDialogs.h" @@ -185,8 +185,10 @@ static void solver_choose_executable_cb(Fl_Widget *w, void *data) } } -solverWindow::solverWindow(int solverIndex) +solverWindow::solverWindow(int solverIndex, int deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; + for(int i = 0; i < MAX_NUM_SOLVER_OPTIONS; i++) if(strlen(SINFO[solverIndex].option_name[i])) SINFO[solverIndex].nboptions = i + 1; @@ -298,4 +300,6 @@ solverWindow::solverWindow(int solverIndex) win->position(CTX.solver_position[0], CTX.solver_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } diff --git a/Fltk/solverWindow.h b/Fltk/solverWindow.h index d2701762e0654bb3b8fabd3da38a17d505f26e67..694b010e41b54af91431ca0e9a5d405b9b7be705 100644 --- a/Fltk/solverWindow.h +++ b/Fltk/solverWindow.h @@ -20,7 +20,7 @@ class solverWindow{ Fl_Check_Button *butt[10]; Fl_Button *command[10]; public: - solverWindow(int solverIndex); + solverWindow(int solverIndex, int deltaFontSize=0); }; void solver_cb(Fl_Widget *w, void *data); diff --git a/Fltk/statisticsWindow.cpp b/Fltk/statisticsWindow.cpp index 3a4483b972431ca676ac4ba2e78aa09e35ee87f5..7ea9cb4f0782d5891fdcf8f97abcae3880699299 100644 --- a/Fltk/statisticsWindow.cpp +++ b/Fltk/statisticsWindow.cpp @@ -9,7 +9,7 @@ #include "GUI.h" #include "Draw.h" #include "statisticsWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "GModel.h" #include "MElement.h" #include "PView.h" @@ -76,9 +76,11 @@ static void statistics_histogram_cb(Fl_Widget *w, void *data) Draw(); } -statisticsWindow::statisticsWindow() +statisticsWindow::statisticsWindow(int deltaFontSize) { - int i, num = 0; + FL_NORMAL_SIZE -= deltaFontSize; + + int num = 0; int width = 26 * FL_NORMAL_SIZE; int height = 5 * WB + 18 * BH; @@ -160,7 +162,7 @@ statisticsWindow::statisticsWindow() o->end(); } - for(i = 0; i < num; i++) { + for(int i = 0; i < num; i++) { value[i]->align(FL_ALIGN_RIGHT); value[i]->value(0); } @@ -177,6 +179,8 @@ statisticsWindow::statisticsWindow() win->position(CTX.stat_position[0], CTX.stat_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } void statisticsWindow::compute(bool elementQuality) diff --git a/Fltk/statisticsWindow.h b/Fltk/statisticsWindow.h index 0f52f13811b904b1a37d4f60e970bce02997dab6..4b9e439019b845f2e42bd0c01202756854a0a663 100644 --- a/Fltk/statisticsWindow.h +++ b/Fltk/statisticsWindow.h @@ -19,7 +19,7 @@ class statisticsWindow{ Fl_Group *group[3]; double quality[4][100]; public: - statisticsWindow(); + statisticsWindow(int deltaFontSize); void compute(bool elementQuality); void show(); }; diff --git a/Fltk/visibilityWindow.cpp b/Fltk/visibilityWindow.cpp index 00445ab9e909570371bd03d7bec7e6daf6d04a41..91a3eec34a492c108533820e67af45064a90f8e8 100644 --- a/Fltk/visibilityWindow.cpp +++ b/Fltk/visibilityWindow.cpp @@ -13,7 +13,7 @@ #include "GUI.h" #include "Draw.h" #include "visibilityWindow.h" -#include "shortcutWindow.h" +#include "dialogWindow.h" #include "contextWindow.h" #include "GmshDefines.h" #include "GmshMessage.h" @@ -1045,8 +1045,10 @@ static void visibility_interactive_cb(Fl_Widget *w, void *data) Msg::StatusBar(3, false, ""); } -visibilityWindow::visibilityWindow() +visibilityWindow::visibilityWindow(int deltaFontSize) { + FL_NORMAL_SIZE -= deltaFontSize; + static int cols[5] = {15, 95, 95, 180, 0}; int width = cols[0] + cols[1] + cols[2] + cols[3] + 6 * WB; int height = 18 * BH; @@ -1143,6 +1145,8 @@ visibilityWindow::visibilityWindow() tree->box(FL_DOWN_BOX); tree->insertion_mode(FLU_INSERT_BACK); tree->branch_icons(0, 0); + tree->branch_text(FL_BLACK, FL_HELVETICA_BOLD, FL_NORMAL_SIZE - 1); + tree->leaf_text(FL_BLACK, FL_HELVETICA, FL_NORMAL_SIZE - 1); Fl_Group::current()->resizable(tree); tree->hide(); @@ -1320,6 +1324,8 @@ visibilityWindow::visibilityWindow() win->position(CTX.vis_position[0], CTX.vis_position[1]); win->end(); + + FL_NORMAL_SIZE += deltaFontSize; } void visibilityWindow::show(bool redrawOnly) diff --git a/Fltk/visibilityWindow.h b/Fltk/visibilityWindow.h index 10e220c28f8067953eedf926477ce2f50ed14efe..d0f2fcfc3f84d110a0af130e03f517d67aace9a7 100644 --- a/Fltk/visibilityWindow.h +++ b/Fltk/visibilityWindow.h @@ -31,7 +31,7 @@ class visibilityWindow{ Fl_Button *push[2]; Fl_Input *input[10]; public: - visibilityWindow(); + visibilityWindow(int deltaFontSize=0); void show(bool redrawOnly); }; diff --git a/Graphics/PixelBuffer.h b/Graphics/PixelBuffer.h index 139079cde6bfaa748ce7d8cfc63d8fd829ac65b9..6d33fe4467ae136e82e7156e1c6f631b0cb954dc 100644 --- a/Graphics/PixelBuffer.h +++ b/Graphics/PixelBuffer.h @@ -63,9 +63,7 @@ class PixelBuffer{ void Fill(int offscreen) { if(!offscreen){ - SetOpenglContext(); - ClearOpengl(); - Draw2d3d(); + DrawCurrentOpenglWindow(true); glFinish(); glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -85,8 +83,7 @@ class PixelBuffer{ if(!OSMesaMakeCurrent(ctx, _pixels, GL_UNSIGNED_BYTE, _width, _height)){ Msg::Error("OSMesaMakeCurrent failed"); } - ClearOpengl(); - Draw2d3d(); + DrawCurrentOpenglWindow(false); glFinish(); OSMesaDestroyContext(ctx); #else diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp index 7b3e79a8b545d859bf5441839128b7a194e608f2..2c859f251639732548b7fc30841e8235179304b1 100644 --- a/Graphics/drawContext.cpp +++ b/Graphics/drawContext.cpp @@ -4,15 +4,6 @@ // bugs and problems to <gmsh@geuz.org>. #include <FL/gl.h> - -//FIXME: workaround faulty fltk installs -//#include <FL/glu.h> -#ifdef __APPLE__ -# include <OpenGL/glu.h> -#else -# include <GL/glu.h> -#endif - #include "GmshMessage.h" #include "drawContext.h" #include "Trackball.h" @@ -37,12 +28,61 @@ drawContext::drawContext(drawTransform *transform) quaternion[i] = CTX.tmp_quaternion[i]; } viewport[0] = viewport[1] = 0; - viewport[2] = CTX.tmp_viewport[2]; - viewport[3] = CTX.tmp_viewport[3]; + viewport[2] = CTX.gl_size[0]; + viewport[3] = CTX.gl_size[1]; render_mode = GMSH_RENDER; vxmin = vymin = vxmax = vymax = 0.; pixel_equiv_x = pixel_equiv_y = 0.; + + _quadric = 0; // cannot create it here: needs valid opengl context + _displayLists = 0; +} + +drawContext::~drawContext() +{ + if(_quadric) gluDeleteQuadric(_quadric); + if(_displayLists) glDeleteLists(_displayLists, 2); +} + +void drawContext::createQuadricsAndDisplayLists() +{ + if(!_quadric) _quadric = gluNewQuadric(); + if(!_quadric){ + Msg::Error("Could not create quadric"); + return; + } + + if(!_displayLists) _displayLists = glGenLists(2); + if(!_displayLists){ + Msg::Error("Could not generate display lists"); + return; + } + + // display list 0 (sphere) + glNewList(_displayLists + 0, GL_COMPILE); + gluSphere(_quadric, 1., CTX.quadric_subdivisions, CTX.quadric_subdivisions); + glEndList(); + + // display list 1 (arrow) + glNewList(_displayLists + 1, GL_COMPILE); + glTranslated(0., 0., CTX.arrow_rel_stem_length); + if(CTX.arrow_rel_head_radius > 0 && CTX.arrow_rel_stem_length < 1) + gluCylinder(_quadric, CTX.arrow_rel_head_radius, 0., + (1. - CTX.arrow_rel_stem_length), CTX.quadric_subdivisions, 1); + if(CTX.arrow_rel_head_radius > CTX.arrow_rel_stem_radius) + gluDisk(_quadric, CTX.arrow_rel_stem_radius, CTX.arrow_rel_head_radius, + CTX.quadric_subdivisions, 1); + else + gluDisk(_quadric, CTX.arrow_rel_head_radius, CTX.arrow_rel_stem_radius, + CTX.quadric_subdivisions, 1); + glTranslated(0., 0., -CTX.arrow_rel_stem_length); + if(CTX.arrow_rel_stem_radius > 0 && CTX.arrow_rel_stem_length > 0){ + gluCylinder(_quadric, CTX.arrow_rel_stem_radius, CTX.arrow_rel_stem_radius, + CTX.arrow_rel_stem_length, CTX.quadric_subdivisions, 1); + gluDisk(_quadric, 0, CTX.arrow_rel_stem_radius, CTX.quadric_subdivisions, 1); + } + glEndList(); } void drawContext::buildRotationMatrix() @@ -153,6 +193,12 @@ static int needPolygonOffset() void drawContext::draw3d() { + // We can only create this when a valid opengl context exists. (It's + // cheap to create so we just do it at each redraw: this makes it + // much simpler to deal with option changes, e.g. arrow shape + // changes) + createQuadricsAndDisplayLists(); + // We should only enable the polygon offset when there is a mix of // lines and polygons to be drawn; enabling it all the time can lead // to very small but annoying artifacts in the picture. Since there @@ -171,7 +217,6 @@ void drawContext::draw3d() glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); - initProjection(); initRenderModel(); initPosition(); @@ -207,8 +252,8 @@ void drawContext::draw2d() void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick) { double Va = - (GLdouble) (viewport[3] - viewport[1]) / - (GLdouble) (viewport[2] - viewport[0]); + (double) (viewport[3] - viewport[1]) / + (double) (viewport[2] - viewport[0]); double Wa = (CTX.max[1] - CTX.min[1]) / (CTX.max[0] - CTX.min[0]); // compute the viewport in World coordinates (with margins) diff --git a/Graphics/drawContext.h b/Graphics/drawContext.h index ac361956bb0d562e306cb42e95401374112a1bc0..512370a1da6fec8b3d5eaed3950363958e740926 100644 --- a/Graphics/drawContext.h +++ b/Graphics/drawContext.h @@ -7,6 +7,16 @@ #define _DRAW_CONTEXT_H_ #include <string> +#include <FL/gl.h> + +//FIXME: workaround faulty fltk installs +//#include <FL/glu.h> +#ifdef __APPLE__ +# include <OpenGL/glu.h> +#else +# include <GL/glu.h> +#endif + #include "SBoundingBox3d.h" class PView; @@ -58,6 +68,8 @@ class drawTransformScaled : public drawTransform { class drawContext { private: drawTransform *_transform; + GLUquadricObj *_quadric; + GLuint _displayLists; public: double r[3]; // current Euler angles (in degrees!) @@ -75,7 +87,7 @@ class drawContext { public: drawContext(drawTransform *transform=0); - virtual ~drawContext(){} + ~drawContext(); void setTransform(drawTransform *transform){ _transform = transform; } drawTransform *getTransform(){ return _transform; } void transform(double &x, double &y, double &z) @@ -90,6 +102,7 @@ class drawContext { { if(_transform) _transform->transformTwoForm(x, y, z); } + void createQuadricsAndDisplayLists(); void buildRotationMatrix(); void setQuaternion(double p1x, double p1y, double p2x, double p2y); void addQuaternion(double p1x, double p1y, double p2x, double p2y); @@ -126,14 +139,15 @@ class drawContext { void drawStringCenter(std::string s); void drawStringRight(std::string s); void drawString(std::string s, double style); + void drawSphere(double R, double x, double y, double z, int n1, int n2, int light); void drawSphere(double size, double x, double y, double z, int light); void drawCylinder(double width, double *x, double *y, double *z, int light); void drawTaperedCylinder(double width, double val1, double val2, double ValMin, double ValMax, double *x, double *y, double *z, int light); - void drawVector(int Type, int Fill, - double relHeadRadius, double relStemLength, - double relStemRadius, double x, double y, double z, + void drawArrow3d(double x, double y, double z, double dx, double dy, double dz, + double length, int light); + void drawVector(int Type, int Fill, double x, double y, double z, double dx, double dy, double dz, int light); void drawBox(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, diff --git a/Graphics/drawGeom.cpp b/Graphics/drawGeom.cpp index ed528bc3493c6bf21839f05fcb6b46a66c7fdfa2..c21c2b29411337543cde57c8c10b1f94a0eee98f 100644 --- a/Graphics/drawGeom.cpp +++ b/Graphics/drawGeom.cpp @@ -180,9 +180,8 @@ class drawGEdge { double x = p.x(), y = p.y(), z = p.z(); _ctx->transform(x, y, z); _ctx->transformOneForm(der[0], der[1], der[2]); - _ctx->drawVector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - x, y, z, der[0], der[1], der[2], CTX.geom.light); + _ctx->drawVector(CTX.vector_type, 0, x, y, z, der[0], der[1], der[2], + CTX.geom.light); } if(select) { @@ -295,9 +294,8 @@ class drawGFace { double x = p.x(), y = p.y(), z = p.z(); _ctx->transform(x, y, z); _ctx->transformTwoForm(n[0], n[1], n[2]); - _ctx->drawVector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - x, y, z, n[0], n[1], n[2], CTX.geom.light); + _ctx->drawVector(CTX.vector_type, 0, x, y, z, n[0], n[1], n[2], + CTX.geom.light); } } void _drawPlaneGFace(GFace *f) @@ -365,9 +363,8 @@ class drawGFace { double x = p.x(), y = p.y(), z = p.z(); _ctx->transform(x, y, z); _ctx->transformTwoForm(n[0], n[1], n[2]); - _ctx->drawVector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - x, y, z, n[0], n[1], n[2], CTX.geom.light); + _ctx->drawVector(CTX.vector_type, 0, x, y, z, n[0], n[1], n[2], + CTX.geom.light); } } diff --git a/Graphics/drawGlyph.cpp b/Graphics/drawGlyph.cpp index d4e8fdee43da70b3b1e3d1383725565259419117..80789d92579c727b290df160f1d89418ea2211af 100644 --- a/Graphics/drawGlyph.cpp +++ b/Graphics/drawGlyph.cpp @@ -5,15 +5,6 @@ #include <string.h> #include <FL/gl.h> - -//FIXME: workaround faulty fltk installs -//#include <FL/glu.h> -#ifdef __APPLE__ -# include <OpenGL/glu.h> -#else -# include <GL/glu.h> -#endif - #include "drawContext.h" #include "Draw.h" #include "GmshDefines.h" @@ -123,23 +114,26 @@ void drawContext::drawString(std::string s, double style) } } -void drawContext::drawSphere(double size, double x, double y, double z, int light) +void drawContext::drawSphere(double R, double x, double y, double z, + int n1, int n2, int light) { if(light) glEnable(GL_LIGHTING); + glPushMatrix(); + glTranslated(x, y, z); + gluSphere(_quadric, R, n1, n2); + glPopMatrix(); + glDisable(GL_LIGHTING); +} - static int first = 1; - static GLUquadricObj *qua; - - if(first){ - first = 0; - qua = gluNewQuadric(); - } +void drawContext::drawSphere(double size, double x, double y, double z, int light) +{ + double ss = size * pixel_equiv_x / s[0]; // size is in pixels + if(light) glEnable(GL_LIGHTING); glPushMatrix(); glTranslated(x, y, z); - double ss = size * pixel_equiv_x / s[0]; // size is in pixels glScaled(ss, ss, ss); - gluSphere(qua, 1, CTX.quadric_subdivisions, CTX.quadric_subdivisions); + glCallList(_displayLists + 0); glPopMatrix(); glDisable(GL_LIGHTING); } @@ -150,14 +144,6 @@ void drawContext::drawTaperedCylinder(double width, double val1, double val2, { if(light) glEnable(GL_LIGHTING); - static int first = 1; - static GLUquadricObj *qua; - - if(first){ - first = 0; - qua = gluNewQuadric(); - } - double dx = x[1] - x[0]; double dy = y[1] - y[0]; double dz = z[1] - z[0]; @@ -180,7 +166,7 @@ void drawContext::drawTaperedCylinder(double width, double val1, double val2, glPushMatrix(); glTranslated(x[0], y[0], z[0]); glRotated(phi, axis[0], axis[1], axis[2]); - gluCylinder(qua, radius1, radius2, length, CTX.quadric_subdivisions, 1); + gluCylinder(_quadric, radius1, radius2, length, CTX.quadric_subdivisions, 1); glPopMatrix(); glDisable(GL_LIGHTING); @@ -190,14 +176,6 @@ void drawContext::drawCylinder(double width, double *x, double *y, double *z, in { if(light) glEnable(GL_LIGHTING); - static int first = 1; - static GLUquadricObj *qua; - - if(first){ - first = 0; - qua = gluNewQuadric(); - } - double dx = x[1] - x[0]; double dy = y[1] - y[0]; double dz = z[1] - z[0]; @@ -218,15 +196,13 @@ void drawContext::drawCylinder(double width, double *x, double *y, double *z, in glPushMatrix(); glTranslated(x[0], y[0], z[0]); glRotated(phi, axis[0], axis[1], axis[2]); - gluCylinder(qua, radius, radius, length, CTX.quadric_subdivisions, 1); + gluCylinder(_quadric, radius, radius, length, CTX.quadric_subdivisions, 1); glPopMatrix(); glDisable(GL_LIGHTING); } static void drawSimpleVector(int arrow, int fill, - double relHeadRadius, double relStemLength, - double relStemRadius, double x, double y, double z, double dx, double dy, double dz, double d, int light) @@ -263,11 +239,11 @@ static void drawSimpleVector(int arrow, int fill, u[1] /= l; u[2] /= l; - double b = relHeadRadius * d; + double b = CTX.arrow_rel_head_radius * d; if(arrow){ - double f1 = relStemLength; - double f2 = (1-2.*relStemRadius) * f1; // hack :-) + double f1 = CTX.arrow_rel_stem_length; + double f2 = (1 - 2. * CTX.arrow_rel_stem_radius) * f1; // hack :-) if(fill) { glBegin(GL_LINES); @@ -395,29 +371,13 @@ static void drawSimpleVector(int arrow, int fill, } -static void drawArrow3d(double relHeadRadius, double relStemLength, double relStemRadius, - double x, double y, double z, double dx, double dy, double dz, - double length, int light) +void drawContext::drawArrow3d(double x, double y, double z, + double dx, double dy, double dz, + double length, int light) { - if(light) glEnable(GL_LIGHTING); - - int subdiv = CTX.quadric_subdivisions; - double head_r = relHeadRadius * length; - double head_l = (1. - relStemLength) * length; - double stem_r = relStemRadius * length; - double stem_l = relStemLength * length; - - static int first = 1; - static GLUquadricObj *qua; - - if(first){ - first = 0; - qua = gluNewQuadric(); - } - double zdir[3] = {0., 0., 1.}; - double vdir[3] = {dx/length, dy/length, dz/length}; - double axis[3], cosphi, phi; + double vdir[3] = {dx / length, dy / length, dz / length}; + double axis[3], cosphi; prodve(zdir, vdir, axis); prosca(zdir, vdir, &cosphi); if(!norme(axis)){ @@ -425,31 +385,19 @@ static void drawArrow3d(double relHeadRadius, double relStemLength, double relSt axis[1] = 1.; axis[2] = 0.; } - phi = 180. * myacos(cosphi) / M_PI; + double phi = 180. * myacos(cosphi) / M_PI; + if(light) glEnable(GL_LIGHTING); glPushMatrix(); glTranslated(x, y, z); + glScaled(length, length, length); glRotated(phi, axis[0], axis[1], axis[2]); - glTranslated(0., 0., stem_l); - if(head_l && head_r) - gluCylinder(qua, head_r, 0., head_l, subdiv, 1); - if(head_r > stem_r) - gluDisk(qua, stem_r, head_r, subdiv, 1); - else - gluDisk(qua, head_r, stem_r, subdiv, 1); - glTranslated(0., 0., -stem_l); - if(stem_l && stem_r){ - gluCylinder(qua, stem_r, stem_r, stem_l, subdiv, 1); - gluDisk(qua, 0, stem_r, subdiv, 1); - } + glCallList(_displayLists + 1); glPopMatrix(); - glDisable(GL_LIGHTING); } -void drawContext::drawVector(int Type, int Fill, - double relHeadRadius, double relStemLength, - double relStemRadius, double x, double y, double z, +void drawContext::drawVector(int Type, int Fill, double x, double y, double z, double dx, double dy, double dz, int light) { double length = sqrt(dx * dx + dy * dy + dz * dz); @@ -464,7 +412,7 @@ void drawContext::drawVector(int Type, int Fill, glEnd(); break; case 6: - if(relHeadRadius){ + if(CTX.arrow_rel_head_radius){ glBegin(GL_POINTS); glVertex3d(x + dx, y + dy, z + dz); glEnd(); @@ -477,17 +425,14 @@ void drawContext::drawVector(int Type, int Fill, glEnd(); break; case 2: - drawSimpleVector(1, Fill, relHeadRadius, relStemLength, relStemRadius, - x, y, z, dx, dy, dz, length, light); + drawSimpleVector(1, Fill, x, y, z, dx, dy, dz, length, light); break; case 3: - drawSimpleVector(0, Fill, relHeadRadius, relStemLength, relStemRadius, - x, y, z, dx, dy, dz, length, light); + drawSimpleVector(0, Fill, x, y, z, dx, dy, dz, length, light); break; case 4: default: - drawArrow3d(relHeadRadius, relStemLength, relStemRadius, - x, y, z, dx, dy, dz, length, light); + drawArrow3d(x, y, z, dx, dy, dz, length, light); break; } } @@ -635,9 +580,7 @@ void drawContext::drawPlaneInBoundingBox(double xmin, double ymin, double zmin, drawCylinder(CTX.line_width, xx, yy, zz, 1); } for(int j = 0; j < nb; j++){ - drawArrow3d(CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - p[j].x, p[j].y, p[j].z, n[0], n[1], n[2], length, 1); + drawArrow3d(p[j].x, p[j].y, p[j].z, n[0], n[1], n[2], length, 1); if(shade){ p_shade[n_shade].x = p[j].x; p_shade[n_shade].y = p[j].y; diff --git a/Graphics/drawMesh.cpp b/Graphics/drawMesh.cpp index 442ba70896682cc0c93301b97f7436a2121bf24c..e3ff5d6381af0014f2eaec3efaa13b2c89867a97 100644 --- a/Graphics/drawMesh.cpp +++ b/Graphics/drawMesh.cpp @@ -210,9 +210,8 @@ static void drawNormals(drawContext *ctx, std::vector<T*> &elements) for(int j = 0; j < 3; j++) n[j] *= CTX.mesh.normals * ctx->pixel_equiv_x / ctx->s[j]; SPoint3 pc = ele->barycenter(); - ctx->drawVector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - pc.x(), pc.y(), pc.z(), n[0], n[1], n[2], CTX.mesh.light); + ctx->drawVector(CTX.vector_type, 0, pc.x(), pc.y(), pc.z(), n[0], n[1], n[2], + CTX.mesh.light); } } @@ -227,9 +226,8 @@ static void drawTangents(drawContext *ctx, std::vector<T*> &elements) for(int j = 0; j < 3; j++) t[j] *= CTX.mesh.tangents * ctx->pixel_equiv_x / ctx->s[j]; SPoint3 pc = ele->barycenter(); - ctx->drawVector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - pc.x(), pc.y(), pc.z(), t[0], t[1], t[2], CTX.mesh.light); + ctx->drawVector(CTX.vector_type, 0, pc.x(), pc.y(), pc.z(), t[0], t[1], t[2], + CTX.mesh.light); } } diff --git a/Graphics/drawPost.cpp b/Graphics/drawPost.cpp index fc0c6a3634b2ba4fecf6e704e24af6a18b3e9827..1ce052d0868db7d8018d793530fe10b7e1d3fa58 100644 --- a/Graphics/drawPost.cpp +++ b/Graphics/drawPost.cpp @@ -1097,8 +1097,7 @@ static void drawVectorArray(drawContext *ctx, PView *p, VertexArray *va) z -= 0.5 * dz; } ctx->drawVector(opt->VectorType, opt->IntervalsType != PViewOptions::Iso, - opt->ArrowRelHeadRadius, opt->ArrowRelStemLength, - opt->ArrowRelStemRadius, x, y, z, dx, dy, dz, opt->Light); + x, y, z, dx, dy, dz, opt->Light); } } } @@ -1179,9 +1178,8 @@ static void drawNormalVectorGlyphs(drawContext *ctx, PView *p, int numNodes, for(int i = 0; i < 3; i++) n[i] *= opt->Normals * ctx->pixel_equiv_x / ctx->s[i]; glColor4ubv((GLubyte *) & opt->color.normals); - ctx->drawVector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - pc[0], pc[1], pc[2], n[0], n[1], n[2], opt->Light); + ctx->drawVector(CTX.vector_type, 0, pc[0], pc[1], pc[2], n[0], n[1], n[2], + opt->Light); } static void drawTangentVectorGlyphs(drawContext *ctx, PView *p, int numNodes, @@ -1197,9 +1195,8 @@ static void drawTangentVectorGlyphs(drawContext *ctx, PView *p, int numNodes, for(int i = 0; i < 3; i++) t[i] *= opt->Tangents * ctx->pixel_equiv_x / ctx->s[i]; glColor4ubv((GLubyte *) & opt->color.tangents); - ctx->drawVector(CTX.vector_type, 0, CTX.arrow_rel_head_radius, - CTX.arrow_rel_stem_length, CTX.arrow_rel_stem_radius, - pc[0], pc[1], pc[2], t[0], t[1], t[2], opt->Light); + ctx->drawVector(CTX.vector_type, 0, pc[0], pc[1], pc[2], t[0], t[1], t[2], + opt->Light); } static void drawGlyphs(drawContext *ctx, PView *p) diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp index 220d08473cb0cd50d5516e06a21d6b4a9ae6cced..af6bc4212cfa021209f7f51a32de7f49bf3e42d4 100644 --- a/Plugin/CutPlane.cpp +++ b/Plugin/CutPlane.cpp @@ -4,7 +4,6 @@ // bugs and problems to <gmsh@geuz.org>. #if defined(HAVE_FLTK) -#include <FL/gl.h> #include "drawContext.h" #include "Draw.h" #endif diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp index 1608248e37086c742bd9d4ce5295543553465b06..40458339bea8272967fb6e1daaca46f5bef131f2 100644 --- a/Plugin/CutSphere.cpp +++ b/Plugin/CutSphere.cpp @@ -5,14 +5,7 @@ #include <string.h> #if defined(HAVE_FLTK) -#include <FL/gl.h> -//FIXME: workaround faulty fltk installs -//#include <FL/glu.h> -#ifdef __APPLE__ -# include <OpenGL/glu.h> -#else -# include <GL/glu.h> -#endif +#include "drawContext.h" #include "Draw.h" #endif #include "CutSphere.h" @@ -41,23 +34,16 @@ extern "C" void GMSH_CutSpherePlugin::draw(void *context) { #if defined(HAVE_FLTK) - static GLUquadricObj *qua; - static int first = 1; - if(first) { - first = 0; - qua = gluNewQuadric(); - } GLint mode[2]; glGetIntegerv(GL_POLYGON_MODE, mode); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glPushMatrix(); glColor4ubv((GLubyte *) & CTX.color.fg); glLineWidth(CTX.line_width); - glTranslated(CutSphereOptions_Number[0].def, - CutSphereOptions_Number[1].def, - CutSphereOptions_Number[2].def); - gluSphere(qua, CutSphereOptions_Number[3].def, 40, 40); - glPopMatrix(); + drawContext *ctx = (drawContext*)context; + ctx->drawSphere(CutSphereOptions_Number[3].def, + CutSphereOptions_Number[0].def, + CutSphereOptions_Number[1].def, + CutSphereOptions_Number[2].def, 40, 40, 1); glPolygonMode(GL_FRONT_AND_BACK, mode[1]); #endif } diff --git a/Plugin/Makefile b/Plugin/Makefile index 168bb719405f5d72bec06098ecc49c6041eee122..515a6cf560b594db7bbf402cda263efff2a5bf3a 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -91,12 +91,12 @@ CutPlane${OBJEXT}: CutPlane.cpp ../Graphics/drawContext.h \ ../Common/GmshMessage.h ../Post/PView.h ../Post/PViewDataList.h \ ../Post/PViewData.h ../Numeric/GmshMatrix.h ../Common/ListUtils.h \ ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h -CutSphere${OBJEXT}: CutSphere.cpp ../Fltk/Draw.h CutSphere.h Levelset.h Plugin.h \ - ../Common/Options.h ../Post/ColorTable.h ../Common/GmshMessage.h \ - ../Post/PView.h ../Geo/SPoint3.h ../Post/PViewDataList.h \ - ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \ - ../Numeric/GmshMatrix.h ../Common/ListUtils.h ../Common/Context.h \ - ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h +CutSphere${OBJEXT}: CutSphere.cpp ../Graphics/drawContext.h \ + ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Fltk/Draw.h CutSphere.h \ + Levelset.h Plugin.h ../Common/Options.h ../Post/ColorTable.h \ + ../Common/GmshMessage.h ../Post/PView.h ../Post/PViewDataList.h \ + ../Post/PViewData.h ../Numeric/GmshMatrix.h ../Common/ListUtils.h \ + ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h CutMap${OBJEXT}: CutMap.cpp CutMap.h Levelset.h Plugin.h ../Common/Options.h \ ../Post/ColorTable.h ../Common/GmshMessage.h ../Post/PView.h \ ../Geo/SPoint3.h ../Post/PViewDataList.h ../Post/PViewData.h \ diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index a97d87d93794c7d39998d0f7f7eb9b99c8891de1..bf8eb7c6e398a3860e1a19ec2d01f4b801ff79a7 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -60,7 +60,6 @@ class PViewOptions { double Offset[3], Raise[3], Transform[3][3], DisplacementFactor, NormalRaise; double Explode; double ArrowSizeMin, ArrowSizeMax; - double ArrowRelHeadRadius, ArrowRelStemRadius, ArrowRelStemLength; double Normals, Tangents; int Visible, IntervalsType, NbIso; int Light, LightTwoSide, LightLines, SmoothNormals; diff --git a/doc/VERSIONS.txt b/doc/VERSIONS.txt index a43052c9e5881a5b6b8e470d6558adb68e766ab2..0cda2c7ca73ab6f2eaaef6f9e7b0eb8e4c8cbc5f 100644 --- a/doc/VERSIONS.txt +++ b/doc/VERSIONS.txt @@ -1,8 +1,8 @@ -$Id: VERSIONS.txt,v 1.28 2008-12-28 17:23:39 geuzaine Exp $ +$Id: VERSIONS.txt,v 1.29 2009-01-03 08:56:45 geuzaine Exp $ 2.3.0 (?): restored full-quad recombine algorithm; fixed clipping planes when more than 32 views are present ({Geometry,Mesh,View}.Clip -replaces General.Clip); modified arrow size and Transform options; +replaces General.Clip); modified arrow size and transform options; improved visibility browser; major graphics and GUI code refactoring; improved automatic transfinite corner selection (now also for volumes); many small improvements and small bug fixes. diff --git a/doc/texinfo/opt_general.texi b/doc/texinfo/opt_general.texi index 2f40cfdff4215205d2702336dc9e1c031f9a241f..582cfdc732ccf22e17bed8d5cbb25c772d51966b 100644 --- a/doc/texinfo/opt_general.texi +++ b/doc/texinfo/opt_general.texi @@ -756,7 +756,7 @@ Saved in: @code{General.OptionsFileName} @item General.QuadricSubdivisions Number of subdivisions used to draw points or lines as spheres or cylinders@* -Default value: @code{8}@* +Default value: @code{6}@* Saved in: @code{General.OptionsFileName} @item General.RotationX diff --git a/doc/texinfo/opt_solver.texi b/doc/texinfo/opt_solver.texi index a1a074b19024526f79e48697806b0402a23040ba..83de45736ba011bc547ba9c167256501f2f470a9 100644 --- a/doc/texinfo/opt_solver.texi +++ b/doc/texinfo/opt_solver.texi @@ -18,7 +18,7 @@ Saved in: @code{General.OptionsFileName} Help string for solver 0@* Default value: @code{"A General environment for the treatment of Discrete Problems. -Copyright (C) 1997-2008 +Copyright (C) 1997-2009 Patrick Dular and Christophe Geuzaine. Visit http://www.geuz.org/getdp/ for more info"}@* Saved in: @code{General.OptionsFileName} diff --git a/doc/texinfo/opt_view.texi b/doc/texinfo/opt_view.texi index 87c9b40ee4261de71128e3eeac457b247c70a042..899bd12bff6f3b7a7fdf0b8993cf146b29b0d083 100644 --- a/doc/texinfo/opt_view.texi +++ b/doc/texinfo/opt_view.texi @@ -124,11 +124,6 @@ Threshold angle below which normals are not smoothed@* Default value: @code{30}@* Saved in: @code{General.OptionsFileName} -@item View.ArrowHeadRadius -Relative radius of arrow head@* -Default value: @code{0.12}@* -Saved in: @code{General.OptionsFileName} - @item View.ArrowSizeMax Maximum display size of arrows (in pixels)@* Default value: @code{60}@* @@ -139,16 +134,6 @@ Minimum display size of arrows (in pixels)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} -@item View.ArrowStemLength -Relative length of arrow stem@* -Default value: @code{0.56}@* -Saved in: @code{General.OptionsFileName} - -@item View.ArrowStemRadius -Relative radius of arrow stem@* -Default value: @code{0.02}@* -Saved in: @code{General.OptionsFileName} - @item View.AutoPosition Position the scale or 2D plot automatically@* Default value: @code{1}@*