]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Made the nesting feature disabled until the nested features are modified/current
authormpv <mpv@opencascade.com>
Thu, 8 Oct 2015 11:11:05 +0000 (14:11 +0300)
committermpv <mpv@opencascade.com>
Thu, 8 Oct 2015 11:11:05 +0000 (14:11 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Objects.cpp
src/Model/Model_Update.cpp

index e0ae73e76109b438637f051a4f49870317863581..c049e739b017a0752bfddd4c134246cec56f6d5d 100644 (file)
@@ -759,20 +759,16 @@ void Model_Document::setCurrentFeature(
 
   TDF_Label aRefLab = generalLabel().FindChild(TAG_CURRENT_FEATURE);
   CompositeFeaturePtr aMain; // main feature that may nest the new current
+  std::set<FeaturePtr> anOwners; // composites that contain theCurrent (with any level of nesting)
   if (theCurrent.get()) {
     aMain = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theCurrent);
-    if (!aMain.get()) {
-      // if feature nests into compisite feature, make the composite feature as current
-      const std::set<AttributePtr>& aRefsToMe = theCurrent->data()->refsToMe();
-      std::set<AttributePtr>::const_iterator aRefToMe = aRefsToMe.begin();
-      for(; aRefToMe != aRefsToMe.end(); aRefToMe++) {
-        CompositeFeaturePtr aComposite = 
-          std::dynamic_pointer_cast<ModelAPI_CompositeFeature>((*aRefToMe)->owner());
-        if (aComposite.get() && aComposite->isSub(theCurrent)) {
-          aMain = aComposite;
-          break;
-        }
+    CompositeFeaturePtr anOwner = ModelAPI_Tools::compositeOwner(theCurrent);
+    while(anOwner.get()) {
+      if (!aMain.get()) {
+        aMain = anOwner;
       }
+      anOwners.insert(anOwner);
+      anOwner = ModelAPI_Tools::compositeOwner(anOwner);
     }
   }
 
@@ -817,8 +813,13 @@ void Model_Document::setCurrentFeature(
     if (anIter == theCurrent) aPassed = true;
 
     bool aDisabledFlag = !aPassed;
-    if (aMain.get() && aMain->isSub(anIter)) // sub-elements of not-disabled feature are not disabled
-      aDisabledFlag = false;
+    if (aMain.get()) {
+      if (aMain->isSub(anIter)) // sub-elements of not-disabled feature are not disabled
+        aDisabledFlag = false;
+      else if (anOwners.find(anIter) != anOwners.end()) // disable the higher-level feature is the nested is the current
+        aDisabledFlag = true;
+    }
+
     if (anIter->getKind() == "Parameter") {// parameters are always out of the history of features, but not parameters
       if (theCurrent.get() && theCurrent->getKind() != "Parameter")
         aDisabledFlag = false;
index 82831c710236276940b14fed8e748974bce803ab..9e209eb72b491e9e9c65c33a698981a7d6074f6e 100644 (file)
@@ -754,6 +754,7 @@ void Model_Objects::synchronizeBackRefs()
               std::dynamic_pointer_cast<Model_Data>((*aRefTo)->data());
             aRefData->addBackReference(aFeature, aRefsIter->first); // here the Concealed flag is updated
             // update enable/disable status: the nested status must be equal to the composite
+            /* MPV: not sub-elements of sketch may be enabled during editition of sketch
             CompositeFeaturePtr aComp = 
               std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
             if (aComp.get()) {
@@ -762,6 +763,7 @@ void Model_Objects::synchronizeBackRefs()
                 aReferenced->setDisabled(aComp->isDisabled());
               }
             }
+            */
           }
         }
       }
index 69b34511427b86548183f9f238b290f550032646..69a10d74524b891531046efd56878009db4102eb 100644 (file)
@@ -274,8 +274,13 @@ void Model_Update::updateFeature(FeaturePtr theFeature)
   // check all features this feature depended on (recursive call of updateFeature)
   static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
 
-  if (theFeature->isDisabled())
+  if (theFeature->isDisabled()) {
+    // possibly sub-elements are not disabled?
+    CompositeFeaturePtr aCompos = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
+    if (aCompos)
+      iterateUpdate(aCompos);
     return;
+  }
 
   // do not execute the composite that contains the current
   bool isPostponedMain = false;