From fd0a553162f214858657e9b15626dff84a9531cc Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 16 Apr 2015 19:15:27 +0300 Subject: [PATCH] Make features parameters arguments updated with update of parameter value --- src/Model/Model_AttributeSelection.h | 2 +- src/Model/Model_Update.cpp | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 22aaf8d9f..b900299de 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -72,7 +72,7 @@ protected: TDF_LabelMap& scope(); /// Sets the ID of the attribute in Data (called from Data): here it is used for myRef ID setting - MODELAPI_EXPORT virtual void setID(const std::string theID); + MODEL_EXPORT virtual void setID(const std::string theID); friend class Model_Data; friend class Model_AttributeSelectionList; diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 142f5c1e1..403b3dffc 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -217,6 +218,28 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) if (theFeature->data()->execState() != ModelAPI_StateDone) aMustbeUpdated = true; + ModelAPI_ExecState aState = ModelAPI_StateDone; + + // check the parameters: values can be changed + 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); + aMustbeUpdated = true; + } + } else { + aState = ModelAPI_StateInvalidArgument; + } + } + } + // composite feature must be executed after sub-features execution CompositeFeaturePtr aComposite = std::dynamic_pointer_cast(theFeature); @@ -227,7 +250,6 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) aMustbeUpdated = true; } } - ModelAPI_ExecState aState = ModelAPI_StateDone; // 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 > > aRefs; -- 2.39.2