From f33aab5f5e0e8767d7710b316ec3bc7c9bdc170a Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 6 Dec 2020 17:19:09 +0100 Subject: [PATCH] Sketcher: Reduce ViewProviderUpdates when deleting Internal Alignment Geometry ============================================================================== Deletion of a geometry having internal alignment geometry (B-Spline, Ellipse, ...) involves calling a geometry deletion operation for each internal aligment constraint in addition to the one of the geometry. Before this commit, an update call was performed for each of these operations. Now, there is a single update trigger operation after all the geometries are deleted. --- src/Mod/Sketcher/App/SketchObject.cpp | 22 +++++++++++++++------- src/Mod/Sketcher/App/SketchObject.h | 2 ++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 7201e7bb11..4abae2d918 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -146,6 +146,7 @@ SketchObject::SketchObject() internaltransaction=false; managedoperation=false; + deletinginternalgeometry=false; } SketchObject::~SketchObject() @@ -955,6 +956,11 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo) geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId())) { this->deleteUnusedInternalGeometry(GeoId, true); + + Geometry.touch(); + + if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver + solve(); return 0; } } @@ -997,10 +1003,12 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo) this->Constraints.setValues(std::move(newConstraints)); } // Update geometry indices and rebuild vertexindex now via onChanged, so that ViewProvider::UpdateData is triggered. - Geometry.touch(); + if(!deletinginternalgeometry) { + Geometry.touch(); - if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver - solve(); + if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver + solve(); + } return 0; } @@ -4971,6 +4979,8 @@ int SketchObject::exposeInternalGeometry(int GeoId) int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) { + Base::StateLocker lock(deletinginternalgeometry, true); + if (GeoId < 0 || GeoId > getHighestCurveIndex()) return -1; @@ -5225,10 +5235,8 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) } } - // ignore weight constraints - else if (((*itc)->Type!=Sketcher::Weight) && ( (*itc)->Second == (*it) || (*itc)->First == (*it) || (*itc)->Third == (*it)) ) { - (*ita)++; - } + // We do not ignore weight constraints as we did with radius constraints, because the radius magnitude no longer makes sense + // without the B-Spline. } if ( (*ita) < 2 ) { // IA diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 9d0611839e..6fd1577012 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -511,6 +511,8 @@ private: bool internaltransaction; bool managedoperation; // indicates whether changes to properties are the deed of SketchObject or not (for input validation) + + bool deletinginternalgeometry; // sets a lock to deletinginternalgeometryoperation so that no individual triggers are perform on each element. }; typedef App::FeaturePythonT SketchObjectPython;