{
if (!myFlushActive)
return;
+ bool hasEventsToFlush = !myGroups.empty();
std::map<char*, std::shared_ptr<Events_Message> >::iterator aMyGroup;
for(aMyGroup = myGroups.find(theID.eventText());
aMyGroup != myGroups.end(); aMyGroup = myGroups.find(theID.eventText()))
}
}
}
+ if (hasEventsToFlush && myGroups.empty()) { // no more messages left in the queue, so, finalize the sketch processing
+ static Events_ID anID = Events_Loop::eventByName("SketchPrepared");
+ std::shared_ptr<Events_Message> aMsg(new Events_Message(anID, this));
+ Events_Loop::loop()->send(aMsg, false);
+ }
}
void Events_Loop::eraseMessages(const Events_ID& theID)
void SketchSolver_Manager::processEvent(
const std::shared_ptr<Events_Message>& theMessage)
{
+ bool needToResolve = false;
+ bool isUpdateFlushed = false;
+ bool isMovedEvt = false;
+
static const Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
static const Events_ID aSketchPreparedEvent = Events_Loop::eventByName(EVENT_SKETCH_PREPARED);
// sketch is prepared for resolve: all the needed events
// are collected and must be processed by the solver
if (theMessage->eventID() == aSketchPreparedEvent) {
flushGrouped(anUpdateEvent);
- return;
+ needToResolve = true;
}
if (myIsComputed)
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
std::set<ObjectPtr> aFeatures = anUpdateMsg->objects();
- bool isUpdateFlushed = stopSendUpdate();
+ isUpdateFlushed = stopSendUpdate();
- bool isMovedEvt = theMessage->eventID()
+ isMovedEvt = theMessage->eventID()
== Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
// Shows that the message has at least one feature applicable for solver
hasProperFeature = updateFeature(aFeature, isMovedEvt) || hasProperFeature;
}
- if (isMovedEvt && !hasProperFeature) {
- // in this iteration it will compute nothing, so, no problem with recursion
- // it is important that solver flushes signal updated after processing move signal as there
- // is optimization that relies on this update, might be found by key "optimization"
- myIsComputed = false;
- }
-
- // Solve the set of constraints
- bool needToUpdate = resolveConstraints();
-
- // Features may be updated => now send events, but for all changed at once
- if (isUpdateFlushed)
- allowSendUpdate();
-
- myIsComputed = false;
-
- // send update for movement in any case
- if (needToUpdate || isMovedEvt)
- Events_Loop::loop()->flush(anUpdateEvent);
+ if (isMovedEvt && hasProperFeature)
+ needToResolve = true;
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
(*aGroupIter)->repairConsistency();
++aGroupIter;
}
-
- resolveConstraints();
}
myIsComputed = false;
}
+
+ // resolve constraints if needed
+ bool needToUpdate = needToResolve && resolveConstraints();
+
+ // Features may be updated => now send events, but for all changed at once
+ if (isUpdateFlushed)
+ allowSendUpdate();
+
+ myIsComputed = false;
+
+ // send update for movement in any case
+ if (needToUpdate || isMovedEvt)
+ Events_Loop::loop()->flush(anUpdateEvent);
}
// ============================================================================