]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_AttributeSelection.cpp
Salome HOME
Debug and optimization of selection of elements of the sketch.
[modules/shaper.git] / src / Model / Model_AttributeSelection.cpp
index 17120173be44d4a53d24551876438d059fe27540..148dbb9b6e5e50af4ab54ee65e60f54fcbadf2d8 100644 (file)
@@ -1636,6 +1636,29 @@ bool Model_AttributeSelection::restoreContext(std::string theName,
   static const ResultPtr anEmpty;
   theValue = aDoc->findNamingName(aSubShapeName, anUniqueContext ? aCont : anEmpty);
 
+  // sketch sub-component shape and name is located in separated feature label, try the sub-name
+  if (theValue.IsNull() && aCont->groupName() == ModelAPI_ResultConstruction::group()) {
+    std::string::size_type aSlash = aSubShapeName.rfind('/');
+    if (aSlash != std::string::npos) {
+      std::string aCompName = aSubShapeName.substr(aSlash + 1);
+      CompositeFeaturePtr aComposite =
+        std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aDoc->feature(aCont));
+      if (aComposite.get() && aComposite->numberOfSubs()) {
+        const int aSubNum = aComposite->numberOfSubs();
+        for (int a = 0; a < aSubNum; a++) {
+          FeaturePtr aSub = aComposite->subFeature(a);
+          const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aSub->results();
+          std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRes = aResults.cbegin();
+          for (; aRes != aResults.cend(); aRes++) {
+            if ((*aRes)->data()->name() == aCompName) {
+              theValue = std::dynamic_pointer_cast<Model_Data>((*aRes)->data())->shapeLab();
+            }
+          }
+        }
+      }
+    }
+  }
+
   /* to find the latest lower result that keeps given shape
   bool aFindNewContext = true;
   while(aFindNewContext && aCont.get()) {