1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_MultiRotation.cpp
4 // Created: 04 Apr 2017
5 // Author: Clarisse Genrault (CEA)
7 #include <FeaturesAPI_MultiRotation.h>
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
12 //==================================================================================================
13 FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
14 const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
21 //==================================================================================================
22 FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
23 const std::shared_ptr<ModelAPI_Feature>& theFeature,
24 const std::list<ModelHighAPI_Selection>& theMainObjects,
25 const ModelHighAPI_Selection& theAxis,
26 const ModelHighAPI_Integer& theNumber)
27 : ModelHighAPI_Interface(theFeature)
30 fillAttribute(theMainObjects, mainObjects());
31 fillAttribute(theAxis, axisAngular());
32 fillAttribute("",useStepAngular());
33 setNumberAngular(theNumber);
37 //==================================================================================================
38 FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
39 const std::shared_ptr<ModelAPI_Feature>& theFeature,
40 const std::list<ModelHighAPI_Selection>& theMainObjects,
41 const ModelHighAPI_Selection& theAxis,
42 const ModelHighAPI_Double& theStep,
43 const ModelHighAPI_Integer& theNumber)
44 : ModelHighAPI_Interface(theFeature)
47 fillAttribute(theMainObjects, mainObjects());
48 fillAttribute(theAxis, axisAngular());
49 fillAttribute(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID(),useStepAngular());
50 fillAttribute(theStep, stepAngular());
51 setNumberAngular(theNumber);
55 //==================================================================================================
56 FeaturesAPI_MultiRotation::~FeaturesAPI_MultiRotation()
60 //==================================================================================================
61 void FeaturesAPI_MultiRotation::setMainObjects(
62 const std::list<ModelHighAPI_Selection>& theMainObjects)
64 fillAttribute(theMainObjects, mainObjects());
69 //==================================================================================================
70 void FeaturesAPI_MultiRotation::setAxisAngular(const ModelHighAPI_Selection& theAxis)
72 fillAttribute(theAxis, axisAngular());
77 //==================================================================================================
78 void FeaturesAPI_MultiRotation::setStepAngular(const ModelHighAPI_Double& theStep)
80 fillAttribute(theStep, stepAngular());
85 //==================================================================================================
86 void FeaturesAPI_MultiRotation::setNumberAngular(const ModelHighAPI_Integer& theNumber)
88 fillAttribute(theNumber, nbAngular());
93 //==================================================================================================
94 void FeaturesAPI_MultiRotation::dump(ModelHighAPI_Dumper& theDumper) const
96 FeaturePtr aBase = feature();
97 const std::string& aDocName = theDumper.name(aBase->document());
99 AttributeSelectionListPtr anAttrObjects =
100 aBase->selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID());
101 theDumper << aBase << " = model.addMultiRotation(" << aDocName << ", " << anAttrObjects;
103 AttributeSelectionPtr anAttrAxis =
104 aBase->selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID());
105 theDumper << ", " << anAttrAxis;
107 if (aBase->string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->isInitialized()
108 && !aBase->string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->value().empty()) {
109 AttributeDoublePtr anAttrStepAngular =
110 aBase->real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID());
111 theDumper << ", " << anAttrStepAngular;
114 AttributeIntegerPtr anAttrNumberAngular =
115 aBase->integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID());
116 theDumper << ", " << anAttrNumberAngular;
118 theDumper << ")" << std::endl;
121 //==================================================================================================
122 MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
123 const std::list<ModelHighAPI_Selection>& theMainObjects,
124 const ModelHighAPI_Selection& theAxis,
125 const ModelHighAPI_Integer& theNumber)
127 std::shared_ptr<ModelAPI_Feature> aFeature =
128 thePart->addFeature(FeaturesAPI_MultiRotation::ID());
129 return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
130 theAxis, theNumber));
133 //==================================================================================================
134 MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
135 const std::list<ModelHighAPI_Selection>& theMainObjects,
136 const ModelHighAPI_Selection& theAxis,
137 const ModelHighAPI_Double& theStep,
138 const ModelHighAPI_Integer& theNumber)
140 std::shared_ptr<ModelAPI_Feature> aFeature =
141 thePart->addFeature(FeaturesAPI_MultiRotation::ID());
142 return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
143 theAxis, theStep, theNumber));