From: azv Date: Thu, 22 May 2014 11:17:37 +0000 (+0400) Subject: Small update in ConstraintManager to avoid too many events X-Git-Tag: V_0.2~26^2~1^2^2~6^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b3b72ea4864f94001e37d8ca53a59c4c518c5bc7;p=modules%2Fshaper.git Small update in ConstraintManager to avoid too many events --- 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;