]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Small update in ConstraintManager to avoid too many events
authorazv <azv@opencascade.com>
Thu, 22 May 2014 11:17:37 +0000 (15:17 +0400)
committerazv <azv@opencascade.com>
Thu, 22 May 2014 11:17:37 +0000 (15:17 +0400)
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/SketchSolver/SketchSolver_ConstraintManager.h

index a543a181f433a03208d2c82d4b9efde9088c561b..dba0d550c36942d1b7a8bb3e304db6a255347016 100644 (file)
@@ -81,7 +81,8 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
     const Model_FeatureUpdatedMessage* anUpdateMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
     std::set< boost::shared_ptr<ModelAPI_Feature> > 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<ModelAPI_Feature> >::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<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWork
   return boost::shared_ptr<SketchPlugin_Feature>();
 }
 
-void SketchSolver_ConstraintManager::resolveConstraints()
+void SketchSolver_ConstraintManager::resolveConstraints(const bool needEvent)
 {
   std::vector<SketchSolver_ConstraintGroup*>::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));
 }
 
 
index 9cbb23bab85a60b03f8b6758f3e2e070ca1d06a1..b833f54dc29fa701ff6e3e4046fa2ad320c92cd1 100644 (file)
@@ -84,8 +84,9 @@ protected:
   void updateEntity(boost::shared_ptr<SketchPlugin_Feature> 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;