-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
ModelAPI_Tools::allResults(theFeature, allResults);
std::list<ResultPtr>::iterator aRes = allResults.begin();
for(; aRes != allResults.end(); aRes++) {
- const std::set<std::shared_ptr<ModelAPI_Attribute> >& aRefs = (*aRes)->data()->refsToMe();
- std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator aRefIter = aRefs.cbegin();
- for(; aRefIter != aRefs.cend(); aRefIter++) {
- if ((*aRefIter)->isArgument()) {
- FeaturePtr aReferenced = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefIter)->owner());
+ const std::set<std::shared_ptr<ModelAPI_Attribute> >& aResRefs = (*aRes)->data()->refsToMe();
+ std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator aRIter = aResRefs.cbegin();
+ for(; aRIter != aResRefs.cend(); aRIter++) {
+ if ((*aRIter)->isArgument()) {
+ FeaturePtr aReferenced = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRIter)->owner());
if (aReferenced.get()) {
addModified(aReferenced, theFeature);
}
void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessage)
{
static Events_Loop* aLoop = Events_Loop::loop();
- static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
+ //static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
static const Events_ID kCreatedEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED);
static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
}
}
processFeatures();
- myIsPreviewBlocked = myIsPreviewBlocked;
+ myIsPreviewBlocked = aPreviewBlockedState;
}
}
aFeatures.push_back(*anObjIter);
} else {
aResults.push_back(*anObjIter);
+ ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*anObjIter);
+ if (aPart.get() && aPart->data().get() && aPart->data()->isValid()) {
+ aPart->shape(); // to update the shape on creation of the result
+ }
}
}
}
for(; aRefIter != aRefs.cend(); aRefIter++) {
if (!(*aRefIter)->owner()->data()->isValid())
continue;
- FeaturePtr anUpdated = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefIter)->owner());
+ anUpdated = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefIter)->owner());
if (anUpdated.get()) {
if (addModified(anUpdated, aReason))
aSomeModified = true;
return false;
}
+ // check this feature is not yet checked or processed
+ bool aIsModified = myModified.find(theFeature) != myModified.end();
+ if (!aIsModified && myIsFinish) { // get info about the modification for features without preview
+ if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated) {
+ aIsModified = true;
+ std::set<std::shared_ptr<ModelAPI_Feature> > aNewSet;
+ // contains itself, so, we don't know which was the reason and the reason is any
+ aNewSet.insert(theFeature);
+ myModified[theFeature] = aNewSet;
+ }
+ }
+
if (myProcessed.find(theFeature) == myProcessed.end()) {
myProcessed[theFeature] = 0;
- } else {
+ } else if (aIsModified) {
int aCount = myProcessed[theFeature];
if (aCount > 100) {
// too many repetition of processing (in VS it may crash on 330 with stack overflow)
myProcessed[theFeature] = aCount + 1;
}
- // check this feature is not yet checked or processed
- bool aIsModified = myModified.find(theFeature) != myModified.end();
- if (!aIsModified && myIsFinish) { // get info about the modification for features without preview
- if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated) {
- aIsModified = true;
- std::set<std::shared_ptr<ModelAPI_Feature> > aNewSet;
- // contains itself, so, we don't know which was the reason and the reason is any
- aNewSet.insert(theFeature);
- myModified[theFeature] = aNewSet;
- }
- }
-
#ifdef DEB_UPDATE
std::cout<<"* Process feature "<<theFeature->name()<<std::endl;
#endif
}
// searching for the next not used reason
aProcessedReasons.insert(aReason);
- aReasons.erase(aReason);
+ // check theFeature is still in the list of modified, because it may be removed sometimes
+ // while updating SketchPlugin_Ellipse
+ if (myModified.find(theFeature) != myModified.end())
+ aReasons.erase(aReason);
+ else
+ break;
}
// restore the modified reasons: they will be used in the update of arguments
if (allSubsUsed) { // restore theFeature in this set
if (myUpdateBlocked) {
if (!theFeature->isStable()) {
aDoExecute = true;
- } else if (theFeature->results().size()) { // execute only not-results features
- aDoExecute = !(theFeature->firstResult()->groupName() == ModelAPI_ResultBody::group() ||
- theFeature->firstResult()->groupName() == ModelAPI_ResultPart::group() ||
- theFeature->getKind() == "Sketch");
+ } else if (theFeature->results().size()) { // execute only not persistent results features
+ aDoExecute = !theFeature->isPersistentResult();
} else {
aDoExecute = aState != ModelAPI_StateInvalidArgument;
}
bool isObligatory = aFactory->isCase(theFeature, theFeature->data()->id(aSel));
if (isObligatory)
aState = ModelAPI_StateInvalidArgument;
+ } else if (theFeature->getKind() == "Sketch" && aSel->id() == "External" &&
+ aSel->isInitialized()) {
+ // #19703 : if sketch plane was selected, but after context disappears, it must become invalid
+ aSel->update();
+ if (aSel->isInvalid()) {
+ aState = ModelAPI_StateInvalidArgument;
+ }
}
}
// update the selection list attributes if any
for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
+ // #19071 : avoid sending of update event in cycle
+ bool aWasBlocked = theFeature->data()->blockSendAttributeUpdated(true);
+ // list to keep the shared pointers while update is blocked (in messages raw poiters are used)
+ std::list<AttributeSelectionPtr> anAttrList;
for(int a = aSel->size() - 1; a >= 0; a--) {
std::shared_ptr<ModelAPI_AttributeSelection> aSelAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aSel->value(a));
// update argument only if the referenced object is ready to use
if (aContext.get() && !aContext->isDisabled()) {
if (isReason(theFeature, aContext)) {
+ anAttrList.push_back(aSelAttr);
if (!aSelAttr->update()) {
bool isObligatory = !aFactory->isNotObligatory(
theFeature->getKind(), theFeature->data()->id(aSel)) &&
}
}
}
+ if (!aWasBlocked)
+ theFeature->data()->blockSendAttributeUpdated(false);
}
if (aState != ModelAPI_StateDone)