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