Skip to content

Commit

Permalink
[Sketcher] Fix endpoint-to-endpoint/edge tangency substitution
Browse files Browse the repository at this point in the history
Only substitute if the point(s) involved are `start`/`end`. Centers do
not make sense here.
  • Loading branch information
AjinkyaDahale committed Aug 19, 2024
1 parent 20549ca commit dcaebbf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
22 changes: 17 additions & 5 deletions src/Mod/Sketcher/Gui/CommandConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
|| PosId1 == 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.
Expand Down Expand Up @@ -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::PointPos::end)
|| !(PosId2 == Sketcher::PointPos::start
|| PosId2 == Sketcher::PointPos::end)) {
continue;
}
if ((*it)->FirstPos == Sketcher::PointPos::none
&& (*it)->SecondPos == Sketcher::PointPos::none) {

Expand Down Expand Up @@ -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;
Expand All @@ -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"));
Expand Down
11 changes: 7 additions & 4 deletions src/Mod/Sketcher/Gui/DrawSketchHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
int preSelPnt = getPreselectPoint();
int preSelCrv = getPreselectCurve();
int preSelCrs = getPreselectCross();
int GeoId = GeoEnum::GeoUndef;

int GeoId = GeoEnum::GeoUndef;
PointPos PosId = PointPos::none;

if (preSelPnt != -1) {
Expand All @@ -459,15 +459,18 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
}
}
}
else if (preSelCrs == 0) { // root point
else if (preSelCrs == 0) {
// root point
GeoId = Sketcher::GeoEnum::RtPnt;
PosId = PointPos::start;
}
else if (preSelCrs == 1) { // x axis
else if (preSelCrs == 1) {
// x axis
GeoId = Sketcher::GeoEnum::HAxis;
hitShapeDir = Base::Vector3d(1, 0, 0);
}
else if (preSelCrs == 2) { // y axis
else if (preSelCrs == 2) {
// y axis
GeoId = Sketcher::GeoEnum::VAxis;
hitShapeDir = Base::Vector3d(0, 1, 0);
}
Expand Down

0 comments on commit dcaebbf

Please sign in to comment.