]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2370: History line and folder
authorazv <azv@opencascade.com>
Fri, 15 Dec 2017 09:21:07 +0000 (12:21 +0300)
committerazv <azv@opencascade.com>
Fri, 15 Dec 2017 09:21:33 +0000 (12:21 +0300)
Skip folders when searching next feature in the history

src/Model/Model_Objects.cpp

index bf41c45cca262a7e875e67d4ddab495298593b1d..85a9f6dc2c3daefb5b3fa86e2ef818f41ea2a13b 100644 (file)
@@ -1888,9 +1888,16 @@ FeaturePtr Model_Objects::nextFeature(FeaturePtr theCurrent, const bool theRever
   std::shared_ptr<Model_Data> aData = std::static_pointer_cast<Model_Data>(theCurrent->data());
   if (aData.get() && aData->isValid()) {
     TDF_Label aFeatureLabel = aData->label().Father();
-    TDF_Label aNextLabel = nextLabel(aFeatureLabel, theReverse);
-    if (!aNextLabel.IsNull())
-      return feature(aNextLabel);
+    do {
+      TDF_Label aNextLabel = nextLabel(aFeatureLabel, theReverse);
+      if (aNextLabel.IsNull())
+        break; // last or something is wrong
+      FeaturePtr aFound = feature(aNextLabel);
+      if (aFound)
+        return aFound; // the feature is found
+      // if the next label is a folder, skip it
+      aFeatureLabel = folder(aNextLabel).get() ? aNextLabel : TDF_Label();
+    } while (!aFeatureLabel.IsNull());
   }
   return FeaturePtr(); // not found, last, or something is wrong
 }