Salome HOME
Prepare version 1.2.1: quick fix for iteration 2 release
[modules/shaper.git] / src / Model / Model_ResultBody.cpp
index 00a3871e0bcc8055ecdc6a647122b8d47e8e3c59..f7492cc9534cfb7d71a92083b6e66dfefe547a3e 100644 (file)
@@ -40,6 +40,7 @@
 
 Model_ResultBody::Model_ResultBody()
 {
+  myIsDisabled = true; // by default it is not initialized and false to be after created
   setIsConcealed(false);
 }
 
@@ -65,14 +66,26 @@ static void EvolutionToSelection(TDF_Label theLab, const bool theFlag) {
   Handle(TNaming_NamedShape) aName;
   int anEvolution = -1;
   if (theLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
-    anEvolution = (int)(aName->Evolution());
+    TNaming_Evolution aNSEvol = aName->Evolution();
+    if ((aNSEvol == TNaming_SELECTED && theFlag) ||
+        (aNSEvol != TNaming_SELECTED && !theFlag)) { // nothing to do, it is already correct
+      return;
+    }
+    anEvolution = (int)(aNSEvol);
+    if (!theFlag) {
+      Handle(TDataStd_Integer) anAttrEvol;
+      if (theLab.FindAttribute(TDataStd_Integer::GetID(), anAttrEvol)) {
+        anEvolution = anAttrEvol->Get();
+      }
+    } else {
+      TDataStd_Integer::Set(theLab, anEvolution);
+    }
+
     for(TNaming_Iterator anIter(aName); anIter.More(); anIter.Next()) {
       aShapePairs.push_back(std::pair<TopoDS_Shape, TopoDS_Shape>
         (anIter.OldShape(), anIter.NewShape()));
     }
   }
-  // remove old
-  theLab.ForgetAttribute(TNaming_NamedShape::GetID());
   // create new
   TNaming_Builder aBuilder(theLab);
   TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution);
@@ -87,7 +100,7 @@ static void EvolutionToSelection(TDF_Label theLab, const bool theFlag) {
     } else if (anEvol == TNaming_DELETE) {
       aBuilder.Delete(aPairsIter->first);
     } else if (anEvol == TNaming_PRIMITIVE) {
-      aBuilder.Generated(aPairsIter->first, aPairsIter->second);
+      aBuilder.Generated(aPairsIter->second);
     }
   }
   // recursive call for all sub-labels