Salome HOME
Debug of Box macro feature to the updated architecture
[modules/shaper.git] / src / Model / Model_Objects.cpp
index 2356a20537c7b0e12758f70dfcd11a50aeda74f5..9ebc1e4d8ae617241b5a107657cc1ed2af931804 100644 (file)
@@ -105,11 +105,8 @@ void Model_Objects::addFeature(FeaturePtr theFeature, const FeaturePtr theAfterT
   if (!theFeature->isAction()) {  // do not add action to the data model
     TDF_Label aFeaturesLab = featuresLabel();
     TDF_Label aFeatureLab = aFeaturesLab.NewChild();
-    initData(theFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
-    // keep the feature ID to restore document later correctly
-    TDataStd_Comment::Set(aFeatureLab, theFeature->getKind().c_str());
-    myFeatures.Bind(aFeatureLab, theFeature);
-    // store feature in the features array
+    // store feature in the features array: before "initData" because in macro features
+    // in initData it creates new features, appeared later than this
     TDF_Label aPrevFeateureLab;
     if (theAfterThis.get()) { // searching for the previous feature label
       std::shared_ptr<Model_Data> aPrevData = 
@@ -119,6 +116,11 @@ void Model_Objects::addFeature(FeaturePtr theFeature, const FeaturePtr theAfterT
       }
     }
     AddToRefArray(aFeaturesLab, aFeatureLab, aPrevFeateureLab);
+
+    initData(theFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
+    // keep the feature ID to restore document later correctly
+    TDataStd_Comment::Set(aFeatureLab, theFeature->getKind().c_str());
+    myFeatures.Bind(aFeatureLab, theFeature);
     // event: feature is added
     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
     ModelAPI_EventCreator::get()->sendUpdated(theFeature, anEvent);
@@ -227,9 +229,7 @@ void Model_Objects::removeFeature(FeaturePtr theFeature)
     // erase all attributes under the label of feature
     aFeatureLabel.ForgetAllAttributes();
     // remove it from the references array
-    if (theFeature->isInHistory()) {
-      RemoveFromRefArray(featuresLabel(), aFeatureLabel);
-    }
+    RemoveFromRefArray(featuresLabel(), aFeatureLabel);
     // event: feature is deleted
     ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
     // the redisplay signal should be flushed in order to erase the feature presentation in the viewer