1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef ConstructionPlugin_Axis_H
21 #define ConstructionPlugin_Axis_H
23 #include "ConstructionPlugin.h"
24 #include <ModelAPI_Feature.h>
25 #include <ModelAPI_Result.h>
26 #include <GeomAPI_ICustomPrs.h>
28 /**\class ConstructionPlugin_Axis
30 * \brief Feature for creation of the new axis in PartSet.
32 class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomPrs
35 /// Returns the kind of a feature
36 CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
38 static std::string MY_KIND = ConstructionPlugin_Axis::ID();
43 inline static const std::string& ID()
45 static const std::string CONSTRUCTION_AXIS_KIND("Axis");
46 return CONSTRUCTION_AXIS_KIND;
49 /// attribute name for first point
50 inline static const std::string& METHOD()
52 static const std::string METHOD_ATTR("CreationMethod");
56 /// Attribute name for creation method.
57 inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
59 static const std::string METHOD_ATTR("AxisByPointsCase");
63 /// Attribute name for creation method.
64 inline static const std::string& CREATION_METHOD_BY_CYLINDRICAL_FACE()
66 static const std::string METHOD_ATTR("AxisByCylindricalFaceCase");
70 /// Attribute name for creation method.
71 inline static const std::string& CREATION_METHOD_BY_POINT_AND_DIRECTION()
73 static const std::string METHOD_ATTR("AxisByPointAndDirection");
77 /// Attribute name for creation method.
78 inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
80 static const std::string METHOD_ATTR("AxisByDimensionsCase");
84 /// Attribute name for creation method.
85 inline static const std::string& CREATION_METHOD_BY_LINE()
87 static const std::string METHOD_ATTR("by_line");
91 /// Attribute name for creation method.
92 inline static const std::string& CREATION_METHOD_BY_PLANE_AND_POINT()
94 static const std::string METHOD_ATTR("by_plane_and_point");
98 /// Attribute name for creation method.
99 inline static const std::string& CREATION_METHOD_BY_TWO_PLANES()
101 static const std::string METHOD_ATTR("by_two_planes");
105 /// attribute name for first point
106 inline static const std::string& POINT_FIRST()
108 static const std::string POINT_ATTR_FIRST("FirstPoint");
109 return POINT_ATTR_FIRST;
111 /// attribute name for second point
112 inline static const std::string& POINT_SECOND()
114 static const std::string POINT_ATTR_SECOND("SecondPoint");
115 return POINT_ATTR_SECOND;
117 /// attribute name for second point
118 inline static const std::string& CYLINDRICAL_FACE()
120 static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
121 return CYLINDRICAL_FACE_ATTR;
123 /// attribute name for the X dimension
124 inline static const std::string& DX()
126 static const std::string DX_ATTR("DX");
129 /// attribute name for the Y dimension
130 inline static const std::string& DY()
132 static const std::string DY_ATTR("DY");
135 /// attribute name for the Z dimension
136 inline static const std::string& DZ()
138 static const std::string DZ_ATTR("DZ");
142 /// attribute name for X direction
143 inline static const std::string& X_DIRECTION()
145 static const std::string ATTR_X_DIRECTION("X_Direction");
146 return ATTR_X_DIRECTION;
149 /// attribute name for Y direction
150 inline static const std::string& Y_DIRECTION()
152 static const std::string ATTR_Y_DIRECTION("Y_Direction");
153 return ATTR_Y_DIRECTION;
156 /// attribute name for Y direction
157 inline static const std::string& Z_DIRECTION()
159 static const std::string ATTR_Z_DIRECTION("Z_Direction");
160 return ATTR_Z_DIRECTION;
163 /// Attribute name for line.
164 inline static const std::string& LINE()
166 static const std::string ATTR_ID("line");
170 /// Attribute name for plane.
171 inline static const std::string& PLANE()
173 static const std::string ATTR_ID("plane");
177 /// Attribute name for point.
178 inline static const std::string& POINT()
180 static const std::string ATTR_ID("point");
184 /// Attribute name for plane 1.
185 inline static const std::string& PLANE1()
187 static const std::string ATTR_ID("plane1");
191 /// Attribute name for use offset for plane 1.
192 inline static const std::string& USE_OFFSET1()
194 static const std::string ATTR_ID("use_offset1");
198 /// Attribute name for offset for plane 1.
199 inline static const std::string& OFFSET1()
201 static const std::string ATTR_ID("offset1");
205 /// Attribute name for reverse offset for plane 1.
206 inline static const std::string& REVERSE_OFFSET1()
208 static const std::string ATTR_ID("reverse_offset1");
212 /// Attribute name for plane 2.
213 inline static const std::string& PLANE2()
215 static const std::string ATTR_ID("plane2");
219 /// Attribute name for use offset for plane 2.
220 inline static const std::string& USE_OFFSET2()
222 static const std::string ATTR_ID("use_offset2");
226 /// Attribute name for offset for plane 2.
227 inline static const std::string& OFFSET2()
229 static const std::string ATTR_ID("offset2");
233 /// Attribute name for reverse offset for plane 2.
234 inline static const std::string& REVERSE_OFFSET2()
236 static const std::string ATTR_ID("reverse_offset2");
240 /// Returns a minimal length for axis
241 inline static const double MINIMAL_LENGTH() { return 1.e-5; }
243 /// Creates a new part document if needed
244 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
246 /// Request for initialization of data model of the feature: adding all attributes
247 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
249 /// Use plugin manager for features creation
250 ConstructionPlugin_Axis();
252 /// Customize presentation of the feature
253 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
254 std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
257 /// Creates a new axis by two defined points
258 void createAxisByTwoPoints();
259 /// Creates a new axis using three dimensions
260 void createAxisByDimensions();
261 /// Creates a new axis as copy of cylindrical face axis
262 void createAxisByCylindricalFace();
263 /// Creates a new axis by point and direction
264 void createAxisByPointAndDirection();
265 void createAxisByLine();
266 void createAxisByPlaneAndPoint();
267 void createAxisByTwoPlanes();