Salome HOME
Fix for the issue #562
[modules/shaper.git] / src / Model / Model_Update.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_Update.cxx
4 // Created:     25 Jun 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include <Model_Update.h>
8 #include <Model_Document.h>
9 #include <Model_Data.h>
10 #include <Model_Objects.h>
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Data.h>
13 #include <ModelAPI_Document.h>
14 #include <ModelAPI_Events.h>
15 #include <ModelAPI_AttributeReference.h>
16 #include <ModelAPI_AttributeRefList.h>
17 #include <ModelAPI_AttributeRefAttr.h>
18 #include <ModelAPI_AttributeSelection.h>
19 #include <ModelAPI_AttributeSelectionList.h>
20 #include <ModelAPI_Result.h>
21 #include <ModelAPI_ResultPart.h>
22 #include <ModelAPI_Validator.h>
23 #include <ModelAPI_CompositeFeature.h>
24 #include <ModelAPI_Session.h>
25 #include <ModelAPI_Tools.h>
26 #include <GeomDataAPI_Point.h>
27 #include <GeomDataAPI_Point2D.h>
28 #include <Events_Loop.h>
29 #include <Events_LongOp.h>
30 #include <Events_Error.h>
31 #include <Config_PropManager.h>
32
33 using namespace std;
34
35 Model_Update MY_UPDATER_INSTANCE;  /// the only one instance initialized on load of the library
36
37 Model_Update::Model_Update()
38 {
39   Events_Loop* aLoop = Events_Loop::loop();
40   static const Events_ID kChangedEvent = aLoop->eventByName("PreferenceChanged");
41   aLoop->registerListener(this, kChangedEvent);
42   static const Events_ID kRebuildEvent = aLoop->eventByName("Rebuild");
43   aLoop->registerListener(this, kRebuildEvent);
44   static const Events_ID kCreatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED);
45   aLoop->registerListener(this, kCreatedEvent);
46   static const Events_ID kUpdatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED);
47   aLoop->registerListener(this, kUpdatedEvent);
48   static const Events_ID kMovedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
49   aLoop->registerListener(this, kMovedEvent);
50   static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
51   aLoop->registerListener(this, kOpFinishEvent);
52   static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
53   aLoop->registerListener(this, kOpAbortEvent);
54   static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
55   aLoop->registerListener(this, kOpStartEvent);
56
57   Config_PropManager::registerProp("Model update", "automatic_rebuild", "Rebuild immediately",
58                                    Config_Prop::Boolean, "false");
59   myIsAutomatic =
60     Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
61   myIsParamUpdated = false;
62 }
63
64 void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessage)
65 {
66   static Events_Loop* aLoop = Events_Loop::loop();
67   static const Events_ID kChangedEvent = aLoop->eventByName("PreferenceChanged");
68   static const Events_ID kRebuildEvent = aLoop->eventByName("Rebuild");
69   static const Events_ID kCreatedEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
70   static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED);
71   static const Events_ID kMovedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
72   static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
73   static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
74   static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
75   bool isOperationChanged = false;
76   if (theMessage->eventID() == kChangedEvent) { // automatic and manual rebuild flag is changed
77     bool aPropVal =
78       Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
79     if (aPropVal != myIsAutomatic) { // something is changed
80       myIsAutomatic = aPropVal;
81       if (myIsAutomatic) // higher level of automatization => to rebuild
82         processOperation(false);
83     }
84   } else if (theMessage->eventID() == kRebuildEvent) { // the rebuild command
85     processOperation(true);
86   } else if (theMessage->eventID() == kCreatedEvent || theMessage->eventID() == kUpdatedEvent ||
87              theMessage->eventID() == kMovedEvent) {
88     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
89         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
90     const std::set<ObjectPtr>& anObjs = aMsg->objects();
91     std::set<ObjectPtr>::const_iterator anObjIter = anObjs.cbegin();
92     bool isOnlyResults = true; // check that only results were changed: only redisplay is needed
93     for(; anObjIter != anObjs.cend(); anObjIter++) {
94       if (!std::dynamic_pointer_cast<ModelAPI_Result>(*anObjIter).get()) {
95         isOnlyResults = false;
96       }
97       if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) {
98         myIsParamUpdated = true;
99       }
100       // created objects are always must be up to date (python box feature)
101       // and updated not in internal uptation chain
102       if (theMessage->eventID() == kCreatedEvent) {
103         myJustCreated.insert(*anObjIter);
104       } else if (myJustCreated.find(*anObjIter) == myJustCreated.end()) { // moved and updated
105         myJustUpdated.insert(*anObjIter);
106       }
107     }
108      // this event is for solver update, not here, do not react immideately
109     if (!isOnlyResults && !(theMessage->eventID() == kMovedEvent))
110       processOperation(false);
111   } else if (theMessage->eventID() == kOpStartEvent) {
112     // we don't need the update only on operation start (caused problems in PartSet_Listener::processEvent)
113     isOperationChanged = true;
114   } else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent) {
115     processOperation(true, theMessage->eventID() == kOpFinishEvent);
116     isOperationChanged = true;
117   }
118   if (isOperationChanged) {
119     // remove all macros before clearing all created and execute all not-previewed
120     std::set<ObjectPtr>::iterator aCreatedIter = myJustCreated.begin();
121     std::set<ObjectPtr>::iterator anUpdatedIter = myJustUpdated.begin();
122     for(; aCreatedIter != myJustCreated.end() || anUpdatedIter != myJustUpdated.end();
123       aCreatedIter == myJustCreated.end() ? anUpdatedIter++ : aCreatedIter++) {
124       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*
125         (aCreatedIter == myJustCreated.end() ? anUpdatedIter : aCreatedIter));
126       if (aFeature.get()) {
127         // execute not-previewed feature on "apply"
128         if (!aFeature->isPreviewNeeded() && (myJustCreated.find(aFeature) != myJustCreated.end() ||
129           myJustUpdated.find(aFeature) != myJustUpdated.end())) {
130           static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
131           if (aFactory->validate(aFeature)) {
132             executeFeature(aFeature);
133           }
134         }
135         // remove macro on apply
136         if (aFeature->isMacro()) {
137           aFeature->document()->removeFeature(aFeature);
138         }
139       }
140     }
141     myJustCreated.clear();
142     myJustUpdated.clear();
143     myIsParamUpdated = false;
144   }
145 }
146
147 void Model_Update::processOperation(const bool theTotalUpdate, const bool theFinish)
148 {
149   if (theFinish) {
150     // the hardcode (DBC asked): hide the sketch referenced by extrusion on apply
151     std::set<std::shared_ptr<ModelAPI_Object> >::iterator aFIter;
152     for(aFIter = myJustCreated.begin(); aFIter != myJustCreated.end(); aFIter++)
153     {
154       FeaturePtr aF = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
155       if (aF && aF->data()->isValid() && aF->getKind() == "Extrusion") {
156         AttributeSelectionListPtr aBase = aF->selectionList("base");
157         if (aBase.get()) {
158           for(int a = aBase->size() - 1; a >= 0; a--) {
159             ResultPtr aSketchRes = aBase->value(a)->context();
160             if (aSketchRes) {
161               aSketchRes->setDisplayed(false);
162             }
163           }
164         }
165       }
166     }
167   }
168   // perform update of everything if needed
169   if (!myIsExecuted) {
170     myIsExecuted = true;
171
172     bool isAutomaticChanged = false;
173
174     if (theTotalUpdate && !myIsAutomatic) { // Apply button now works as "Rebuild"
175       isAutomaticChanged = true;
176       myIsAutomatic = true;
177     }
178
179     updateInDoc(ModelAPI_Session::get()->moduleDocument());
180
181     if (isAutomaticChanged) myIsAutomatic = false;
182     myIsExecuted = false;
183
184     // flush to update display
185     static Events_Loop* aLoop = Events_Loop::loop();
186     static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
187     aLoop->flush(EVENT_DISP);
188   }
189 }
190
191 void Model_Update::updateInDoc(std::shared_ptr<ModelAPI_Document> theDoc)
192 {
193   std::set<FeaturePtr> alreadyProcessed; // features that are processed before others
194   // all features one by one
195   Model_Objects* anObjs = std::dynamic_pointer_cast<Model_Document>(theDoc)->objects();
196   if (!anObjs) return;
197   FeaturePtr aFeatureIter = anObjs->firstFeature();
198   for (; aFeatureIter.get(); aFeatureIter = anObjs->nextFeature(aFeatureIter)) {
199     if (!aFeatureIter->data()->isValid()) // this may be on close of the document
200       continue;
201     if (aFeatureIter && alreadyProcessed.find(aFeatureIter) == alreadyProcessed.end()) {
202       // update selection and parameters attributes first, before sub-features analysis (sketch plane)
203       updateArguments(aFeatureIter);
204       // composite feature must be executed after sub-features execution
205       CompositeFeaturePtr aComposite = 
206         std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeatureIter);
207       if (aComposite) {
208         // number of subs can be changed in execution: like fillet
209         for(int a = 0; a < aComposite->numberOfSubs(); a++) {
210           FeaturePtr aSub = aComposite->subFeature(a);
211           updateArguments(aSub);
212           updateFeature(aSub);
213           alreadyProcessed.insert(aSub);
214         }
215       }
216
217       updateFeature(aFeatureIter);
218       // update the document results recursively
219       const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aFeatureIter->results();
220       std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
221       for (; aRIter != aResults.cend(); aRIter++) {
222         ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aRIter);
223         if (aPart.get()) {
224           if (!aPart->isDisabled() && aPart->partDoc().get()) {
225             updateInDoc(aPart->partDoc());
226           }
227         }
228       }
229     }
230   }
231 }
232
233 void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_ExecState theState) 
234 {
235   // make updated and redisplay all results
236   static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
237   const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
238   std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
239   for (; aRIter != aResults.cend(); aRIter++) {
240     std::shared_ptr<ModelAPI_Result> aRes = *aRIter;
241     aRes->data()->execState(theState);
242     myJustUpdated.insert(aRes);
243     ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
244   }
245   // to redisplay "presentable" feature (for ex. distance constraint)
246   ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
247   theFeature->data()->execState(theState);
248 }
249
250 /// Updates the state by the referenced object: if something bad with it, set state for this one
251 ModelAPI_ExecState stateByReference(ObjectPtr theTarget, const ModelAPI_ExecState theCurrent)
252 {
253   if (theTarget) {
254     ModelAPI_ExecState aRefState = theTarget->data()->execState();
255     if (aRefState == ModelAPI_StateMustBeUpdated) {
256       return ModelAPI_StateMustBeUpdated;
257     } else if (aRefState != ModelAPI_StateDone) {
258       return ModelAPI_StateInvalidArgument;
259     }
260   }
261   return theCurrent;
262 }
263
264 void Model_Update::updateArguments(FeaturePtr theFeature) {
265   // perform this method also for disabled features: to make "not done" state for
266   // featuers referenced to the active and modified features
267
268   static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
269
270   bool aJustUpdated = false;
271   ModelAPI_ExecState aState = theFeature->data()->execState();
272   if (aState == ModelAPI_StateInvalidArgument) // a chance to be corrected
273     aState = ModelAPI_StateMustBeUpdated;
274   // check the parameters state
275   // Double
276   std::list<AttributePtr> aDoubles =
277     theFeature->data()->attributes(ModelAPI_AttributeDouble::typeId());
278   std::list<AttributePtr>::iterator aDoubleIter = aDoubles.begin();
279   for(; aDoubleIter != aDoubles.end(); aDoubleIter++) {
280     AttributeDoublePtr aDouble =
281       std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(*aDoubleIter);
282     if (aDouble.get() && !aDouble->text().empty()) {
283       if (myIsParamUpdated) {
284         ModelAPI_AttributeEvalMessage::send(aDouble, this);
285       }
286       if (aDouble->expressionInvalid()) {
287         aState = ModelAPI_StateInvalidArgument;
288       }
289     }
290   }
291   // Point
292   {
293     std::list<AttributePtr> anAttributes =
294       theFeature->data()->attributes(GeomDataAPI_Point::typeId());
295     std::list<AttributePtr>::iterator anIter = anAttributes.begin();
296     for(; anIter != anAttributes.end(); anIter++) {
297       AttributePointPtr aPointAttribute =
298         std::dynamic_pointer_cast<GeomDataAPI_Point>(*anIter);
299       if (aPointAttribute.get()) {
300         if (myIsParamUpdated) {
301           ModelAPI_AttributeEvalMessage::send(aPointAttribute, this);
302         }
303         if ((!aPointAttribute->textX().empty() && aPointAttribute->expressionInvalid(0)) ||
304             (!aPointAttribute->textY().empty() && aPointAttribute->expressionInvalid(1)) ||
305             (!aPointAttribute->textZ().empty() && aPointAttribute->expressionInvalid(2)))
306           aState = ModelAPI_StateInvalidArgument;
307       }
308     }
309   }
310   // Point2D
311   {
312     std::list<AttributePtr> anAttributes =
313       theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
314     std::list<AttributePtr>::iterator anIter = anAttributes.begin();
315     for(; anIter != anAttributes.end(); anIter++) {
316       AttributePoint2DPtr aPoint2DAttribute =
317         std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
318       if (aPoint2DAttribute.get()) {
319         if (myIsParamUpdated) {
320           ModelAPI_AttributeEvalMessage::send(aPoint2DAttribute, this);
321         }
322         if ((!aPoint2DAttribute->textX().empty() && aPoint2DAttribute->expressionInvalid(0)) ||
323             (!aPoint2DAttribute->textY().empty() && aPoint2DAttribute->expressionInvalid(1)))
324           aState = ModelAPI_StateInvalidArgument;
325       }
326     }
327   }
328
329   //if (aState == ModelAPI_StateDone) {// all referenced objects are ready to be used
330     //std::cout<<"Execute feature "<<theFeature->getKind()<<std::endl;
331     // before execution update the selection attributes if any
332     list<AttributePtr> aRefs = 
333       theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
334     list<AttributePtr>::iterator aRefsIter = aRefs.begin();
335     for (; aRefsIter != aRefs.end(); aRefsIter++) {
336       std::shared_ptr<ModelAPI_AttributeSelection> aSel =
337         std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
338       ObjectPtr aContext = aSel->context();
339       // update argument onlt if the referenced object is changed
340       if (aContext.get() && isUpdated(aContext) && !aContext->isDisabled()) {
341         if (aState == ModelAPI_StateDone)
342           aState = ModelAPI_StateMustBeUpdated;
343         if (!aSel->update()) { // this must be done on execution since it may be long operation
344           if (!aFactory->isNotObligatory(theFeature->getKind(), theFeature->data()->id(aSel)) &&
345               aFactory->isCase(theFeature, theFeature->data()->id(aSel)))
346             aState = ModelAPI_StateInvalidArgument;
347         }
348       }
349     }
350     aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
351     for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
352       std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
353         std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
354       for(int a = aSel->size() - 1; a >= 0; a--) {
355         std::shared_ptr<ModelAPI_AttributeSelection> aSelAttr =
356           std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aSel->value(a));
357         if (aSelAttr) {
358           ObjectPtr aContext = aSelAttr->context();
359           // update argument onlt if the referenced object is changed
360           if (aContext.get() && isUpdated(aContext) && !aContext->isDisabled()) {
361             if (aState == ModelAPI_StateDone)
362               aState = ModelAPI_StateMustBeUpdated;
363             if (!aSelAttr->update()) {
364               if (!aFactory->isNotObligatory(
365                 theFeature->getKind(), theFeature->data()->id(aSel)) &&
366                 aFactory->isCase(theFeature, theFeature->data()->id(aSel)))
367                 aState = ModelAPI_StateInvalidArgument;
368             }
369           }
370         }
371       }
372     }
373   //}
374   if (aJustUpdated && myJustCreated.find(theFeature) == myJustCreated.end())
375   myJustUpdated.insert(theFeature);
376   if (aState != ModelAPI_StateDone)
377     theFeature->data()->execState(aState);
378 }
379
380 void Model_Update::updateFeature(FeaturePtr theFeature)
381 {
382   // check all features this feature depended on (recursive call of updateFeature)
383   static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
384
385   if (theFeature->data()->execState() == ModelAPI_StateInvalidArgument)
386     return;
387   bool aJustUpdated = false;
388
389   if (theFeature) {
390     if (myIsAutomatic && theFeature->data()->execState() == ModelAPI_StateMustBeUpdated)
391       aJustUpdated = true;
392
393     ModelAPI_ExecState aState = ModelAPI_StateDone;
394
395     // check all references: if referenced objects are updated, this object also must be updated
396     // also check state of referenced objects: if they are not ready, inherit corresponding state
397     std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
398     std::shared_ptr<Model_Data> aData = 
399       std::dynamic_pointer_cast<Model_Data>(theFeature->data());
400     aData->referencesToObjects(aRefs);
401     std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRef = aRefs.begin();
402     for(; aRef != aRefs.end(); aRef++) {
403       std::list<ObjectPtr>::iterator aRefObj = aRef->second.begin();
404       for(; aRefObj != aRef->second.end(); aRefObj++) {
405         // if reference is null, it may bmean that this reference is to other document
406         // the does not supported by RefList: peremeters may be recomputed
407         if (!aRefObj->get() || myJustCreated.find(*aRefObj) != myJustCreated.end() ||
408             myJustUpdated.find(*aRefObj) != myJustUpdated.end()) {
409           aJustUpdated = true;
410         }
411         aState = stateByReference(*aRefObj, aState);
412       }
413     }
414
415     // some arguments were changed, so, this feature must be updated
416     if (myJustCreated.find(theFeature) != myJustCreated.end()) {
417       aJustUpdated = true;
418     } else {
419       if (aJustUpdated) {
420         if (myJustUpdated.find(theFeature) == myJustUpdated.end())
421           myJustUpdated.insert(theFeature);
422       } else {
423         aJustUpdated = myJustUpdated.find(theFeature) != myJustUpdated.end();
424       }
425     }
426     //std::cout<<"Update feature "<<theFeature->getKind()<<" must be updated = "<<aMustbeUpdated<<std::endl;
427     // execute feature if it must be updated
428     if (aJustUpdated) {
429       if (theFeature->isDisabled()) {  // do not execute the disabled feature
430         // the disabled features must be updated after enabling anyway if their arguments were changed
431         if (theFeature->data()->execState() == ModelAPI_StateDone &&
432           aState == ModelAPI_StateMustBeUpdated)
433           theFeature->data()->execState(ModelAPI_StateMustBeUpdated);
434       } else {
435         if (theFeature->isPreviewNeeded()) {
436           if (std::dynamic_pointer_cast<Model_Document>(theFeature->document())->executeFeatures() ||
437               !theFeature->isPersistentResult()) {
438             if (aFactory->validate(theFeature)) {
439               FeaturePtr aCurrent = theFeature->document()->currentFeature(false);
440               if (myIsAutomatic || !theFeature->isPersistentResult() /* execute quick, not persistent results */
441                   || (isUpdated(theFeature) && 
442                        (theFeature == aCurrent || 
443                         (aCurrent.get() && aCurrent->isMacro())))) // currently edited
444               {
445                 if (aState == ModelAPI_StateDone || aState == ModelAPI_StateMustBeUpdated) {
446                   executeFeature(theFeature);
447                 }
448               } else { // must be updatet, but not updated yet
449                 theFeature->data()->execState(ModelAPI_StateMustBeUpdated);
450                 const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
451                 std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
452                 for (; aRIter != aResults.cend(); aRIter++) {
453                   std::shared_ptr<ModelAPI_Result> aRes = *aRIter;
454                   aRes->data()->execState(ModelAPI_StateMustBeUpdated);
455                 }
456               }
457             } else {
458               theFeature->eraseResults();
459               redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
460             }
461           } else { // for automatically updated features (on abort, etc) it is necessary to redisplay anyway
462             redisplayWithResults(theFeature, ModelAPI_StateNothing);
463           }
464         } else { // preview is not needed => make state Done
465           if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated)
466             theFeature->data()->execState(ModelAPI_StateDone);
467         }
468       }
469     }
470   }
471 }
472
473 void Model_Update::executeFeature(FeaturePtr theFeature)
474 {
475   // execute in try-catch to avoid internal problems of the feature
476   ModelAPI_ExecState aState = ModelAPI_StateDone;
477   theFeature->data()->execState(ModelAPI_StateDone);
478   try {
479     theFeature->execute();
480     if (theFeature->data()->execState() != ModelAPI_StateDone) {
481       aState = ModelAPI_StateExecFailed;
482     } else {
483       aState = ModelAPI_StateDone;
484     }
485   } catch(...) {
486     aState = ModelAPI_StateExecFailed;
487     Events_Error::send(
488       "Feature " + theFeature->getKind() + " has failed during the execution");
489   }
490   if (aState != ModelAPI_StateDone) {
491     theFeature->eraseResults();
492   }
493   redisplayWithResults(theFeature, aState);
494 }
495
496 bool Model_Update::isUpdated(const ObjectPtr& theObj)
497 {
498   return myJustCreated.find(theObj) != myJustCreated.end() ||
499          myJustUpdated.find(theObj) != myJustUpdated.end();
500 }