]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make features parameters arguments updated with update of parameter value
authormpv <mpv@opencascade.com>
Thu, 16 Apr 2015 16:15:27 +0000 (19:15 +0300)
committermpv <mpv@opencascade.com>
Thu, 16 Apr 2015 16:15:27 +0000 (19:15 +0300)
src/Model/Model_AttributeSelection.h
src/Model/Model_Update.cpp

index 22aaf8d9f9b831476ba6d1c63d47701f7570f6b3..b900299de1b8f16fc8e3b22e3e64c68d89e222e8 100644 (file)
@@ -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;
index 142f5c1e12557284b0c4420054f1eb4c42b94dfe..403b3dffc759e217a86476a58ac5d94eeb84a630 100644 (file)
@@ -20,6 +20,7 @@
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_Tools.h>
 #include <Events_Loop.h>
 #include <Events_LongOp.h>
 #include <Events_Error.h>
@@ -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<AttributePtr> aDoubles = 
+      theFeature->data()->attributes(ModelAPI_AttributeDouble::typeId()); 
+    std::list<AttributePtr>::iterator aDoubleIter = aDoubles.begin();
+    for(; aDoubleIter != aDoubles.end(); aDoubleIter++) {
+      AttributeDoublePtr aDouble = 
+        std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(*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<ModelAPI_CompositeFeature>(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<std::pair<std::string, std::list<ObjectPtr> > > aRefs;