From 4fb4dfbb7642a3998b71d7845c1b51eaa1e68b36 Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 5 Apr 2017 10:58:58 +0300 Subject: [PATCH] Issue #2082: Sketch multiple rotation does not work as expected Avoid blocking features in PlaneGCSSolver for a long time. --- src/SketchPlugin/SketchPlugin_Trim.cpp | 3 +-- src/SketchSolver/SketchSolver_Manager.cpp | 9 ++++++++- src/SketchSolver/SketchSolver_Manager.h | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Trim.cpp b/src/SketchPlugin/SketchPlugin_Trim.cpp index 538f1b937..f2d2c4da8 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.cpp +++ b/src/SketchPlugin/SketchPlugin_Trim.cpp @@ -1045,7 +1045,6 @@ FeaturePtr SketchPlugin_Trim::trimArc(const std::shared_ptr& theS (aBaseFeature->attribute(aModifiedAttribute))); // equal Radius constraint for arcs - anNewFeature->execute(); // we need the created arc result to set equal constraint createConstraintForObjects(SketchPlugin_ConstraintEqual::ID(), getFeatureResult(aBaseFeature), getFeatureResult(anNewFeature)); @@ -1279,7 +1278,7 @@ FeaturePtr SketchPlugin_Trim::createArcFeature(const FeaturePtr& theBaseFeature, bool aReversed = theBaseFeature->boolean(SketchPlugin_Arc::REVERSED_ID())->value(); aFeature->boolean(SketchPlugin_Arc::REVERSED_ID())->setValue(aReversed); } - //aFeature->execute(); // to obtain result + aFeature->execute(); // to obtain result (need to calculate arc parameters before sending Update) aFeature->data()->blockSendAttributeUpdated(aWasBlocked); #ifdef DEBUG_TRIM diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index ec2f8d77b..849c95b0c 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -151,6 +151,7 @@ void SketchSolver_Manager::processEvent( // resolve constraints if needed bool needToUpdate = needToResolve && resolveConstraints(); + releaseFeaturesIfEventsBlocked(); // Features may be updated => now send events, but for all changed at once if (isUpdateFlushed) @@ -238,11 +239,17 @@ bool SketchSolver_Manager::resolveConstraints() for (; aGroupIter != myGroups.end(); ++aGroupIter) { if ((*aGroupIter)->resolveConstraints()) needToUpdate = true; - (*aGroupIter)->blockEvents(false); } return needToUpdate; } +void SketchSolver_Manager::releaseFeaturesIfEventsBlocked() const +{ + std::list::const_iterator aGroupIter = myGroups.begin(); + for (; aGroupIter != myGroups.end(); ++aGroupIter) + (*aGroupIter)->blockEvents(false); +} + bool SketchSolver_Manager::stopSendUpdate() const { static const Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); diff --git a/src/SketchSolver/SketchSolver_Manager.h b/src/SketchSolver/SketchSolver_Manager.h index d69cccbfd..fc1b42229 100644 --- a/src/SketchSolver/SketchSolver_Manager.h +++ b/src/SketchSolver/SketchSolver_Manager.h @@ -77,8 +77,11 @@ private: /// \brief Allow to send the Update event void allowSendUpdate() const; + /// \brief Allow send events about changing features in groups + void releaseFeaturesIfEventsBlocked() const; + private: - std::list myGroups; ///< Groups of constraints + std::list myGroups; ///< Groups of constraints /// true if computation is performed and all "updates" are generated by this algo /// and needs no recomputation bool myIsComputed; -- 2.39.2