From 0346c94b50dfebbbec2422bad95c53b99f455d3a Mon Sep 17 00:00:00 2001 From: Mihail Dumitrescu Date: Wed, 29 May 2024 16:48:30 +0300 Subject: [PATCH] Add ParallelPlane attachment mode. It results in an attachment similar to ObjectXY but with the XY plane translated to pass through a selected vertex. It is most useful to place sketches: pick a plane (XY, XZ, YZ) or another sketch then select a vertex to automatically translate the sketch in the Z-direction. In contrast to the Translate mode it does not change the origin. --- src/Mod/Part/App/Attacher.cpp | 39 +++++++++++++++++++++++++++-- src/Mod/Part/App/Attacher.h | 2 ++ src/Mod/Part/Gui/AttacherTexts.cpp | 6 +++++ tests/src/Mod/Part/App/Attacher.cpp | 5 ++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index cce95345fa..5138333a68 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -31,6 +31,7 @@ # include # include # include +# include # include # include # include @@ -133,6 +134,8 @@ const char* AttachEngine::eMapModeStrings[]= { "OYZ", "OYX", + "ParallelPlane", + nullptr}; //this list must be in sync with eRefType enum. @@ -1041,6 +1044,11 @@ AttachEngine3D::AttachEngine3D() modeRefTypes[mmObjectXZ] = ss; modeRefTypes[mmObjectYZ] = ss; + modeRefTypes[mmParallelPlane].push_back( + cat(eRefType(rtFlatFace | rtFlagHasPlacement), rtVertex)); + modeRefTypes[mmParallelPlane].push_back( + cat(eRefType(rtAnything | rtFlagHasPlacement), rtVertex)); + modeRefTypes[mmInertialCS].push_back(cat(rtAnything)); modeRefTypes[mmInertialCS].push_back(cat(rtAnything,rtAnything)); modeRefTypes[mmInertialCS].push_back(cat(rtAnything,rtAnything,rtAnything)); @@ -1194,7 +1202,8 @@ AttachEngine3D::_calculateAttachedPlacement(const std::vectortranslate("Attacher3D", "Object's Y Z X","Attachment3D mode caption"), qApp->translate("Attacher3D", "X', Y', Z' axes are matched with object's local Y, Z, X, respectively.","Attachment3D mode tooltip")); + case mmParallelPlane: + return TwoStrings(qApp->translate("Attacher3D", "XY parallel to plane","Attachment3D mode caption"), + qApp->translate("Attacher3D", "X' Y' plane is parallel to the plane (object's XY) and passes through the vertex.","Attachment3D mode tooltip")); case mmFlatFace: return TwoStrings(qApp->translate("Attacher3D", "XY on plane","Attachment3D mode caption"), qApp->translate("Attacher3D", "X' Y' plane is aligned to coincide planar face.","Attachment3D mode tooltip")); @@ -138,6 +141,9 @@ TextSet getUIStrings(Base::Type attacherType, eMapMode mmode) case mmObjectYZ: return TwoStrings(qApp->translate("Attacher2D", "Object's YZ","AttachmentPlane mode caption"), qApp->translate("Attacher2D", "Plane is aligned to YZ local plane of linked object.","AttachmentPlane mode tooltip")); + case mmParallelPlane: + return TwoStrings(qApp->translate("Attacher2D", "XY parallel to plane","AttachmentPlane mode caption"), + qApp->translate("Attacher2D", "X' Y' plane is parallel to the plane (object's XY) and passes through the vertex","AttachmentPlane mode tooltip")); case mmFlatFace: return TwoStrings(qApp->translate("Attacher2D", "Plane face","AttachmentPlane mode caption"), qApp->translate("Attacher2D", "Plane is aligned to coincide planar face.","AttachmentPlane mode tooltip")); diff --git a/tests/src/Mod/Part/App/Attacher.cpp b/tests/src/Mod/Part/App/Attacher.cpp index 53ac4819ee..67b25e466b 100644 --- a/tests/src/Mod/Part/App/Attacher.cpp +++ b/tests/src/Mod/Part/App/Attacher.cpp @@ -171,6 +171,8 @@ TEST_F(AttacherTest, TestAllStringModesValid) "OXZ", "OYZ", "OYX", + + "ParallelPlane", }; int index = 0; for (auto mode : modes) { @@ -197,6 +199,9 @@ TEST_F(AttacherTest, TestAllModesBoundaries) _boxes[1]->recomputeFeature(); EXPECT_TRUE(boxesMatch(_boxes[1]->Shape.getBoundingBox(), Base::BoundBox3d(0, 0, 0, 3, 1, 2))); + _boxes[1]->MapMode.setValue(mmParallelPlane); + _boxes[1]->recomputeFeature(); + EXPECT_TRUE(boxesMatch(_boxes[1]->Shape.getBoundingBox(), Base::BoundBox3d(0, 0, 0, 3, 1, 2))); _boxes[1]->MapMode.setValue(mmFlatFace); _boxes[1]->recomputeFeature(); EXPECT_TRUE(boxesMatch(_boxes[1]->Shape.getBoundingBox(), Base::BoundBox3d(0, 0, 0, 3, 1, 2)));