Salome HOME
053a10f7df6ab8dac3019d9e50a86ef22d35a670
[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_Tools.h>
10
11 //==================================================================================================
12 FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature)
13 : ModelHighAPI_Interface(theFeature)
14 {
15   initialize();
16 }
17
18 //==================================================================================================
19 FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
20                                            const std::list<ModelHighAPI_Selection>& theMainObjects,
21                                            const ModelHighAPI_Selection& theAxisObject,
22                                            const ModelHighAPI_Double& theAngle)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if(initialize()) {
26     fillAttribute(theMainObjects, mymainObjects);
27     fillAttribute(theAxisObject, myaxisObject);
28     setAngle(theAngle);
29   }
30 }
31
32 //==================================================================================================
33 FeaturesAPI_Rotation::~FeaturesAPI_Rotation()
34 {
35
36 }
37
38 //==================================================================================================
39 void FeaturesAPI_Rotation::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
40 {
41   fillAttribute(theMainObjects, mymainObjects);
42
43   execute();
44 }
45
46 //==================================================================================================
47 void FeaturesAPI_Rotation::setAxisObject(const ModelHighAPI_Selection& theAxisObject)
48 {
49   fillAttribute(theAxisObject, myaxisObject);
50
51   execute();
52 }
53
54 //==================================================================================================
55 void FeaturesAPI_Rotation::setAngle(const ModelHighAPI_Double& theAngle)
56 {
57   fillAttribute(theAngle, myangle);
58
59   execute();
60 }
61
62 // TODO(spo): make add* as static functions of the class
63 //==================================================================================================
64 RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
65                         const std::list<ModelHighAPI_Selection>& theMainObjects,
66                         const ModelHighAPI_Selection& theAxisObject,
67                         const ModelHighAPI_Double& theDistance)
68 {
69   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Rotation::ID());
70   return RotationPtr(new FeaturesAPI_Rotation(aFeature, theMainObjects, theAxisObject, theDistance));
71 }