1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Placement.cpp
4 // Created: 07 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_Placement.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
12 //==================================================================================================
13 FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
19 //==================================================================================================
20 FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21 const std::list<ModelHighAPI_Selection>& theObjects,
22 const ModelHighAPI_Selection& theStartShape,
23 const ModelHighAPI_Selection& theEndShape,
24 const bool theReverseDirection,
25 const bool theCentering)
26 : ModelHighAPI_Interface(theFeature)
29 fillAttribute(theObjects, myobjects);
30 fillAttribute(theStartShape, mystartShape);
31 fillAttribute(theEndShape, myendShape);
32 fillAttribute(theReverseDirection, myreverseDirection);
33 setCentering(theCentering);
37 //==================================================================================================
38 FeaturesAPI_Placement::~FeaturesAPI_Placement()
43 //==================================================================================================
44 void FeaturesAPI_Placement::setObjects(const std::list<ModelHighAPI_Selection>& theObjects)
46 fillAttribute(theObjects, myobjects);
51 //==================================================================================================
52 void FeaturesAPI_Placement::setStartShape(const ModelHighAPI_Selection& theStartShape)
54 fillAttribute(theStartShape, mystartShape);
59 //==================================================================================================
60 void FeaturesAPI_Placement::setEndShape(const ModelHighAPI_Selection& theEndShape)
62 fillAttribute(theEndShape, myendShape);
67 //==================================================================================================
68 void FeaturesAPI_Placement::setReverseDirection(const bool theReverseDirection)
70 fillAttribute(theReverseDirection, myreverseDirection);
75 //==================================================================================================
76 void FeaturesAPI_Placement::setCentering(const bool theCentering)
78 fillAttribute(theCentering, mycentering);
83 //==================================================================================================
84 void FeaturesAPI_Placement::dump(ModelHighAPI_Dumper& theDumper) const
86 FeaturePtr aBase = feature();
87 const std::string& aDocName = theDumper.name(aBase->document());
89 AttributeSelectionListPtr anAttrObjects =
90 aBase->selectionList(FeaturesPlugin_Placement::OBJECTS_LIST_ID());
91 AttributeSelectionPtr anAttrStartShape =
92 aBase->selection(FeaturesPlugin_Placement::START_SHAPE_ID());
93 AttributeSelectionPtr anAttrEndShape = aBase->selection(FeaturesPlugin_Placement::END_SHAPE_ID());
94 AttributeBooleanPtr anAttrReverse = aBase->boolean(FeaturesPlugin_Placement::REVERSE_ID());
95 AttributeBooleanPtr anAttrCentering = aBase->boolean(FeaturesPlugin_Placement::CENTERING_ID());
97 theDumper << aBase << " = model.addPlacement(" << aDocName << ", "
98 << anAttrObjects << ", " << anAttrStartShape << ", " << anAttrEndShape << ", "
99 << anAttrReverse << ", " << anAttrCentering << ")" << std::endl;
102 //==================================================================================================
103 PlacementPtr addPlacement(const std::shared_ptr<ModelAPI_Document>& thePart,
104 const std::list<ModelHighAPI_Selection>& theObjects,
105 const ModelHighAPI_Selection& theStartShape,
106 const ModelHighAPI_Selection& theEndShape,
107 const bool theReverseDirection,
108 const bool theCentering)
110 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Placement::ID());
111 return PlacementPtr(new FeaturesAPI_Placement(aFeature,