diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index d0d046b54..bfcbb6199 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -89,6 +89,8 @@ SketchObject::SketchObject() lastSolverStatus=0; lastSolveTime=0; + solverNeedsUpdate=false; + noRecomputes=false; } @@ -127,7 +129,9 @@ App::DocumentObjectExecReturn *SketchObject::execute(void) lastHasConflict = solvedSketch.hasConflicts(); lastHasRedundancies = solvedSketch.hasRedundancies(); lastConflicting=solvedSketch.getConflicting(); - lastRedundant=solvedSketch.getRedundant(); + lastRedundant=solvedSketch.getRedundant(); + + solverNeedsUpdate=false; if (lastDoF < 0) { // over-constrained sketch std::string msg="Over-constrained sketch\n"; @@ -195,6 +199,8 @@ int SketchObject::solve() lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(), getExternalGeometryCount()); + solverNeedsUpdate=false; + lastHasConflict = solvedSketch.hasConflicts(); int err=0; @@ -362,14 +368,16 @@ int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toP // of SketchObject upon moving. => use updateGeometry parameter = true then - if(updateGeometry) { + if(updateGeometry || solverNeedsUpdate) { lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(), getExternalGeometryCount()); lastHasConflict = solvedSketch.hasConflicts(); lastHasRedundancies = solvedSketch.hasRedundancies(); lastConflicting=solvedSketch.getConflicting(); - lastRedundant=solvedSketch.getRedundant(); + lastRedundant=solvedSketch.getRedundant(); + + solverNeedsUpdate=false; } if (lastDoF < 0) // over-constrained sketch @@ -583,6 +591,7 @@ int SketchObject::toggleConstruction(int GeoId) this->Geometry.setValues(newVals); //this->Constraints.acceptGeometry(getCompleteGeometry()); <= This is not necessary for a toggle. Reducing redundant solving. Abdullah + solverNeedsUpdate=true; return 0; } @@ -600,6 +609,7 @@ int SketchObject::setConstruction(int GeoId, bool on) this->Geometry.setValues(newVals); //this->Constraints.acceptGeometry(getCompleteGeometry()); <= This is not necessary for a toggle. Reducing redundant solving. Abdullah + solverNeedsUpdate=true; return 0; } diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index d599646cf..f58f15105 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -51,7 +51,7 @@ public: App ::PropertyLinkSubList ExternalGeometry; /** @name methods overide Feature */ //@{ - /// recalculate the Feature + /// recalculate the Feature (if no recompute is needed see also solve() and updateSolverGeometry() ) App::DocumentObjectExecReturn *execute(void); /// returns the type name of the ViewProvider @@ -118,7 +118,10 @@ public: /// returns non zero if the sketch contains conflicting constraints int hasConflicts(void); - /// solves the sketch and updates the Geometry + /** solves the sketch and updates the geometry, but not all the dependent features (does not recompute) + When a recompute is necessary, recompute triggers execute() which solves the sketch and updates all dependent features + When a solve only is necessary (e.g. DoF changed), solve() solves the sketch and updates the geometry, but does not trigger any updates + */ int solve(); /// set the datum of a Distance or Angle constraint and solve int setDatum(int ConstrId, double Datum); @@ -233,6 +236,11 @@ private: Sketch solvedSketch; + /** this internal flag indicate that an operation modifying the geometry, but not the DoF of the sketch took place (e.g. toggle construction), + so if next action is a movement of a point (movePoint), the geometry must be updated first. + */ + bool solverNeedsUpdate; + int lastDoF; bool lastHasConflict; bool lastHasRedundancies;