1 // Name : SketchAPI_Rotation.cpp
5 // 16/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Rotation.h"
9 #include <SketchAPI_SketchEntity.h>
10 //--------------------------------------------------------------------------------------
11 #include <ModelHighAPI_Dumper.h>
12 #include <ModelHighAPI_Tools.h>
14 #include <SketchPlugin_SketchEntity.h>
15 //--------------------------------------------------------------------------------------
16 SketchAPI_Rotation::SketchAPI_Rotation(
17 const std::shared_ptr<ModelAPI_Feature> & theFeature)
18 : ModelHighAPI_Interface(theFeature)
23 SketchAPI_Rotation::SketchAPI_Rotation(
24 const std::shared_ptr<ModelAPI_Feature> & theFeature,
25 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
26 const ModelHighAPI_RefAttr & theCenter,
27 const ModelHighAPI_Double & theAngle,
28 const ModelHighAPI_Integer & theNumberOfObjects,
30 : ModelHighAPI_Interface(theFeature)
33 fillAttribute(theObjects, rotationList());
34 fillAttribute(theCenter, center());
35 fillAttribute(theAngle, angle());
36 fillAttribute(theNumberOfObjects, numberOfObjects());
37 fillAttribute(theFullValue ? "FullAngle" : "SingleAngle", valueType());
43 SketchAPI_Rotation::~SketchAPI_Rotation()
48 std::list<std::shared_ptr<ModelHighAPI_Interface> > SketchAPI_Rotation::rotated() const
50 std::list<ObjectPtr> aList = rotatedObjects()->list();
51 // remove all initial features
52 std::list<FeaturePtr> anIntermediate;
53 std::list<ObjectPtr>::const_iterator anIt = aList.begin();
54 for (; anIt != aList.end(); ++anIt) {
55 FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
56 AttributeBooleanPtr isCopy = aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID());
57 if (isCopy.get() && isCopy->value())
58 anIntermediate.push_back(aFeature);
60 return SketchAPI_SketchEntity::wrap(anIntermediate);
63 //--------------------------------------------------------------------------------------
65 void SketchAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
67 FeaturePtr aBase = feature();
68 const std::string& aSketchName = theDumper.parentName(aBase);
70 AttributeRefListPtr aRotObjects = rotationList();
71 AttributeRefAttrPtr aCenter = center();
72 AttributeDoublePtr anAngle = angle();
73 AttributeIntegerPtr aNbCopies = numberOfObjects();
74 bool isFullValue = valueType()->value() != "SingleAngle";
76 theDumper << aBase << " = " << aSketchName << ".addRotation("
77 << aRotObjects << ", " << aCenter << ", " << anAngle << ", " << aNbCopies;
79 theDumper << ", " << isFullValue;
80 theDumper << ")" << std::endl;
82 // Dump variables for a list of rotated features
84 std::list<std::shared_ptr<ModelHighAPI_Interface> > aList = rotated();
85 std::list<std::shared_ptr<ModelHighAPI_Interface> >::const_iterator anIt = aList.begin();
86 for (; anIt != aList.end(); ++anIt) {
87 if (anIt != aList.begin())
89 theDumper << theDumper.name((*anIt)->feature(), false);
91 theDumper << "] = " << theDumper.name(aBase) << ".rotated()" << std::endl;