Salome HOME
Merge remote-tracking branch 'origin/cgt/devCEA'
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Rotation.cpp
index a043f5928b73f2a67053d85aa4ecad9bbabc1ebe..366a751b4da62eae4bee3729be6729c1140d77a2 100644 (file)
@@ -6,25 +6,26 @@
 
 #include "FeaturesAPI_Rotation.h"
 
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Tools.h>
 
 //==================================================================================================
-FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature> & theFeature)
+FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature)
 : ModelHighAPI_Interface(theFeature)
 {
   initialize();
 }
 
 //==================================================================================================
-FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                            const std::list<ModelHighAPI_Selection>& theMainObjects,
                                            const ModelHighAPI_Selection& theAxisObject,
                                            const ModelHighAPI_Double& theAngle)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
-    setMainObjects(theMainObjects);
-    setAxisObject(theAxisObject);
+    fillAttribute(theMainObjects, mymainObjects);
+    fillAttribute(theAxisObject, myaxisObject);
     setAngle(theAngle);
   }
 }
@@ -59,13 +60,27 @@ void FeaturesAPI_Rotation::setAngle(const ModelHighAPI_Double& theAngle)
   execute();
 }
 
-// TODO(spo): make add* as static functions of the class
 //==================================================================================================
-RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document> & thePart,
+void FeaturesAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  AttributeSelectionListPtr anAttrObjects =
+    aBase->selectionList(FeaturesPlugin_Rotation::OBJECTS_LIST_ID());
+  AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID());
+  AttributeDoublePtr anAttrAngle = aBase->real(FeaturesPlugin_Rotation::ANGLE_ID());
+
+  theDumper << aBase << " = model.addRotation(" << aDocName << ", "
+            << anAttrObjects << ", " << anAttrAxis << ", " << anAttrAngle << ")" << std::endl;
+}
+
+//==================================================================================================
+RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const std::list<ModelHighAPI_Selection>& theMainObjects,
                         const ModelHighAPI_Selection& theAxisObject,
-                        const ModelHighAPI_Double& theDistance)
+                        const ModelHighAPI_Double& theAngle)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Rotation::ID());
-  return RotationPtr(new FeaturesAPI_Rotation(aFeature, theMainObjects, theAxisObject, theDistance));
+  return RotationPtr(new FeaturesAPI_Rotation(aFeature, theMainObjects, theAxisObject, theAngle));
 }