1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ConstructionPlugin_Axis_H
22 #define ConstructionPlugin_Axis_H
24 #include "ConstructionPlugin.h"
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Result.h>
27 #include <GeomAPI_ICustomPrs.h>
29 /**\class ConstructionPlugin_Axis
31 * \brief Feature for creation of the new axis in PartSet.
33 class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomPrs
36 /// Returns the kind of a feature
37 CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
39 static std::string MY_KIND = ConstructionPlugin_Axis::ID();
44 inline static const std::string& ID()
46 static const std::string CONSTRUCTION_AXIS_KIND("Axis");
47 return CONSTRUCTION_AXIS_KIND;
50 /// attribute name for first point
51 inline static const std::string& METHOD()
53 static const std::string METHOD_ATTR("CreationMethod");
57 /// Attribute name for creation method.
58 inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
60 static const std::string METHOD_ATTR("AxisByPointsCase");
64 /// Attribute name for creation method.
65 inline static const std::string& CREATION_METHOD_BY_CYLINDRICAL_FACE()
67 static const std::string METHOD_ATTR("AxisByCylindricalFaceCase");
71 /// Attribute name for creation method.
72 inline static const std::string& CREATION_METHOD_BY_POINT_AND_DIRECTION()
74 static const std::string METHOD_ATTR("AxisByPointAndDirection");
78 /// Attribute name for creation method.
79 inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
81 static const std::string METHOD_ATTR("AxisByDimensionsCase");
85 /// Attribute name for creation method.
86 inline static const std::string& CREATION_METHOD_BY_LINE()
88 static const std::string METHOD_ATTR("by_line");
92 /// Attribute name for creation method.
93 inline static const std::string& CREATION_METHOD_BY_PLANE_AND_POINT()
95 static const std::string METHOD_ATTR("by_plane_and_point");
99 /// Attribute name for creation method.
100 inline static const std::string& CREATION_METHOD_BY_TWO_PLANES()
102 static const std::string METHOD_ATTR("by_two_planes");
106 /// attribute name for first point
107 inline static const std::string& POINT_FIRST()
109 static const std::string POINT_ATTR_FIRST("FirstPoint");
110 return POINT_ATTR_FIRST;
112 /// attribute name for second point
113 inline static const std::string& POINT_SECOND()
115 static const std::string POINT_ATTR_SECOND("SecondPoint");
116 return POINT_ATTR_SECOND;
118 /// attribute name for second point
119 inline static const std::string& CYLINDRICAL_FACE()
121 static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
122 return CYLINDRICAL_FACE_ATTR;
124 /// attribute name for the X dimension
125 inline static const std::string& DX()
127 static const std::string DX_ATTR("DX");
130 /// attribute name for the Y dimension
131 inline static const std::string& DY()
133 static const std::string DY_ATTR("DY");
136 /// attribute name for the Z dimension
137 inline static const std::string& DZ()
139 static const std::string DZ_ATTR("DZ");
143 /// attribute name for X direction
144 inline static const std::string& X_DIRECTION()
146 static const std::string ATTR_X_DIRECTION("X_Direction");
147 return ATTR_X_DIRECTION;
150 /// attribute name for Y direction
151 inline static const std::string& Y_DIRECTION()
153 static const std::string ATTR_Y_DIRECTION("Y_Direction");
154 return ATTR_Y_DIRECTION;
157 /// attribute name for Y direction
158 inline static const std::string& Z_DIRECTION()
160 static const std::string ATTR_Z_DIRECTION("Z_Direction");
161 return ATTR_Z_DIRECTION;
164 /// Attribute name for line.
165 inline static const std::string& LINE()
167 static const std::string ATTR_ID("line");
171 /// Attribute name for plane.
172 inline static const std::string& PLANE()
174 static const std::string ATTR_ID("plane");
178 /// Attribute name for point.
179 inline static const std::string& POINT()
181 static const std::string ATTR_ID("point");
185 /// Attribute name for plane 1.
186 inline static const std::string& PLANE1()
188 static const std::string ATTR_ID("plane1");
192 /// Attribute name for use offset for plane 1.
193 inline static const std::string& USE_OFFSET1()
195 static const std::string ATTR_ID("use_offset1");
199 /// Attribute name for offset for plane 1.
200 inline static const std::string& OFFSET1()
202 static const std::string ATTR_ID("offset1");
206 /// Attribute name for reverse offset for plane 1.
207 inline static const std::string& REVERSE_OFFSET1()
209 static const std::string ATTR_ID("reverse_offset1");
213 /// Attribute name for plane 2.
214 inline static const std::string& PLANE2()
216 static const std::string ATTR_ID("plane2");
220 /// Attribute name for use offset for plane 2.
221 inline static const std::string& USE_OFFSET2()
223 static const std::string ATTR_ID("use_offset2");
227 /// Attribute name for offset for plane 2.
228 inline static const std::string& OFFSET2()
230 static const std::string ATTR_ID("offset2");
234 /// Attribute name for reverse offset for plane 2.
235 inline static const std::string& REVERSE_OFFSET2()
237 static const std::string ATTR_ID("reverse_offset2");
241 /// Returns a minimal length for axis
242 inline static const double MINIMAL_LENGTH() { return 1.e-5; }
244 /// Creates a new part document if needed
245 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
247 /// Request for initialization of data model of the feature: adding all attributes
248 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
250 /// Construction result is allways recomuted on the fly
251 CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
253 /// Use plugin manager for features creation
254 ConstructionPlugin_Axis();
256 /// Customize presentation of the feature
257 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
258 std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
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();