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_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;
50 inline static const std::string& ID()
52 static const std::string CONSTRUCTION_PLANE_KIND("Plane");
53 return CONSTRUCTION_PLANE_KIND;
56 /// Attribute name for creation method.
57 inline static const std::string& CREATION_METHOD()
59 static const std::string MY_CREATION_METHOD_ID("creation_method");
60 return MY_CREATION_METHOD_ID;
63 /// Attribute name for creation method.
64 inline static const std::string& CREATION_METHOD_BY_GENERAL_EQUATION()
66 static const std::string MY_CREATION_METHOD_ID("by_general_equation");
67 return MY_CREATION_METHOD_ID;
70 /// Attribute name for creation method.
71 inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
73 static const std::string MY_CREATION_METHOD_ID("by_three_points");
74 return MY_CREATION_METHOD_ID;
77 /// Attribute name for creation method.
78 inline static const std::string& CREATION_METHOD_BY_LINE_AND_POINT()
80 static const std::string MY_CREATION_METHOD_ID("by_line_and_point");
81 return MY_CREATION_METHOD_ID;
84 /// Attribute name for creation method.
85 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE()
87 static const std::string MY_CREATION_METHOD_ID("by_other_plane");
88 return MY_CREATION_METHOD_ID;
91 /// Attribute name for creation method.
92 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE_OPTION()
94 static const std::string MY_CREATION_METHOD_ID("by_other_plane_option");
95 return MY_CREATION_METHOD_ID;
98 /// Attribute name for creation method.
99 inline static const std::string& CREATION_METHOD_BY_DISTANCE_FROM_OTHER()
101 static const std::string MY_CREATION_METHOD_ID("by_distance_from_other");
102 return MY_CREATION_METHOD_ID;
105 /// Attribute name for creation method.
106 inline static const std::string& CREATION_METHOD_BY_COINCIDENT_TO_POINT()
108 static const std::string MY_CREATION_METHOD_ID("by_coincident_to_point");
109 return MY_CREATION_METHOD_ID;
112 /// Attribute name for creation method.
113 inline static const std::string& CREATION_METHOD_BY_ROTATION()
115 static const std::string MY_CREATION_METHOD_ID("by_rotation");
116 return MY_CREATION_METHOD_ID;
119 /// Attribute name for creation method.
120 inline static const std::string& CREATION_METHOD_BY_TWO_PARALLEL_PLANES()
122 static const std::string MY_CREATION_METHOD_ID("by_two_parallel_planes");
123 return MY_CREATION_METHOD_ID;
126 /// Attribute name for first point.
127 inline static const std::string& POINT1()
129 static const std::string ATTR_ID("point1");
133 /// Attribute name for second point.
134 inline static const std::string& POINT2()
136 static const std::string ATTR_ID("point2");
140 /// Attribute name for third point.
141 inline static const std::string& POINT3()
143 static const std::string ATTR_ID("point3");
147 /// Attribute name for line.
148 inline static const std::string& LINE()
150 static const std::string ATTR_ID("line");
154 /// Attribute name for point.
155 inline static const std::string& POINT()
157 static const std::string ATTR_ID("point");
161 /// Attribute name for perpendicular flag.
162 inline static const std::string& PERPENDICULAR()
164 static const std::string ATTR_ID("perpendicular");
168 /// Attribute name for selected plane.
169 inline static const std::string& PLANE()
171 static const std::string ATTR_ID("plane");
175 /// Attribute name for distance.
176 inline static const std::string& DISTANCE()
178 static const std::string ATTR_ID("distance");
182 /// Attribute name for reverse flag.
183 inline static const std::string& REVERSE()
185 static const std::string ATTR_ID("reverse");
189 /// Attribute name for coincident point.
190 inline static const std::string& COINCIDENT_POINT()
192 static const std::string ATTR_ID("coincident_point");
196 /// Attribute name for axis.
197 inline static const std::string& AXIS()
199 static const std::string ATTR_ID("axis");
203 /// Attribute name for angle.
204 inline static const std::string& ANGLE()
206 static const std::string ATTR_ID("angle");
210 inline static const std::string& PLANE1()
212 static const std::string ATTR_ID("plane1");
216 inline static const std::string& PLANE2()
218 static const std::string ATTR_ID("plane2");
223 /// Attribute name for a parameter for the general equation of a plane (ax+by+cz+d=0)
224 inline static const std::string& A()
226 static const std::string ATTR_ID("A");
229 /// Attribute name for b parameter for the general equation of a plane (ax+by+cz+d=0)
230 inline static const std::string& B()
232 static const std::string ATTR_ID("B");
235 /// Attribute name for c parameter for the general equation of a plane (ax+by+cz+d=0)
236 inline static const std::string& C()
238 static const std::string ATTR_ID("C");
241 /// Attribute name for d parameter for the general equation of a plane (ax+by+cz+d=0)
242 inline static const std::string& D()
244 static const std::string ATTR_ID("D");
248 /// Creates a new part document if needed
249 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
251 /// Request for initialization of data model of the feature: adding all attributes
252 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
254 /// Use plugin manager for features creation
255 ConstructionPlugin_Plane();
257 /// Customize presentation of the feature
258 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
259 std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
262 /// Creates a new plane by general equation.
263 std::shared_ptr<GeomAPI_Shape> createByGeneralEquation();
264 std::shared_ptr<GeomAPI_Shape> createByThreePoints();
265 std::shared_ptr<GeomAPI_Shape> createByLineAndPoint();
266 std::shared_ptr<GeomAPI_Shape> createByCoincidentPoint();
267 std::shared_ptr<GeomAPI_Shape> createByRotation();
268 std::shared_ptr<GeomAPI_Shape> createByTwoParallelPlanes();
269 /// Creates a new plane by copy of face plane with translation along the normal
270 /// to the specified distance.
271 std::shared_ptr<GeomAPI_Shape> createByDistanceFromOther();