1 // Copyright (C) 2014-2021 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Model_Update.h>
21 #include <Model_Document.h>
22 #include <Model_Data.h>
23 #include <Model_Objects.h>
24 #include <ModelAPI_Feature.h>
25 #include <ModelAPI_Data.h>
26 #include <ModelAPI_Document.h>
27 #include <ModelAPI_Events.h>
28 #include <ModelAPI_AttributeReference.h>
29 #include <ModelAPI_AttributeRefList.h>
30 #include <ModelAPI_AttributeRefAttr.h>
31 #include <ModelAPI_AttributeSelection.h>
32 #include <ModelAPI_AttributeSelectionList.h>
33 #include <ModelAPI_Result.h>
34 #include <ModelAPI_ResultPart.h>
35 #include <ModelAPI_Validator.h>
36 #include <ModelAPI_CompositeFeature.h>
37 #include <ModelAPI_Session.h>
38 #include <ModelAPI_Tools.h>
39 #include <ModelAPI_ResultBody.h>
40 #include <ModelAPI_ResultPart.h>
41 #include <ModelAPI_ResultConstruction.h>
42 #include <GeomAPI_Shape.h>
43 #include <GeomDataAPI_Point.h>
44 #include <GeomDataAPI_Dir.h>
45 #include <GeomDataAPI_Point2D.h>
46 #include <Events_Loop.h>
47 #include <Events_LongOp.h>
48 #include <Events_InfoMessage.h>
49 #include <Config_PropManager.h>
51 Model_Update MY_UPDATER_INSTANCE; /// the only one instance initialized on load of the library
55 #include <Locale_Convert.h>
58 Model_Update::Model_Update()
60 Events_Loop* aLoop = Events_Loop::loop();
61 static const Events_ID kChangedEvent = aLoop->eventByName("PreferenceChanged");
62 aLoop->registerListener(this, kChangedEvent);
63 static const Events_ID kCreatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED);
64 aLoop->registerListener(this, kCreatedEvent);
65 static const Events_ID kUpdatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED);
66 aLoop->registerListener(this, kUpdatedEvent);
67 static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
68 aLoop->registerListener(this, kOpFinishEvent);
69 static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
70 aLoop->registerListener(this, kOpAbortEvent);
71 static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
72 aLoop->registerListener(this, kOpStartEvent);
73 static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED);
74 aLoop->registerListener(this, kStabilityEvent);
75 static const Events_ID kPreviewBlockedEvent = aLoop->eventByName(EVENT_PREVIEW_BLOCKED);
76 aLoop->registerListener(this, kPreviewBlockedEvent);
77 static const Events_ID kPreviewRequestedEvent = aLoop->eventByName(EVENT_PREVIEW_REQUESTED);
78 aLoop->registerListener(this, kPreviewRequestedEvent);
79 static const Events_ID kReorderEvent = aLoop->eventByName(EVENT_ORDER_UPDATED);
80 aLoop->registerListener(this, kReorderEvent);
81 static const Events_ID kUpdatedSel = aLoop->eventByName(EVENT_UPDATE_SELECTION);
82 aLoop->registerListener(this, kUpdatedSel);
83 static const Events_ID kAutoRecomp = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE);
84 aLoop->registerListener(this, kAutoRecomp);
86 // Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
87 myIsParamUpdated = false;
89 myIsProcessed = false;
90 myIsPreviewBlocked = false;
91 myUpdateBlocked = false;
94 bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
96 if (!theFeature->data()->isValid())
97 return false; // delete an extrusion created on the sketch
100 bool isNotExecuted = theFeature->isPersistentResult() &&
101 !std::dynamic_pointer_cast<Model_Document>((theFeature)->document())->executeFeatures();
103 redisplayWithResults(theFeature, ModelAPI_StateNothing, false); // redisplay even not executed
104 if (!theReason.get()) // no reason => no construction reason
106 if (myNotPersistentRefs.find(theFeature) == myNotPersistentRefs.end()) {
107 myNotPersistentRefs[theFeature].insert(theReason);
109 std::set<std::shared_ptr<ModelAPI_Feature> > aNewSet;
110 aNewSet.insert(theReason);
111 myNotPersistentRefs[theFeature] = aNewSet;
116 // update arguments for "apply button" state change
117 if ((!theFeature->isPreviewNeeded() && !myIsFinish) || myIsPreviewBlocked) {
119 myProcessOnFinish[theFeature].insert(theReason);
120 else if (myProcessOnFinish.find(theFeature) == myProcessOnFinish.end())
121 myProcessOnFinish[theFeature] = std::set<std::shared_ptr<ModelAPI_Feature> >();
123 std::wcout<<L"*** Add process on finish "<<theFeature->name()<<std::endl;
125 // keeps the currently updated features to avoid infinitive cycling here: where feature on
126 // "updateArguments" sends "updated" (in selection attribute) and goes here again
127 static std::set<FeaturePtr> aCurrentlyUpdated;
128 if (aCurrentlyUpdated.find(theFeature) == aCurrentlyUpdated.end()) {
129 aCurrentlyUpdated.insert(theFeature);
130 updateArguments(theFeature);
131 aCurrentlyUpdated.erase(theFeature);
133 // make it without conditions otherwise the apply button may have a bad state
134 theFeature->data()->execState(ModelAPI_StateDone);
135 static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
136 // need to be validated to update the "Apply" state if not previewed
137 aFactory->validate(theFeature);
139 // to redisplay split's arguments presentation, even result is not computed
140 if (!theFeature->isPreviewNeeded()) {
141 static Events_Loop* aLoop = Events_Loop::loop();
142 static const Events_ID kRedisplayEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
143 ModelAPI_EventCreator::get()->sendUpdated(theFeature, kRedisplayEvent);
144 aLoop->flush(kRedisplayEvent);
147 if (!myIsPreviewBlocked)
150 if (myModified.find(theFeature) != myModified.end()) {
151 if (theReason.get()) {
153 //std::cout<<"*** Add already modified "
154 // <<theFeature->name()<<" reason "<<theReason->name()<<std::endl;
156 myModified[theFeature].insert(theReason);
160 // do not add the disabled, but possibly the sub-elements are not disabled
161 bool aIsDisabled = theFeature->isDisabled();
163 std::set<std::shared_ptr<ModelAPI_Feature> > aNewSet;
164 if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated ||
165 theFeature->data()->execState() == ModelAPI_StateInvalidArgument || // issue 1519
166 theFeature->data()->execState() == ModelAPI_StateExecFailed) {
167 // do not forget that in this case all were the reasons
168 aNewSet.insert(theFeature);
171 aNewSet.insert(theReason);
173 myModified[theFeature] = aNewSet;
175 if (theReason.get()) {
176 //std::cout<<"*** Add modified "<<theFeature->name()
177 // <<" reason "<<theReason->name()<<std::endl;
179 //std::cout<<"*** Add modified "<<theFeature->name()<<std::endl;
182 } else { // will be updated during the finish of the operation, or when it becomes enabled
183 if (theFeature->data()->execState() == ModelAPI_StateDone ||
184 theFeature->data()->execState() == ModelAPI_StateExecFailed) // fix issue 1819
185 theFeature->data()->execState(ModelAPI_StateMustBeUpdated);
187 return true; // do not need iteration deeply if it is already marked as modified or so
189 //std::cout<<"*** Set modified state "<<theFeature->name()<<std::endl;
192 // clear processed and fill modified recursively
193 std::set<FeaturePtr> aRefSet;
194 const std::set<std::shared_ptr<ModelAPI_Attribute> >& aRefs = theFeature->data()->refsToMe();
195 std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator aRefIter = aRefs.cbegin();
196 for(; aRefIter != aRefs.cend(); aRefIter++) {
197 if ((*aRefIter)->isArgument()) {
198 FeaturePtr aReferenced = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefIter)->owner());
199 if (aReferenced.get()) {
200 aRefSet.insert(aReferenced);
204 // process also results
205 std::list<ResultPtr> allResults; // list of this feature and results
206 ModelAPI_Tools::allResults(theFeature, allResults);
207 std::list<ResultPtr>::iterator aRes = allResults.begin();
208 for(; aRes != allResults.end(); aRes++) {
209 const std::set<std::shared_ptr<ModelAPI_Attribute> >& aResRefs = (*aRes)->data()->refsToMe();
210 std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator aRIter = aResRefs.cbegin();
211 for(; aRIter != aResRefs.cend(); aRIter++) {
212 if ((*aRIter)->isArgument()) {
213 FeaturePtr aReferenced = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRIter)->owner());
214 if (aReferenced.get()) {
215 aRefSet.insert(aReferenced);
220 // also add part feature that contains this feature to the modified
221 if (theFeature->document()->kind() != "PartSet") {
222 FeaturePtr aPart = ModelAPI_Tools::findPartFeature(
223 ModelAPI_Session::get()->moduleDocument(), theFeature->document());
225 aRefSet.insert(aPart);
227 for(std::set<FeaturePtr>::iterator aRef = aRefSet.begin(); aRef != aRefSet.end(); aRef++)
228 addModified(*aRef, theFeature);
233 void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessage)
235 static Events_Loop* aLoop = Events_Loop::loop();
236 //static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
237 static const Events_ID kCreatedEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
238 static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED);
239 static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
240 static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
241 static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
242 static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED);
243 static const Events_ID kPreviewBlockedEvent = aLoop->eventByName(EVENT_PREVIEW_BLOCKED);
244 static const Events_ID kPreviewRequestedEvent = aLoop->eventByName(EVENT_PREVIEW_REQUESTED);
245 static const Events_ID kReorderEvent = aLoop->eventByName(EVENT_ORDER_UPDATED);
246 static const Events_ID kRedisplayEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
247 static const Events_ID kUpdatedSel = aLoop->eventByName(EVENT_UPDATE_SELECTION);
250 std::cout<<"****** Event "<<theMessage->eventID().eventText()<<std::endl;
252 // check the automatic update flag on any event
253 bool aNewAutomaticState = ModelAPI_Session::get()->isAutoUpdateBlocked();
254 if (myUpdateBlocked != aNewAutomaticState) {
255 myUpdateBlocked = aNewAutomaticState;
256 if (!myUpdateBlocked) { // process all modified features, even if preview is blocked
257 bool aPreviewBlockedState = myIsPreviewBlocked; // to update the selected arguments
258 myIsPreviewBlocked = false;
259 // iterate everything and add features in state "MustBeUpdated" into modified
260 std::list<std::shared_ptr<ModelAPI_Document> > allDocs =
261 ModelAPI_Session::get()->allOpenedDocuments();
262 std::list<std::shared_ptr<ModelAPI_Document> >::iterator aDoc = allDocs.begin();
263 for(; aDoc != allDocs.end(); aDoc++) {
264 std::list<std::shared_ptr<ModelAPI_Feature> > allFeats = (*aDoc)->allFeatures();
265 std::list<std::shared_ptr<ModelAPI_Feature> >::iterator aFeat = allFeats.begin();
266 for(; aFeat != allFeats.end(); aFeat++) {
267 if ((*aFeat)->data()->isValid() &&
268 (*aFeat)->data()->execState() == ModelAPI_StateMustBeUpdated) {
269 addModified(*aFeat, FeaturePtr());
274 myIsPreviewBlocked = aPreviewBlockedState;
278 if (theMessage->eventID() == kStabilityEvent) {
279 updateStability(theMessage->sender());
282 if (theMessage->eventID() == kPreviewBlockedEvent) {
283 myIsPreviewBlocked = true;
286 if (theMessage->eventID() == kPreviewRequestedEvent) {
287 if (myIsPreviewBlocked) {
288 bool anUpdateState = myUpdateBlocked;
289 myUpdateBlocked = false;
290 myIsPreviewBlocked = false;
292 myIsPreviewBlocked = true;
293 myUpdateBlocked = anUpdateState;
297 if (theMessage->eventID() == kUpdatedSel) {
298 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
299 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
300 updateSelection(aMsg->objects());
302 // creation is added to "update" to avoid recomputation twice:
303 // on create and immediately after on update
304 if (theMessage->eventID() == kCreatedEvent) {
305 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
306 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
307 const std::set<ObjectPtr>& anObjs = aMsg->objects();
308 std::set<ObjectPtr>::const_iterator anObjIter = anObjs.cbegin();
309 std::list<ObjectPtr> aFeatures, aResults;
310 for(; anObjIter != anObjs.cend(); anObjIter++) {
311 if (std::dynamic_pointer_cast<Model_Document>((*anObjIter)->document())->executeFeatures()) {
312 if ((*anObjIter)->groupName() == ModelAPI_Feature::group()) {
313 // results creation means enabling, not update
314 aFeatures.push_back(*anObjIter);
316 aResults.push_back(*anObjIter);
317 ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*anObjIter);
318 if (aPart.get() && aPart->data().get() && aPart->data()->isValid()) {
319 aPart->shape(); // to update the shape on creation of the result
324 ModelAPI_EventCreator::get()->sendUpdated(aFeatures, kUpdatedEvent);
325 ModelAPI_EventCreator::get()->sendUpdated(aResults, kRedisplayEvent);
328 if (theMessage->eventID() == kUpdatedEvent) {
329 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
330 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
331 const std::set<ObjectPtr>& anObjs = aMsg->objects();
332 std::set<ObjectPtr>::const_iterator anObjIter = anObjs.cbegin();
333 bool aSomeModified = false; // check that features not changed: only redisplay is needed
334 for(; anObjIter != anObjs.cend(); anObjIter++) {
335 if (!(*anObjIter)->data()->isValid())
338 std::wcout<<L">>> in event updated "<<Locale::Convert::toWString((*anObjIter)->groupName())
339 <<L" "<<(*anObjIter)->data()->name()<<std::endl;
341 if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) {
342 myIsParamUpdated = true;
344 // on undo/redo, abort do not update persistent features
345 FeaturePtr anUpdated = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
346 if (anUpdated.get()) {
347 if (addModified(anUpdated, FeaturePtr()))
348 aSomeModified = true;
350 // process the updated result as update of features that refers to this result
351 const std::set<std::shared_ptr<ModelAPI_Attribute> >&
352 aRefs = (*anObjIter)->data()->refsToMe();
353 std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator aRefIter = aRefs.cbegin();
355 ResultPtr aReasonResult = std::dynamic_pointer_cast<ModelAPI_Result>(*anObjIter);
356 if (aReasonResult.get())
357 aReason = (*anObjIter)->document()->feature(aReasonResult);
358 for(; aRefIter != aRefs.cend(); aRefIter++) {
359 if (!(*aRefIter)->owner()->data()->isValid())
361 anUpdated = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefIter)->owner());
362 if (anUpdated.get()) {
363 if (addModified(anUpdated, aReason))
364 aSomeModified = true;
369 // this event is for solver update, not here, do not react immediately
373 } else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent ||
374 theMessage->eventID() == kOpStartEvent) {
375 myIsPreviewBlocked = false;
377 if (theMessage->eventID() == kOpFinishEvent) {// if update is blocked, skip
379 // add features that wait for finish as modified
380 std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >::
381 iterator aFeature = myProcessOnFinish.begin();
382 for(; aFeature != myProcessOnFinish.end(); aFeature++) {
383 if (aFeature->first->data()->isValid()) {// there may be already removed while wait
384 if (aFeature->second.empty()) {
385 addModified(aFeature->first, FeaturePtr());
388 std::set<std::shared_ptr<ModelAPI_Feature> >::iterator aReasons;
389 for(aReasons = aFeature->second.begin(); aReasons != aFeature->second.end(); aReasons++){
390 addModified(aFeature->first, *aReasons);
396 // processed features must be only on finish, so clear anyway (to avoid re-import on load)
397 myProcessOnFinish.clear();
399 // #2156: current must be sketch, left after the macro execution
400 DocumentPtr anActiveDoc = ModelAPI_Session::get()->activeDocument();
402 if (anActiveDoc.get())
403 aCurrent = anActiveDoc->currentFeature(false);
405 if (!(theMessage->eventID() == kOpStartEvent)) {
406 processFeatures(false);
409 if (anActiveDoc.get() && aCurrent.get() && aCurrent->data()->isValid()) {
410 if (anActiveDoc->currentFeature(false) != aCurrent &&
411 ModelAPI_Tools::compositeOwner(anActiveDoc->currentFeature(false)) == aCurrent)
412 anActiveDoc->setCurrentFeature(aCurrent, false); // #2156 make the current feature back
415 // remove all macros before clearing all created
416 std::set<FeaturePtr>::iterator anUpdatedIter = myWaitForFinish.begin();
417 while(anUpdatedIter != myWaitForFinish.end()) {
418 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anUpdatedIter);
419 if (aFeature.get()) {
420 // remove macro on finish
421 if (aFeature->isMacro()) {
422 aFeature->document()->removeFeature(aFeature);
423 myWaitForFinish.erase(aFeature);
425 // to avoid the map update problems on "remove"
426 if (myWaitForFinish.find(aFeature) == myWaitForFinish.end()) {
427 anUpdatedIter = myWaitForFinish.begin();
435 // the redisplay signal should be flushed in order
436 // to erase the feature presentation in the viewer
437 // if should be done after removeFeature() of document,
438 // by this reason, upper processFeatures() do not perform this flush
439 Events_Loop::loop()->flush(kRedisplayEvent);
441 // in the end of transaction everything is updated, so clear the old objects
442 //myIsParamUpdated = false; // to avoid problems in sprocket.py parameter update
443 myWaitForFinish.clear();
444 } else if (theMessage->eventID() == kReorderEvent) {
445 std::shared_ptr<ModelAPI_OrderUpdatedMessage> aMsg =
446 std::dynamic_pointer_cast<ModelAPI_OrderUpdatedMessage>(theMessage);
447 if (aMsg->reordered().get())
448 addModified(aMsg->reordered(), aMsg->reordered()); // to update all attributes
452 void Model_Update::processFeatures(const bool theFlushRedisplay)
454 // perform update of everything if it is not performed right now or any preview is blocked
455 if (!myIsProcessed && !myIsPreviewBlocked) {
456 myIsProcessed = true;
458 std::cout<<"****** Start processing"<<std::endl;
461 while(!myModified.empty()) {
462 processFeature(myModified.begin()->first);
464 myIsProcessed = false;
466 // to update the object browser if something is updated/created during executions
467 static Events_Loop* aLoop = Events_Loop::loop();
468 static const Events_ID kCreatedEvent= aLoop->eventByName(EVENT_OBJECT_CREATED);
469 aLoop->flush(kCreatedEvent);
470 static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED);
471 aLoop->flush(kUpdatedEvent);
473 // flush to update display
474 if (theFlushRedisplay) {
475 static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
476 aLoop->flush(EVENT_DISP);
479 std::cout<<"****** End processing"<<std::endl;
485 // collects all the features this feature depends on: reasons
486 static void allReasons(FeaturePtr theFeature, std::set<FeaturePtr>& theReasons) {
487 std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > > aDeps;
488 theFeature->data()->referencesToObjects(aDeps);
489 std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > >::iterator
490 anAttrsIter = aDeps.begin();
491 for(; anAttrsIter != aDeps.end(); anAttrsIter++) {
492 if (theFeature->attribute(anAttrsIter->first)->isArgument()) {
493 std::list<std::shared_ptr<ModelAPI_Object> >::iterator aDepIter = anAttrsIter->second.begin();
494 for(; aDepIter != anAttrsIter->second.end(); aDepIter++) {
495 FeaturePtr aDepFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(*aDepIter);
496 if (!aDepFeat.get()) { // so, it depends on the result and process the feature owner of it
497 ResultPtr aDepRes = std::dynamic_pointer_cast<ModelAPI_Result>(*aDepIter);
499 aDepFeat = (*aDepIter)->document()->feature(aDepRes);
502 if (aDepFeat.get() && aDepFeat->data()->isValid()) {
503 theReasons.insert(aDepFeat);
508 if (theFeature->getKind() == "Part") {
509 // part is not depended on its subs directly, but subs must be iterated anyway
510 CompositeFeaturePtr aPart = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
511 int aNum = aPart->numberOfSubs();
512 for(int a = 0; a < aNum; a++) {
513 FeaturePtr aSub = aPart->subFeature(a);
514 if (aSub.get() && aSub->data()->isValid()) {
515 theReasons.insert(aSub);
521 bool Model_Update::processFeature(FeaturePtr theFeature)
523 static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
525 if (!theFeature->data()->isValid()) { // deleted feature, just remove from all containers
526 if (myModified.find(theFeature) != myModified.end())
527 myModified.erase(theFeature);
531 if (theFeature->isPersistentResult()) {
532 if (!std::dynamic_pointer_cast<Model_Document>((theFeature)->document())->executeFeatures())
536 // check this feature is not yet checked or processed
537 bool aIsModified = myModified.find(theFeature) != myModified.end();
538 if (!aIsModified && myIsFinish) { // get info about the modification for features without preview
539 if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated) {
541 std::set<std::shared_ptr<ModelAPI_Feature> > aNewSet;
542 // contains itself, so, we don't know which was the reason and the reason is any
543 aNewSet.insert(theFeature);
544 myModified[theFeature] = aNewSet;
548 if (myProcessed.find(theFeature) == myProcessed.end()) {
549 myProcessed[theFeature] = 0;
550 } else if (aIsModified) {
551 int aCount = myProcessed[theFeature];
553 // too many repetition of processing (in VS it may crash on 330 with stack overflow)
554 Events_InfoMessage("Model_Update",
555 "Feature '%1' is updated in infinitive loop").arg(theFeature->data()->name()).send();
560 myProcessed[theFeature] = aCount + 1;
564 std::wcout<<L"* Process feature "<<theFeature->name()<<std::endl;
567 // update the sketch plane before the sketch sub-elements are recomputed
568 // (otherwise sketch will update plane, modify subs, after executed, but with old subs edges)
569 if (aIsModified && theFeature->getKind() == "Sketch") {
571 std::wcout << L"****** Update sketch args " << theFeature->name() << std::endl;
573 AttributeSelectionPtr anExtSel = theFeature->selection("External");
574 if (anExtSel.get()) {
575 ResultPtr aContext = anExtSel->context();
576 if (aContext.get() && aContext->document().get()) {
577 FeaturePtr anExtBase = aContext->document()->feature(aContext);
578 if (anExtBase.get()) {
579 processFeature(anExtBase);
581 std::shared_ptr<GeomDataAPI_Point> anOrigin =
582 std::dynamic_pointer_cast<GeomDataAPI_Point>(theFeature->attribute("Origin"));
583 double anOX = anOrigin->x(), anOY = anOrigin->y(), anOZ = anOrigin->z();
584 std::shared_ptr<GeomDataAPI_Dir> aDir =
585 std::dynamic_pointer_cast<GeomDataAPI_Dir>(theFeature->attribute("DirX"));
586 double aDX = aDir->x(), aDY = aDir->y(), aDZ = aDir->z();
587 std::shared_ptr<GeomDataAPI_Dir> aNorm =
588 std::dynamic_pointer_cast<GeomDataAPI_Dir>(theFeature->attribute("Norm"));
589 double aNX = aNorm->x(), aNY = aNorm->y(), aNZ = aNorm->z();
590 // update sketch plane
591 updateArguments(theFeature);
592 theFeature->attributeChanged("External"); // to recompute origin, direction and normal
593 // check it is updated, so all must be changed
594 if (anOrigin->x() != anOX || anOrigin->y() != anOY || anOrigin->z() != anOZ ||
595 aDir->x() != aDX || aDir->y() != aDY || aDir->z() != aDZ ||
596 aNorm->x() != aNX || aNorm->y() != aNY || aNorm->z() != aNZ)
598 std::set<FeaturePtr> aWholeR;
599 allReasons(theFeature, aWholeR);
600 std::set<FeaturePtr>::iterator aRIter = aWholeR.begin();
601 for (; aRIter != aWholeR.end(); aRIter++) {
602 if ((*aRIter)->data()->selection("External").get())
603 (*aRIter)->attributeChanged("External");
610 if (!aIsModified) { // no modification is needed
614 // evaluate parameter before the sub-elements update:
615 // it updates dependencies on evaluation (#1085)
616 if (theFeature->getKind() == "Parameter") {
617 theFeature->execute();
620 bool isReferencedInvalid = false;
621 // check all features this feature depended on (recursive call of updateFeature)
622 std::set<FeaturePtr>& aReasons = myModified[theFeature];
623 bool allSubsUsed = aReasons.find(theFeature) != aReasons.end();
625 // add all subs in aReasons and temporary remove "theFeature" to avoid processing itself
626 allReasons(theFeature, aReasons);
627 aReasons.erase(theFeature);
629 // take reasons one by one (they may be added during the feature process
630 // (circle by the radius of sketch)
631 std::set<FeaturePtr> aProcessedReasons;
632 while(!aReasons.empty()) {
633 FeaturePtr aReason = *(aReasons.begin());
635 //cout<<theFeature->name()<<" process next reason "<<aReason->name()<<endl;
637 if (aReason != theFeature && (aReason)->data()->isValid()) {
638 if (processFeature(aReason))
640 // check validity of aReason once again because it may be removed by dependent feature
641 // (e.g. by SketchPlugin_IntersectionPoint)
642 if (!aReason->data()->isValid() ||
643 aReason->data()->execState() == ModelAPI_StateInvalidArgument)
644 isReferencedInvalid = true;
646 // searching for the next not used reason
647 aProcessedReasons.insert(aReason);
648 // check theFeature is still in the list of modified, because it may be removed sometimes
649 // while updating SketchPlugin_Ellipse
650 if (myModified.find(theFeature) != myModified.end())
651 aReasons.erase(aReason);
655 // restore the modified reasons: they will be used in the update of arguments
656 if (allSubsUsed) { // restore theFeature in this set
657 aProcessedReasons.insert(theFeature);
659 myModified[theFeature] = aProcessedReasons;
661 // do not execute the composite that contains the current
662 bool isPostponedMain = false;
663 CompositeFeaturePtr aCompos = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
664 if (theFeature->getKind() == "ExtrusionSketch" && aCompos.get()) {
665 CompositeFeaturePtr aCurrentOwner =
666 ModelAPI_Tools::compositeOwner(theFeature->document()->currentFeature(false));
667 isPostponedMain = aCurrentOwner.get() && aCompos->isSub(aCurrentOwner);
668 } else if (theFeature->getKind() == "Sketch" &&
669 std::dynamic_pointer_cast<Model_Document>((theFeature)->document())->executeFeatures()) {
670 // send event that sketch is prepared to be recomputed
671 static Events_ID anID = Events_Loop::eventByName("SketchPrepared");
672 std::shared_ptr<Events_Message> aMsg(new Events_Message(anID, this));
673 Events_Loop* aLoop = Events_Loop::loop();
674 // in case it is finish operation, flush for the sketch other events (#2450)
675 aLoop->flush(aLoop->eventByName(EVENT_OBJECT_UPDATED));
677 // check that sub-elements of sketch are updated => sketch must be re-processed
678 std::set<FeaturePtr> aWholeR;
679 allReasons(theFeature, aWholeR);
680 std::set<FeaturePtr>::iterator aRIter = aWholeR.begin();
681 for(; aRIter != aWholeR.end(); aRIter++) {
682 if (myModified.find(*aRIter) != myModified.end()) {
683 processFeature(theFeature);
690 std::wcout<<L"Update args "<<theFeature->name()<<std::endl;
692 // TestImport.py : after arguments are updated, theFeature may be removed
693 if (!theFeature->data()->isValid())
695 // Update selection and parameters attributes first, before sub-features analysis (sketch plane).
696 updateArguments(theFeature);
698 // add this feature to the processed right now to be able remove it from this list on
699 // update signal during this feature execution
700 myModified.erase(theFeature);
701 if (myNotPersistentRefs.find(theFeature) != myNotPersistentRefs.end())
702 myNotPersistentRefs.erase(theFeature);
703 if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated)
704 theFeature->data()->execState(ModelAPI_StateDone);
706 // this checking must be after the composite feature sub-elements processing:
707 // composite feature status may depend on it's sub-elements
708 if ((theFeature->data()->execState() == ModelAPI_StateInvalidArgument || isReferencedInvalid) &&
709 theFeature->getKind() != "Part") {
710 // don't disable Part because it will make disabled all the features
711 // (performance and problems with the current feature)
713 std::wcout<<L"Invalid args "<<theFeature->name()<<std::endl;
715 theFeature->eraseResults(false);
716 redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
717 return true; // so, feature is modified (results are erased)
720 // execute feature if it must be updated
721 ModelAPI_ExecState aState = theFeature->data()->execState();
722 if (aFactory->validate(theFeature)) {
723 if (!isPostponedMain) {
724 bool aDoExecute = true;
725 if (myUpdateBlocked) {
726 if (!theFeature->isStable() || (theFeature->getKind().size() > 6 &&
727 theFeature->getKind().substr(0, 6) == "Sketch")) { // automatic update sketch elements
729 } else if (theFeature->results().size()) { // execute only not persistent results features
730 aDoExecute = !theFeature->isPersistentResult();
732 aDoExecute = aState != ModelAPI_StateInvalidArgument;
736 executeFeature(theFeature);
738 // store information that this feature must be executed later
739 theFeature->data()->execState(ModelAPI_StateMustBeUpdated);
744 std::wcout<<L"Feature is not valid, erase results "<<theFeature->name()<<std::endl;
746 theFeature->eraseResults(false);
747 redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
752 void Model_Update::redisplayWithResults(
753 FeaturePtr theFeature, const ModelAPI_ExecState theState, bool theUpdateState)
755 // make updated and redisplay all results
756 static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
758 std::list<ResultPtr> allResults;
759 ModelAPI_Tools::allResults(theFeature, allResults);
760 std::list<ResultPtr>::iterator aRIter = allResults.begin();
761 for (; aRIter != allResults.cend(); aRIter++) {
762 std::shared_ptr<ModelAPI_Result> aRes = *aRIter;
763 if (!aRes->isDisabled()) {
764 // update state only for enabled results
765 // (Placement Result Part may make the original Part Result as invalid)
767 aRes->data()->execState(theState);
769 if (theFeature->data()->updateID() > aRes->data()->updateID()) {
770 aRes->data()->setUpdateID(theFeature->data()->updateID());
772 ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
774 // to redisplay "presentable" feature (for ex. distance constraint)
775 ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
777 theFeature->data()->execState(theState);
780 /// Updates the state by the referenced object: if something bad with it, set state for this one
781 ModelAPI_ExecState stateByReference(ObjectPtr theTarget, const ModelAPI_ExecState theCurrent)
784 ModelAPI_ExecState aRefState = theTarget->data()->execState();
785 if (aRefState == ModelAPI_StateMustBeUpdated) {
786 if (theCurrent == ModelAPI_StateDone)
787 return ModelAPI_StateMustBeUpdated;
788 } else if (aRefState != ModelAPI_StateDone) {
789 return ModelAPI_StateInvalidArgument;
795 void Model_Update::updateArguments(FeaturePtr theFeature) {
796 // perform this method also for disabled features: to make "not done" state for
797 // features referenced to the active and modified features
798 static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
800 ModelAPI_ExecState aState = theFeature->data()->execState();
801 if (aState == ModelAPI_StateExecFailed) { // try again failed feature: issue 577
802 aState = ModelAPI_StateMustBeUpdated;
804 if (aState == ModelAPI_StateInvalidArgument) // a chance to be corrected
805 aState = ModelAPI_StateMustBeUpdated;
806 // check the parameters state
809 std::list<AttributePtr> anAttrinbutes =
810 theFeature->data()->attributes(ModelAPI_AttributeInteger::typeId());
811 std::list<AttributePtr>::iterator anIter = anAttrinbutes.begin();
812 for(; anIter != anAttrinbutes.end(); anIter++) {
813 AttributeIntegerPtr anAttribute =
814 std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(*anIter);
815 if (anAttribute.get() && !anAttribute->text().empty()) {
816 if (myIsParamUpdated) {
817 ModelAPI_AttributeEvalMessage::send(anAttribute, this);
819 if (anAttribute->expressionInvalid()) {
820 aState = ModelAPI_StateInvalidArgument;
827 std::list<AttributePtr> aDoubles =
828 theFeature->data()->attributes(ModelAPI_AttributeDouble::typeId());
829 std::list<AttributePtr>::iterator aDoubleIter = aDoubles.begin();
830 for(; aDoubleIter != aDoubles.end(); aDoubleIter++) {
831 AttributeDoublePtr aDouble =
832 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(*aDoubleIter);
833 if (aDouble.get() && !aDouble->text().empty()) {
834 if (myIsParamUpdated) {
835 ModelAPI_AttributeEvalMessage::send(aDouble, this);
837 if (aDouble->expressionInvalid()) {
838 aState = ModelAPI_StateInvalidArgument;
845 std::list<AttributePtr> anAttributes =
846 theFeature->data()->attributes(GeomDataAPI_Point::typeId());
847 std::list<AttributePtr>::iterator anIter = anAttributes.begin();
848 for(; anIter != anAttributes.end(); anIter++) {
849 AttributePointPtr aPointAttribute =
850 std::dynamic_pointer_cast<GeomDataAPI_Point>(*anIter);
851 if (aPointAttribute.get() && (!aPointAttribute->textX().empty() ||
852 !aPointAttribute->textY().empty() || !aPointAttribute->textZ().empty())) {
853 if (myIsParamUpdated) {
854 ModelAPI_AttributeEvalMessage::send(aPointAttribute, this);
856 if ((!aPointAttribute->textX().empty() && aPointAttribute->expressionInvalid(0)) ||
857 (!aPointAttribute->textY().empty() && aPointAttribute->expressionInvalid(1)) ||
858 (!aPointAttribute->textZ().empty() && aPointAttribute->expressionInvalid(2)))
859 aState = ModelAPI_StateInvalidArgument;
865 std::list<AttributePtr> anAttributes =
866 theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
867 std::list<AttributePtr>::iterator anIter = anAttributes.begin();
868 for(; anIter != anAttributes.end(); anIter++) {
869 AttributePoint2DPtr aPoint2DAttribute =
870 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
871 if (aPoint2DAttribute.get()) {
872 if (myIsParamUpdated && (!aPoint2DAttribute->textX().empty() ||
873 !aPoint2DAttribute->textY().empty())) {
874 ModelAPI_AttributeEvalMessage::send(aPoint2DAttribute, this);
876 if ((!aPoint2DAttribute->textX().empty() && aPoint2DAttribute->expressionInvalid(0)) ||
877 (!aPoint2DAttribute->textY().empty() && aPoint2DAttribute->expressionInvalid(1)))
878 aState = ModelAPI_StateInvalidArgument;
882 // update the selection attributes if any
883 std::list<AttributePtr> aRefs =
884 theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
885 std::list<AttributePtr>::iterator aRefsIter = aRefs.begin();
886 for (; aRefsIter != aRefs.end(); aRefsIter++) {
887 std::shared_ptr<ModelAPI_AttributeSelection> aSel =
888 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
889 ObjectPtr aContext = aSel->context();
890 // update argument only if the referenced object is ready to use
891 if (aContext.get() && !aContext->isDisabled()) {
892 if (isReason(theFeature, aContext)) {
893 if (!aSel->update()) { // this must be done on execution since it may be long operation
894 bool isObligatory = !aFactory->isNotObligatory(
895 theFeature->getKind(), theFeature->data()->id(aSel)) &&
896 aFactory->isCase(theFeature, theFeature->data()->id(aSel));
898 // #24260 : sketch plane was selected, but selection becomes wrong, make it invalid
899 (theFeature->getKind() == "Sketch" && aSel->id() == "External"))
900 aState = ModelAPI_StateInvalidArgument;
903 } else if (aContext.get()) {
904 // here it may be not obligatory, but if the reference is wrong, it should not be correct
905 bool isObligatory = aFactory->isCase(theFeature, theFeature->data()->id(aSel));
907 aState = ModelAPI_StateInvalidArgument;
908 } else if (theFeature->getKind() == "Sketch" && aSel->id() == "External" &&
909 aSel->isInitialized()) {
910 // #19703 : if sketch plane was selected, but after context disappears, it must become invalid
912 if (aSel->isInvalid()) {
913 aState = ModelAPI_StateInvalidArgument;
917 // update the selection list attributes if any
918 aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
919 for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
920 std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
921 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
922 // #19071 : avoid sending of update event in cycle
923 bool aWasBlocked = theFeature->data()->blockSendAttributeUpdated(true);
924 // list to keep the shared pointers while update is blocked (in messages raw poiters are used)
925 std::list<AttributeSelectionPtr> anAttrList;
926 for(int a = aSel->size() - 1; a >= 0; a--) {
927 std::shared_ptr<ModelAPI_AttributeSelection> aSelAttr =
928 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aSel->value(a));
930 ObjectPtr aContext = aSelAttr->context();
931 // update argument only if the referenced object is ready to use
932 if (aContext.get() && !aContext->isDisabled()) {
933 if (isReason(theFeature, aContext)) {
934 anAttrList.push_back(aSelAttr);
935 if (!aSelAttr->update()) {
936 bool isObligatory = !aFactory->isNotObligatory(
937 theFeature->getKind(), theFeature->data()->id(aSel)) &&
938 aFactory->isCase(theFeature, theFeature->data()->id(aSel));
940 aState = ModelAPI_StateInvalidArgument;
943 } else if (aContext.get()) {
944 // here it may be not obligatory, but if the reference is wrong, it should not be correct
945 bool isObligatory = aFactory->isCase(theFeature, theFeature->data()->id(aSel));
947 aState = ModelAPI_StateInvalidArgument;
952 theFeature->data()->blockSendAttributeUpdated(false);
955 if (aState != ModelAPI_StateDone)
956 theFeature->data()->execState(aState);
959 bool Model_Update::isReason(std::shared_ptr<ModelAPI_Feature>& theFeature,
960 std::shared_ptr<ModelAPI_Object> theReason)
962 std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
963 ::iterator aReasonsIt = myModified.find(theFeature);
964 if (aReasonsIt != myModified.end()) {
965 if (aReasonsIt->second.find(theFeature) != aReasonsIt->second.end())
966 return true; // any is reason if it contains itself
967 FeaturePtr aReasFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(theReason);
968 if (!aReasFeat.get()) { // try to get feature of this result
969 ResultPtr aReasRes = std::dynamic_pointer_cast<ModelAPI_Result>(theReason);
971 aReasFeat = theReason->document()->feature(aReasRes);
973 if (aReasonsIt->second.find(aReasFeat) != aReasonsIt->second.end())
976 // another try: postponed modification by not-persistences
977 std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
978 ::iterator aNotPersist = myNotPersistentRefs.find(theFeature);
979 if (aNotPersist != myNotPersistentRefs.end()) {
980 FeaturePtr aReasFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(theReason);
981 if (!aReasFeat.get()) { // try to get feature of this result
982 ResultPtr aReasRes = std::dynamic_pointer_cast<ModelAPI_Result>(theReason);
984 aReasFeat = theReason->document()->feature(aReasRes);
986 if (aNotPersist->second.find(aReasFeat) != aNotPersist->second.end())
990 // this case only for not-previewed items update state, nothing is changed in args for it
994 void Model_Update::executeFeature(FeaturePtr theFeature)
997 std::wcout<<L"Execute Feature "<<theFeature->name()<<std::endl;
999 // execute in try-catch to avoid internal problems of the feature
1000 ModelAPI_ExecState aState = ModelAPI_StateDone;
1001 theFeature->data()->execState(ModelAPI_StateDone);
1003 theFeature->execute();
1004 if (theFeature->data()->execState() != ModelAPI_StateDone) {
1005 aState = ModelAPI_StateExecFailed;
1007 aState = ModelAPI_StateDone;
1010 aState = ModelAPI_StateExecFailed;
1011 Events_InfoMessage("Model_Update",
1012 "Feature %1 has failed during the execution").arg(theFeature->getKind()).send();
1014 // The macro feature has to be deleted in any case even its execution is failed
1015 myWaitForFinish.insert(theFeature);
1016 if (aState != ModelAPI_StateDone) {
1017 theFeature->eraseResults(false);
1019 theFeature->data()->setUpdateID(ModelAPI_Session::get()->transactionID());
1020 redisplayWithResults(theFeature, aState);
1023 // it is called on GUI edit of feature start
1025 void Model_Update::updateStability(void* theSender)
1027 static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
1029 bool added = false; // object may be was crated
1030 ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theSender);
1031 if (aSender && aSender->document()) {
1032 FeaturePtr aFeatureSender =
1033 std::dynamic_pointer_cast<ModelAPI_Feature>(aSender->data()->owner());
1034 if (aFeatureSender.get()) {
1035 Model_Objects* aDocObjects =
1036 std::dynamic_pointer_cast<Model_Document>(aSender->document())->objects();
1038 //aDocObjects->synchronizeBackRefs();
1039 // remove or add all concealment refs from this feature
1040 std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
1041 aSender->data()->referencesToObjects(aRefs);
1042 std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator
1043 aRefIt = aRefs.begin();
1044 for(; aRefIt != aRefs.end(); aRefIt++) {
1045 if (!aFactory->isConcealed(aFeatureSender->getKind(), aRefIt->first))
1046 // take into account only concealed references
1047 // (do not remove the sketch constraint and the edge on constraint edit)
1049 std::list<ObjectPtr>& aRefFeaturesList = aRefIt->second;
1050 std::list<ObjectPtr>::iterator aReferenced = aRefFeaturesList.begin();
1051 for(; aReferenced != aRefFeaturesList.end(); aReferenced++) {
1052 // stability is only on results: feature to feature reference mean nested
1053 // features, that will remove nesting references
1054 if (aReferenced->get() && (*aReferenced)->data()->isValid() &&
1055 (*aReferenced)->groupName() != ModelAPI_Feature::group()) {
1056 std::shared_ptr<Model_Data> aData =
1057 std::dynamic_pointer_cast<Model_Data>((*aReferenced)->data());
1058 if (aFeatureSender->isStable()) {
1059 aData->addBackReference(aFeatureSender, aRefIt->first);
1061 aData->removeBackReference(aFeatureSender, aRefIt->first);
1062 added = true; // remove of concealment may be caused creation of some result
1071 static Events_Loop* aLoop = Events_Loop::loop();
1072 static Events_ID kEventCreated = aLoop->eventByName(EVENT_OBJECT_CREATED);
1073 aLoop->flush(kEventCreated);
1079 void Model_Update::updateSelection(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects)
1081 std::set<std::shared_ptr<ModelAPI_Object> >::iterator anObj = theObjects.begin();
1082 for(; anObj != theObjects.end(); anObj++) {
1083 std::list<AttributePtr> aRefs =
1084 (*anObj)->data()->attributes(ModelAPI_AttributeSelection::typeId());
1085 std::list<AttributePtr>::iterator aRefsIter = aRefs.begin();
1086 for (; aRefsIter != aRefs.end(); aRefsIter++) {
1087 AttributeSelectionPtr aSel =
1088 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
1089 bool aRemove = false;
1090 aSel->updateInHistory(aRemove);
1092 // update the selection list attributes if any
1093 aRefs = (*anObj)->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
1094 for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
1095 std::set<int> aRemoveSet;
1096 std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
1097 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
1098 for(int a = aSel->size() - 1; a >= 0; a--) {
1099 AttributeSelectionPtr aSelAttr =
1100 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aSel->value(a));
1101 if (aSelAttr.get()) {
1102 bool aRemove = false;
1103 aSelAttr->updateInHistory(aRemove);
1105 aRemoveSet.insert(a);
1109 aSel->remove(aRemoveSet);