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