Salome HOME
afdddbe469efb6298acc6ef72817a9864b7bb6c2
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Axis.h
1 // Copyright (C) 2014-2023  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 ConstructionPlugin_Axis_H
21 #define ConstructionPlugin_Axis_H
22
23 #include "ConstructionPlugin.h"
24 #include <ModelAPI_Feature.h>
25 #include <ModelAPI_Result.h>
26 #include <GeomAPI_ICustomPrs.h>
27
28 /**\class ConstructionPlugin_Axis
29  * \ingroup Plugins
30  * \brief Feature for creation of the new axis in PartSet.
31  */
32 class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomPrs
33 {
34  public:
35   /// Returns the kind of a feature
36   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
37   {
38     static std::string MY_KIND = ConstructionPlugin_Axis::ID();
39     return MY_KIND;
40   }
41
42   /// Axis kind
43   inline static const std::string& ID()
44   {
45     static const std::string CONSTRUCTION_AXIS_KIND("Axis");
46     return CONSTRUCTION_AXIS_KIND;
47   }
48
49   /// attribute name for first point
50   inline static const std::string& METHOD()
51   {
52     static const std::string METHOD_ATTR("CreationMethod");
53     return METHOD_ATTR;
54   }
55
56   /// Attribute name for creation method.
57   inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
58   {
59     static const std::string METHOD_ATTR("AxisByPointsCase");
60     return METHOD_ATTR;
61   }
62
63   /// Attribute name for creation method.
64   inline static const std::string& CREATION_METHOD_BY_CYLINDRICAL_FACE()
65   {
66     static const std::string METHOD_ATTR("AxisByCylindricalFaceCase");
67     return METHOD_ATTR;
68   }
69
70   /// Attribute name for creation method.
71   inline static const std::string& CREATION_METHOD_BY_POINT_AND_DIRECTION()
72   {
73     static const std::string METHOD_ATTR("AxisByPointAndDirection");
74     return METHOD_ATTR;
75   }
76
77   /// Attribute name for creation method.
78   inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
79   {
80     static const std::string METHOD_ATTR("AxisByDimensionsCase");
81     return METHOD_ATTR;
82   }
83
84   /// Attribute name for creation method.
85   inline static const std::string& CREATION_METHOD_BY_LINE()
86   {
87     static const std::string METHOD_ATTR("by_line");
88     return METHOD_ATTR;
89   }
90
91   /// Attribute name for creation method.
92   inline static const std::string& CREATION_METHOD_BY_PLANE_AND_POINT()
93   {
94     static const std::string METHOD_ATTR("by_plane_and_point");
95     return METHOD_ATTR;
96   }
97
98   /// Attribute name for creation method.
99   inline static const std::string& CREATION_METHOD_BY_TWO_PLANES()
100   {
101     static const std::string METHOD_ATTR("by_two_planes");
102     return METHOD_ATTR;
103   }
104
105   /// attribute name for first point
106   inline static const std::string& POINT_FIRST()
107   {
108     static const std::string POINT_ATTR_FIRST("FirstPoint");
109     return POINT_ATTR_FIRST;
110   }
111   /// attribute name for second point
112   inline static const std::string& POINT_SECOND()
113   {
114     static const std::string POINT_ATTR_SECOND("SecondPoint");
115     return POINT_ATTR_SECOND;
116   }
117   /// attribute name for second point
118   inline static const std::string& CYLINDRICAL_FACE()
119   {
120     static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
121     return CYLINDRICAL_FACE_ATTR;
122   }
123   /// attribute name for the X dimension
124   inline static const std::string& DX()
125   {
126     static const std::string DX_ATTR("DX");
127     return DX_ATTR;
128   }
129   /// attribute name for the Y dimension
130   inline static const std::string& DY()
131   {
132     static const std::string DY_ATTR("DY");
133     return DY_ATTR;
134   }
135   /// attribute name for the Z dimension
136   inline static const std::string& DZ()
137   {
138     static const std::string DZ_ATTR("DZ");
139     return DZ_ATTR;
140   }
141
142   /// attribute name for X direction
143   inline static const std::string& X_DIRECTION()
144   {
145     static const std::string ATTR_X_DIRECTION("X_Direction");
146     return ATTR_X_DIRECTION;
147   }
148
149   /// attribute name for Y direction
150   inline static const std::string& Y_DIRECTION()
151   {
152     static const std::string ATTR_Y_DIRECTION("Y_Direction");
153     return ATTR_Y_DIRECTION;
154   }
155
156   /// attribute name for Y direction
157   inline static const std::string& Z_DIRECTION()
158   {
159     static const std::string ATTR_Z_DIRECTION("Z_Direction");
160     return ATTR_Z_DIRECTION;
161   }
162
163   /// Attribute name for line.
164   inline static const std::string& LINE()
165   {
166     static const std::string ATTR_ID("line");
167     return ATTR_ID;
168   }
169
170   /// Attribute name for plane.
171   inline static const std::string& PLANE()
172   {
173     static const std::string ATTR_ID("plane");
174     return ATTR_ID;
175   }
176
177   /// Attribute name for point.
178   inline static const std::string& POINT()
179   {
180     static const std::string ATTR_ID("point");
181     return ATTR_ID;
182   }
183
184   /// Attribute name for plane 1.
185   inline static const std::string& PLANE1()
186   {
187     static const std::string ATTR_ID("plane1");
188     return ATTR_ID;
189   }
190
191   /// Attribute name for use offset for plane 1.
192   inline static const std::string& USE_OFFSET1()
193   {
194     static const std::string ATTR_ID("use_offset1");
195     return ATTR_ID;
196   }
197
198   /// Attribute name for offset for plane 1.
199   inline static const std::string& OFFSET1()
200   {
201     static const std::string ATTR_ID("offset1");
202     return ATTR_ID;
203   }
204
205   /// Attribute name for reverse offset for plane 1.
206   inline static const std::string& REVERSE_OFFSET1()
207   {
208     static const std::string ATTR_ID("reverse_offset1");
209     return ATTR_ID;
210   }
211
212   /// Attribute name for plane 2.
213   inline static const std::string& PLANE2()
214   {
215     static const std::string ATTR_ID("plane2");
216     return ATTR_ID;
217   }
218
219   /// Attribute name for use offset for plane 2.
220   inline static const std::string& USE_OFFSET2()
221   {
222     static const std::string ATTR_ID("use_offset2");
223     return ATTR_ID;
224   }
225
226   /// Attribute name for offset for plane 2.
227   inline static const std::string& OFFSET2()
228   {
229     static const std::string ATTR_ID("offset2");
230     return ATTR_ID;
231   }
232
233   /// Attribute name for reverse offset for plane 2.
234   inline static const std::string& REVERSE_OFFSET2()
235   {
236     static const std::string ATTR_ID("reverse_offset2");
237     return ATTR_ID;
238   }
239
240   /// Returns a minimal length for axis
241   inline static const double MINIMAL_LENGTH() { return 1.e-5; }
242
243   /// Creates a new part document if needed
244   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
245
246   /// Request for initialization of data model of the feature: adding all attributes
247   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
248
249   /// Use plugin manager for features creation
250   ConstructionPlugin_Axis();
251
252   /// Customize presentation of the feature
253   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs);
254
255  protected:
256   /// Creates a new axis by two defined points
257   void createAxisByTwoPoints();
258   /// Creates a new axis using three dimensions
259   void createAxisByDimensions();
260   /// Creates a new axis as copy of cylindrical face axis
261   void createAxisByCylindricalFace();
262   /// Creates a new axis by point and direction
263   void createAxisByPointAndDirection();
264   void createAxisByLine();
265   void createAxisByPlaneAndPoint();
266   void createAxisByTwoPlanes();
267 };
268
269
270 #endif