{
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));
}
}
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));
+}
//! 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
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();
{
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;
}