Salome HOME
Merge branch 'csgroup_IS2'
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Tools.cpp
index f436e8011ad637f9703efcc5e2d76c276a4bb993..9a36609a4e5d6c07188af5c03bd88270d749f566 100644 (file)
@@ -263,9 +263,32 @@ bool FeaturesPlugin_Tools::shapesFromSelectionList(
     const std::shared_ptr<ModelAPI_AttributeSelectionList> theSelectionList,
     const bool theStoreFullHierarchy,
     GeomAPI_ShapeHierarchy& theHierarchy,
-    std::list<ResultPtr>& theParts)
+    std::list<ResultPtr>& theParts, std::string &theTextureFile)
 {
   int aSize = theSelectionList->size();
+  if(aSize == 1)
+  {
+    auto anObjectAttr = theSelectionList->value(0);
+    if(anObjectAttr.get())
+    {
+      FeaturePtr aFeature = anObjectAttr->contextFeature();
+      if(aFeature.get() &&  aFeature->results().size() == 1)
+      {
+        theTextureFile = aFeature->firstResult()->getTextureFile();
+      }
+      else
+      {
+        if(!aFeature.get())
+        {
+          auto aResult =  anObjectAttr->context();
+          if(aResult.get())
+          {
+            theTextureFile = aResult->getTextureFile();
+          }
+        }
+      }
+    }
+  }
   for (int anObjectsIndex = 0; anObjectsIndex < aSize; anObjectsIndex++) {
     AttributeSelectionPtr anObjectAttr = theSelectionList->value(anObjectsIndex);
     std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();