1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_Update.cxx
4 // Created: 25 Jun 2014
5 // Author: Mikhail PONIKAROV
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>
35 Model_Update MY_UPDATER_INSTANCE; /// the only one instance initialized on load of the library
38 Model_Update::Model_Update()
40 Events_Loop* aLoop = Events_Loop::loop();
41 static const Events_ID kChangedEvent = aLoop->eventByName("PreferenceChanged");
42 aLoop->registerListener(this, kChangedEvent);
43 static const Events_ID kRebuildEvent = aLoop->eventByName("Rebuild");
44 aLoop->registerListener(this, kRebuildEvent);
45 static const Events_ID kCreatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED);
46 aLoop->registerListener(this, kCreatedEvent);
47 static const Events_ID kUpdatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED);
48 aLoop->registerListener(this, kUpdatedEvent);
49 static const Events_ID kMovedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
50 aLoop->registerListener(this, kMovedEvent);
51 static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
52 aLoop->registerListener(this, kOpFinishEvent);
53 static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
54 aLoop->registerListener(this, kOpAbortEvent);
55 static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
56 aLoop->registerListener(this, kOpStartEvent);
58 Config_PropManager::registerProp("Model update", "automatic_rebuild", "Rebuild immediately",
59 Config_Prop::Boolean, "false");
61 Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
62 myIsParamUpdated = false;
66 void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessage)
68 static Events_Loop* aLoop = Events_Loop::loop();
69 static const Events_ID kChangedEvent = aLoop->eventByName("PreferenceChanged");
70 static const Events_ID kRebuildEvent = aLoop->eventByName("Rebuild");
71 static const Events_ID kCreatedEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
72 static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED);
73 static const Events_ID kMovedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
74 static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
75 static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
76 static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
77 if (theMessage->eventID() == kChangedEvent) { // automatic and manual rebuild flag is changed
79 Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
80 if (aPropVal != myIsAutomatic) { // something is changed
81 myIsAutomatic = aPropVal;
82 if (myIsAutomatic) // higher level of automatization => to rebuild
83 processOperation(false);
85 } else if (theMessage->eventID() == kRebuildEvent) { // the rebuild command
86 processOperation(true);
87 } else if (theMessage->eventID() == kCreatedEvent || theMessage->eventID() == kUpdatedEvent ||
88 theMessage->eventID() == kMovedEvent) {
89 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
90 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
91 const std::set<ObjectPtr>& anObjs = aMsg->objects();
92 std::set<ObjectPtr>::const_iterator anObjIter = anObjs.cbegin();
93 bool isOnlyResults = true; // check that only results were changed: only redisplay is needed
94 for(; anObjIter != anObjs.cend(); anObjIter++) {
95 if (!std::dynamic_pointer_cast<ModelAPI_Result>(*anObjIter).get()) {
96 isOnlyResults = false;
98 if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) {
99 myIsParamUpdated = true;
101 // created objects are always must be up to date (python box feature)
102 // and updated not in internal uptation chain
103 myJustUpdated.insert(*anObjIter);
105 // something is updated during the execution: re-execute it (sketch update by parameters)
107 FeaturePtr anUpdated = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
108 if (anUpdated.get() && anUpdated->data()->isValid() &&
109 myProcessed.find(anUpdated) != myProcessed.end()) {
110 if (anUpdated->isPreviewNeeded() || myIsFinish) {
111 ModelAPI_ExecState aState = anUpdated->data()->execState();
112 static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
113 if (aFactory->validate(anUpdated)) {
115 std::cout<<"Execute immideately "<<anUpdated->name()<<std::endl;
117 executeFeature(anUpdated);
119 anUpdated->eraseResults();
120 redisplayWithResults(anUpdated, ModelAPI_StateInvalidArgument); // result also must be updated
126 if ((*anObjIter)->data() && (*anObjIter)->data()->isValid()) {
127 std::cout<<"Add updated "<<(*anObjIter)->groupName()<<" "
128 <<(*anObjIter)->data()->name()<<std::endl;
132 // this event is for solver update, not here, do not react immediately
133 if (!isOnlyResults && !(theMessage->eventID() == kMovedEvent))
134 processOperation(false);
135 } else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent ||
136 theMessage->eventID() == kOpStartEvent) {
138 if (!(theMessage->eventID() == kOpStartEvent)) {
140 processOperation(true, theMessage->eventID() == kOpFinishEvent);
143 // remove all macros before clearing all created
144 std::set<ObjectPtr>::iterator anUpdatedIter = myWaitForFinish.begin();
145 while(anUpdatedIter != myWaitForFinish.end()) {
146 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anUpdatedIter);
147 if (aFeature.get()) {
148 // remove macro on finish
149 if (aFeature->isMacro()) {
150 aFeature->document()->removeFeature(aFeature);
151 myWaitForFinish.erase(aFeature);
153 // to avoid the map update problems on "remove"
154 if (myWaitForFinish.find(aFeature) == myWaitForFinish.end()) {
155 anUpdatedIter = myWaitForFinish.begin();
163 // in the end of transaction everything is updated, so clear the old objects (the only one
164 // place where results are cleared)
165 myIsParamUpdated = false;
166 myJustUpdated.clear();
167 myWaitForFinish.clear();
171 void Model_Update::processOperation(const bool theTotalUpdate, const bool theFinish)
174 // the hardcode (DBC asked): hide the sketch referenced by extrusion on apply
175 std::set<std::shared_ptr<ModelAPI_Object> >::iterator aFIter;
176 for(aFIter = myWaitForFinish.begin(); aFIter != myWaitForFinish.end(); aFIter++)
178 FeaturePtr aF = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
179 if (aF && aF->data()->isValid() && aF->getKind() == "Extrusion") {
180 AttributeSelectionListPtr aBase = aF->selectionList("base");
182 for(int a = aBase->size() - 1; a >= 0; a--) {
183 ResultPtr aSketchRes = aBase->value(a)->context();
185 aSketchRes->setDisplayed(false);
192 // perform update of everything if needed
195 std::cout<<"****** Start processing"<<std::endl;
199 bool isAutomaticChanged = false;
201 if (theTotalUpdate && !myIsAutomatic) { // Apply button now works as "Rebuild"
202 isAutomaticChanged = true;
203 myIsAutomatic = true;
206 // iterate all features in the root document to update each
207 DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
208 Model_Objects* anObjs = std::dynamic_pointer_cast<Model_Document>(aRootDoc)->objects();
210 // two cycles: parameters are first to process
211 FeaturePtr aFeatureIter = anObjs->firstFeature();
212 myProcessed.clear(); // to avoid processing twice
213 for (; aFeatureIter.get(); aFeatureIter = anObjs->nextFeature(aFeatureIter)) {
214 if (aFeatureIter->getKind() == "Parameter")
215 updateFeature(aFeatureIter);
217 aFeatureIter = anObjs->firstFeature();
218 for (; aFeatureIter.get(); aFeatureIter = anObjs->nextFeature(aFeatureIter)) {
219 if (aFeatureIter->getKind() != "Parameter")
220 updateFeature(aFeatureIter);
223 if (isAutomaticChanged) myIsAutomatic = false;
224 myProcessed.clear(); // to avoid keeping features in memory
225 myIsExecuted = false;
227 // flush to update display
228 static Events_Loop* aLoop = Events_Loop::loop();
229 static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
230 aLoop->flush(EVENT_DISP);
232 std::cout<<"****** End processing"<<std::endl;
237 void Model_Update::updateFeature(FeaturePtr theFeature)
239 // check all features this feature depended on (recursive call of updateFeature)
240 static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
242 if (myProcessed.find(theFeature) != myProcessed.end())
244 myProcessed.insert(theFeature);
245 if (theFeature->isDisabled())
249 std::cout<<"Update Feature "<<theFeature->name()<<std::endl;
251 CompositeFeaturePtr aCompos = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
252 // If automatice update is not needed and feature attributes were not updated right now,
253 // do not execute it and do not update arguments.
254 if (!myIsAutomatic && myJustUpdated.find(theFeature) == myJustUpdated.end() && !aCompos.get()) {
255 // execute will be performed later, but some features may have not-result
256 // presentations, so call update for them (like coincidence in the sketcher)
257 static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
258 ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
262 // Update selection and parameters attributes first, before sub-features analysis (sketch plane).
263 updateArguments(theFeature);
265 // composite feature must be executed after sub-features execution
267 // two cycles: parameters must be processed first
268 for(int a = 0; a < aCompos->numberOfSubs(); a++) {
269 FeaturePtr aSub = aCompos->subFeature(a);
270 if (aSub->getKind() == "Parameter")
273 // number of subs can be changed in execution: like fillet
274 for(int a = 0; a < aCompos->numberOfSubs(); a++) {
275 FeaturePtr aSub = aCompos->subFeature(a);
276 if (aSub->getKind() != "Parameter")
279 // reupdate arguments of composite feature: it may be changed during subs execution
280 if (theFeature->data()->execState() != ModelAPI_StateMustBeUpdated)
281 updateArguments(theFeature);
283 // this checking must be after the composite feature sub-elements processing:
284 // composite feature status may depend on it's subelements
285 if (theFeature->data()->execState() == ModelAPI_StateInvalidArgument) {
286 theFeature->eraseResults();
287 redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
291 bool aJustUpdated = myJustUpdated.find(theFeature) != myJustUpdated.end();
293 if (myIsAutomatic && theFeature->data()->execState() == ModelAPI_StateMustBeUpdated)
296 // On abort, undo or redo execute is not needed: results in document are updated automatically
297 // But redisplay is needed: results are updated, must be also updated in the viewer.
299 !std::dynamic_pointer_cast<Model_Document>(theFeature->document())->executeFeatures()) {
300 if (!theFeature->isPersistentResult()) { // not persistent must be re-executed on abort, etc.
301 ModelAPI_ExecState aState = theFeature->data()->execState();
302 if (aFactory->validate(theFeature)) {
303 executeFeature(theFeature);
305 theFeature->eraseResults();
306 redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
309 redisplayWithResults(theFeature, ModelAPI_StateNothing);
310 if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated) { // it is done (in the tree)
311 theFeature->data()->execState(ModelAPI_StateDone);
317 // execute feature if it must be updated
318 if (theFeature->isPreviewNeeded() || myIsFinish) {
320 ModelAPI_ExecState aState = theFeature->data()->execState();
321 if (aFactory->validate(theFeature)) {
323 std::cout<<"Execute Feature "<<theFeature->name()<<std::endl;
325 executeFeature(theFeature);
327 theFeature->eraseResults();
328 redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
331 } else { // preview is not needed => make state Done
332 if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated) {
333 theFeature->data()->execState(ModelAPI_StateDone);
334 if (aJustUpdated) // store that it must be updated on finish
335 myJustUpdated.insert(theFeature);
340 void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_ExecState theState)
342 // make updated and redisplay all results
343 static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
344 const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
345 std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
346 for (; aRIter != aResults.cend(); aRIter++) {
347 std::shared_ptr<ModelAPI_Result> aRes = *aRIter;
348 if (!aRes->isDisabled()) {// update state only for enabled results (Placement Result Part may make the original Part Result as invalid)
349 aRes->data()->execState(theState);
350 if (theState == ModelAPI_StateDone) // feature become "done", so execution changed results
351 myJustUpdated.insert(aRes);
353 if (theFeature->data()->updateID() > aRes->data()->updateID()) {
354 aRes->data()->setUpdateID(theFeature->data()->updateID());
356 ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
358 // to redisplay "presentable" feature (for ex. distance constraint)
359 ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
360 theFeature->data()->execState(theState);
363 /// Updates the state by the referenced object: if something bad with it, set state for this one
364 ModelAPI_ExecState stateByReference(ObjectPtr theTarget, const ModelAPI_ExecState theCurrent)
367 ModelAPI_ExecState aRefState = theTarget->data()->execState();
368 if (aRefState == ModelAPI_StateMustBeUpdated) {
369 if (theCurrent == ModelAPI_StateDone)
370 return ModelAPI_StateMustBeUpdated;
371 } else if (aRefState != ModelAPI_StateDone) {
372 return ModelAPI_StateInvalidArgument;
378 void Model_Update::updateArguments(FeaturePtr theFeature) {
379 // perform this method also for disabled features: to make "not done" state for
380 // features referenced to the active and modified features
382 static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
384 ModelAPI_ExecState aState = theFeature->data()->execState();
385 if (aState == ModelAPI_StateExecFailed) { // try again failed feature: issue 577
386 aState = ModelAPI_StateMustBeUpdated;
388 if (aState == ModelAPI_StateInvalidArgument) // a chance to be corrected
389 aState = ModelAPI_StateMustBeUpdated;
390 // check the parameters state
392 std::list<AttributePtr> aDoubles =
393 theFeature->data()->attributes(ModelAPI_AttributeDouble::typeId());
394 std::list<AttributePtr>::iterator aDoubleIter = aDoubles.begin();
395 for(; aDoubleIter != aDoubles.end(); aDoubleIter++) {
396 AttributeDoublePtr aDouble =
397 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(*aDoubleIter);
398 if (aDouble.get() && !aDouble->text().empty()) {
399 if (myIsParamUpdated) {
400 ModelAPI_AttributeEvalMessage::send(aDouble, this);
402 if (aDouble->expressionInvalid()) {
403 aState = ModelAPI_StateInvalidArgument;
409 std::list<AttributePtr> anAttributes =
410 theFeature->data()->attributes(GeomDataAPI_Point::typeId());
411 std::list<AttributePtr>::iterator anIter = anAttributes.begin();
412 for(; anIter != anAttributes.end(); anIter++) {
413 AttributePointPtr aPointAttribute =
414 std::dynamic_pointer_cast<GeomDataAPI_Point>(*anIter);
415 if (aPointAttribute.get()) {
416 if (myIsParamUpdated) {
417 ModelAPI_AttributeEvalMessage::send(aPointAttribute, this);
419 if ((!aPointAttribute->textX().empty() && aPointAttribute->expressionInvalid(0)) ||
420 (!aPointAttribute->textY().empty() && aPointAttribute->expressionInvalid(1)) ||
421 (!aPointAttribute->textZ().empty() && aPointAttribute->expressionInvalid(2)))
422 aState = ModelAPI_StateInvalidArgument;
428 std::list<AttributePtr> anAttributes =
429 theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
430 std::list<AttributePtr>::iterator anIter = anAttributes.begin();
431 for(; anIter != anAttributes.end(); anIter++) {
432 AttributePoint2DPtr aPoint2DAttribute =
433 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
434 if (aPoint2DAttribute.get()) {
435 if (myIsParamUpdated) {
436 ModelAPI_AttributeEvalMessage::send(aPoint2DAttribute, this);
438 if ((!aPoint2DAttribute->textX().empty() && aPoint2DAttribute->expressionInvalid(0)) ||
439 (!aPoint2DAttribute->textY().empty() && aPoint2DAttribute->expressionInvalid(1)))
440 aState = ModelAPI_StateInvalidArgument;
445 //if (aState == ModelAPI_StateDone) {// all referenced objects are ready to be used
446 //std::cout<<"Execute feature "<<theFeature->getKind()<<std::endl;
447 // before execution update the selection attributes if any
448 list<AttributePtr> aRefs =
449 theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
450 list<AttributePtr>::iterator aRefsIter = aRefs.begin();
451 for (; aRefsIter != aRefs.end(); aRefsIter++) {
452 std::shared_ptr<ModelAPI_AttributeSelection> aSel =
453 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
454 ObjectPtr aContext = aSel->context();
455 // update argument only if the referenced object is changed
456 if (aContext.get() && !aContext->isDisabled() &&
457 (myJustUpdated.find(aContext) != myJustUpdated.end() ||
458 aContext->data()->updateID() > theFeature->data()->updateID())) {
459 if (aState == ModelAPI_StateDone)
460 aState = ModelAPI_StateMustBeUpdated;
461 if (!aSel->update()) { // this must be done on execution since it may be long operation
462 if (!aFactory->isNotObligatory(theFeature->getKind(), theFeature->data()->id(aSel)) &&
463 aFactory->isCase(theFeature, theFeature->data()->id(aSel)))
464 aState = ModelAPI_StateInvalidArgument;
468 aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
469 for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
470 std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
471 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
472 for(int a = aSel->size() - 1; a >= 0; a--) {
473 std::shared_ptr<ModelAPI_AttributeSelection> aSelAttr =
474 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aSel->value(a));
476 ObjectPtr aContext = aSelAttr->context();
477 // update argument onlt if the referenced object is changed
478 if (aContext.get() && !aContext->isDisabled() &&
479 (myJustUpdated.find(aContext) != myJustUpdated.end() ||
480 aContext->data()->updateID() > theFeature->data()->updateID())) {
481 if (aState == ModelAPI_StateDone)
482 aState = ModelAPI_StateMustBeUpdated;
483 if (!aSelAttr->update()) {
484 if (!aFactory->isNotObligatory(
485 theFeature->getKind(), theFeature->data()->id(aSel)) &&
486 aFactory->isCase(theFeature, theFeature->data()->id(aSel)))
487 aState = ModelAPI_StateInvalidArgument;
493 // check all references: if referenced objects are updated, this object also must be updated
494 // also check state of referenced objects: if they are not ready, inherit corresponding state
495 std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefsObj;
496 std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theFeature->data());
497 aData->referencesToObjects(aRefsObj);
498 std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRef = aRefsObj.begin();
499 for(; aRef != aRefsObj.end(); aRef++) {
500 std::list<ObjectPtr>::iterator aRefObj = aRef->second.begin();
501 for(; aRefObj != aRef->second.end(); aRefObj++) {
502 // if reference is null, it may mean that this reference is to other document
503 // the does not supported by RefList: parameters may be recomputed
504 if (!aRefObj->get() && theFeature->firstResult().get() &&
505 theFeature->firstResult()->groupName() == ModelAPI_ResultParameter::group()) {
506 if (aState == ModelAPI_StateDone)
507 aState = ModelAPI_StateMustBeUpdated;
508 } else if (myJustUpdated.find(*aRefObj) != myJustUpdated.end() ||
509 (aRefObj->get() && (*aRefObj)->data()->updateID() > theFeature->data()->updateID())) {
510 if (aState == ModelAPI_StateDone)
511 aState = ModelAPI_StateMustBeUpdated;
513 aState = stateByReference(*aRefObj, aState);
516 // composites sub-elements
517 CompositeFeaturePtr aCompos = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
518 // composite feature must be executed after sub-features execution
520 // number of subs can be changed in execution: like fillet
521 for(int a = 0; a < aCompos->numberOfSubs(); a++) {
522 FeaturePtr aSub = aCompos->subFeature(a);
523 if (aSub.get() && aState == ModelAPI_StateDone) {
524 if (myJustUpdated.find(aSub) != myJustUpdated.end() ||
525 (aSub->data()->updateID() > theFeature->data()->updateID())) {
526 aState = ModelAPI_StateMustBeUpdated;
528 // also check that all results of subs were updated: composite also depends on the results
529 const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aSub->results();
530 std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aResults.begin();
531 for(; aResIter != aResults.end(); aResIter++) {
532 if (aResIter->get() && (*aResIter)->data()->isValid() && !(*aResIter)->isDisabled() &&
533 (myJustUpdated.find(*aResIter) != myJustUpdated.end() ||
534 ((*aResIter)->data()->updateID() > theFeature->data()->updateID()))) {
535 aState = ModelAPI_StateMustBeUpdated;
543 if (aState != ModelAPI_StateDone)
544 theFeature->data()->execState(aState);
547 void Model_Update::executeFeature(FeaturePtr theFeature)
549 // execute in try-catch to avoid internal problems of the feature
550 ModelAPI_ExecState aState = ModelAPI_StateDone;
551 theFeature->data()->execState(ModelAPI_StateDone);
553 theFeature->execute();
554 myJustUpdated.erase(theFeature);
555 if (theFeature->data()->execState() != ModelAPI_StateDone) {
556 aState = ModelAPI_StateExecFailed;
558 aState = ModelAPI_StateDone;
559 myWaitForFinish.insert(theFeature);
562 aState = ModelAPI_StateExecFailed;
564 "Feature " + theFeature->getKind() + " has failed during the execution");
566 if (aState != ModelAPI_StateDone) {
567 theFeature->eraseResults();
569 theFeature->data()->setUpdateID(ModelAPI_Session::get()->transactionID());
570 redisplayWithResults(theFeature, aState);