]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Speed up the redraw of sketch with constraints moved by the point of the line
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 8 Dec 2014 16:24:24 +0000 (19:24 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 8 Dec 2014 16:24:24 +0000 (19:24 +0300)
src/Events/Events_Loop.cpp
src/Events/Events_Loop.h
src/Model/Model_Update.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp

index 9447c376b97c6a4f017be8206e8c13f41325fed6..f9b9d004626bb4dbfe9c16cf12266277f9a60793 100644 (file)
@@ -115,14 +115,18 @@ void Events_Loop::flush(const Events_ID& theID)
 {
   if (!myFlushActive)
     return;
-  std::map<char*, std::shared_ptr<Events_Message>>::iterator aMyGroup =
-    myGroups.find(theID.eventText());
-  if (aMyGroup != myGroups.end()) {  // really sends
-    myFlushed.insert(theID.myID);
+  std::map<char*, std::shared_ptr<Events_Message> >::iterator aMyGroup;
+  for(aMyGroup = myGroups.find(theID.eventText());
+    aMyGroup != myGroups.end(); aMyGroup = myGroups.find(theID.eventText()))
+  {  // really sends
+    bool aWasFlushed = myFlushed.find(theID.myID) != myFlushed.end();
+    if (!aWasFlushed)
+      myFlushed.insert(theID.myID);
     std::shared_ptr<Events_Message> aGroup = aMyGroup->second;
     myGroups.erase(aMyGroup);
     send(aGroup, false);
-    myFlushed.erase(myFlushed.find(theID.myID));
+    if (!aWasFlushed)
+      myFlushed.erase(myFlushed.find(theID.myID));
   }
 }
 
@@ -147,3 +151,16 @@ void Events_Loop::autoFlush(const Events_ID& theID, const bool theAuto)
   else
     myFlushed.erase(myFlushed.find(theID.myID));
 }
+
+bool Events_Loop::isFlushed(const Events_ID& theID)
+{
+  return myFlushed.find(theID.myID) != myFlushed.end();
+}
+
+void Events_Loop::setFlushed(const Events_ID& theID, const bool theValue)
+{
+  if (theValue)
+    myFlushed.insert(theID.myID);
+  else
+    myFlushed.erase(myFlushed.find(theID.myID));
+}
index c8b7798c0e06944cdc3348fdbe6e60126a662ee1..317c62d3b9e9dea0b5ef33b4c75684ede9c328ef 100644 (file)
@@ -72,6 +72,11 @@ class Events_Loop
 
   //! Enables flush without grouping for the given message
   EVENTS_EXPORT void autoFlush(const Events_ID& theID, const bool theAuto = true);
+
+  //! Returns true if the evement is flushed right now
+  EVENTS_EXPORT bool isFlushed(const Events_ID& theID);
+  //! Sets the flag that the event is flished right now
+  EVENTS_EXPORT void setFlushed(const Events_ID& theID, const bool theValue);
 };
 
 #endif
index 31c8b7565956247856dac960f303e15b1565f893..3a70e463a2b8a73b74c16cc938fa877ce197f907 100644 (file)
@@ -163,7 +163,7 @@ void Model_Update::updateInDoc(std::shared_ptr<ModelAPI_Document> theDoc)
 
 void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_ExecState theState) 
 {
-  // maske updated and redisplay all results
+  // make updated and redisplay all results
   static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
   std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
index 3ba3fdda466add2db602fe914e8348843d1fa56f..a69eb95bcae4cf6f924d4cb1e7cb545ba45a1a93 100644 (file)
@@ -374,14 +374,24 @@ void SketchSolver_ConstraintManager::resolveConstraints()
 {
   myIsComputed = true;
   bool needToUpdate = false;
+  static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+  // to avoid redisplay of each segment on update by solver one by one in the viewer
+  bool isUpdateFlushed = Events_Loop::loop()->isFlushed(anUpdateEvent);
+  if (isUpdateFlushed) {
+    Events_Loop::loop()->setFlushed(anUpdateEvent, false);
+  }
+
   std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter;
   for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
     if ((*aGroupIter)->resolveConstraints())
       needToUpdate = true;
 
-  // Features may be updated => send events
+  // Features may be updated => now send events, btu for all changed at once
+  if (isUpdateFlushed) {
+    Events_Loop::loop()->setFlushed(anUpdateEvent, true);
+  }
   if (needToUpdate)
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+    Events_Loop::loop()->flush(anUpdateEvent);
   myIsComputed = false;
 }