Salome HOME
Correct case when the weak-named attribute is dumped in Geom mode: geometrical repres...
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_RemoveSubShapes.cpp
index 24447bc00ecb24490d2467f47f47c9eec66e0e84..784869fdb57abff897fb4408c3c47bed6864e044 100644 (file)
@@ -62,7 +62,20 @@ void FeaturesAPI_RemoveSubShapes::setBase(const ModelHighAPI_Selection& theBase)
 void FeaturesAPI_RemoveSubShapes::setSubShapesToKeep(
   const std::list<ModelHighAPI_Selection>& theSubShapes)
 {
-  fillAttribute(theSubShapes, mysubshapes);
+  fillAttribute(FeaturesPlugin_RemoveSubShapes::CREATION_METHOD_BY_KEEP_SUBSHAPES(),
+                mycreationMethod);
+  fillAttribute(theSubShapes, mysubshapesToKeep);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_RemoveSubShapes::setSubShapesToRemove(
+  const std::list<ModelHighAPI_Selection>& theSubShapes)
+{
+  fillAttribute(FeaturesPlugin_RemoveSubShapes::CREATION_METHOD_BY_REMOVE_SUBSHAPES(),
+                mycreationMethod);
+  fillAttribute(theSubShapes, mysubshapesToRemove);
 
   execute();
 }
@@ -75,12 +88,29 @@ void FeaturesAPI_RemoveSubShapes::dump(ModelHighAPI_Dumper& theDumper) const
 
   AttributeSelectionPtr anAttrBaseShape =
     aBase->selection(FeaturesPlugin_RemoveSubShapes::BASE_SHAPE_ID());
-  AttributeSelectionListPtr anAttrSubShapes =
-    aBase->selectionList(FeaturesPlugin_RemoveSubShapes::SUBSHAPES_ID());
 
-  theDumper << aBase << " = model.addRemoveSubShapes(" << aDocName <<
-    ", " << anAttrBaseShape << ")" << std::endl;
-  theDumper << aBase << ".setSubShapesToKeep(" << anAttrSubShapes << ")" << std::endl;
+  std::string aCreationMethod =
+    aBase->string(FeaturesPlugin_RemoveSubShapes::CREATION_METHOD())->value();
+
+  AttributeSelectionListPtr anAttrSubShapes;
+
+  bool isKeepSubs =
+      aCreationMethod == FeaturesPlugin_RemoveSubShapes::CREATION_METHOD_BY_KEEP_SUBSHAPES();
+  if (isKeepSubs) {
+    anAttrSubShapes =
+      aBase->selectionList(FeaturesPlugin_RemoveSubShapes::SUBSHAPES_TO_KEEP_ID());
+  }
+  else {
+    anAttrSubShapes =
+      aBase->selectionList(FeaturesPlugin_RemoveSubShapes::SUBSHAPES_TO_REMOVE_ID());
+  }
+
+  theDumper << aBase << " = model.addRemoveSubShapes("
+            << aDocName << ", " << anAttrBaseShape << ")"
+            << "\n"
+            << theDumper.name(aBase)
+            << (isKeepSubs ? ".setSubShapesToKeep(" : ".setSubShapesToRemove(")
+            << anAttrSubShapes << ")" << std::endl;
 }
 
 //==================================================================================================