From 9edea749d7ce1d515abf658d71cc731a619047d6 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Mon, 19 Aug 2024 06:54:34 +0530 Subject: [PATCH] [Sketcher] Fix endpoint-to-endpoint/edge tangency substitution Only substitute if the point(s) involved are `start`/`end`. Centers do not make sense here. --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 8911caec31ac8..186d1fdf00791 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -3777,7 +3777,9 @@ bool CmdSketcherConstrainCoincidentUnified::substituteConstraintCombinationsPoin if ((*it)->Type == Sketcher::Tangent && (*it)->FirstPos == Sketcher::PointPos::none && (*it)->SecondPos == Sketcher::PointPos::none && (*it)->Third == GeoEnum::GeoUndef && (((*it)->First == GeoId1 && (*it)->Second == GeoId2) - || ((*it)->Second == GeoId1 && (*it)->First == GeoId2))) { + || ((*it)->Second == GeoId1 && (*it)->First == GeoId2)) + && (PosId1 == Sketcher::PointPos::start + || PosId2 == Sketcher::PointPos::end)) { // NOTE: This function does not either open or commit a command as it is used for group // addition it relies on such infrastructure being provided by the caller. @@ -3813,6 +3815,12 @@ bool CmdSketcherConstrainCoincidentUnified::substituteConstraintCombinationsCoin if ((*it)->Type == Sketcher::Tangent && (*it)->Third == GeoEnum::GeoUndef && (((*it)->First == GeoId1 && (*it)->Second == GeoId2) || ((*it)->Second == GeoId1 && (*it)->First == GeoId2))) { + if (!(PosId1 == Sketcher::PointPos::start + || PosId1 == Sketcher::PointPose::end) + || !(PosId2 == Sketcher::PointPos::start + || PosId2 == Sketcher::PointPose::end)) { + continue; + } if ((*it)->FirstPos == Sketcher::PointPos::none && (*it)->SecondPos == Sketcher::PointPos::none) { @@ -6569,8 +6577,11 @@ bool CmdSketcherConstrainTangent::substituteConstraintCombinations(SketchObject* ++it, ++cid) { if ((*it)->Type == Sketcher::Coincident && (((*it)->First == GeoId1 && (*it)->Second == GeoId2) - || ((*it)->Second == GeoId1 && (*it)->First == GeoId2))) { - + || ((*it)->Second == GeoId1 && (*it)->First == GeoId2)) + && ((*it)->FirstPos == Sketcher::PointPos::start + || (*it)->FirstPos == Sketcher::PointPos::end) + && ((*it)->SecondPos == Sketcher::PointPos::start + || (*it)->SecondPos == Sketcher::PointPos::end)) { // save values because 'doEndpointTangency' changes the // constraint property and thus invalidates this iterator int first = (*it)->First; @@ -6596,8 +6607,9 @@ bool CmdSketcherConstrainTangent::substituteConstraintCombinations(SketchObject* } else if ((*it)->Type == Sketcher::PointOnObject && (((*it)->First == GeoId1 && (*it)->Second == GeoId2) - || ((*it)->Second == GeoId1 && (*it)->First == GeoId2))) { - + || ((*it)->Second == GeoId1 && (*it)->First == GeoId2)) + && ((*it)->FirstPos == Sketcher::PointPos::start + || (*it)->FirstPos == Sketcher::PointPos::end)) { Gui::Command::openCommand( QT_TRANSLATE_NOOP("Command", "Swap point on object and tangency with point to curve tangency"));