1 // Copyright (C) 2014-2023 CEA, EDF
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>
28 #include <GeomAPI_Shape.h>
30 /// \class ConstructionPlugin_Plane
32 /// \brief Feature for creation of the new planar surface in PartSet.
33 class ConstructionPlugin_Plane: public ModelAPI_Feature, public GeomAPI_ICustomPrs
36 /// \return the kind of a feature.
37 CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
39 static std::string MY_KIND = ConstructionPlugin_Plane::ID();
43 /// Default color for a plane.
44 inline static const std::string& DEFAULT_COLOR()
46 static const std::string CONSTRUCTION_PLANE_COLOR("150,150,180");
47 return CONSTRUCTION_PLANE_COLOR;
50 /// Default color property name.
51 inline static const std::string& COLOR_NAME()
53 static const std::string PLANE_COLOR_NAME("construction_plane_color");
54 return PLANE_COLOR_NAME;
58 inline static const std::string& ID()
60 static const std::string CONSTRUCTION_PLANE_KIND("Plane");
61 return CONSTRUCTION_PLANE_KIND;
64 /// Attribute name for creation method.
65 inline static const std::string& CREATION_METHOD()
67 static const std::string MY_CREATION_METHOD_ID("creation_method");
68 return MY_CREATION_METHOD_ID;
71 /// Attribute name for creation method.
72 inline static const std::string& CREATION_METHOD_BY_GENERAL_EQUATION()
74 static const std::string MY_CREATION_METHOD_ID("by_general_equation");
75 return MY_CREATION_METHOD_ID;
78 /// Attribute name for creation method.
79 inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
81 static const std::string MY_CREATION_METHOD_ID("by_three_points");
82 return MY_CREATION_METHOD_ID;
85 /// Attribute name for creation method.
86 inline static const std::string& CREATION_METHOD_BY_LINE_AND_POINT()
88 static const std::string MY_CREATION_METHOD_ID("by_line_and_point");
89 return MY_CREATION_METHOD_ID;
92 /// Attribute name for creation method.
93 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE()
95 static const std::string MY_CREATION_METHOD_ID("by_other_plane");
96 return MY_CREATION_METHOD_ID;
99 /// Attribute name for creation method.
100 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE_OPTION()
102 static const std::string MY_CREATION_METHOD_ID("by_other_plane_option");
103 return MY_CREATION_METHOD_ID;
106 /// Attribute name for creation method.
107 inline static const std::string& CREATION_METHOD_BY_DISTANCE_FROM_OTHER()
109 static const std::string MY_CREATION_METHOD_ID("by_distance_from_other");
110 return MY_CREATION_METHOD_ID;
113 /// Attribute name for creation method.
114 inline static const std::string& CREATION_METHOD_BY_COINCIDENT_TO_POINT()
116 static const std::string MY_CREATION_METHOD_ID("by_coincident_to_point");
117 return MY_CREATION_METHOD_ID;
120 /// Attribute name for creation method.
121 inline static const std::string& CREATION_METHOD_BY_ROTATION()
123 static const std::string MY_CREATION_METHOD_ID("by_rotation");
124 return MY_CREATION_METHOD_ID;
127 /// Attribute name for creation method.
128 inline static const std::string& CREATION_METHOD_BY_TWO_PARALLEL_PLANES()
130 static const std::string MY_CREATION_METHOD_ID("by_two_parallel_planes");
131 return MY_CREATION_METHOD_ID;
134 /// Attribute name for first point.
135 inline static const std::string& POINT1()
137 static const std::string ATTR_ID("point1");
141 /// Attribute name for second point.
142 inline static const std::string& POINT2()
144 static const std::string ATTR_ID("point2");
148 /// Attribute name for third point.
149 inline static const std::string& POINT3()
151 static const std::string ATTR_ID("point3");
155 /// Attribute name for line.
156 inline static const std::string& LINE()
158 static const std::string ATTR_ID("line");
162 /// Attribute name for point.
163 inline static const std::string& POINT()
165 static const std::string ATTR_ID("point");
169 /// Attribute name for perpendicular flag.
170 inline static const std::string& PERPENDICULAR()
172 static const std::string ATTR_ID("perpendicular");
176 /// Attribute name for selected plane.
177 inline static const std::string& PLANE()
179 static const std::string ATTR_ID("plane");
183 /// Attribute name for distance.
184 inline static const std::string& DISTANCE()
186 static const std::string ATTR_ID("distance");
190 /// Attribute name for reverse flag.
191 inline static const std::string& REVERSE()
193 static const std::string ATTR_ID("reverse");
197 /// Attribute name for coincident point.
198 inline static const std::string& COINCIDENT_POINT()
200 static const std::string ATTR_ID("coincident_point");
204 /// Attribute name for axis.
205 inline static const std::string& AXIS()
207 static const std::string ATTR_ID("axis");
211 /// Attribute name for angle.
212 inline static const std::string& ANGLE()
214 static const std::string ATTR_ID("angle");
218 inline static const std::string& PLANE1()
220 static const std::string ATTR_ID("plane1");
224 inline static const std::string& PLANE2()
226 static const std::string ATTR_ID("plane2");
230 inline static const std::string& NB_COPIES()
232 static const std::string ATTR_ID("nb_copies");
236 /// Attribute name for a parameter for the general equation of a plane (ax+by+cz+d=0)
237 inline static const std::string& A()
239 static const std::string ATTR_ID("A");
242 /// Attribute name for b parameter for the general equation of a plane (ax+by+cz+d=0)
243 inline static const std::string& B()
245 static const std::string ATTR_ID("B");
248 /// Attribute name for c parameter for the general equation of a plane (ax+by+cz+d=0)
249 inline static const std::string& C()
251 static const std::string ATTR_ID("C");
254 /// Attribute name for d parameter for the general equation of a plane (ax+by+cz+d=0)
255 inline static const std::string& D()
257 static const std::string ATTR_ID("D");
261 /// Creates a new part document if needed
262 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
264 /// Request for initialization of data model of the feature: adding all attributes
265 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
267 /// Use plugin manager for features creation
268 ConstructionPlugin_Plane();
270 /// Customize presentation of the feature
271 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs);
274 /// Creates a new plane by general equation.
275 std::shared_ptr<GeomAPI_Shape> createByGeneralEquation();
276 std::shared_ptr<GeomAPI_Shape> createByThreePoints();
277 std::shared_ptr<GeomAPI_Shape> createByLineAndPoint();
278 std::shared_ptr<GeomAPI_Shape> createByCoincidentPoint();
279 void createByRotation(ListOfShape& theShapes);
280 std::shared_ptr<GeomAPI_Shape> createByTwoParallelPlanes();
281 /// Creates a new plane by copy of face plane with translation along the normal
282 /// to the specified distance.
283 void createByDistanceFromOther(ListOfShape& theShapes);