]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #1326
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 3 Mar 2016 07:41:59 +0000 (10:41 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 3 Mar 2016 07:41:59 +0000 (10:41 +0300)
src/Model/Model_Document.cpp
src/Model/Model_ResultPart.cpp

index 5f18fe56a011a13a6ae424944b80536c3a4a8051..c004332cc131d674d5f4b9ff679739b640e74d28 100755 (executable)
@@ -905,6 +905,17 @@ std::shared_ptr<ModelAPI_Feature> Model_Document::currentFeature(const bool theV
   return std::shared_ptr<ModelAPI_Feature>(); // null feature means the higher than first
 }
 
+// recursive function to check if theSub is a child of theMain composite feature
+// through all the hierarchy of parents
+static bool isSub(const CompositeFeaturePtr theMain, const FeaturePtr theSub) {
+  CompositeFeaturePtr aParent = ModelAPI_Tools::compositeOwner(theSub);
+  if (!aParent.get())
+    return false;
+  if (aParent == theMain)
+    return true;
+  return isSub(theMain, aParent);
+}
+
 void Model_Document::setCurrentFeature(
   std::shared_ptr<ModelAPI_Feature> theCurrent, const bool theVisible)
 {
@@ -970,7 +981,7 @@ void Model_Document::setCurrentFeature(
 
     bool aDisabledFlag = !aPassed;
     if (aMain.get()) {
-      if (aMain->isSub(anIter)) // sub-elements of not-disabled feature are not disabled
+      if (isSub(aMain, 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;
index 57dcd9a783533374395cb04b82a11d998ae93f8d..a5d266d8165736f94bb7f7581fa4a9a7de4a1b85 100644 (file)
@@ -119,9 +119,13 @@ bool Model_ResultPart::setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
     if (!myTrsf.get()) { // disable of base result part
       DocumentPtr aDoc = Model_ResultPart::partDoc();
       if (aDoc.get() && aDoc->isOpened()) {
-        std::shared_ptr<Model_Document> anIntDoc = std::dynamic_pointer_cast<Model_Document>(aDoc);
         // make the current feature the last in any case: to update shapes defore deactivation too
-        FeaturePtr aLastFeature = anIntDoc->lastFeature();
+        int aSize = aDoc->size(ModelAPI_Feature::group());
+        FeaturePtr aLastFeature;
+        if (aSize)
+          aLastFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aDoc->object(
+            ModelAPI_Feature::group(), aSize - 1));
+
         aDoc->setCurrentFeature(aLastFeature, false);
         if (theFlag) { // disable, so make all features disabled too
           // update the shape just before the deactivation: it will be used outside of part