]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix the issue related to copying AttributeSelectionList (issue #18710)
authorazv <azv@opencascade.com>
Thu, 13 Feb 2020 12:39:09 +0000 (15:39 +0300)
committerazv <azv@opencascade.com>
Thu, 13 Feb 2020 12:39:09 +0000 (15:39 +0300)
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_AttributeSelectionList.h
src/ModelAPI/ModelAPI_AttributeSelectionList.h

index 05826f0a8833f8ecb8878557a9001912fd6a028f..ca42c50ea082ebb0bac8b35122d1c8fd22a15d91 100644 (file)
@@ -111,15 +111,9 @@ void ExchangePlugin_ExportFeature::initAttributes()
   AttributeStringPtr aTypeAttr = string(EXPORT_TYPE_ID());
   if (aTypeAttr->isInitialized() && aTypeAttr->value() == "XAO") {
     AttributeSelectionListPtr aSelList = selectionList(SELECTION_LIST_ID());
-    int aSelListSize = aSelList->size();
     AttributeSelectionListPtr aXAOSelList = selectionList(XAO_SELECTION_LIST_ID());
-    if (aSelListSize > 0 && aXAOSelList->size() == 0) {
-      for (int i = 0; i < aSelListSize; ++i) {
-        AttributeSelectionPtr aSelection = aSelList->value(i);
-        aXAOSelList->append(aSelection->context(), aSelection->value());
-      }
-      aXAOSelList->setSelectionType(aSelList->selectionType());
-    }
+    if (aSelList->size() > 0 && aXAOSelList->size() == 0)
+      aSelList->copyTo(aXAOSelList);
     aSelList->clear();
   }
 }
index 170190ef66879e1e44f82e71e4be35340ea4f2ca..9e7b0b6ff1144cf9957a4cf6599808398844e791 100644 (file)
@@ -269,6 +269,16 @@ void Model_AttributeSelectionList::remove(const std::set<int>& theIndices)
   }
 }
 
+void Model_AttributeSelectionList::copyTo(AttributeSelectionListPtr theTarget) const
+{
+  std::shared_ptr<Model_AttributeSelectionList> aTarget =
+    std::dynamic_pointer_cast<Model_AttributeSelectionList>(theTarget);
+  if (aTarget) {
+    copyAttrs(myLab, aTarget->myLab);
+    aTarget->reinit();
+  }
+}
+
 int Model_AttributeSelectionList::size()
 {
   return mySize->Get();
index 3ed3e2804aca7e396befd8f711a858dd1829a9d2..2db50d9b400f5b49254550a7493886c7bcbd24ec 100644 (file)
@@ -66,6 +66,9 @@ public:
   MODEL_EXPORT virtual void append(const std::string& theType, const std::string& theContextName,
                                    const int theIndex);
 
+  /// Copy the selection list to the destination attribute
+  MODEL_EXPORT virtual void copyTo(AttributeSelectionListPtr theTarget) const;
+
   /// Reset temporary stored values
   virtual void removeTemporaryValues();
 
index 60b9becfad0f08d09dc1acf4e2b56597a343095e..16cd5f97981514ce40dbfae7fe18e50d94c438be 100644 (file)
@@ -64,6 +64,9 @@ public:
   virtual void append(const std::string& theType, const std::string& theContextName,
                       const int theIndex) = 0;
 
+  /// Copy the selection list to the destination attribute
+  virtual void copyTo(std::shared_ptr<ModelAPI_AttributeSelectionList> theTarget) const = 0;
+
   /// Reset temporary stored values
   virtual void removeTemporaryValues() = 0;