From b3b72ea4864f94001e37d8ca53a59c4c518c5bc7 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 22 May 2014 15:17:37 +0400 Subject: [PATCH] Small update in ConstraintManager to avoid too many events --- src/SketchSolver/SketchSolver_ConstraintManager.cpp | 10 ++++++---- src/SketchSolver/SketchSolver_ConstraintManager.h | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index a543a181f..dba0d550c 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -81,7 +81,8 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa const Model_FeatureUpdatedMessage* anUpdateMsg = dynamic_cast(theMessage); std::set< boost::shared_ptr > aFeatures = anUpdateMsg->features(); - if (!(theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURES_MOVED))) + bool isModifiedEvt = theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURES_MOVED); + if (!isModifiedEvt) { std::set< boost::shared_ptr >::iterator aFeatIter; for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) @@ -111,7 +112,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa } // Solve the set of constraints - resolveConstraints(); + resolveConstraints(isModifiedEvt); } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) { @@ -277,14 +278,15 @@ boost::shared_ptr SketchSolver_ConstraintManager::findWork return boost::shared_ptr(); } -void SketchSolver_ConstraintManager::resolveConstraints() +void SketchSolver_ConstraintManager::resolveConstraints(const bool needEvent) { std::vector::iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) (*aGroupIter)->resolveConstraints(); // Features may be updated => send events - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + if (needEvent) + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); } diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.h b/src/SketchSolver/SketchSolver_ConstraintManager.h index 9cbb23bab..b833f54dc 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.h +++ b/src/SketchSolver/SketchSolver_ConstraintManager.h @@ -84,8 +84,9 @@ protected: void updateEntity(boost::shared_ptr theFeature); /** \brief Goes through the list of groups and solve the constraints + * \param[in] needEvent shows that some features are probably updated and Update event should be thrown */ - void resolveConstraints(); + void resolveConstraints(const bool needEvent); private: class SketchSolver_ConstraintGroup; -- 2.39.2