From cb68fa4fb801495c6a86ff3520403a6485eea0e9 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Fri, 18 Dec 2020 15:28:49 +0100 Subject: [PATCH] Sketcher: rewrite SketchObject getGeometryWithDependentParameters to use SolverGeometryExtension --- src/Mod/Sketcher/App/SketchObject.cpp | 78 +++++++++++++-------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index ed1fa11b4c..5ad7d19137 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -79,10 +79,12 @@ #include #include -#include "SketchObject.h" -#include "Sketch.h" +#include #include #include +#include + +#include "SketchObject.h" #undef DEBUG @@ -7008,55 +7010,47 @@ void SketchObject::getGeometryWithDependentParameters(std::vectorgetTypeId() == Part::GeomPoint::getClassTypeId()) { - addelement(geoid, Sketcher::start); - } - else if(geo->getTypeId() == Part::GeomLineSegment::getClassTypeId() || - geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if(geo) { + if(geo->hasExtension(Sketcher::SolverGeometryExtension::getClassTypeId())) { - addelement(geoid, Sketcher::start); - addelement(geoid, Sketcher::end); - addelement(geoid, Sketcher::none); - } - else if(geo->getTypeId() == Part::GeomCircle::getClassTypeId() || - geo->getTypeId() == Part::GeomEllipse::getClassTypeId() ) { + auto solvext = std::static_pointer_cast( + geo->getExtension(Sketcher::SolverGeometryExtension::getClassTypeId()).lock()); - addelement(geoid, Sketcher::mid); - addelement(geoid, Sketcher::none); - } - else if(geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() || - geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() || - geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() || - geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() ) { - - addelement(geoid, Sketcher::start); - addelement(geoid, Sketcher::end); - addelement(geoid, Sketcher::mid); - addelement(geoid, Sketcher::none); + if (solvext->getGeometry() == Sketcher::SolverGeometryExtension::NotFullyConstraint) { + // The solver differentiates whether the parameters that are dependent are not those + // of start, end, mid, and assigns them to the edge (edge params = curve params - parms of start, end, mid). + // The user looking at the UI expects that the edge of a NotFullyConstraint geometry + // will always move, even if the edge parameters are independent, for example if mid is + // the only dependent parameter. In other words, the user could reasonably restrict the edge + // to reach a fully constrained element. Under this understanding, the edge parameter would + // always be dependent, unless the element is fully constrained. + // + // While this is ok from a user visual expectation point of view, it leads to a loss of information + // of whether restricting the point start, end, mid that is dependent may suffice, or even if such + // points are restricted, the edge would still need to be restricted. + // + // Because Python gets the information in this function, it would lead to Python users having access + // to a lower amount of detail. + // + // For this reason, this function returns edge as dependent parameter if and only if constraining the + // parameters of the points would not suffice to constraint the element. + if (solvext->getEdge() == SolverGeometryExtension::Dependent) + geometrymap.emplace_back(geoid,Sketcher::none); + if (solvext->getStart() == SolverGeometryExtension::Dependent) + geometrymap.emplace_back(geoid,Sketcher::start); + if (solvext->getEnd() == SolverGeometryExtension::Dependent) + geometrymap.emplace_back(geoid,Sketcher::start); + if (solvext->getMid() == SolverGeometryExtension::Dependent) + geometrymap.emplace_back(geoid,Sketcher::start); + } + } } geoid++; } - - if(curQRAlg == GCS::EigenSparseQR) { - getSolvedSketch().setQRAlgorithm(GCS::EigenSparseQR); - } } bool SketchObject::evaluateConstraint(const Constraint *constraint) const