When moving an angle, we did not take into account the case where they are reversed. This fixes that.

This commit is contained in:
Paddle
2023-11-24 09:08:05 +01:00
parent b239797b3e
commit 05c382f6d9
3 changed files with 18 additions and 2 deletions

View File

@@ -664,7 +664,12 @@ void SketchObject::reverseAngleConstraintToSupplementary(Constraint* constr, int
{
std::swap(constr->First, constr->Second);
std::swap(constr->FirstPos, constr->SecondPos);
constr->FirstPos = (constr->FirstPos == Sketcher::PointPos::start) ? Sketcher::PointPos::end : Sketcher::PointPos::start;
if (constr->FirstPos == constr->SecondPos) {
constr->FirstPos = (constr->FirstPos == Sketcher::PointPos::start) ? Sketcher::PointPos::end : Sketcher::PointPos::start;
}
else {
constr->SecondPos = (constr->SecondPos == Sketcher::PointPos::start) ? Sketcher::PointPos::end : Sketcher::PointPos::start;
}
// Edit the expression if any, else modify constraint value directly
if (constraintHasExpression(constNum)) {
@@ -677,6 +682,12 @@ void SketchObject::reverseAngleConstraintToSupplementary(Constraint* constr, int
}
}
void SketchObject::inverseAngleConstraint(Constraint* constr)
{
constr->FirstPos = (constr->FirstPos == Sketcher::PointPos::start) ? Sketcher::PointPos::end : Sketcher::PointPos::start;
constr->SecondPos = (constr->SecondPos == Sketcher::PointPos::start) ? Sketcher::PointPos::end : Sketcher::PointPos::start;
}
bool SketchObject::constraintHasExpression(int constNum) const
{
App::ObjectIdentifier path = Constraints.createPath(constNum);

View File

@@ -271,6 +271,7 @@ public:
/// Change an angle constraint to its supplementary angle.
void reverseAngleConstraintToSupplementary(Constraint* constr, int constNum);
void inverseAngleConstraint(Constraint* constr);
/// Modify an angle constraint expression string to its supplementary angle
static std::string reverseAngleConstraintExpression(std::string expression);

View File

@@ -1918,8 +1918,12 @@ void ViewProviderSketch::moveAngleConstraint(int constNum, const Base::Vector2d&
sign2 = isLeftOfLine(p21, p22, ap3);
}
bool inverse = !(sign1 == sign3 && sign2 == sign4);
if (inverse) {
obj->inverseAngleConstraint(constr);
}
p0 = Base::Vector3d(intersection.x, intersection.y, 0.);
factor *= (sign1 == sign3 && sign2 == sign4) ? 1. : -1.;
}
else {// angle-via-point
Base::Vector3d p = getSolvedSketch().getPoint(constr->Third, constr->ThirdPos);