Block for set initialized in order to compute distance value after isValid checking. isValid functionality changes the attribute content, but the isInitialized flag should not be modified
selectConstruction(theContext, theSubShape);
}
}
- myIsInitialized = true;
+ //the attribute initialized state should be changed by sendAttributeUpdated only
+ //myIsInitialized = true;
std::string aSelName = namingName();
if(!aSelName.empty())
void ModelAPI_Attribute::setInitialized()
{
- myIsInitialized = true;
+ if (!mySetInitializedBlocked)
+ myIsInitialized = true;
+}
+
+bool ModelAPI_Attribute::blockSetInitialized(const bool theBlock)
+{
+ bool aBlocked = mySetInitializedBlocked;
+
+ mySetInitializedBlocked = theBlock;
+
+ return aBlocked;
}
void ModelAPI_Attribute::setIsArgument(const bool theFlag)
ModelAPI_Attribute::ModelAPI_Attribute()
{
+ mySetInitializedBlocked = false;
myIsInitialized = false;
myIsArgument = true;
myIsImmutable = false;
protected:
// accessible from the attributes
bool myIsInitialized; ///< is some value assigned to this attribute
+ bool mySetInitializedBlocked; ///< is initialized blocked
bool myIsArgument; ///< is this attribute used as an argument for execution
bool myIsImmutable; ///< is this attribute can be changed programmatically (e.g. by constraint)
/// Makes attribute initialized
MODELAPI_EXPORT void setInitialized();
+ /// Blocks sending "attribute updated" if theBlock is true
+ /// \param theBlock a block value
+ /// \return the previous block value
+ MODELAPI_EXPORT bool blockSetInitialized(const bool theBlock);
+
/// Set this attribute is argument for result (change of this attribute requires update of result).
/// By default it is true.
MODELAPI_EXPORT void setIsArgument(const bool theFlag);
//********************************************************************
bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& theOwner)
{
+ DataPtr aData = myFeature->data();
+ AttributePtr anAttribute = myFeature->attribute(attributeID());
+
// stores the current values of the widget attribute
+ aData->blockSendAttributeUpdated(true);
+ bool isAttributeBlocked = anAttribute->blockSetInitialized(true);
storeAttributeValue();
// saves the owner value to the widget attribute
// restores the current values of the widget attribute
restoreAttributeValue(aValid);
+ aData->blockSendAttributeUpdated(false);
+ anAttribute->blockSetInitialized(isAttributeBlocked);
return aValid;
}
DataPtr aData = myFeature->data();
AttributePtr anAttribute = myFeature->attribute(attributeID());
- aData->blockSendAttributeUpdated(true);
-
- // 3. check the acceptability of the current values
std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
bool aValid = true;
aValid = aAttrValidator->isValid(anAttribute, *aArgs);
}
}
- aData->blockSendAttributeUpdated(false);
-
return aValid;
}