diff --git a/Common/Context.h b/Common/Context.h index 570e7e6daa2809e6e412ef71fea5bd3b04fa022f..b6c0434c5038b11cadc236fde9873912702e3c8f 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -70,7 +70,7 @@ struct contextGeometryOptions { double tolerance, snap[3], transform[3][3], offset[3]; int occFixDegenerated, occFixSmallEdges, occFixSmallFaces; int occSewFaces, occConnectFaces; - int copyMeshingMethod, exactExtrusion; + int copyMeshingMethod, copyDisplayAttributes, exactExtrusion; int matchGeomAndMesh; int hideCompounds, orientedPhysicals; }; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 749e527c27c868946fe76dfdcbd05ca0358bb605..1a340be2224873c2ec99731d5c64765f98a0430a 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -739,6 +739,8 @@ StringXNumber GeometryOptions_Number[] = { "Enable clipping planes? (Plane[i]=2^i, i=0,...,5)" }, { F|O, "CopyMeshingMethod" , opt_geometry_copy_meshing_method, 0. , "Copy meshing method (unstructured or transfinite) when duplicating geometrical entities?" }, + { F|O, "CopyDisplayAttributes" , opt_geometry_copy_display_attributes, 0. , + "Copy display attributes (visibiliy, color) when duplicating geometrical entities?" }, { F|O, "ExactExtrusion" , opt_geometry_exact_extrusion, 1. , "Use exact extrusion formula in interpolations (set to 0 to allow " diff --git a/Common/Options.cpp b/Common/Options.cpp index f85aa81b6efcb940e4b7cae0f670dc673ac5a577..4a2b7faf6b1e904d446b0c7a77eea27002013175 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -4554,6 +4554,13 @@ double opt_geometry_copy_meshing_method(OPT_ARGS_NUM) return CTX::instance()->geom.copyMeshingMethod; } +double opt_geometry_copy_display_attributes(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->geom.copyDisplayAttributes = (int)val; + return CTX::instance()->geom.copyDisplayAttributes; +} + double opt_geometry_exact_extrusion(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 0dc1d9fbfd2e8d54ec267174d24d1ce191e909a1..e3bb2a8ba32a4b90450596b1472f33714dd5c872 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -363,6 +363,7 @@ double opt_geometry_snap1(OPT_ARGS_NUM); double opt_geometry_snap2(OPT_ARGS_NUM); double opt_geometry_clip(OPT_ARGS_NUM); double opt_geometry_copy_meshing_method(OPT_ARGS_NUM); +double opt_geometry_copy_display_attributes(OPT_ARGS_NUM); double opt_geometry_exact_extrusion(OPT_ARGS_NUM); double opt_geometry_match_geom_and_mesh(OPT_ARGS_NUM); double opt_mesh_label_sampling(OPT_ARGS_NUM); diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp index 053d487718086093c3d8e4ee072c1722c76b1378..2b25b50a6c815734c931150c6b860a1b842c78a0 100644 --- a/Geo/Geo.cpp +++ b/Geo/Geo.cpp @@ -958,6 +958,9 @@ static void CopyVertex(Vertex *v, Vertex *vv) vv->Pos.X = v->Pos.X; vv->Pos.Y = v->Pos.Y; vv->Pos.Z = v->Pos.Z; + if(CTX::instance()->geom.copyDisplayAttributes){ + vv->Visible = v->Visible; + } } static Vertex *DuplicateVertex(Vertex *v) @@ -976,16 +979,20 @@ static int compareAbsCurve(const void *a, const void *b) return abs(q->Num) - abs(w->Num); } -static void CopyCurve(Curve *c, Curve *cc, bool copyMeshingMethod) +static void CopyCurve(Curve *c, Curve *cc) { cc->Typ = c->Typ; - if(copyMeshingMethod){ + if(CTX::instance()->geom.copyMeshingMethod){ cc->Method = c->Method; cc->nbPointsTransfinite = c->nbPointsTransfinite; cc->typeTransfinite = c->typeTransfinite; cc->coeffTransfinite = c->coeffTransfinite; cc->ReverseMesh = c->ReverseMesh; } + if(CTX::instance()->geom.copyDisplayAttributes){ + cc->Visible = c->Visible; + cc->Color = c->Color; + } cc->l = c->l; for(int i = 0; i < 4; i++) for(int j = 0; j < 4; j++) @@ -999,10 +1006,10 @@ static void CopyCurve(Curve *c, Curve *cc, bool copyMeshingMethod) End_Curve(cc); } -static Curve *DuplicateCurve(Curve *c, bool copyMeshingMethod) +static Curve *DuplicateCurve(Curve *c) { Curve *pc = Create_Curve(NEWLINE(), 0, 1, NULL, NULL, -1, -1, 0., 1.); - CopyCurve(c, pc, copyMeshingMethod); + CopyCurve(c, pc); Tree_Insert(GModel::current()->getGEOInternals()->Curves, &pc); for(int i = 0; i < List_Nbr(c->Control_Points); i++) { Vertex *v; @@ -1016,14 +1023,14 @@ static Curve *DuplicateCurve(Curve *c, bool copyMeshingMethod) return pc; } -static void CopySurface(Surface *s, Surface *ss, bool copyMeshingMethod) +static void CopySurface(Surface *s, Surface *ss) { - // Trevor Strickler modified - if(s->Typ == MSH_SURF_COMPOUND) - ss->Typ = MSH_SURF_REGL; - else - ss->Typ = s->Typ; - if(copyMeshingMethod){ + // Trevor Strickler modified + if(s->Typ == MSH_SURF_COMPOUND) + ss->Typ = MSH_SURF_REGL; + else + ss->Typ = s->Typ; + if(CTX::instance()->geom.copyMeshingMethod){ ss->Method = s->Method; ss->Recombine = s->Recombine; ss->RecombineAngle = s->RecombineAngle; @@ -1031,6 +1038,10 @@ static void CopySurface(Surface *s, Surface *ss, bool copyMeshingMethod) if(List_Nbr(s->TrsfPoints)) Msg::Warning("Only automatic transfinite surface specifications can be copied"); } + if(CTX::instance()->geom.copyDisplayAttributes){ + ss->Visible = s->Visible; + ss->Color = s->Color; + } ss->Generatrices = List_Create(List_Nbr(s->Generatrices) + 1, 1, sizeof(Curve *)); ss->GeneratricesByTag = List_Create(List_Nbr(s->GeneratricesByTag) + 1, 1, sizeof(int)); ss->InSphereCenter = s->InSphereCenter; // FIXME: hack... @@ -1039,44 +1050,48 @@ static void CopySurface(Surface *s, Surface *ss, bool copyMeshingMethod) End_Surface(ss); } -static Surface *DuplicateSurface(Surface *s, bool copyMeshingMethod) +static Surface *DuplicateSurface(Surface *s) { Surface *ps = Create_Surface(NEWSURFACE(), 0); - CopySurface(s, ps, copyMeshingMethod); + CopySurface(s, ps); Tree_Insert(GModel::current()->getGEOInternals()->Surfaces, &ps); for(int i = 0; i < List_Nbr(ps->Generatrices); i++) { Curve *c; List_Read(ps->Generatrices, i, &c); - Curve *newc = DuplicateCurve(c, copyMeshingMethod); + Curve *newc = DuplicateCurve(c); List_Write(ps->Generatrices, i, &newc); } return ps; } -static void CopyVolume(Volume *v, Volume *vv, bool copyMeshingMethod) +static void CopyVolume(Volume *v, Volume *vv) { vv->Typ = v->Typ; - if(copyMeshingMethod){ + if(CTX::instance()->geom.copyMeshingMethod){ vv->Method = v->Method; vv->QuadTri = v->QuadTri; vv->Recombine3D = v->Recombine3D; if(List_Nbr(v->TrsfPoints)) Msg::Warning("Only automatic transfinite volume specifications can be copied"); } + if(CTX::instance()->geom.copyDisplayAttributes){ + vv->Visible = v->Visible; + vv->Color = v->Color; + } List_Copy(v->Surfaces, vv->Surfaces); List_Copy(v->SurfacesOrientations, vv->SurfacesOrientations); List_Copy(v->SurfacesByTag, vv->SurfacesByTag); } -static Volume *DuplicateVolume(Volume *v, bool copyMeshingMethod) +static Volume *DuplicateVolume(Volume *v) { Volume *pv = Create_Volume(NEWVOLUME(), 0); - CopyVolume(v, pv, copyMeshingMethod); + CopyVolume(v, pv); Tree_Insert(GModel::current()->getGEOInternals()->Volumes, &pv); for(int i = 0; i < List_Nbr(pv->Surfaces); i++) { Surface *s; List_Read(pv->Surfaces, i, &s); - Surface *news = DuplicateSurface(s, copyMeshingMethod); + Surface *news = DuplicateSurface(s); List_Write(pv->Surfaces, i, &news); } return pv; @@ -1111,7 +1126,7 @@ void CopyShape(int Type, int Num, int *New) Msg::Error("Unknown curve %d", Num); return; } - newc = DuplicateCurve(c, CTX::instance()->geom.copyMeshingMethod); + newc = DuplicateCurve(c); *New = newc->Num; break; case MSH_SURF_TRIC: @@ -1121,7 +1136,7 @@ void CopyShape(int Type, int Num, int *New) Msg::Error("Unknown surface %d", Num); return; } - news = DuplicateSurface(s, CTX::instance()->geom.copyMeshingMethod); + news = DuplicateSurface(s); *New = news->Num; break; case MSH_VOLUME: @@ -1129,7 +1144,7 @@ void CopyShape(int Type, int Num, int *New) Msg::Error("Unknown volume %d", Num); return; } - newvol = DuplicateVolume(vol, CTX::instance()->geom.copyMeshingMethod); + newvol = DuplicateVolume(vol); *New = newvol->Num; break; default: @@ -3011,7 +3026,7 @@ int Extrude_ProtudeCurve(int type, int ic, Msg::Debug("Extrude Curve %d", ic); - chapeau = DuplicateCurve(pc, false); + chapeau = DuplicateCurve(pc); chapeau->Extrude = new ExtrudeParams(COPIED_ENTITY); chapeau->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha); @@ -3190,7 +3205,7 @@ int Extrude_ProtudeSurface(int type, int is, Msg::Debug("Extrude Surface %d", is); - chapeau = DuplicateSurface(ps, false); + chapeau = DuplicateSurface(ps); chapeau->Extrude = new ExtrudeParams(COPIED_ENTITY); chapeau->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha); chapeau->Extrude->geo.Source = is; // not ps->Num: we need the sign info diff --git a/doc/texinfo/commandline.texi b/doc/texinfo/commandline.texi index 99be7c084c61edbe2834f3e03fdcdd4605c78e71..c0be5da8fc35c2cf28ba3b052452d9ad51fee3d8 100644 --- a/doc/texinfo/commandline.texi +++ b/doc/texinfo/commandline.texi @@ -71,7 +71,7 @@ Load background mesh from file @item -check Perform various consistency checks on mesh @item -mpass int -Do several passes on the mesh for complex backround fields +Do several passes on the mesh for complex background fields @item -ignorePartBound Ignore partitions boundaries @end ftable @@ -121,6 +121,8 @@ Print process id on stdout Always listen to incoming connection requests @item -watch pattern Pattern of files to merge as they become available +@item -bg file +Load background (image or PDF) file @item -v int Set verbosity level @item -nopopup diff --git a/doc/texinfo/opt_general.texi b/doc/texinfo/opt_general.texi index 396fbd4717b5ef6796f4eedde5bab727711f6653..ee5d466cc1b93c0e996d5e9085c046d4a10a20de 100644 --- a/doc/texinfo/opt_general.texi +++ b/doc/texinfo/opt_general.texi @@ -254,14 +254,29 @@ Draw background gradient (0=none, 1=vertical, 2=horizontal, 3=radial)@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} +@item General.BackgroundImage3D +Create background image in the 3D model (units = model units) or as 2D background (units = pixels)@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + @item General.BackgroundImagePositionX -X position (in pixels) of background image (< 0: measure from right edge; >= 1e5: centered)@* -Default value: @code{100000}@* +X position of background image (for 2D background: < 0: measure from right edge; >= 1e5: centered)@* +Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item General.BackgroundImagePositionY -Y position (in pixels) of background image (< 0: measure from bottom edge; >= 1e5: centered)@* -Default value: @code{100000}@* +Y position of background image (for 2D background: < 0: measure from bottom edge; >= 1e5: centered)@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + +@item General.BackgroundImageWidth +Width of background image (0: actual width; -1: fullscreen)@* +Default value: @code{-1}@* +Saved in: @code{General.OptionsFileName} + +@item General.BackgroundImageHeight +Height of background image (0: actual width; -1: fullscreen)@* +Default value: @code{-1}@* Saved in: @code{General.OptionsFileName} @item General.Camera diff --git a/doc/texinfo/opt_geometry.texi b/doc/texinfo/opt_geometry.texi index 8d8eb3b344b7e11453a79b2255d0ad90d3841474..195f61c776a26454318dd3b2da929a3ecf751864 100644 --- a/doc/texinfo/opt_geometry.texi +++ b/doc/texinfo/opt_geometry.texi @@ -19,6 +19,11 @@ Copy meshing method (unstructured or transfinite) when duplicating geometrical e Default value: @code{0}@* Saved in: @code{General.OptionsFileName} +@item Geometry.CopyDisplayAttributes +Copy display attributes (visibiliy, color) when duplicating geometrical entities?@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + @item Geometry.ExactExtrusion Use exact extrusion formula in interpolations (set to 0 to allow geometrical transformations of extruded entities)@* Default value: @code{1}@*