diff --git a/Common/Context.h b/Common/Context.h index e936995a989da9fe23a538acd6825110cf7a530b..af611e008133162faa11e78ccb14ea7eac2c2fdc 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -49,7 +49,7 @@ struct contextMeshOptions { struct contextGeometryOptions { int draw, light, lightTwoSide, points, lines, surfaces, volumes; - int pointsNum, linesNum, surfacesNum, volumesNum; + int pointsNum, linesNum, surfacesNum, volumesNum, labelType; double pointSize, lineWidth, selectedPointSize, selectedLineWidth; int pointType, lineType, surfaceType, numSubEdges; int oldCircle, extrudeSplinePoints, extrudeReturnLateral, oldNewreg; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 0fc99e2585ca1ccea0774e26318cac41e618c2a8..6fc74258405e7cd01da3de9b5db272d046ad0e5b 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -678,6 +678,8 @@ StringXNumber GeometryOptions_Number[] = { { F|O, "HighlightOrphans" , opt_geometry_highlight_orphans, 0. , "Highlight orphan entities (lines connected to a single surface, etc.)?" }, + { F|O, "LabelType" , opt_geometry_label_type , 1. , + "Type of entity label (1=elementary number, 2=physical number)" }, { F|O, "Light" , opt_geometry_light , 1. , "Enable lighting for the geometry" }, { F|O, "LightTwoSide" , opt_geometry_light_two_side , 1. , diff --git a/Common/Options.cpp b/Common/Options.cpp index b0e39e3390b338b54987eb4d8718dda2058dc585..a84b043e336c629c54f32197b5537d38b3ca673a 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -3935,6 +3935,22 @@ double opt_geometry_volumes_num(OPT_ARGS_NUM) return CTX::instance()->geom.volumesNum; } +double opt_geometry_label_type(OPT_ARGS_NUM) +{ + if(action & GMSH_SET){ + CTX::instance()->geom.labelType = (int)val; + if(CTX::instance()->geom.labelType < 1 || CTX::instance()->geom.labelType > 2) + CTX::instance()->geom.labelType = 1; + } +#if defined(HAVE_FLTK) + if(FlGui::available() && (action & GMSH_GUI)){ + FlGui::instance()->options->geo.choice[4]->value + (CTX::instance()->geom.labelType - 1); + } +#endif + return CTX::instance()->geom.labelType; +} + double opt_geometry_point_size(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 620e7cd2d8d8b367e7feb047901e381897fb131b..eec6a8d48988e58922f83bf40c5c2cb66441853e 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -307,6 +307,7 @@ double opt_geometry_points_num(OPT_ARGS_NUM); double opt_geometry_lines_num(OPT_ARGS_NUM); double opt_geometry_surfaces_num(OPT_ARGS_NUM); double opt_geometry_volumes_num(OPT_ARGS_NUM); +double opt_geometry_label_type(OPT_ARGS_NUM); double opt_geometry_point_size(OPT_ARGS_NUM); double opt_geometry_point_sel_size(OPT_ARGS_NUM); double opt_geometry_point_type(OPT_ARGS_NUM); diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index 1b848ec40e61112c071c81f200a001f09baa77b6..c36fdb9ec504128da05481cd1e54b36fc590adf3 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -3381,7 +3381,7 @@ void onelabGroup::_addGmshMenus() _tree->sortorder(FL_TREE_SORT_NONE); // add static geometry and mesh module items - for(int i = 0; i < sizeof(static_modules) / sizeof(static_modules[0]); i++) + for(unsigned int i = 0; i < sizeof(static_modules) / sizeof(static_modules[0]); i++) _addMenu(static_modules[i].label, static_modules[i].callback, static_modules[i].arg); // add dynamic solver module items diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 645f40bf874a1ca42bda1c8485c6b3005307c683..a472a9964afe9da7c5f428650cf9587d9ee8fb18 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -434,6 +434,7 @@ static void geometry_options_ok_cb(Fl_Widget *w, void *data) opt_geometry_line_type(0, GMSH_SET, o->geo.choice[1]->value()); opt_geometry_surface_type(0, GMSH_SET, o->geo.choice[2]->value()); opt_geometry_transform(0, GMSH_SET, o->geo.choice[3]->value()); + opt_geometry_label_type(0, GMSH_SET, o->geo.choice[4]->value() + 1); if(old_hide_compound != (int)opt_geometry_hide_compounds(0, GMSH_GET, 0)){ GModel::current()->setCompoundVisibility(); @@ -1903,27 +1904,38 @@ optionWindow::optionWindow(int deltaFontSize) geo.butt[3]->callback(geometry_options_ok_cb); geo.butt[4] = new Fl_Check_Button - (L + width / 2, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Point numbers"); + (L + width / 2, 2 * WB + 1 * BH, BW / 2 - WB, BH, "Point labels"); geo.butt[4]->type(FL_TOGGLE_BUTTON); geo.butt[4]->callback(geometry_options_ok_cb); geo.butt[5] = new Fl_Check_Button - (L + width / 2, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Line numbers"); + (L + width / 2, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Line labels"); geo.butt[5]->type(FL_TOGGLE_BUTTON); geo.butt[5]->callback(geometry_options_ok_cb); geo.butt[6] = new Fl_Check_Button - (L + width / 2, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surface numbers"); + (L + width / 2, 2 * WB + 3 * BH, BW / 2 - WB, BH, "Surface labels"); geo.butt[6]->type(FL_TOGGLE_BUTTON); geo.butt[6]->callback(geometry_options_ok_cb); geo.butt[7] = new Fl_Check_Button - (L + width / 2, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Volume numbers"); + (L + width / 2, 2 * WB + 4 * BH, BW / 2 - WB, BH, "Volume labels"); geo.butt[7]->type(FL_TOGGLE_BUTTON); geo.butt[7]->callback(geometry_options_ok_cb); + static Fl_Menu_Item menu_label_type[] = { + {"Elementary tags", 0, 0, 0}, + {"Physical tags", 0, 0, 0}, + {0} + }; + geo.choice[4] = new Fl_Choice + (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Label type"); + geo.choice[4]->menu(menu_label_type); + geo.choice[4]->align(FL_ALIGN_RIGHT); + geo.choice[4]->callback(geometry_options_ok_cb); + geo.value[0] = new Fl_Value_Input - (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Normals"); + (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Normals"); geo.value[0]->minimum(0); geo.value[0]->maximum(500); geo.value[0]->step(1); @@ -1932,7 +1944,7 @@ optionWindow::optionWindow(int deltaFontSize) geo.value[0]->callback(geometry_options_ok_cb); geo.value[1] = new Fl_Value_Input - (L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Tangents"); + (L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Tangents"); geo.value[1]->minimum(0); geo.value[1]->maximum(500); geo.value[1]->step(1); @@ -1941,7 +1953,7 @@ optionWindow::optionWindow(int deltaFontSize) geo.value[1]->callback(geometry_options_ok_cb); geo.butt[17] = new Fl_Check_Button - (L + 2 * WB, 2 * WB + 7 * BH, BW, BH, "Hide entities making up coumpounds"); + (L + 2 * WB, 2 * WB + 8 * BH, BW, BH, "Hide entities making up coumpounds"); geo.butt[17]->type(FL_TOGGLE_BUTTON); geo.butt[17]->callback(geometry_options_ok_cb); @@ -2348,8 +2360,8 @@ optionWindow::optionWindow(int deltaFontSize) static Fl_Menu_Item menu_label_type[] = { {"Number", 0, 0, 0}, - {"Elementary entity", 0, 0, 0}, - {"Physical group", 0, 0, 0}, + {"Elementary tag", 0, 0, 0}, + {"Physical tag", 0, 0, 0}, {"Mesh partition", 0, 0, 0}, {"Coordinates", 0, 0, 0}, {0} diff --git a/Graphics/drawGeom.cpp b/Graphics/drawGeom.cpp index 987d9f96f31ce21606b4497256e0d696b3db6341..ac19ee24c462a68a5d69fb7ef95c2497f4b740be 100644 --- a/Graphics/drawGeom.cpp +++ b/Graphics/drawGeom.cpp @@ -13,6 +13,28 @@ #include "GEdgeCompound.h" #include "GFaceCompound.h" +static void drawEntityLabel(drawContext *ctx, GEntity *e, + double x, double y, double z, double offset) +{ + char str[256]; + if(CTX::instance()->geom.labelType == 1){ + sprintf(str, "%d", e->tag()); + } + else{ + strcpy(str, ""); + for(unsigned int i = 0; i < e->physicals.size(); i++){ + char tmp[32]; + if(i) strcat(str, ", "); + sprintf(tmp, "%d", e->physicals[i]); + strcat(str, tmp); + } + } + glRasterPos3d(x + offset / ctx->s[0], + y + offset / ctx->s[1], + z + offset / ctx->s[2]); + ctx->drawString(str); +} + class drawGVertex { private : drawContext *_ctx; @@ -71,14 +93,9 @@ class drawGVertex { } if(CTX::instance()->geom.pointsNum) { - char Num[100]; - sprintf(Num, "%d", v->tag()); double offset = (0.5 * CTX::instance()->geom.pointSize + 0.1 * CTX::instance()->glFontSize) * _ctx->pixel_equiv_x; - glRasterPos3d(x + offset / _ctx->s[0], - y + offset / _ctx->s[1], - z + offset / _ctx->s[2]); - _ctx->drawString(Num); + drawEntityLabel(_ctx, v, x, y, z, offset); } if(select) { @@ -166,16 +183,11 @@ class drawGEdge { if(CTX::instance()->geom.linesNum) { GPoint p = e->point(t_min + 0.5 * (t_max - t_min)); - char Num[100]; - sprintf(Num, "%d", e->tag()); double offset = (0.5 * CTX::instance()->geom.lineWidth + 0.1 * CTX::instance()->glFontSize) * _ctx->pixel_equiv_x; double x = p.x(), y = p.y(), z = p.z(); _ctx->transform(x, y, z); - glRasterPos3d(x + offset / _ctx->s[0], - y + offset / _ctx->s[1], - z + offset / _ctx->s[2]); - _ctx->drawString(Num); + drawEntityLabel(_ctx, e, x, y, z, offset); } if(CTX::instance()->geom.tangents) { @@ -303,15 +315,10 @@ class drawGFace { if(CTX::instance()->geom.surfacesNum) { GPoint p = f->point(uav, vav); - char Num[100]; - sprintf(Num, "%d", f->tag()); double offset = 0.1 * CTX::instance()->glFontSize * _ctx->pixel_equiv_x; double x = p.x(), y = p.y(), z = p.z(); _ctx->transform(x, y, z); - glRasterPos3d(x + offset / _ctx->s[0], - y + offset / _ctx->s[1], - z + offset / _ctx->s[2]); - _ctx->drawString(Num); + drawEntityLabel(_ctx, f, x, y, z, offset); } if(CTX::instance()->geom.normals) { @@ -363,17 +370,12 @@ class drawGFace { if(f->cross.size() < 2) return; if(CTX::instance()->geom.surfacesNum) { - char Num[100]; - sprintf(Num, "%d", f->tag()); double offset = 0.1 * CTX::instance()->glFontSize * _ctx->pixel_equiv_x; double x = 0.5 * (f->cross[0].x() + f->cross[1].x()); double y = 0.5 * (f->cross[0].y() + f->cross[1].y()); double z = 0.5 * (f->cross[0].z() + f->cross[1].z()); _ctx->transform(x, y, z); - glRasterPos3d(x + offset / _ctx->s[0], - y + offset / _ctx->s[0], - z + offset / _ctx->s[0]); - _ctx->drawString(Num); + drawEntityLabel(_ctx, f, x, y, z, offset); } if(CTX::instance()->geom.normals) { @@ -486,14 +488,9 @@ class drawGRegion { _ctx->drawSphere(size, x, y, z, CTX::instance()->geom.light); if(CTX::instance()->geom.volumesNum){ - char Num[100]; - sprintf(Num, "%d", r->tag()); double offset = (0.5 * size + 0.1 * CTX::instance()->glFontSize) * _ctx->pixel_equiv_x; - glRasterPos3d(x + offset / _ctx->s[0], - y + offset / _ctx->s[1], - z + offset / _ctx->s[2]); - _ctx->drawString(Num); + drawEntityLabel(_ctx, r, x, y, z, offset); } if(select) {