From: mpv Date: Mon, 25 May 2015 09:09:12 +0000 (+0300) Subject: Correctly manage the invalid expressions X-Git-Tag: V_1.2.0~100 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=16d1695b03bd17ebf4ba4a26e41956d1dd7a89d8;p=modules%2Fshaper.git Correctly manage the invalid expressions --- diff --git a/src/Model/Model_AttributeDouble.cpp b/src/Model/Model_AttributeDouble.cpp index 29ca7be4e..c65748dee 100644 --- a/src/Model/Model_AttributeDouble.cpp +++ b/src/Model/Model_AttributeDouble.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace std; @@ -52,3 +53,19 @@ string Model_AttributeDouble::text() { return TCollection_AsciiString(myText->Get()).ToCString(); } + +Standard_GUID kInvalidGUID("caee5ce4-34b1-4b29-abcb-685287d18096"); + +void Model_AttributeDouble::setExpressionInvalid(const bool theFlag) +{ + if (theFlag) { + TDataStd_UAttribute::Set(myReal->Label(), kInvalidGUID); + } else { + myReal->Label().ForgetAttribute(kInvalidGUID); + } +} + +bool Model_AttributeDouble::expressionInvalid() +{ + return myReal->Label().IsAttribute(kInvalidGUID); +} diff --git a/src/Model/Model_AttributeDouble.h b/src/Model/Model_AttributeDouble.h index 951c99613..6c9999365 100644 --- a/src/Model/Model_AttributeDouble.h +++ b/src/Model/Model_AttributeDouble.h @@ -36,6 +36,12 @@ class Model_AttributeDouble : public ModelAPI_AttributeDouble /// Returns the double value MODEL_EXPORT virtual std::string text(); + /// Allows to set expression (text) as invalid (by the parameters listener) + MODEL_EXPORT virtual void setExpressionInvalid(const bool theFlag); + + /// Returns true if text is invalid + MODEL_EXPORT virtual bool expressionInvalid(); + protected: /// Initializes attibutes Model_AttributeDouble(TDF_Label& theLabel); diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 90e577c05..5b379c982 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -703,7 +703,9 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr if (anIter == theCurrent) aPassed = true; bool aDisabledFlag = !aPassed; - if (aMain.get() && aMain->isSub(anIter)) + if (aMain.get() && aMain->isSub(anIter)) // sub-elements of not-disabled feature are not disabled + aDisabledFlag = false; + if (anIter->getKind() == "Parameter") // parameters are always out of the history aDisabledFlag = false; if (anIter->setDisabled(aDisabledFlag)) { // state of feature is changed => so feature become updated diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 8eae85c93..be69043e9 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -260,27 +260,17 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { ModelAPI_ExecState aState = theFeature->data()->execState(); if (aState == ModelAPI_StateInvalidArgument) // a chance to be corrected aState = ModelAPI_StateMustBeUpdated; - // check the parameters: values can be changed - /* parameters evaluator now does this + // check the parameters state std::list aDoubles = theFeature->data()->attributes(ModelAPI_AttributeDouble::typeId()); std::list::iterator aDoubleIter = aDoubles.begin(); for(; aDoubleIter != aDoubles.end(); aDoubleIter++) { AttributeDoublePtr aDouble = std::dynamic_pointer_cast(*aDoubleIter); - if (aDouble.get() && !aDouble->text().empty()) { - double aNewVal; - if (ModelAPI_Tools::findVariable(aDouble->text(), aNewVal)) { - if (aNewVal != aDouble->value()) { - aDouble->setValue(aNewVal); - aJustUpdated = true; - } - } else { - aState = ModelAPI_StateInvalidArgument; - } + if (aDouble.get() && aDouble->expressionInvalid()) { + aState = ModelAPI_StateInvalidArgument; } } - */ //if (aState == ModelAPI_StateDone) {// all referenced objects are ready to be used //std::cout<<"Execute feature "<getKind()<text(), anError); if (anError.empty()) { aDoubleAttribute->setValue(aValue); + aDoubleAttribute->setExpressionInvalid(false); + } else { // set feature as invalid-parameter arguments + aDoubleAttribute->setExpressionInvalid(true); } } } else {