SketchSolver_ConstraintManager::SketchSolver_ConstraintManager()
{
myGroups.clear();
+ myIsComputed = false;
// Register in event loop
Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
void SketchSolver_ConstraintManager::processEvent(
const boost::shared_ptr<Events_Message>& theMessage)
{
+ if (myIsComputed)
+ return;
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)
|| theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)
|| theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) {
// ============================================================================
void SketchSolver_ConstraintManager::resolveConstraints()
{
+ myIsComputed = true;
bool needToUpdate = false;
std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter;
for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
// Features may be updated => send events
if (needToUpdate)
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ myIsComputed = false;
}
private:
static SketchSolver_ConstraintManager* _self; ///< Self pointer to implement singleton functionality
std::vector<SketchSolver_ConstraintGroup*> myGroups; ///< Groups of constraints
+ /// true if computation is performed and all "updates" are generated by this algo
+ /// and needs no recomputation
+ bool myIsComputed;
};
#endif