diff --git a/Common/Context.h b/Common/Context.h index 6064141bc71884519a9d83f23a239a9665797c4e..9d22f18bd4a9c71808bdf4004e8fc90dab9d631a 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -151,8 +151,8 @@ class CTX { // fltk font size (and delta for palette windows) int fontSize, deltaFontSize; // font name, FLTK enum and size for opengl graphics - std::string glFont; - int glFontEnum, glFontSize; + std::string glFont, glFontTitle; + int glFontEnum, glFontEnumTitle, glFontSize, glFontSizeTitle; // point/line widths double pointSize, lineWidth; // light options diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 9184fa154284c91c9e491293bc40ffa666b9c6ba..6afa974de0d6630cdcc872cccd3a1c2610238c53 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -56,6 +56,8 @@ StringXString GeneralOptions_String[] = { { F|O, "GraphicsFont" , opt_general_graphics_font , "Helvetica" , "Font used in the graphic window" }, + { F|O, "GraphicsFontTitle" , opt_general_graphics_font_title , "Helvetica" , + "Font used in the graphic window for titles" }, { F|S, "OptionsFileName" , opt_general_options_filename , ".gmsh-options" , "Option file created with `Tools->Options->Save'; automatically read on startup" }, @@ -601,6 +603,8 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "GraphicsFontSize" , opt_general_graphics_fontsize , 17. , "Size of the font in the graphic window" }, + { F|O, "GraphicsFontSizeTitle" , opt_general_graphics_fontsize_title , 19. , + "Size of the font in the graphic window for titles" }, { F|S, "GraphicsHeight" , opt_general_graphics_size1 , 600. , "Height (in pixels) of the graphic window" }, { F|S, "GraphicsPositionX" , opt_general_graphics_position0 , 50. , @@ -1533,9 +1537,9 @@ StringXNumber ViewOptions_Number[] = { "Show element boundaries?" }, { F|O, "ShowScale" , opt_view_show_scale , 1. , "Show value scale?" }, - { F|O, "ShowTime" , opt_view_show_time , 1. , - "Time display mode (0=hidden, 1=value if multi-step, 2=value always, " - "3=step if multi-step, 4=step always)" }, + { F|O, "ShowTime" , opt_view_show_time , 3. , + "Time display mode (0=hidden, 1=time value if multi-step, 2=time value always, " + "3=time step if multi-step, 4=time step always)" }, { F|O, "SmoothNormals" , opt_view_smooth_normals , 0. , "Smooth the normals?" }, { F|O, "Stipple" , opt_view_use_stipple , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 16b5729e4146b955a850db97b5b0c0697358dbf0..b5b07f57a7ebfed94fd4082c1865bc864687177e 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1077,6 +1077,23 @@ std::string opt_general_graphics_font(OPT_ARGS_STR) return CTX::instance()->glFont; } +std::string opt_general_graphics_font_title(OPT_ARGS_STR) +{ + if(action & GMSH_SET) + CTX::instance()->glFontTitle = val; +#if defined(HAVE_FLTK) + int index = drawContext::global()->getFontIndex(CTX::instance()->glFontTitle.c_str()); + if(action & GMSH_SET){ + CTX::instance()->glFontTitle = drawContext::global()->getFontName(index); + CTX::instance()->glFontEnumTitle = drawContext::global()->getFontEnum(index); + } + if(FlGui::available() && (action & GMSH_GUI)){ + FlGui::instance()->options->general.choice[6]->value(index); + } +#endif + return CTX::instance()->glFontTitle; +} + std::string opt_solver_socket_name(OPT_ARGS_STR) { if(action & GMSH_SET) @@ -2347,6 +2364,18 @@ double opt_general_graphics_fontsize(OPT_ARGS_NUM) return CTX::instance()->glFontSize; } +double opt_general_graphics_fontsize_title(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->glFontSizeTitle = (int)val; +#if defined(HAVE_FLTK) + if(FlGui::available() && (action & GMSH_GUI)) + FlGui::instance()->options->general.value[28]->value + (CTX::instance()->glFontSizeTitle); +#endif + return CTX::instance()->glFontSizeTitle; +} + double opt_general_polygon_offset_always(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 834d029a7a11b8e8d2f52f2a561ed17e019451e7..87b58a6691da937f9aae4b32abe6ab4158f906e1 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -49,6 +49,7 @@ std::string opt_general_web_browser(OPT_ARGS_STR); std::string opt_general_watch_file_pattern(OPT_ARGS_STR); std::string opt_general_gui_theme(OPT_ARGS_STR); std::string opt_general_graphics_font(OPT_ARGS_STR); +std::string opt_general_graphics_font_title(OPT_ARGS_STR); std::string opt_solver_socket_name(OPT_ARGS_STR); std::string opt_solver_name(OPT_ARGS_STR); std::string opt_solver_name0(OPT_ARGS_STR); @@ -228,6 +229,7 @@ std::string opt_view_stipple9(OPT_ARGS_STR); double opt_general_initial_context(OPT_ARGS_NUM); double opt_general_fontsize(OPT_ARGS_NUM); double opt_general_graphics_fontsize(OPT_ARGS_NUM); +double opt_general_graphics_fontsize_title(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); diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index f5e119c98372acac254e80b418a824fd84c1024e..c7042a73349f96150ad9474f3cd677438b4e6160 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -276,6 +276,7 @@ static void general_options_ok_cb(Fl_Widget *w, void *data) opt_general_rotation_center2(0, GMSH_SET, o->general.value[10]->value()); opt_general_quadric_subdivisions(0, GMSH_SET, o->general.value[11]->value()); opt_general_graphics_fontsize(0, GMSH_SET, o->general.value[12]->value()); + opt_general_graphics_fontsize_title(0, GMSH_SET, o->general.value[28]->value()); opt_general_clip_factor(0, GMSH_SET, o->general.value[14]->value()); opt_general_polygon_offset_factor(0, GMSH_SET, o->general.value[15]->value()); opt_general_polygon_offset_units(0, GMSH_SET, o->general.value[16]->value()); @@ -303,6 +304,7 @@ static void general_options_ok_cb(Fl_Widget *w, void *data) opt_general_vector_type(0, GMSH_SET, o->general.choice[0]->value() + 1); opt_general_graphics_font(0, GMSH_SET, o->general.choice[1]->text()); + opt_general_graphics_font_title(0, GMSH_SET, o->general.choice[6]->text()); opt_general_orthographic(0, GMSH_SET, !o->general.choice[2]->value()); opt_general_axes(0, GMSH_SET, o->general.choice[4]->value()); opt_general_background_gradient(0, GMSH_SET, o->general.choice[5]->value()); @@ -1543,20 +1545,31 @@ optionWindow::optionWindow(int deltaFontSize) (L + 2 * IW - 2 * WB, 2 * WB + 8 * BH, BB, BH, "Edit arrow"); b->callback(general_arrow_param_cb); - general.choice[1] = new Fl_Choice - (L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Font"); + int w1 = (int)(4. * IW / 5.), w2 = IW - w1; + general.choice[1] = new Fl_Choice(L + 2 * WB, 2 * WB + 9 * BH, w1, BH); general.choice[1]->menu(menu_font_names); general.choice[1]->align(FL_ALIGN_RIGHT); general.choice[1]->callback(general_options_ok_cb); - general.value[12] = new Fl_Value_Input - (L + 2 * WB, 2 * WB + 10 * BH, IW, BH, "Font size"); + (L + 2 * WB + w1, 2 * WB + 9 * BH, w2, BH, "Default font"); general.value[12]->minimum(5); general.value[12]->maximum(40); general.value[12]->step(1); general.value[12]->align(FL_ALIGN_RIGHT); general.value[12]->callback(general_options_ok_cb); + general.choice[6] = new Fl_Choice(L + 2 * WB, 2 * WB + 10 * BH, w1, BH); + general.choice[6]->menu(menu_font_names); + general.choice[6]->align(FL_ALIGN_RIGHT); + general.choice[6]->callback(general_options_ok_cb); + general.value[28] = new Fl_Value_Input + (L + 2 * WB + w1, 2 * WB + 10 * BH, w2, BH, "Title font"); + general.value[28]->minimum(5); + general.value[28]->maximum(40); + general.value[28]->step(1); + general.value[28]->align(FL_ALIGN_RIGHT); + general.value[28]->callback(general_options_ok_cb); + o->end(); } { diff --git a/Graphics/drawContext.h b/Graphics/drawContext.h index e9c53c541feb83b3bbd6011216eb07ed299d0004..750e25c2542b8f88a0580118964d6f62ddccf582 100644 --- a/Graphics/drawContext.h +++ b/Graphics/drawContext.h @@ -191,12 +191,12 @@ class drawContext { void drawAxes(); void drawSmallAxes(); void drawScales(); - void drawString(std::string s, std::string &font_name, int font_enum, + void drawString(const std::string &s, const std::string &font_name, int font_enum, int font_size, int align); - void drawString(std::string s); - void drawStringCenter(std::string s); - void drawStringRight(std::string s); - void drawString(std::string s, double style); + void drawString(const std::string &s); + void drawStringCenter(const std::string &s); + void drawStringRight(const std::string &s); + void drawString(const 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); diff --git a/Graphics/drawGlyph.cpp b/Graphics/drawGlyph.cpp index 7820468aac4802250b83d9dd240b521a59be08a5..e4a7437968709e4017253ebb608394bd69cc1592 100644 --- a/Graphics/drawGlyph.cpp +++ b/Graphics/drawGlyph.cpp @@ -12,8 +12,8 @@ #include "gl2ps.h" #include "SVector3.h" -void drawContext::drawString(std::string s, std::string &font_name, int font_enum, - int font_size, int align) +void drawContext::drawString(const std::string &s, const std::string &font_name, + int font_enum, int font_size, int align) { if(CTX::instance()->printing && !CTX::instance()->print.text) return; @@ -81,25 +81,25 @@ void drawContext::drawString(std::string s, std::string &font_name, int font_enu } } -void drawContext::drawString(std::string s) +void drawContext::drawString(const std::string &s) { drawString(s, CTX::instance()->glFont, CTX::instance()->glFontEnum, CTX::instance()->glFontSize, 0); } -void drawContext::drawStringCenter(std::string s) +void drawContext::drawStringCenter(const std::string &s) { drawString(s, CTX::instance()->glFont, CTX::instance()->glFontEnum, CTX::instance()->glFontSize, 1); } -void drawContext::drawStringRight(std::string s) +void drawContext::drawStringRight(const std::string &s) { drawString(s, CTX::instance()->glFont, CTX::instance()->glFontEnum, CTX::instance()->glFontSize, 2); } -void drawContext::drawString(std::string s, double style) +void drawContext::drawString(const std::string &s, double style) { unsigned int bits = (unsigned int)style; diff --git a/Graphics/drawScales.cpp b/Graphics/drawScales.cpp index 7c7d1c178cdb14592930ac0bb2c2e9068886e069..a3e70592c93e366d2a64b560ecac26582835c82e 100644 --- a/Graphics/drawScales.cpp +++ b/Graphics/drawScales.cpp @@ -178,18 +178,23 @@ static void drawScaleLabel(drawContext *ctx, PView *p, double xmin, double ymin, sprintf(label, "%s (%s)", data->getName().c_str(), tmp); } else if((opt->showTime == 3 && nt > 1) || opt->showTime == 4){ - sprintf(label, "%s (%d)", data->getName().c_str(), opt->timeStep); + sprintf(label, "%s (%d/%d)", data->getName().c_str(), opt->timeStep, + data->getNumTimeSteps() - 1); } else sprintf(label, "%s", data->getName().c_str()); if(horizontal){ glRasterPos2d(xmin + width / 2., ymin + height + tic + 1.4 * font_h); - ctx->drawStringCenter(label); + ctx->drawString(label, CTX::instance()->glFontTitle, + CTX::instance()->glFontEnumTitle, + CTX::instance()->glFontSizeTitle, 1); } else{ glRasterPos2d(xmin, ymin - 2 * font_h); - ctx->drawString(label); + ctx->drawString(label, CTX::instance()->glFontTitle, + CTX::instance()->glFontEnumTitle, + CTX::instance()->glFontSizeTitle, 0); } }