Salome HOME
Issue #2563: CEA 2018-1 Common
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_BooleanCommon.cpp
index bd53854ef0e99c93d25775ab1c77672b7f2ce235..b1af676882115e71249dd47b099eba95ccff94b2 100644 (file)
@@ -32,6 +32,20 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   initialize();
 }
 
+//==================================================================================================
+FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& theMainObjects)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod);
+    fillAttribute(theMainObjects, mymainObjects);
+
+    execute(false);
+  }
+}
+
 //==================================================================================================
 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
@@ -40,6 +54,7 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
+    fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
 
@@ -66,11 +81,24 @@ void FeaturesAPI_BooleanCommon::setMainObjects(
 void FeaturesAPI_BooleanCommon::setToolObjects(
   const std::list<ModelHighAPI_Selection>& theToolObjects)
 {
+  fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
   fillAttribute(theToolObjects, mytoolObjects);
 
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_BooleanCommon::setAdvancedMode(const bool theMode)
+{
+  if (theMode) {
+    fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
+  } else {
+    fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod);
+  }
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -79,12 +107,27 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const
   theDumper << aBase << " = model.addCommon";
 
   const std::string& aDocName = theDumper.name(aBase->document());
+  AttributeStringPtr aMode = aBase->string(FeaturesPlugin_BooleanCommon::CREATION_METHOD());
   AttributeSelectionListPtr anObjects =
     aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID());
   AttributeSelectionListPtr aTools =
     aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID());
 
-  theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl;
+  theDumper << "(" << aDocName << ", " << anObjects;
+
+  if (aMode->value() == FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED()) {
+    theDumper << ", " << aTools;
+  }
+
+  theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
+                           const std::list<ModelHighAPI_Selection>& theMainObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
+  return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects));
 }
 
 //==================================================================================================