From: nds Date: Thu, 26 Mar 2015 08:10:59 +0000 (+0300) Subject: Union of validator and filter functionalities. X-Git-Tag: V_1.1.0~80^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6d0f6cf0ef745f17dbac17c01e20e94292a80ec3;p=modules%2Fshaper.git Union of validator and filter functionalities. 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 --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 9133794ae..f8be8ab4d 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -117,7 +117,8 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext, selectConstruction(theContext, theSubShape); } } - myIsInitialized = true; + //the attribute initialized state should be changed by sendAttributeUpdated only + //myIsInitialized = true; std::string aSelName = namingName(); if(!aSelName.empty()) diff --git a/src/ModelAPI/ModelAPI_Attribute.cpp b/src/ModelAPI/ModelAPI_Attribute.cpp index 249353c54..e7553a05d 100644 --- a/src/ModelAPI/ModelAPI_Attribute.cpp +++ b/src/ModelAPI/ModelAPI_Attribute.cpp @@ -30,7 +30,17 @@ bool ModelAPI_Attribute::isInitialized() 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) @@ -62,6 +72,7 @@ const std::string& ModelAPI_Attribute::id() const ModelAPI_Attribute::ModelAPI_Attribute() { + mySetInitializedBlocked = false; myIsInitialized = false; myIsArgument = true; myIsImmutable = false; diff --git a/src/ModelAPI/ModelAPI_Attribute.h b/src/ModelAPI/ModelAPI_Attribute.h index 179fbae2f..1892b77bc 100644 --- a/src/ModelAPI/ModelAPI_Attribute.h +++ b/src/ModelAPI/ModelAPI_Attribute.h @@ -25,6 +25,7 @@ class ModelAPI_Attribute 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) @@ -48,6 +49,11 @@ class ModelAPI_Attribute /// 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); diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 2dd78afc6..e7285ab15 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -41,7 +41,12 @@ bool ModuleBase_WidgetValidated::setSelection(ModuleBase_ViewerPrs theValue) //******************************************************************** 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 @@ -52,6 +57,8 @@ bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& the // restores the current values of the widget attribute restoreAttributeValue(aValid); + aData->blockSendAttributeUpdated(false); + anAttribute->blockSetInitialized(isAttributeBlocked); return aValid; } @@ -68,9 +75,6 @@ bool ModuleBase_WidgetValidated::isValidAttribute() const DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); - aData->blockSendAttributeUpdated(true); - - // 3. check the acceptability of the current values std::list::iterator aValidator = aValidators.begin(); std::list >::iterator aArgs = anArguments.begin(); bool aValid = true; @@ -81,8 +85,6 @@ bool ModuleBase_WidgetValidated::isValidAttribute() const aValid = aAttrValidator->isValid(anAttribute, *aArgs); } } - aData->blockSendAttributeUpdated(false); - return aValid; }