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_Plane_H
22 #define ConstructionPlugin_Plane_H
24 #include "ConstructionPlugin.h"
26 #include <ModelAPI_Feature.h>
27 #include <ModelAPI_Result.h>
28 #include <GeomAPI_ICustomPrs.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;
51 inline static const std::string& ID()
53 static const std::string CONSTRUCTION_PLANE_KIND("Plane");
54 return CONSTRUCTION_PLANE_KIND;
57 /// Attribute name for creation method.
58 inline static const std::string& CREATION_METHOD()
60 static const std::string MY_CREATION_METHOD_ID("creation_method");
61 return MY_CREATION_METHOD_ID;
64 /// Attribute name for creation method.
65 inline static const std::string& CREATION_METHOD_BY_GENERAL_EQUATION()
67 static const std::string MY_CREATION_METHOD_ID("by_general_equation");
68 return MY_CREATION_METHOD_ID;
71 /// Attribute name for creation method.
72 inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
74 static const std::string MY_CREATION_METHOD_ID("by_three_points");
75 return MY_CREATION_METHOD_ID;
78 /// Attribute name for creation method.
79 inline static const std::string& CREATION_METHOD_BY_LINE_AND_POINT()
81 static const std::string MY_CREATION_METHOD_ID("by_line_and_point");
82 return MY_CREATION_METHOD_ID;
85 /// Attribute name for creation method.
86 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE()
88 static const std::string MY_CREATION_METHOD_ID("by_other_plane");
89 return MY_CREATION_METHOD_ID;
92 /// Attribute name for creation method.
93 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE_OPTION()
95 static const std::string MY_CREATION_METHOD_ID("by_other_plane_option");
96 return MY_CREATION_METHOD_ID;
99 /// Attribute name for creation method.
100 inline static const std::string& CREATION_METHOD_BY_DISTANCE_FROM_OTHER()
102 static const std::string MY_CREATION_METHOD_ID("by_distance_from_other");
103 return MY_CREATION_METHOD_ID;
106 /// Attribute name for creation method.
107 inline static const std::string& CREATION_METHOD_BY_COINCIDENT_TO_POINT()
109 static const std::string MY_CREATION_METHOD_ID("by_coincident_to_point");
110 return MY_CREATION_METHOD_ID;
113 /// Attribute name for creation method.
114 inline static const std::string& CREATION_METHOD_BY_ROTATION()
116 static const std::string MY_CREATION_METHOD_ID("by_rotation");
117 return MY_CREATION_METHOD_ID;
120 /// Attribute name for creation method.
121 inline static const std::string& CREATION_METHOD_BY_TWO_PARALLEL_PLANES()
123 static const std::string MY_CREATION_METHOD_ID("by_two_parallel_planes");
124 return MY_CREATION_METHOD_ID;
127 /// Attribute name for first point.
128 inline static const std::string& POINT1()
130 static const std::string ATTR_ID("point1");
134 /// Attribute name for second point.
135 inline static const std::string& POINT2()
137 static const std::string ATTR_ID("point2");
141 /// Attribute name for third point.
142 inline static const std::string& POINT3()
144 static const std::string ATTR_ID("point3");
148 /// Attribute name for line.
149 inline static const std::string& LINE()
151 static const std::string ATTR_ID("line");
155 /// Attribute name for point.
156 inline static const std::string& POINT()
158 static const std::string ATTR_ID("point");
162 /// Attribute name for perpendicular flag.
163 inline static const std::string& PERPENDICULAR()
165 static const std::string ATTR_ID("perpendicular");
169 /// Attribute name for selected plane.
170 inline static const std::string& PLANE()
172 static const std::string ATTR_ID("plane");
176 /// Attribute name for distance.
177 inline static const std::string& DISTANCE()
179 static const std::string ATTR_ID("distance");
183 /// Attribute name for reverse flag.
184 inline static const std::string& REVERSE()
186 static const std::string ATTR_ID("reverse");
190 /// Attribute name for coincident point.
191 inline static const std::string& COINCIDENT_POINT()
193 static const std::string ATTR_ID("coincident_point");
197 /// Attribute name for axis.
198 inline static const std::string& AXIS()
200 static const std::string ATTR_ID("axis");
204 /// Attribute name for angle.
205 inline static const std::string& ANGLE()
207 static const std::string ATTR_ID("angle");
211 inline static const std::string& PLANE1()
213 static const std::string ATTR_ID("plane1");
217 inline static const std::string& PLANE2()
219 static const std::string ATTR_ID("plane2");
224 /// Attribute name for a parameter for the general equation of a plane (ax+by+cz+d=0)
225 inline static const std::string& A()
227 static const std::string ATTR_ID("A");
230 /// Attribute name for b parameter for the general equation of a plane (ax+by+cz+d=0)
231 inline static const std::string& B()
233 static const std::string ATTR_ID("B");
236 /// Attribute name for c parameter for the general equation of a plane (ax+by+cz+d=0)
237 inline static const std::string& C()
239 static const std::string ATTR_ID("C");
242 /// Attribute name for d parameter for the general equation of a plane (ax+by+cz+d=0)
243 inline static const std::string& D()
245 static const std::string ATTR_ID("D");
249 /// Creates a new part document if needed
250 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
252 /// Request for initialization of data model of the feature: adding all attributes
253 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
255 /// Construction result is always recomputed on the fly
256 CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
258 /// Use plugin manager for features creation
259 ConstructionPlugin_Plane();
261 /// Customize presentation of the feature
262 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
263 std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
266 /// Creates a new plane by general equation.
267 std::shared_ptr<GeomAPI_Shape> createByGeneralEquation();
268 std::shared_ptr<GeomAPI_Shape> createByThreePoints();
269 std::shared_ptr<GeomAPI_Shape> createByLineAndPoint();
270 std::shared_ptr<GeomAPI_Shape> createByCoincidentPoint();
271 std::shared_ptr<GeomAPI_Shape> createByRotation();
272 std::shared_ptr<GeomAPI_Shape> createByTwoParallelPlanes();
273 /// Creates a new plane by copy of face plane with translation along the normal
274 /// to the specified distance.
275 std::shared_ptr<GeomAPI_Shape> createByDistanceFromOther();