1 // Copyright (C) 2017-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: FeaturesAPI_MultiRotation.cpp
21 // Created: 04 Apr 2017
22 // Author: Clarisse Genrault (CEA)
24 #include <FeaturesAPI_MultiRotation.h>
26 #include <ModelHighAPI_Dumper.h>
27 #include <ModelHighAPI_Tools.h>
29 //==================================================================================================
30 FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
31 const std::shared_ptr<ModelAPI_Feature>& theFeature)
32 : ModelHighAPI_Interface(theFeature)
38 //==================================================================================================
39 FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
40 const std::shared_ptr<ModelAPI_Feature>& theFeature,
41 const std::list<ModelHighAPI_Selection>& theMainObjects,
42 const ModelHighAPI_Selection& theAxis,
43 const ModelHighAPI_Integer& theNumber)
44 : ModelHighAPI_Interface(theFeature)
47 fillAttribute(theMainObjects, mainObjects());
48 fillAttribute(theAxis, axisAngular());
49 fillAttribute("",useStepAngular());
50 setNumberAngular(theNumber);
54 //==================================================================================================
55 FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
56 const std::shared_ptr<ModelAPI_Feature>& theFeature,
57 const std::list<ModelHighAPI_Selection>& theMainObjects,
58 const ModelHighAPI_Selection& theAxis,
59 const ModelHighAPI_Double& theStep,
60 const ModelHighAPI_Integer& theNumber)
61 : ModelHighAPI_Interface(theFeature)
64 fillAttribute(theMainObjects, mainObjects());
65 fillAttribute(theAxis, axisAngular());
66 fillAttribute(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID(),useStepAngular());
67 fillAttribute(theStep, stepAngular());
68 setNumberAngular(theNumber);
72 //==================================================================================================
73 FeaturesAPI_MultiRotation::~FeaturesAPI_MultiRotation()
77 //==================================================================================================
78 void FeaturesAPI_MultiRotation::setMainObjects(
79 const std::list<ModelHighAPI_Selection>& theMainObjects)
81 fillAttribute(theMainObjects, mainObjects());
86 //==================================================================================================
87 void FeaturesAPI_MultiRotation::setAxisAngular(const ModelHighAPI_Selection& theAxis)
89 fillAttribute(theAxis, axisAngular());
94 //==================================================================================================
95 void FeaturesAPI_MultiRotation::setStepAngular(const ModelHighAPI_Double& theStep)
97 fillAttribute(theStep, stepAngular());
102 //==================================================================================================
103 void FeaturesAPI_MultiRotation::setNumberAngular(const ModelHighAPI_Integer& theNumber)
105 fillAttribute(theNumber, nbAngular());
110 //==================================================================================================
111 void FeaturesAPI_MultiRotation::dump(ModelHighAPI_Dumper& theDumper) const
113 FeaturePtr aBase = feature();
114 const std::string& aDocName = theDumper.name(aBase->document());
116 AttributeSelectionListPtr anAttrObjects =
117 aBase->selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID());
118 theDumper << aBase << " = model.addMultiRotation(" << aDocName << ", " << anAttrObjects;
120 AttributeSelectionPtr anAttrAxis =
121 aBase->selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID());
122 theDumper << ", " << anAttrAxis;
124 if (aBase->string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->isInitialized()
125 && !aBase->string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->value().empty()) {
126 AttributeDoublePtr anAttrStepAngular =
127 aBase->real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID());
128 theDumper << ", " << anAttrStepAngular;
131 AttributeIntegerPtr anAttrNumberAngular =
132 aBase->integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID());
133 theDumper << ", " << anAttrNumberAngular;
135 theDumper << ")" << std::endl;
138 //==================================================================================================
139 MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
140 const std::list<ModelHighAPI_Selection>& theMainObjects,
141 const ModelHighAPI_Selection& theAxis,
142 const ModelHighAPI_Integer& theNumber)
144 std::shared_ptr<ModelAPI_Feature> aFeature =
145 thePart->addFeature(FeaturesAPI_MultiRotation::ID());
146 return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
147 theAxis, theNumber));
150 //==================================================================================================
151 MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
152 const std::list<ModelHighAPI_Selection>& theMainObjects,
153 const ModelHighAPI_Selection& theAxis,
154 const ModelHighAPI_Double& theStep,
155 const ModelHighAPI_Integer& theNumber)
157 std::shared_ptr<ModelAPI_Feature> aFeature =
158 thePart->addFeature(FeaturesAPI_MultiRotation::ID());
159 return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
160 theAxis, theStep, theNumber));