1 // Copyright (C) 2014-2021 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_Plane_H
21 #define ConstructionPlugin_Plane_H
23 #include "ConstructionPlugin.h"
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Result.h>
27 #include <GeomAPI_ICustomPrs.h>
29 /// \class ConstructionPlugin_Plane
31 /// \brief Feature for creation of the new planar surface in PartSet.
32 class ConstructionPlugin_Plane: public ModelAPI_Feature, public GeomAPI_ICustomPrs
35 /// \return the kind of a feature.
36 CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
38 static std::string MY_KIND = ConstructionPlugin_Plane::ID();
42 /// Default color for a plane.
43 inline static const std::string& DEFAULT_COLOR()
45 static const std::string CONSTRUCTION_PLANE_COLOR("150,150,180");
46 return CONSTRUCTION_PLANE_COLOR;
49 /// Default color property name.
50 inline static const std::string& COLOR_NAME()
52 static const std::string PLANE_COLOR_NAME("construction_plane_color");
53 return PLANE_COLOR_NAME;
57 inline static const std::string& ID()
59 static const std::string CONSTRUCTION_PLANE_KIND("Plane");
60 return CONSTRUCTION_PLANE_KIND;
63 /// Attribute name for creation method.
64 inline static const std::string& CREATION_METHOD()
66 static const std::string MY_CREATION_METHOD_ID("creation_method");
67 return MY_CREATION_METHOD_ID;
70 /// Attribute name for creation method.
71 inline static const std::string& CREATION_METHOD_BY_GENERAL_EQUATION()
73 static const std::string MY_CREATION_METHOD_ID("by_general_equation");
74 return MY_CREATION_METHOD_ID;
77 /// Attribute name for creation method.
78 inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
80 static const std::string MY_CREATION_METHOD_ID("by_three_points");
81 return MY_CREATION_METHOD_ID;
84 /// Attribute name for creation method.
85 inline static const std::string& CREATION_METHOD_BY_LINE_AND_POINT()
87 static const std::string MY_CREATION_METHOD_ID("by_line_and_point");
88 return MY_CREATION_METHOD_ID;
91 /// Attribute name for creation method.
92 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE()
94 static const std::string MY_CREATION_METHOD_ID("by_other_plane");
95 return MY_CREATION_METHOD_ID;
98 /// Attribute name for creation method.
99 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE_OPTION()
101 static const std::string MY_CREATION_METHOD_ID("by_other_plane_option");
102 return MY_CREATION_METHOD_ID;
105 /// Attribute name for creation method.
106 inline static const std::string& CREATION_METHOD_BY_DISTANCE_FROM_OTHER()
108 static const std::string MY_CREATION_METHOD_ID("by_distance_from_other");
109 return MY_CREATION_METHOD_ID;
112 /// Attribute name for creation method.
113 inline static const std::string& CREATION_METHOD_BY_COINCIDENT_TO_POINT()
115 static const std::string MY_CREATION_METHOD_ID("by_coincident_to_point");
116 return MY_CREATION_METHOD_ID;
119 /// Attribute name for creation method.
120 inline static const std::string& CREATION_METHOD_BY_ROTATION()
122 static const std::string MY_CREATION_METHOD_ID("by_rotation");
123 return MY_CREATION_METHOD_ID;
126 /// Attribute name for creation method.
127 inline static const std::string& CREATION_METHOD_BY_TWO_PARALLEL_PLANES()
129 static const std::string MY_CREATION_METHOD_ID("by_two_parallel_planes");
130 return MY_CREATION_METHOD_ID;
133 /// Attribute name for first point.
134 inline static const std::string& POINT1()
136 static const std::string ATTR_ID("point1");
140 /// Attribute name for second point.
141 inline static const std::string& POINT2()
143 static const std::string ATTR_ID("point2");
147 /// Attribute name for third point.
148 inline static const std::string& POINT3()
150 static const std::string ATTR_ID("point3");
154 /// Attribute name for line.
155 inline static const std::string& LINE()
157 static const std::string ATTR_ID("line");
161 /// Attribute name for point.
162 inline static const std::string& POINT()
164 static const std::string ATTR_ID("point");
168 /// Attribute name for perpendicular flag.
169 inline static const std::string& PERPENDICULAR()
171 static const std::string ATTR_ID("perpendicular");
175 /// Attribute name for selected plane.
176 inline static const std::string& PLANE()
178 static const std::string ATTR_ID("plane");
182 /// Attribute name for distance.
183 inline static const std::string& DISTANCE()
185 static const std::string ATTR_ID("distance");
189 /// Attribute name for reverse flag.
190 inline static const std::string& REVERSE()
192 static const std::string ATTR_ID("reverse");
196 /// Attribute name for coincident point.
197 inline static const std::string& COINCIDENT_POINT()
199 static const std::string ATTR_ID("coincident_point");
203 /// Attribute name for axis.
204 inline static const std::string& AXIS()
206 static const std::string ATTR_ID("axis");
210 /// Attribute name for angle.
211 inline static const std::string& ANGLE()
213 static const std::string ATTR_ID("angle");
217 inline static const std::string& PLANE1()
219 static const std::string ATTR_ID("plane1");
223 inline static const std::string& PLANE2()
225 static const std::string ATTR_ID("plane2");
230 /// Attribute name for a parameter for the general equation of a plane (ax+by+cz+d=0)
231 inline static const std::string& A()
233 static const std::string ATTR_ID("A");
236 /// Attribute name for b parameter for the general equation of a plane (ax+by+cz+d=0)
237 inline static const std::string& B()
239 static const std::string ATTR_ID("B");
242 /// Attribute name for c parameter for the general equation of a plane (ax+by+cz+d=0)
243 inline static const std::string& C()
245 static const std::string ATTR_ID("C");
248 /// Attribute name for d parameter for the general equation of a plane (ax+by+cz+d=0)
249 inline static const std::string& D()
251 static const std::string ATTR_ID("D");
255 /// Creates a new part document if needed
256 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
258 /// Request for initialization of data model of the feature: adding all attributes
259 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
261 /// Use plugin manager for features creation
262 ConstructionPlugin_Plane();
264 /// Customize presentation of the feature
265 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs);
268 /// Creates a new plane by general equation.
269 std::shared_ptr<GeomAPI_Shape> createByGeneralEquation();
270 std::shared_ptr<GeomAPI_Shape> createByThreePoints();
271 std::shared_ptr<GeomAPI_Shape> createByLineAndPoint();
272 std::shared_ptr<GeomAPI_Shape> createByCoincidentPoint();
273 std::shared_ptr<GeomAPI_Shape> createByRotation();
274 std::shared_ptr<GeomAPI_Shape> createByTwoParallelPlanes();
275 /// Creates a new plane by copy of face plane with translation along the normal
276 /// to the specified distance.
277 std::shared_ptr<GeomAPI_Shape> createByDistanceFromOther();