From a63ed712f60dc9c6def4966b497364403fdcb6cb Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 14 Mar 2024 12:45:19 -0400 Subject: [PATCH] [TD]fix thread line alignment --- src/Mod/TechDraw/App/Cosmetic.cpp | 2 ++ src/Mod/TechDraw/App/CosmeticVertex.cpp | 2 +- src/Mod/TechDraw/Gui/CommandExtensionPack.cpp | 10 +++------- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index 5b65996ff1..070999655a 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -173,6 +173,8 @@ void CosmeticEdge::initialize() m_geometry->setCosmeticTag(getTagAsString()); } +// TODO: not sure that this method should be doing the inversion. CV for example +// accepts input point as is. The caller should have figured out the correct points. TopoDS_Edge CosmeticEdge::TopoDS_EdgeFromVectors(const Base::Vector3d& pt1, const Base::Vector3d& pt2) { // Base::Console().Message("CE::CE(p1, p2)\n"); diff --git a/src/Mod/TechDraw/App/CosmeticVertex.cpp b/src/Mod/TechDraw/App/CosmeticVertex.cpp index c4cb055101..225c504b66 100644 --- a/src/Mod/TechDraw/App/CosmeticVertex.cpp +++ b/src/Mod/TechDraw/App/CosmeticVertex.cpp @@ -195,7 +195,7 @@ Base::Vector3d CosmeticVertex::rotatedAndScaled(const double scale, const double //! converts a point into its unscaled, unrotated form. If point is Gui space coordinates, //! it should be inverted (DU::invertY) before calling this method, and the result should be -//! inverted on return. +//! inverted back on return. Base::Vector3d CosmeticVertex::makeCanonicalPoint(DrawViewPart* dvp, Base::Vector3d point, bool unscale) { // Base::Console().Message("CV::makeCanonicalPoint(%s)\n", DU::formatVector(point).c_str()); diff --git a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp index 346e8cb226..c09c3221d5 100644 --- a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp +++ b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp @@ -2122,8 +2122,8 @@ void _createThreadLines(std::vector SubNames, TechDraw::DrawViewPar TechDraw::GenericPtr line0 = std::static_pointer_cast(geom0); TechDraw::GenericPtr line1 = std::static_pointer_cast(geom1); - // start and end points are scaled and rotated. invert the points - // so the canonicalPoint math works correctly. + // start and end points are scaled,rotated and inverted (CSRIx). We need to + // uninvert the points so the canonicalPoint math works correctly. Base::Vector3d start0 = DU::invertY(line0->getStartPoint()); Base::Vector3d end0 = DU::invertY(line0->getEndPoint()); Base::Vector3d start1 = DU::invertY(line1->getStartPoint()); @@ -2133,11 +2133,6 @@ void _createThreadLines(std::vector SubNames, TechDraw::DrawViewPar start1 = CosmeticVertex::makeCanonicalPoint(objFeat, start1); end0 = CosmeticVertex::makeCanonicalPoint(objFeat, end0); end1 = CosmeticVertex::makeCanonicalPoint(objFeat, end1); - // put the points back into weird Qt coord system. - start0 = DU::invertY(start0); - start1 = DU::invertY(start1); - end0 = DU::invertY(end0); - end1 = DU::invertY(end1); if (DrawUtil::circulation(start0, end0, start1) != DrawUtil::circulation(end0, end1, start1)) { Base::Vector3d help1 = start1; @@ -2148,6 +2143,7 @@ void _createThreadLines(std::vector SubNames, TechDraw::DrawViewPar float kernelDiam = (start1 - start0).Length(); float kernelFactor = (kernelDiam * factor - kernelDiam) / 2; Base::Vector3d delta = (start1 - start0).Normalize() * kernelFactor; + // addCosmeticEdge(pt1, pt2) inverts the points before creating the edge std::string line0Tag = objFeat->addCosmeticEdge(start0 - delta, end0 - delta); std::string line1Tag =