]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make order in enabling/disabling sub-elements of not active sketch
authormpv <mpv@opencascade.com>
Thu, 21 May 2015 11:37:51 +0000 (14:37 +0300)
committermpv <mpv@opencascade.com>
Thu, 21 May 2015 11:37:51 +0000 (14:37 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Objects.cpp

index e5c87013ede6a926641a0f41b1c82a0c4fa167aa..2521227190e4dc4115c5660cf479cd50b8b71a2b 100644 (file)
@@ -570,8 +570,10 @@ void Model_Document::removeFeature(FeaturePtr theFeature)
   if (theFeature == currentFeature(false)) {
     int aCurrentIndex = index(theFeature);
     if (aCurrentIndex != -1) {
-      setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(
-        object(ModelAPI_Feature::group(), aCurrentIndex - 1)), false);
+      ObjectPtr aPrevObj;
+      if (aCurrentIndex != 0)
+        aPrevObj = object(ModelAPI_Feature::group(), aCurrentIndex - 1);
+      setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aPrevObj), false);
     }
   }
   myObjs->removeFeature(theFeature);
@@ -655,6 +657,7 @@ void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurr
   const bool theVisible)
 {
   TDF_Label aRefLab = generalLabel().FindChild(TAG_CURRENT_FEATURE);
+  CompositeFeaturePtr aMain; // main feature that may nest the new current
   if (theCurrent.get()) {
     /*
     if (theVisible) { // make features below which are not in history also enabled: sketch subs
@@ -674,7 +677,8 @@ void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurr
       CompositeFeaturePtr aComposite = 
         std::dynamic_pointer_cast<ModelAPI_CompositeFeature>((*aRefToMe)->owner());
       if (aComposite.get() && aComposite->isSub(theCurrent)) {
-        theCurrent = aComposite;
+        aMain = aComposite;
+        break;
       }
     }
 
@@ -695,10 +699,6 @@ void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurr
   static Events_Loop* aLoop = Events_Loop::loop();
   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
 
-  // if the current feature is composite features, all sub-features also must be enabled
-  CompositeFeaturePtr aCurComp = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theCurrent);
-
-
   bool aPassed = false; // flag that the current object is already passed in cycle
   FeaturePtr anIter = myObjs->lastFeature();
   for(; anIter.get(); anIter = myObjs->nextFeature(anIter, true)) {
@@ -706,7 +706,7 @@ void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurr
     if (anIter == theCurrent) aPassed = true;
 
     bool aDisabledFlag = !aPassed;
-    if (aCurComp.get() && aCurComp->isSub(anIter))
+    if (aMain.get() && aMain->isSub(anIter))
       aDisabledFlag = false;
     if (anIter->setDisabled(aDisabledFlag)) {
       // state of feature is changed => so feature become updated
index e87508864abad949886e2070b4001a5f18c5b833..2dafa892936d21324a40d1c1a3f8c9854660ae06 100644 (file)
@@ -600,6 +600,15 @@ void Model_Objects::synchronizeBackRefs()
             std::shared_ptr<Model_Data> aRefData = 
               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
+            CompositeFeaturePtr aComp = 
+              std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
+            if (aComp.get()) {
+              FeaturePtr aReferenced = std::dynamic_pointer_cast<ModelAPI_Feature>(*aRefTo);
+              if (aReferenced.get()) {
+                aReferenced->setDisabled(aComp->isDisabled());
+              }
+            }
           }
         }
       }