From 7c62a34db47ebb11327c301dba48852e8387f21a Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 13 Nov 2014 11:29:23 +0000 Subject: [PATCH] new options: General.MessageFontSize and Mesh.ToleranceInitialDelaunay --- Common/Context.h | 8 ++++++-- Common/DefaultOptions.h | 4 ++++ Common/Options.cpp | 20 ++++++++++++++++++++ Common/Options.h | 2 ++ Fltk/graphicWindow.cpp | 42 +++++++++++++++++++++++++++++++++++++++-- Fltk/graphicWindow.h | 2 ++ Mesh/meshGRegion.cpp | 33 +++++++------------------------- 7 files changed, 81 insertions(+), 30 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index 34b1c0165e..f324232b97 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -23,12 +23,14 @@ struct contextMeshOptions { int points, lines, triangles, quadrangles, tetrahedra, hexahedra, prisms, pyramids; int surfacesEdges, surfacesFaces, volumesEdges, volumesFaces, numSubEdges; int pointsNum, linesNum, surfacesNum, volumesNum, qualityType, labelType; - int optimize, optimizeNetgen, optimizeLloyd, smoothCrossField, refineSteps, remove4triangles; + int optimize, optimizeNetgen, optimizeLloyd, smoothCrossField, refineSteps; + int remove4triangles; double normals, tangents, explode, angleSmoothNormals, allowSwapEdgeAngle; double mshFileVersion, mshFilePartitioned, pointSize, lineWidth; double qualityInf, qualitySup, radiusInf, radiusSup; double scalingFactor, lcFactor, randFactor, lcIntegrationPrecision; - double lcMin, lcMax, toleranceEdgeLength, anisoMax, smoothRatio; + double lcMin, lcMax, toleranceEdgeLength, toleranceInitialDelaunay; + double anisoMax, smoothRatio; int lcFromPoints, lcFromCurvature, lcExtendFromBoundary; int dual, voronoi, drawSkinOnly, colorCarousel, labelSampling; int fileFormat, nbSmoothing, algo2d, algo3d, algoSubdivide; @@ -187,6 +189,8 @@ class CTX { // font name, FLTK enum and size for opengl graphics std::string glFont, glFontTitle, glFontEngine; int glFontEnum, glFontEnumTitle, glFontSize, glFontSizeTitle; + // font size of messages + int msgFontSize; // point/line widths double pointSize, lineWidth; // light options diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 57172b927b..c24426d919 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -597,6 +597,8 @@ StringXNumber GeneralOptions_Number[] = { "Horizontal position (in pixels) of the (detached) menu tree" }, { F|S, "MenuPositionY" , opt_general_menu_position1 , 400. , "Vertical position (in pixels) of the (detached) menu tree" }, + { F|O, "MessageFontSize" , opt_general_message_fontsize , -1. , + "Size of the font in the message window (-1=automatic)" }, { F|S, "MessageHeight" , opt_general_message_size , 300. , "Height (in pixels) of the message console when it is visible (should be > 0)" }, { F, "MinX" , opt_general_xmin , 0. , @@ -1194,6 +1196,8 @@ StringXNumber MeshOptions_Number[] = { { F|O, "ToleranceEdgeLength" , opt_mesh_tolerance_edge_length, 0.0, "Skip a model edge in mesh generation if its length is less than user's " "defined tolerance" }, + { F|O, "ToleranceInitialDelaunay" , opt_mesh_tolerance_initial_delaunay, 1.e-8, + "Tolerance for initial 3D Delaunay mesher" }, { F|O, "Triangles" , opt_mesh_triangles , 1. , "Display mesh triangles?" }, diff --git a/Common/Options.cpp b/Common/Options.cpp index 86e1ef60a8..62296cb7ea 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -2079,6 +2079,19 @@ double opt_general_message_size(OPT_ARGS_NUM) return CTX::instance()->msgSize; } +double opt_general_message_fontsize(OPT_ARGS_NUM) +{ + if(action & GMSH_SET){ + CTX::instance()->msgFontSize = (int)val; +#if defined(HAVE_FLTK) + if(FlGui::available() && (action & GMSH_GUI)){ + FlGui::instance()->graph[0]->setMessageFontSize(CTX::instance()->msgFontSize); + } +#endif + } + return CTX::instance()->msgFontSize; +} + double opt_general_detached_menu(OPT_ARGS_NUM) { if(action & GMSH_SET){ @@ -4784,6 +4797,13 @@ double opt_mesh_tolerance_edge_length(OPT_ARGS_NUM) return CTX::instance()->mesh.toleranceEdgeLength; } +double opt_mesh_tolerance_initial_delaunay(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->mesh.toleranceInitialDelaunay = val; + return CTX::instance()->mesh.toleranceInitialDelaunay; +} + double opt_mesh_lc_from_curvature(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index b2a800df07..d6c51a09b0 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -133,6 +133,7 @@ double opt_general_polygon_offset_factor(OPT_ARGS_NUM); double opt_general_polygon_offset_units(OPT_ARGS_NUM); double opt_general_system_menu_bar(OPT_ARGS_NUM); double opt_general_message_size(OPT_ARGS_NUM); +double opt_general_message_fontsize(OPT_ARGS_NUM); double opt_general_detached_menu(OPT_ARGS_NUM); double opt_general_menu_size0(OPT_ARGS_NUM); double opt_general_menu_size1(OPT_ARGS_NUM); @@ -384,6 +385,7 @@ double opt_mesh_scaling_factor(OPT_ARGS_NUM); double opt_mesh_lc_min(OPT_ARGS_NUM); double opt_mesh_lc_max(OPT_ARGS_NUM); double opt_mesh_tolerance_edge_length(OPT_ARGS_NUM); +double opt_mesh_tolerance_initial_delaunay(OPT_ARGS_NUM); double opt_mesh_lc_factor(OPT_ARGS_NUM); double opt_mesh_lc_from_curvature(OPT_ARGS_NUM); double opt_mesh_lc_from_points(OPT_ARGS_NUM); diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index 8b9951d099..ec91132d24 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -2728,6 +2728,20 @@ static void message_menu_save_cb(Fl_Widget *w, void *data) g->saveMessages(fileChooserGetName(1).c_str()); } +#if 0 +static void message_menu_increase_font_cb(Fl_Widget *w, void *data) +{ + graphicWindow *g = (graphicWindow*)data; + g->changeMessageFontSize(1); +} + +static void message_menu_decrease_font_cb(Fl_Widget *w, void *data) +{ + graphicWindow *g = (graphicWindow*)data; + g->changeMessageFontSize(-1); +} +#endif + static void message_browser_cb(Fl_Widget *w, void *data) { graphicWindow *g = (graphicWindow*)data; @@ -2738,6 +2752,8 @@ static void message_browser_cb(Fl_Widget *w, void *data) message_menu_scroll_cb, g }, { "Clear Messages", 0, message_menu_clear_cb, g }, { "Save Messages...", 0, message_menu_save_cb, g }, + //{ "Increase font size", 0, message_menu_increase_font_cb, g }, + //{ "Decrease font size", 0, message_menu_decrease_font_cb, g }, { 0 } }; const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0); @@ -2996,7 +3012,12 @@ graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu) _browser = new Fl_Browser(twidth, mh + glheight, glwidth, mheight); _browser->box(GMSH_SIMPLE_TOP_BOX); _browser->textfont(FL_SCREEN); - _browser->textsize(FL_NORMAL_SIZE - 2); + int s = CTX::instance()->msgFontSize; +#if defined(WIN32) // screen font on Windows is really small + _browser->textsize(s <= 0 ? FL_NORMAL_SIZE - 1 : s); +#else + _browser->textsize(s <= 0 ? FL_NORMAL_SIZE - 2 : s); +#endif _browser->type(FL_MULTI_BROWSER); _browser->callback(message_browser_cb, this); _browser->scrollbar_size(std::max(10, FL_NORMAL_SIZE - 2)); // thinner scrollbars @@ -3251,7 +3272,7 @@ void graphicWindow::setStereo(bool st) gl[i]->mode(FL_RGB | FL_DEPTH | FL_DOUBLE | FL_STEREO); } else{ - gl[i]->mode(FL_RGB | FL_DEPTH | FL_DOUBLE ); + gl[i]->mode(FL_RGB | FL_DEPTH | FL_DOUBLE); } gl[i]->show(); } @@ -3452,6 +3473,23 @@ void graphicWindow::copySelectedMessagesToClipboard() Fl::copy(buff.c_str(), buff.size(), 1); } +void graphicWindow::setMessageFontSize(int size) +{ + if(!_browser) return; +#if defined(WIN32) // screen font on Windows is really small + _browser->textsize(size <= 0 ? FL_NORMAL_SIZE - 1 : size); +#else + _browser->textsize(size <= 0 ? FL_NORMAL_SIZE - 2 : size); +#endif + _browser->redraw(); +} + +void graphicWindow::changeMessageFontSize(int incr) +{ + if(!_browser) return; + setMessageFontSize(_browser->textsize() + incr); +} + void graphicWindow::fillRecentHistoryMenu() { #if defined(__APPLE__) diff --git a/Fltk/graphicWindow.h b/Fltk/graphicWindow.h index c8d5446051..b3cd3e94bc 100644 --- a/Fltk/graphicWindow.h +++ b/Fltk/graphicWindow.h @@ -81,6 +81,8 @@ class graphicWindow{ void clearMessages(); void saveMessages(const char *filename); void copySelectedMessagesToClipboard(); + void setMessageFontSize(int size); + void changeMessageFontSize(int incr); void fillRecentHistoryMenu(); }; diff --git a/Mesh/meshGRegion.cpp b/Mesh/meshGRegion.cpp index 68990517ea..647f464037 100644 --- a/Mesh/meshGRegion.cpp +++ b/Mesh/meshGRegion.cpp @@ -1153,9 +1153,9 @@ bool CreateAnEmptyVolumeMesh(GRegion *gr) char opts[128]; buildTetgenStructure(gr, in, numberedV, sqr); printf("tetgen structure created\n"); - sprintf(opts, "-Ype%c", - (Msg::GetVerbosity() < 3) ? 'Q': - (Msg::GetVerbosity() > 6) ? 'V': '\0'); + sprintf(opts, "-Ype%sT%g", + (Msg::GetVerbosity() < 3) ? "Q" : (Msg::GetVerbosity() > 6) ? "V" : "", + CTX::instance()->mesh.toleranceInitialDelaunay); try{ tetrahedralize(opts, &in, &out); } @@ -1214,29 +1214,10 @@ void MeshDelaunayVolumeTetgen(std::vector<GRegion*> ®ions) std::vector<MVertex*> numberedV; char opts[128]; buildTetgenStructure(gr, in, numberedV, sqr); - if(CTX::instance()->mesh.algo3d == ALGO_3D_FRONTAL_DEL || - CTX::instance()->mesh.algo3d == ALGO_3D_FRONTAL_HEX || - CTX::instance()->mesh.algo3d == ALGO_3D_MMG3D || - CTX::instance()->mesh.algo2d == ALGO_2D_FRONTAL_QUAD || - CTX::instance()->mesh.algo2d == ALGO_2D_BAMG){ - sprintf(opts, "Ype%c", (Msg::GetVerbosity() < 3) ? 'Q': - (Msg::GetVerbosity() > 6) ? 'V': '\0'); - // removed -q because mesh sizes at new vertices are wrong - // sprintf(opts, "-q1.5pY%c", (Msg::GetVerbosity() < 3) ? 'Q': - // (Msg::GetVerbosity() > 6) ? 'V': '\0'); - } - else if (CTX::instance()->mesh.algo3d == ALGO_3D_RTREE){ - sprintf(opts, "S0Ype%c", (Msg::GetVerbosity() < 3) ? 'Q': - (Msg::GetVerbosity() > 6) ? 'V': '\0'); - } - else { - sprintf(opts, "Ype%c", - (Msg::GetVerbosity() < 3) ? 'Q': - (Msg::GetVerbosity() > 6) ? 'V': '\0'); - // removed -q because mesh sizes at new vertices are wrong - // sprintf(opts, "-q3.5Ype%c", (Msg::GetVerbosity() < 3) ? 'Q': - // (Msg::GetVerbosity() > 6) ? 'V': '\0');*/ - } + sprintf(opts, "%sYpe%sT%g", + CTX::instance()->mesh.algo3d == ALGO_3D_RTREE ? "S0" : "", + (Msg::GetVerbosity() < 3) ? "Q" : (Msg::GetVerbosity() > 6) ? "V" : "", + CTX::instance()->mesh.toleranceInitialDelaunay); try{ tetrahedralize(opts, &in, &out); } -- GitLab