Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Rotation.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Rotation.cpp
4 // Created:     07 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Rotation.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //==================================================================================================
20 FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                            const std::list<ModelHighAPI_Selection>& theMainObjects,
22                                            const ModelHighAPI_Selection& theAxisObject,
23                                            const ModelHighAPI_Double& theAngle)
24 : ModelHighAPI_Interface(theFeature)
25 {
26   if(initialize()) {
27     fillAttribute(theMainObjects, mymainObjects);
28     fillAttribute(theAxisObject, myaxisObject);
29     setAngle(theAngle);
30   }
31 }
32
33 //==================================================================================================
34 FeaturesAPI_Rotation::~FeaturesAPI_Rotation()
35 {
36
37 }
38
39 //==================================================================================================
40 void FeaturesAPI_Rotation::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
41 {
42   fillAttribute(theMainObjects, mymainObjects);
43
44   execute();
45 }
46
47 //==================================================================================================
48 void FeaturesAPI_Rotation::setAxisObject(const ModelHighAPI_Selection& theAxisObject)
49 {
50   fillAttribute(theAxisObject, myaxisObject);
51
52   execute();
53 }
54
55 //==================================================================================================
56 void FeaturesAPI_Rotation::setAngle(const ModelHighAPI_Double& theAngle)
57 {
58   fillAttribute(theAngle, myangle);
59
60   execute();
61 }
62
63 //==================================================================================================
64 void FeaturesAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
65 {
66   FeaturePtr aBase = feature();
67   const std::string& aDocName = theDumper.name(aBase->document());
68
69   AttributeSelectionListPtr anAttrObjects =
70     aBase->selectionList(FeaturesPlugin_Rotation::OBJECTS_LIST_ID());
71   AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID());
72   AttributeDoublePtr anAttrAngle = aBase->real(FeaturesPlugin_Rotation::ANGLE_ID());
73
74   theDumper << aBase << " = model.addRotation(" << aDocName << ", "
75             << anAttrObjects << ", " << anAttrAxis << ", " << anAttrAngle << ")" << std::endl;
76 }
77
78 //==================================================================================================
79 RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
80                         const std::list<ModelHighAPI_Selection>& theMainObjects,
81                         const ModelHighAPI_Selection& theAxisObject,
82                         const ModelHighAPI_Double& theAngle)
83 {
84   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Rotation::ID());
85   return RotationPtr(new FeaturesAPI_Rotation(aFeature, theMainObjects, theAxisObject, theAngle));
86 }