Salome HOME
Merge remote-tracking branch 'origin/cgt/devCEA'
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Translation.cpp
index 5037e4bfd391126b7dc51b40e26810b96b21791b..6b09954827301b2285e1c18aaed76ad1b2d77691 100644 (file)
@@ -6,20 +6,23 @@
 
 #include "FeaturesAPI_Translation.h"
 
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Tools.h>
 
 //==================================================================================================
-FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+FeaturesAPI_Translation::FeaturesAPI_Translation(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature)
 : ModelHighAPI_Interface(theFeature)
 {
   initialize();
 }
 
 //==================================================================================================
-FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                                 const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                                 const ModelHighAPI_Selection& theAxisObject,
-                                                 const ModelHighAPI_Double& theDistance)
+FeaturesAPI_Translation::FeaturesAPI_Translation(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& theMainObjects,
+  const ModelHighAPI_Selection& theAxisObject,
+  const ModelHighAPI_Double& theDistance)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
@@ -36,7 +39,8 @@ FeaturesAPI_Translation::~FeaturesAPI_Translation()
 }
 
 //==================================================================================================
-void FeaturesAPI_Translation::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
+void FeaturesAPI_Translation::setMainObjects(
+  const std::list<ModelHighAPI_Selection>& theMainObjects)
 {
   fillAttribute(theMainObjects, mymainObjects);
 
@@ -59,7 +63,22 @@ void FeaturesAPI_Translation::setDistance(const ModelHighAPI_Double& theDistance
   execute();
 }
 
-// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  AttributeSelectionListPtr anAttrObjects =
+    aBase->selectionList(FeaturesPlugin_Translation::OBJECTS_LIST_ID());
+  AttributeSelectionPtr anAttrAxis =
+    aBase->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID());
+  AttributeDoublePtr anAttrDistance = aBase->real(FeaturesPlugin_Translation::DISTANCE_ID());
+
+  theDumper << aBase << " = model.addTranslation(" << aDocName << ", "
+            << anAttrObjects << ", " << anAttrAxis << ", " << anAttrDistance << ")" << std::endl;
+}
+
 //==================================================================================================
 TranslationPtr addTranslation(const std::shared_ptr<ModelAPI_Document>& thePart,
                               const std::list<ModelHighAPI_Selection>& theMainObjects,
@@ -67,5 +86,6 @@ TranslationPtr addTranslation(const std::shared_ptr<ModelAPI_Document>& thePart,
                               const ModelHighAPI_Double& theDistance)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Translation::ID());
-  return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, theAxisObject, theDistance));
+  return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects,
+                                                    theAxisObject, theDistance));
 }