Salome HOME
Debug of the sketch faces selection in external document
[modules/shaper.git] / src / Model / Model_Objects.cpp
index 70183795c0f94329fc2eb74310a998e5d7ed8e98..9d89e5c64c37a4d9499513f7b80eb0f52840d0b6 100644 (file)
@@ -41,7 +41,6 @@
 #include <TDF_ChildIDIterator.hxx>
 #include <TDataStd_ReferenceArray.hxx>
 #include <TDataStd_HLabelArray1.hxx>
-#include <TDataStd_Name.hxx>
 #include <TDF_Reference.hxx>
 #include <TDF_ChildIDIterator.hxx>
 #include <TDF_LabelMapHasher.hxx>
@@ -364,7 +363,7 @@ void Model_Objects::eraseAllFeatures()
   }
   kCreator->sendDeleted(myDoc, ModelAPI_Feature::group());
   myFeatures.Clear(); // just remove features without modification of DS
-  updateHistory(ModelAPI_Feature::group());
+  myHistory.clear();
 }
 
 void Model_Objects::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
@@ -1840,8 +1839,6 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set<FeaturePtr>& t
     }
   }
 
-  // for not persistent is will be done by parametric updater automatically
-  //if (!theFeature->isPersistentResult()) return;
   // check the existing results and remove them if there is nothing on the label
   std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
   while(aResIter != theFeature->results().cend()) {
@@ -1881,7 +1878,11 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set<FeaturePtr>& t
             // create the part result: it is better to restore the previous result if it is possible
             theFeature->execute();
         } else if (aGroup->Get() == ModelAPI_ResultConstruction::group().c_str()) {
-          theFeature->execute(); // construction shapes are needed for sketch solver
+          ResultConstructionPtr aConstr = createConstruction(theFeature->data(), aResIndex);
+          if (!aConstr->updateShape())
+            theFeature->execute(); // not stored shape in the data structure, execute to have it
+          else
+            theFeature->setResult(aConstr, aResIndex); // result is ready without execution
         } else if (aGroup->Get() == ModelAPI_ResultGroup::group().c_str()) {
           aNewBody = createGroup(theFeature->data(), aResIndex);
         } else if (aGroup->Get() == ModelAPI_ResultField::group().c_str()) {
@@ -1901,9 +1902,16 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set<FeaturePtr>& t
   if (aResSize > 0) { // check there exist a body that must be updated
     std::list<ResultPtr>::const_iterator aRes = theFeature->results().cbegin();
     for (; aResSize && aRes != theFeature->results().cend(); aRes++, aResSize++) {
-      if ((*aRes)->data()->isValid() && (*aRes)->groupName() == ModelAPI_ResultBody::group()) {
-        ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRes);
-        aBody->updateSubs(aBody->shape(), false);
+      if ((*aRes)->data()->isValid()) {
+        if ((*aRes)->groupName() == ModelAPI_ResultBody::group()) {
+          ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRes);
+          aBody->updateSubs(aBody->shape(), false);
+        } else if ((*aRes)->groupName() == ModelAPI_ResultConstruction::group()) {
+          // update the cashed myShape presented in construction
+          ResultConstructionPtr aConstr =
+            std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aRes);
+          aConstr->updateShape();
+        }
       }
     }
   }
@@ -1985,11 +1993,12 @@ FeaturePtr Model_Objects::lastFeature()
 {
   Handle(TDataStd_ReferenceArray) aRefs;
   if (featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
-    FeaturePtr aLast = feature(aRefs->Value(aRefs->Upper()));
+    // comment this because of #2674 - features are removed from array on deactivation of Part
+    /*FeaturePtr aLast = feature(aRefs->Value(aRefs->Upper()));
     if (!aLast.get() && aRefs->Length() != 0) { // erase the invalid feature from the array
       RemoveFromRefArray(featuresLabel(), aRefs->Value(aRefs->Upper()));
       return lastFeature(); // try once again, after the last was removed
-    }
+    }*/
     return feature(aRefs->Value(aRefs->Upper()));
   }
   return FeaturePtr(); // no features at all