+ }
+ // Point2D
+ {
+ std::list<AttributePtr> anAttributes =
+ theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
+ std::list<AttributePtr>::iterator anIter = anAttributes.begin();
+ for(; anIter != anAttributes.end(); anIter++) {
+ AttributePoint2DPtr aPoint2DAttribute =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
+ if (aPoint2DAttribute.get()) {
+ if (myIsParamUpdated) {
+ ModelAPI_AttributeEvalMessage::send(aPoint2DAttribute, this);
+ }
+ if ((!aPoint2DAttribute->textX().empty() && aPoint2DAttribute->expressionInvalid(0)) ||
+ (!aPoint2DAttribute->textY().empty() && aPoint2DAttribute->expressionInvalid(1)))
+ aState = ModelAPI_StateInvalidArgument;
+ }
+ }
+ }
+
+ //if (aState == ModelAPI_StateDone) {// all referenced objects are ready to be used
+ //std::cout<<"Execute feature "<<theFeature->getKind()<<std::endl;
+ // before execution update the selection attributes if any
+ list<AttributePtr> aRefs =
+ theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
+ list<AttributePtr>::iterator aRefsIter = aRefs.begin();
+ for (; aRefsIter != aRefs.end(); aRefsIter++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> aSel =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
+ ObjectPtr aContext = aSel->context();
+ // update argument only if the referenced object is changed
+ if (aContext.get() && !aContext->isDisabled()) {
+ bool isObligatory = !aFactory->isNotObligatory(
+ theFeature->getKind(), theFeature->data()->id(aSel)) &&
+ aFactory->isCase(theFeature, theFeature->data()->id(aSel));
+ if (isOlder(theFeature, aContext)) {
+ if (aState == ModelAPI_StateDone)
+ aState = ModelAPI_StateMustBeUpdated;
+ if (!aSel->update()) { // this must be done on execution since it may be long operation
+ if (isObligatory)
+ aState = ModelAPI_StateInvalidArgument;
+ }
+ } else if (aSel->isInvalid()) { // not needed to update, but invalid (stated previously)
+ aState = ModelAPI_StateInvalidArgument;
+ }
+ }
+ }
+ aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
+ for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+ std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
+ for(int a = aSel->size() - 1; a >= 0; a--) {
+ std::shared_ptr<ModelAPI_AttributeSelection> aSelAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aSel->value(a));
+ if (aSelAttr) {
+ ObjectPtr aContext = aSelAttr->context();
+ // update argument onlt if the referenced object is changed
+ if (aContext.get() && !aContext->isDisabled()) {
+ bool isObligatory = !aFactory->isNotObligatory(
+ theFeature->getKind(), theFeature->data()->id(aSel)) &&
+ aFactory->isCase(theFeature, theFeature->data()->id(aSel));
+ if (isOlder(theFeature, aContext)) {
+ if (aState == ModelAPI_StateDone)
+ aState = ModelAPI_StateMustBeUpdated;
+ if (!aSelAttr->update()) {
+ if (isObligatory)
+ aState = ModelAPI_StateInvalidArgument;
+ }
+ } else if (aSelAttr->isInvalid()) {
+ aState = ModelAPI_StateInvalidArgument;
+ }
+ }
+ }
+ }
+ }
+ // check all references: if referenced objects are updated, this object also must be updated
+ // also check state of referenced objects: if they are not ready, inherit corresponding state
+ std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefsObj;
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theFeature->data());
+ aData->referencesToObjects(aRefsObj);
+ std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRef = aRefsObj.begin();
+ for(; aRef != aRefsObj.end(); aRef++) {
+ std::list<ObjectPtr>::iterator aRefObj = aRef->second.begin();
+ for(; aRefObj != aRef->second.end(); aRefObj++) {
+ // if reference is null, it may mean that this reference is to other document
+ // the does not supported by RefList: parameters may be recomputed
+ if (!aRefObj->get() && theFeature->firstResult().get() &&
+ theFeature->firstResult()->groupName() == ModelAPI_ResultParameter::group()) {
+ if (aState == ModelAPI_StateDone)
+ aState = ModelAPI_StateMustBeUpdated;
+ } else if (aRefObj->get() && isOlder(theFeature, *aRefObj)) {
+ if (aState == ModelAPI_StateDone)
+ aState = ModelAPI_StateMustBeUpdated;
+ }
+ aState = stateByReference(*aRefObj, aState);
+ }
+ }
+ // composites sub-elements
+ CompositeFeaturePtr aCompos = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
+ // composite feature must be executed after sub-features execution
+ if (aCompos) {
+ // number of subs can be changed in execution: like fillet
+ int aNumSubs = aCompos->numberOfSubs();
+ for(int a = 0; a < aNumSubs; a++) {
+ FeaturePtr aSub = aCompos->subFeature(a);
+ if (aSub.get() && aState == ModelAPI_StateDone) {
+ if (isOlder(theFeature, aSub)) {
+ aState = ModelAPI_StateMustBeUpdated;
+ }
+ // also check that all results of subs were updated: composite also depends on the results
+ const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aSub->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aResults.begin();
+ for(; aResIter != aResults.end(); aResIter++) {
+ if (aResIter->get() && (*aResIter)->data()->isValid() && !(*aResIter)->isDisabled() &&
+ isOlder(theFeature, *aResIter)) {
+ aState = ModelAPI_StateMustBeUpdated;