diff --git a/Common/Context.h b/Common/Context.h index 73e27ae76422a938944b9a3ce393b977af6dacd9..8807f910439e64fb318aba14e0367376b2fa49b1 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -115,6 +115,8 @@ public : double zoom_factor; // mouse2 zoom coefficient int fontsize; // font size for fltk UI + 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 double point_size, line_width; // point/line widths @@ -197,9 +199,8 @@ public : // print options struct{ int format; - int eps_quality, eps_background, eps_font_size, eps_compress, eps_ps3shading; + int eps_quality, eps_background, eps_compress, eps_ps3shading; int eps_occlusion_culling, eps_best_root; - char *eps_font; double eps_line_width_factor, eps_point_size_factor; int jpeg_quality; int gif_dither, gif_sort, gif_interlace, gif_transparent; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 8f469aa3fa053ba18fe72816c89ff513efff91cf..dad185102522e741255ab51e4cc1353cf2109b58 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -48,6 +48,9 @@ StringXString GeneralOptions_String[] = { { F|S, "ErrorFileName" , opt_general_error_filename , ".gmsh-errors" , "File into which the log is saved if a fatal error occurs" }, + { F|S, "GraphicsFont" , opt_general_graphics_font , "Helvetica" , + "Font used in the graphic window" }, + { F|S, "OptionsFileName" , opt_general_options_filename , ".gmsh-options" , "Option file created with `Tools->Options->Save'; automatically read on startup" }, @@ -353,8 +356,6 @@ StringXString ViewOptions_String[] = { } ; StringXString PrintOptions_String[] = { - { F|O, "EpsFont" , opt_print_eps_font , "Courier" , - "Font used in PostScript/PDF output" }, { 0, NULL , NULL , NULL , NULL } } ; @@ -451,7 +452,7 @@ StringXNumber GeneralOptions_Number[] = { { F|S, "FontSize" , opt_general_fontsize , 12. , "Size of the font in the graphical user interface" }, - { F|S, "GraphicsFontSize" , opt_general_graphics_fontsize , 12. , + { F|S, "GraphicsFontSize" , opt_general_graphics_fontsize , 14. , "Size of the font in the graphic window" }, { F|S, "GraphicsHeight" , opt_general_viewport3 , 500. , "Height (in pixels) of the graphic window" }, @@ -573,9 +574,9 @@ StringXNumber GeneralOptions_Number[] = { "Material shininess (must be > 0)" }, { F|O, "SmallAxes" , opt_general_small_axes , 1. , "Display the small axes" }, - { F|O, "SmallAxesPositionX" , opt_general_small_axes_position0 , -45. , + { F|O, "SmallAxesPositionX" , opt_general_small_axes_position0 , -60. , "X position of small axes (use negative values for right alignment)" }, - { F|O, "SmallAxesPositionY" , opt_general_small_axes_position1 , -35. , + { F|O, "SmallAxesPositionY" , opt_general_small_axes_position1 , -40. , "Y position of small axes (use negative values for bottom alignment)" }, { F|S, "SolverPositionX" , opt_general_solver_position0 , 650. , "Horizontal position (in pixels) of the upper left corner of the solver windows" }, @@ -1049,8 +1050,6 @@ StringXNumber PrintOptions_Number[] = { "Try to minimize primitive splitting in BSP tree sorted PostScript/PDF output" }, { F|O, "EpsCompress" , opt_print_eps_compress , 0. , "Compress PostScript/PDF output using zlib" }, - { F|O, "EpsFontSize" , opt_print_eps_font_size , 12. , - "Font size used in PostScript/PDF output" }, { F|O, "EpsLineWidthFactor" , opt_print_eps_line_width_factor , 0.5 , "Width factor for lines in PostScript/PDF output" }, { F|O, "EpsOcclusionCulling" , opt_print_eps_occlusion_culling , 1. , diff --git a/Common/Options.cpp b/Common/Options.cpp index a3ac107f4bfa965436d0448b3e007116b1f9c950..916f6fdbfa6d22be67fecb6fa5a1d8d72198dc63 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.147 2004-04-21 04:26:44 geuzaine Exp $ +// $Id: Options.cpp,v 1.148 2004-04-24 02:13:07 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -123,6 +123,11 @@ void Init_Options(int num) CTX.mesh.oldxtrude = CTX.mesh.oldxtrude_recombine = 0; //old extrusion mesh generator CTX.mesh.check_duplicates = 0; //check for duplicate nodes in Read_Mesh CTX.post.combine_time = 0; // try to combine_time views at startup +#if defined(HAVE_FLTK) + CTX.gl_font_enum = FL_HELVETICA; +#else + CTX.gl_font_enum = -1; +#endif } void ReInit_Options(int num) @@ -828,6 +833,47 @@ char *opt_general_scheme(OPT_ARGS_STR) return CTX.scheme; } +#if defined(HAVE_FLTK) +extern Fl_Menu_Item menu_font_names[]; +#endif + +char *opt_general_graphics_font(OPT_ARGS_STR) +{ + if(action & GMSH_SET) + CTX.gl_font = val; +#if defined(HAVE_FLTK) + int index = -1, i = 0; + if(CTX.gl_font){ + while(menu_font_names[i].label()){ + if(!strcmp(menu_font_names[i].label(), CTX.gl_font)){ + index = i; + break; + } + i++; + } + } + if(action & GMSH_SET){ + if(index < 0){ + Msg(GERROR, "Unknown font \"%s\" (using \"Helvetica\" instead)", CTX.gl_font); + Msg(INFO, "Available fonts:"); + i = 0; + while(menu_font_names[i].label()){ + Msg(INFO, " \"%s\"", menu_font_names[i].label()); + i++; + } + CTX.gl_font = "Helvetica"; + CTX.gl_font_enum = FL_HELVETICA; + } + else + CTX.gl_font_enum = (int)menu_font_names[index].user_data(); + } + if(WID && (action & GMSH_GUI)){ + WID->gen_choice[1]->value(index); + } +#endif + return CTX.gl_font; +} + char *opt_mesh_triangle_options(OPT_ARGS_STR){ if(action & GMSH_SET) CTX.mesh.triangle_options = val; @@ -1718,15 +1764,6 @@ char *opt_view_abscissa_format(OPT_ARGS_STR) return v->AbscissaFormat; } - -char *opt_print_eps_font(OPT_ARGS_STR) -{ - if(action & GMSH_SET) - CTX.print.eps_font = val; - return CTX.print.eps_font; -} - - // Numeric option routines @@ -1748,6 +1785,10 @@ double opt_general_graphics_fontsize(OPT_ARGS_NUM) { if(action & GMSH_SET) CTX.gl_fontsize = (int)val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->gen_value[12]->value(CTX.gl_fontsize); +#endif return CTX.gl_fontsize; } @@ -2207,6 +2248,10 @@ double opt_general_quadric_subdivisions(OPT_ARGS_NUM) { if(action & GMSH_SET) CTX.quadric_subdivisions = (int)val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->gen_value[11]->value(CTX.quadric_subdivisions); +#endif return CTX.quadric_subdivisions; } @@ -2927,6 +2972,10 @@ double opt_geometry_line_sel_width(OPT_ARGS_NUM) { if(action & GMSH_SET) CTX.geom.line_sel_width = val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->geo_value[6]->value(CTX.geom.line_sel_width); +#endif return CTX.geom.line_sel_width; } @@ -4836,13 +4885,6 @@ double opt_print_eps_background(OPT_ARGS_NUM) return CTX.print.eps_background; } -double opt_print_eps_font_size(OPT_ARGS_NUM) -{ - if(action & GMSH_SET) - CTX.print.eps_font_size = (int)val; - return CTX.print.eps_font_size; -} - double opt_print_eps_line_width_factor(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 442350e7cfa0fc490a7b660a889496a69e3bb012..813a58f8fc7bc1f4548d68f18bf6a97bca1ea5b7 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -45,6 +45,7 @@ char * opt_general_options_filename(OPT_ARGS_STR); char * opt_general_editor(OPT_ARGS_STR); char * opt_general_web_browser(OPT_ARGS_STR); char * opt_general_scheme(OPT_ARGS_STR); +char * opt_general_graphics_font(OPT_ARGS_STR); char * opt_mesh_triangle_options(OPT_ARGS_STR); char * opt_solver_name(OPT_ARGS_STR); char * opt_solver_name0(OPT_ARGS_STR); @@ -183,7 +184,6 @@ char * opt_view_format(OPT_ARGS_STR); char * opt_view_filename(OPT_ARGS_STR); char * opt_view_abscissa_name(OPT_ARGS_STR); char * opt_view_abscissa_format(OPT_ARGS_STR); -char * opt_print_eps_font(OPT_ARGS_STR); // NUMBERS @@ -487,7 +487,6 @@ double opt_print_eps_quality(OPT_ARGS_NUM); double opt_print_eps_occlusion_culling(OPT_ARGS_NUM); double opt_print_eps_best_root(OPT_ARGS_NUM); double opt_print_eps_background(OPT_ARGS_NUM); -double opt_print_eps_font_size(OPT_ARGS_NUM); double opt_print_eps_line_width_factor(OPT_ARGS_NUM); double opt_print_eps_point_size_factor(OPT_ARGS_NUM); double opt_print_jpeg_quality(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 9f2b99f483afb0fa1081b2d9df7c7d8326be2745..b9c8f731263f7ecdd5756dc21f6a8221298f6a83 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.220 2004-04-23 18:31:01 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.221 2004-04-24 02:13:07 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -1050,6 +1050,8 @@ void general_options_ok_cb(CALLBACK_ARGS) opt_general_rotation_center0(0, GMSH_SET, WID->gen_value[8]->value()); opt_general_rotation_center1(0, GMSH_SET, WID->gen_value[9]->value()); opt_general_rotation_center2(0, GMSH_SET, WID->gen_value[10]->value()); + opt_general_quadric_subdivisions(0, GMSH_SET, WID->gen_value[11]->value()); + opt_general_graphics_fontsize(0, GMSH_SET, WID->gen_value[12]->value()); opt_general_default_filename(0, GMSH_SET, (char *)WID->gen_input[0]->value()); opt_general_tmp_filename(0, GMSH_SET, (char *)WID->gen_input[1]->value()); @@ -1074,6 +1076,7 @@ void general_options_ok_cb(CALLBACK_ARGS) break; } opt_general_vector_type(0, GMSH_SET, val); + opt_general_graphics_font(0, GMSH_SET, (char *)WID->gen_choice[1]->text()); } void general_arrow_param_cb(CALLBACK_ARGS) @@ -1120,6 +1123,7 @@ void geometry_options_ok_cb(CALLBACK_ARGS) opt_geometry_point_size(0, GMSH_SET, WID->geo_value[3]->value()); opt_geometry_line_width(0, GMSH_SET, WID->geo_value[4]->value()); opt_geometry_point_sel_size(0, GMSH_SET, WID->geo_value[5]->value()); + opt_geometry_line_sel_width(0, GMSH_SET, WID->geo_value[6]->value()); opt_geometry_point_type(0, GMSH_SET, WID->geo_choice[0]->value()); opt_geometry_line_type(0, GMSH_SET, WID->geo_choice[1]->value()); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index e71a24626993d29092f9f923f879f6d01b41e2e4..80fc8e8a7eb85c5647c64b528aa07de929b901cd 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.291 2004-04-23 18:31:01 geuzaine Exp $ +// $Id: GUI.cpp,v 1.292 2004-04-24 02:13:07 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -377,11 +377,29 @@ static Fl_Menu_Item menu_point_display[] = { }; static Fl_Menu_Item menu_line_display[] = { - {"Color segment", 0, 0, 0}, + {"Color segment", 0, 0, 0}, {"3D cylinder", 0, 0, 0}, {0} }; +Fl_Menu_Item menu_font_names[] = { + {"Times-Roman", 0, 0, (void*)FL_TIMES}, + {"Times-Bold", 0, 0, (void*)FL_TIMES_BOLD}, + {"Times-Italic", 0, 0, (void*)FL_TIMES_ITALIC}, + {"Times-BoldItalic", 0, 0, (void*)FL_TIMES_BOLD_ITALIC}, + {"Helvetica", 0, 0, (void*)FL_HELVETICA}, + {"Helvetica-Bold", 0, 0, (void*)FL_HELVETICA_BOLD}, + {"Helvetica-Oblique", 0, 0, (void*)FL_HELVETICA_ITALIC}, + {"Helvetica-BoldOblique", 0, 0, (void*)FL_HELVETICA_BOLD_ITALIC}, + {"Courier", 0, 0, (void*)FL_COURIER}, + {"Courier-Bold", 0, 0, (void*)FL_COURIER_BOLD}, + {"Courier-Oblique", 0, 0, (void*)FL_COURIER_ITALIC}, + {"Courier-BoldOblique", 0, 0, (void*)FL_COURIER_BOLD_ITALIC}, + {"Symbol", 0, 0, (void*)FL_SYMBOL}, + {"ZapfDingbats", 0, 0, (void*)FL_ZAPF_DINGBATS}, + {0} +}; + // Definition of global shortcuts int GUI::global_shortcuts(int event) @@ -1569,17 +1587,23 @@ void GUI::create_option_window() gen_value[4]->step(0.01); gen_value[4]->align(FL_ALIGN_RIGHT); - gen_butt[12] = new Fl_Check_Button(2 * WB, 2 * WB + 4 * BH, BW, BH, "Moving light"); + gen_butt[12] = new Fl_Check_Button(2 * IW - 2 * WB, 2 * WB + 3 * BH, (int)(1.5*BB), BH, "Moving light"); gen_butt[12]->type(FL_TOGGLE_BUTTON); gen_butt[12]->down_box(TOGGLE_BOX); gen_butt[12]->selection_color(TOGGLE_COLOR); - gen_value[1] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "Material shininess"); + gen_value[1] = new Fl_Value_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Material shininess"); gen_value[1]->minimum(0); gen_value[1]->maximum(10); gen_value[1]->step(0.1); gen_value[1]->align(FL_ALIGN_RIGHT); + gen_value[11] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "Quadric subdivisions"); + gen_value[11]->minimum(3); + gen_value[11]->maximum(30); + gen_value[11]->step(1); + gen_value[11]->align(FL_ALIGN_RIGHT); + gen_value[6] = new Fl_Value_Input(2 * WB, 2 * WB + 6 * BH, IW, BH, "Point size"); gen_value[6]->minimum(0.1); gen_value[6]->maximum(50); @@ -1607,6 +1631,16 @@ void GUI::create_option_window() Fl_Button *b = new Fl_Button(2 * IW - 2 * WB, 2 * WB + 8 * BH, (int)(1.5*BB), BH, "Edit arrow shape"); b->callback(general_arrow_param_cb); + gen_choice[1] = new Fl_Choice(2 * WB, 2 * WB + 9 * BH, IW, BH, "Font"); + gen_choice[1]->menu(menu_font_names); + gen_choice[1]->align(FL_ALIGN_RIGHT); + + gen_value[12] = new Fl_Value_Input(2 * WB, 2 * WB + 10 * BH, IW, BH, "Font size"); + gen_value[12]->minimum(5); + gen_value[12]->maximum(40); + gen_value[12]->step(1); + gen_value[12]->align(FL_ALIGN_RIGHT); + o->end(); } { @@ -1693,7 +1727,7 @@ void GUI::create_option_window() geo_value[3]->maximum(50); geo_value[3]->step(0.1); - geo_value[5] = new Fl_Value_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Highlighted point size"); + geo_value[5] = new Fl_Value_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Selected point size"); geo_value[5]->minimum(0.1); geo_value[5]->maximum(50); geo_value[5]->step(0.1); @@ -1707,7 +1741,12 @@ void GUI::create_option_window() geo_value[4]->maximum(50); geo_value[4]->step(0.1); - for(i = 3; i <= 5; i++) { + geo_value[6] = new Fl_Value_Input(2 * WB, 2 * WB + 7 * BH, IW, BH, "Selected line width"); + geo_value[6]->minimum(0.1); + geo_value[6]->maximum(50); + geo_value[6]->step(0.1); + + for(i = 3; i <= 6; i++) { geo_value[i]->align(FL_ALIGN_RIGHT); } o->end(); diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp index 380866fffc66ea8f8f1cbb0c0b6554b107be8d5d..08f4faaac5e82d76b66f9948dd68e31e585f4cc7 100644 --- a/Fltk/Opengl.cpp +++ b/Fltk/Opengl.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl.cpp,v 1.34 2004-02-07 01:40:17 geuzaine Exp $ +// $Id: Opengl.cpp,v 1.35 2004-04-24 02:13:07 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -76,14 +76,14 @@ void Draw_String(char *s) { if(CTX.print.gl_fonts) { - gl_font(FL_HELVETICA, CTX.gl_fontsize); + gl_font(CTX.gl_font_enum, CTX.gl_fontsize); gl_draw(s); } else { // ps or *tex output if(CTX.print.format == FORMAT_JPEGTEX || CTX.print.format == FORMAT_PNGTEX) return; - gl2psText(s, CTX.print.eps_font, CTX.print.eps_font_size); + gl2psText(s, CTX.gl_font, CTX.gl_fontsize); } } diff --git a/Graphics/Graph2D.cpp b/Graphics/Graph2D.cpp index 1b40a3515cd58a5727071bbfb2f77d4d6ebf13b8..bdebad1324915fa742fca9d0d799b50d2e9a80c2 100644 --- a/Graphics/Graph2D.cpp +++ b/Graphics/Graph2D.cpp @@ -1,4 +1,4 @@ -// $Id: Graph2D.cpp,v 1.32 2004-04-20 19:15:14 geuzaine Exp $ +// $Id: Graph2D.cpp,v 1.33 2004-04-24 02:13:07 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -116,7 +116,7 @@ static void Draw_Graph2D(Post_View * v, glEnd(); } - gl_font(FL_HELVETICA, CTX.gl_fontsize); + gl_font(CTX.gl_font_enum, CTX.gl_fontsize); font_h = gl_height(); // total font height font_a = gl_height() - gl_descent(); // height above ref pt @@ -212,7 +212,7 @@ static void Draw_Graph2D(Post_View * v, sprintf(label, "%s (%g)", v->Name, *(double *)List_Pointer(v->Time, v->TimeStep)); else sprintf(label, "%s", v->Name); - glRasterPos2d(xtop - gl_width(label) / 2., ytop + 1.5 * font_h); + glRasterPos2d(xtop - gl_width(label) / 2., ytop + font_h + tic); Draw_String(label); } @@ -288,14 +288,14 @@ static void Draw_Graph2D(Post_View * v, sprintf(label, v->AbscissaFormat, AbsMin + i * (AbsMax - AbsMin) / (double)(nb - 1)); glRasterPos2d(xtop + i * dx - gl_width(label) / 2., - ybot - 1.5 * font_h); + ybot - font_h - tic); Draw_String(label); } } if(v->ShowScale) { glColor4ubv((GLubyte *) & CTX.color.text); sprintf(label, "%s", v->AbscissaName); - glRasterPos2d(xtop + width / 2 - gl_width(label) / 2., ybot - 3 * font_h); + glRasterPos2d(xtop + width / 2 - gl_width(label) / 2., ybot - 2 * font_h - 2 * tic); Draw_String(label); } @@ -391,7 +391,7 @@ void Draw_Graph2D(void) tic = 5; dx = dy = 0.; if(v->ShowScale) { - gl_font(FL_HELVETICA, CTX.gl_fontsize); + gl_font(CTX.gl_font_enum, CTX.gl_fontsize); sprintf(label, v->AbscissaFormat, v->CustomMin); if(gl_width(label) + tic > dx) dx = gl_width(label) + tic; diff --git a/doc/VERSIONS b/doc/VERSIONS index 55ec2f6eae6a70016dcb1784105651bd0fbd94a3..671ed1fa63242a6953768da19cc2a56ec9c3ec2c 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,4 +1,4 @@ -$Id: VERSIONS,v 1.196 2004-04-20 18:14:31 geuzaine Exp $ +$Id: VERSIONS,v 1.197 2004-04-24 02:13:07 geuzaine Exp $ New in 1.52: new raster ("bitmap") PostScript/EPS/PDF output formats; new Plugin(Extract) to extract a given component from a @@ -6,11 +6,12 @@ post-processing view; improved mesh projection on non-planar surfaces; added support for second order tetrahedral elements; added interactive control of element order; refined mesh entity drawing selection (and renamed most of the corresponding options); enhanced log scale in -post-processing; various bug fixes (default postscript printing mode, -drawing of 3D arrows/cylinders on Linux, default home directory on -Windows, default initial file browser directory, extrusion of points -with non-normalized axes of rotation, computation of the scene -bounding box in scripts, + the usual documentation updates); +post-processing; better font selection; various bug fixes (default +postscript printing mode, drawing of 3D arrows/cylinders on Linux, +default home directory on Windows, default initial file browser +directory, extrusion of points with non-normalized axes of rotation, +computation of the scene bounding box in scripts, + the usual +documentation updates); New in 1.51: initial support for visualizing mesh partitions; integrated version 2.0 of the MSH mesh file format; new option to