Salome HOME
Explicitly call execute for nested features before referring
authorazv <azv@opencascade.com>
Tue, 23 Aug 2016 10:45:46 +0000 (13:45 +0300)
committerazv <azv@opencascade.com>
Tue, 23 Aug 2016 10:45:46 +0000 (13:45 +0300)
src/ConstructionAPI/ConstructionAPI_Point.cpp
src/FeaturesAPI/FeaturesAPI_Boolean.cpp
src/ModelHighAPI/ModelHighAPI_Interface.cpp
src/ModelHighAPI/ModelHighAPI_Interface.h
src/ModelHighAPI/ModelHighAPI_Reference.cpp
src/SketchSolver/SketchSolver_Manager.cpp

index 76be0f73bb2e6fd569af7b999a0fdb50592aafa1..5e9aea6e18b291132bd0aa7dcf2045e498c15d13 100644 (file)
@@ -83,7 +83,7 @@ void ConstructionAPI_Point::setByXYZ(const ModelHighAPI_Double& theX,
   fillAttribute(theY, myy);
   fillAttribute(theZ, myz);
 
-  execute();
+  execute(false);
 }
 
 /*//==================================================================================================
index 062731c89972585ea13c405c912139ac57f46f68..f47eab172fd41fbc0562b6ccca1785bb09c892da 100644 (file)
@@ -30,7 +30,7 @@ FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature>
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
 
-    execute();
+    execute(false);
   }
 }
 
index 401ba5467ed6f5a64f615c07ecb271b77b7dfd7e..cfea20834ff7b433975d54317d79da7f3c02b9ee 100644 (file)
@@ -54,14 +54,15 @@ const std::string& ModelHighAPI_Interface::getKind() const
   return feature()->getKind();
 }
 
-void ModelHighAPI_Interface::execute()
+void ModelHighAPI_Interface::execute(bool isForce)
 {
-  //SessionPtr aMgr = ModelAPI_Session::get();
-  //ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  //FeaturePtr aFeature = feature();
-  //if(aFactory->validate(aFeature)) {
-  //  aFeature->execute();
-  //}
+  if (isForce) {
+    SessionPtr aMgr = ModelAPI_Session::get();
+    ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+    FeaturePtr aFeature = feature();
+    if(aFactory->validate(aFeature))
+      aFeature->execute();
+  }
 
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
index f4c156fb756d7ceaedd30ca7754cfbece4d9cdca..43d267642b495617a8b0c65c34d9f60d09578aa6 100644 (file)
@@ -49,8 +49,9 @@ public:
   const std::string& getKind() const;
 
   /// Shortcut for feature()->execute()
+  /// \param isForce start execution of feature instead of sending events
   MODELHIGHAPI_EXPORT
-  void execute();
+  void execute(bool isForce = false);
 
   /// Shortcut for feature()->data()->setName()
   MODELHIGHAPI_EXPORT
index 20a07f53b12dc9323c034eaf8c4c430bab101590..f427b7e921fe59265c042d29cbd9e38cc50a4eea 100644 (file)
@@ -25,6 +25,11 @@ ModelHighAPI_Reference::ModelHighAPI_Reference(
     const std::shared_ptr<ModelHighAPI_Interface> & theValue)
 : myObject(std::shared_ptr<ModelAPI_Object>(theValue->defaultResult()))
 {
+  // the result is not constructed yet, forcibly do it
+  if (!myObject) {
+    theValue->execute(true);
+    myObject = std::shared_ptr<ModelAPI_Object>(theValue->defaultResult());
+  }
 }
 
 ModelHighAPI_Reference::~ModelHighAPI_Reference()
index 4748424f865e704108d37e2005a6dce2557fda3c..61c0547b08e6c46f2cef8a57854c8dae675cea41 100644 (file)
@@ -279,7 +279,7 @@ bool SketchSolver_Manager::changeWorkplane(CompositeFeaturePtr theSketch)
     }
     myGroups.push_back(aNewGroup);
   }
-  return aResult;
+  return aResult || isUpdated;
 }
 
 // ============================================================================