Salome HOME
Merge branch 'V9_2_2_BR'
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Rotation.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef FeaturesPlugin_Rotation_H_
21 #define FeaturesPlugin_Rotation_H_
22
23 #include <FeaturesPlugin.h>
24
25 #include <ModelAPI_Feature.h>
26
27 #include <GeomAlgoAPI_Rotation.h>
28
29 /// \class FeaturesPlugin_Rotation
30 /// \ingroup Plugins
31 /// \brief Feature for rotation objects around the axis.
32 class FeaturesPlugin_Rotation : public ModelAPI_Feature
33 {
34  public:
35   /// Rotation kind.
36   inline static const std::string& ID()
37   {
38     static const std::string MY_ROTATION_ID("Rotation");
39     return MY_ROTATION_ID;
40   }
41
42   /// Attribute name for creation method.
43   inline static const std::string& CREATION_METHOD()
44   {
45     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
46     return MY_CREATION_METHOD_ID;
47   }
48
49   /// Attribute name for creation method "ByAxisAndAngle".
50   inline static const std::string& CREATION_METHOD_BY_ANGLE()
51   {
52     static const std::string MY_CREATION_METHOD_ID("ByAxisAndAngle");
53     return MY_CREATION_METHOD_ID;
54   }
55
56   /// Attribute name for creation method "ByThreePoints".
57   inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
58   {
59     static const std::string MY_CREATION_METHOD_ID("ByThreePoints");
60     return MY_CREATION_METHOD_ID;
61   }
62
63   /// Attribute name of referenced objects.
64   inline static const std::string& OBJECTS_LIST_ID()
65   {
66     static const std::string MY_OBJECTS_LIST_ID("main_objects");
67     return MY_OBJECTS_LIST_ID;
68   }
69
70   /// Attribute name of an axis.
71   inline static const std::string& AXIS_OBJECT_ID()
72   {
73     static const std::string MY_AXIS_OBJECT_ID("axis_object");
74     return MY_AXIS_OBJECT_ID;
75   }
76
77   /// Attribute name of angle.
78   inline static const std::string& ANGLE_ID()
79   {
80     static const std::string MY_ANGLE_ID("angle");
81     return MY_ANGLE_ID;
82   }
83
84   /// Attribute name of a center point.
85   inline static const std::string& CENTER_POINT_ID()
86   {
87     static const std::string MY_CENTER_POINT_ID("center_point");
88     return MY_CENTER_POINT_ID;
89   }
90
91   /// Attribute name of a center point.
92   inline static const std::string& START_POINT_ID()
93   {
94     static const std::string MY_START_POINT_ID("start_point");
95     return MY_START_POINT_ID;
96   }
97
98   /// Attribute name of a center point.
99   inline static const std::string& END_POINT_ID()
100   {
101     static const std::string MY_END_POINT_ID("end_point");
102     return MY_END_POINT_ID;
103   }
104
105   /// \return the kind of a feature.
106   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
107   {
108     static std::string MY_KIND = FeaturesPlugin_Rotation::ID();
109     return MY_KIND;
110   }
111
112   /// Creates a new part document if needed.
113   FEATURESPLUGIN_EXPORT virtual void execute();
114
115   /// Request for initialization of data model of the feature: adding all attributes.
116   FEATURESPLUGIN_EXPORT virtual void initAttributes();
117
118   /// Use plugin manager for features creation.
119   FeaturesPlugin_Rotation();
120
121 private:
122   ///Perform the rotation using an axis and an angle.
123   void performTranslationByAxisAndAngle();
124
125   ///Perform the rotation using a center and two points.
126   void performTranslationByThreePoints();
127 };
128
129 #endif