Salome HOME
1f7624e09e7a0c716da8e8a8cc070f0f685ca2d9
[modules/shaper.git] / src / SketchAPI / SketchAPI_Rotation.cpp
1 // Name   : SketchAPI_Rotation.cpp
2 // Purpose: 
3 //
4 // History:
5 // 16/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Rotation.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelHighAPI_Dumper.h>
11 #include <ModelHighAPI_Tools.h>
12 //--------------------------------------------------------------------------------------
13 SketchAPI_Rotation::SketchAPI_Rotation(
14     const std::shared_ptr<ModelAPI_Feature> & theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 SketchAPI_Rotation::SketchAPI_Rotation(
21     const std::shared_ptr<ModelAPI_Feature> & theFeature,
22     const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
23     const ModelHighAPI_RefAttr & theCenter,
24     const ModelHighAPI_Double & theAngle,
25     const ModelHighAPI_Integer & theNumberOfObjects,
26     bool theFullValue)
27 : ModelHighAPI_Interface(theFeature)
28 {
29   if (initialize()) {
30     fillAttribute(theObjects, rotationList());
31     fillAttribute(theCenter, center());
32     fillAttribute(theAngle, angle());
33     fillAttribute(theNumberOfObjects, numberOfObjects());
34     fillAttribute(theFullValue ? "FullAngle" : "SingleAngle", valueType());
35
36     execute();
37   }
38 }
39
40 SketchAPI_Rotation::~SketchAPI_Rotation()
41 {
42
43 }
44
45 //--------------------------------------------------------------------------------------
46
47 void SketchAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
48 {
49   FeaturePtr aBase = feature();
50   const std::string& aSketchName = theDumper.parentName(aBase);
51
52   AttributeRefListPtr aRotObjects = rotationList();
53   AttributeRefAttrPtr aCenter = center();
54   AttributeDoublePtr anAngle = angle();
55   AttributeIntegerPtr aNbCopies = numberOfObjects();
56   bool isFullValue = valueType()->value() != "SingleAngle";
57
58   theDumper << aBase << " = " << aSketchName << ".addRotation("
59             << aRotObjects << ", " << aCenter << ", " << anAngle << ", " << aNbCopies;
60   if (isFullValue)
61     theDumper << ", " << isFullValue;
62   theDumper << ")" << std::endl;
63 }