]> SALOME platform Git repositories - modules/shaper.git/blob - src/ConstructionPlugin/ConstructionPlugin_Plane.h
Salome HOME
Merge branch 'csgroup_IS2'
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Plane.h
1 // Copyright (C) 2014-2021  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef ConstructionPlugin_Plane_H
21 #define ConstructionPlugin_Plane_H
22
23 #include "ConstructionPlugin.h"
24
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Result.h>
27 #include <GeomAPI_ICustomPrs.h>
28
29 /// \class ConstructionPlugin_Plane
30 /// \ingroup Plugins
31 /// \brief Feature for creation of the new planar surface in PartSet.
32 class ConstructionPlugin_Plane: public ModelAPI_Feature, public GeomAPI_ICustomPrs
33 {
34 public:
35   /// \return the kind of a feature.
36   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
37   {
38     static std::string MY_KIND = ConstructionPlugin_Plane::ID();
39     return MY_KIND;
40   }
41
42   /// Default color for a plane.
43   inline static const std::string& DEFAULT_COLOR()
44   {
45     static const std::string CONSTRUCTION_PLANE_COLOR("150,150,180");
46     return CONSTRUCTION_PLANE_COLOR;
47   }
48
49   /// Default color property name.
50   inline static const std::string& COLOR_NAME()
51   {
52     static const std::string PLANE_COLOR_NAME("construction_plane_color");
53     return PLANE_COLOR_NAME;
54   }
55
56   /// Plane kind.
57   inline static const std::string& ID()
58   {
59     static const std::string CONSTRUCTION_PLANE_KIND("Plane");
60     return CONSTRUCTION_PLANE_KIND;
61   }
62
63   /// Attribute name for creation method.
64   inline static const std::string& CREATION_METHOD()
65   {
66     static const std::string MY_CREATION_METHOD_ID("creation_method");
67     return MY_CREATION_METHOD_ID;
68   }
69
70   /// Attribute name for creation method.
71   inline static const std::string& CREATION_METHOD_BY_GENERAL_EQUATION()
72   {
73     static const std::string MY_CREATION_METHOD_ID("by_general_equation");
74     return MY_CREATION_METHOD_ID;
75   }
76
77   /// Attribute name for creation method.
78   inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
79   {
80     static const std::string MY_CREATION_METHOD_ID("by_three_points");
81     return MY_CREATION_METHOD_ID;
82   }
83
84   /// Attribute name for creation method.
85   inline static const std::string& CREATION_METHOD_BY_LINE_AND_POINT()
86   {
87     static const std::string MY_CREATION_METHOD_ID("by_line_and_point");
88     return MY_CREATION_METHOD_ID;
89   }
90
91   /// Attribute name for creation method.
92   inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE()
93   {
94     static const std::string MY_CREATION_METHOD_ID("by_other_plane");
95     return MY_CREATION_METHOD_ID;
96   }
97
98   /// Attribute name for creation method.
99   inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE_OPTION()
100   {
101     static const std::string MY_CREATION_METHOD_ID("by_other_plane_option");
102     return MY_CREATION_METHOD_ID;
103   }
104
105   /// Attribute name for creation method.
106   inline static const std::string& CREATION_METHOD_BY_DISTANCE_FROM_OTHER()
107   {
108     static const std::string MY_CREATION_METHOD_ID("by_distance_from_other");
109     return MY_CREATION_METHOD_ID;
110   }
111
112   /// Attribute name for creation method.
113   inline static const std::string& CREATION_METHOD_BY_COINCIDENT_TO_POINT()
114   {
115     static const std::string MY_CREATION_METHOD_ID("by_coincident_to_point");
116     return MY_CREATION_METHOD_ID;
117   }
118
119   /// Attribute name for creation method.
120   inline static const std::string& CREATION_METHOD_BY_ROTATION()
121   {
122     static const std::string MY_CREATION_METHOD_ID("by_rotation");
123     return MY_CREATION_METHOD_ID;
124   }
125
126   /// Attribute name for creation method.
127   inline static const std::string& CREATION_METHOD_BY_TWO_PARALLEL_PLANES()
128   {
129     static const std::string MY_CREATION_METHOD_ID("by_two_parallel_planes");
130     return MY_CREATION_METHOD_ID;
131   }
132
133   /// Attribute name for first point.
134   inline static const std::string& POINT1()
135   {
136     static const std::string ATTR_ID("point1");
137     return ATTR_ID;
138   }
139
140   /// Attribute name for second point.
141   inline static const std::string& POINT2()
142   {
143     static const std::string ATTR_ID("point2");
144     return ATTR_ID;
145   }
146
147   /// Attribute name for third point.
148   inline static const std::string& POINT3()
149   {
150     static const std::string ATTR_ID("point3");
151     return ATTR_ID;
152   }
153
154   /// Attribute name for line.
155   inline static const std::string& LINE()
156   {
157     static const std::string ATTR_ID("line");
158     return ATTR_ID;
159   }
160
161   /// Attribute name for point.
162   inline static const std::string& POINT()
163   {
164     static const std::string ATTR_ID("point");
165     return ATTR_ID;
166   }
167
168   /// Attribute name for perpendicular flag.
169   inline static const std::string& PERPENDICULAR()
170   {
171     static const std::string ATTR_ID("perpendicular");
172     return ATTR_ID;
173   }
174
175   /// Attribute name for selected plane.
176   inline static const std::string& PLANE()
177   {
178     static const std::string ATTR_ID("plane");
179     return ATTR_ID;
180   }
181
182   /// Attribute name for distance.
183   inline static const std::string& DISTANCE()
184   {
185     static const std::string ATTR_ID("distance");
186     return ATTR_ID;
187   }
188
189   /// Attribute name for reverse flag.
190   inline static const std::string& REVERSE()
191   {
192     static const std::string ATTR_ID("reverse");
193     return ATTR_ID;
194   }
195
196   /// Attribute name for coincident point.
197   inline static const std::string& COINCIDENT_POINT()
198   {
199     static const std::string ATTR_ID("coincident_point");
200     return ATTR_ID;
201   }
202
203   /// Attribute name for axis.
204   inline static const std::string& AXIS()
205   {
206     static const std::string ATTR_ID("axis");
207     return ATTR_ID;
208   }
209
210   /// Attribute name for angle.
211   inline static const std::string& ANGLE()
212   {
213     static const std::string ATTR_ID("angle");
214     return ATTR_ID;
215   }
216
217   inline static const std::string& PLANE1()
218   {
219     static const std::string ATTR_ID("plane1");
220     return ATTR_ID;
221   }
222
223   inline static const std::string& PLANE2()
224   {
225     static const std::string ATTR_ID("plane2");
226     return ATTR_ID;
227   }
228
229
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()
232   {
233     static const std::string ATTR_ID("A");
234     return ATTR_ID;
235   }
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()
238   {
239     static const std::string ATTR_ID("B");
240     return ATTR_ID;
241   }
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()
244   {
245     static const std::string ATTR_ID("C");
246     return ATTR_ID;
247   }
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()
250   {
251     static const std::string ATTR_ID("D");
252     return ATTR_ID;
253   }
254
255   /// Creates a new part document if needed
256   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
257
258   /// Request for initialization of data model of the feature: adding all attributes
259   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
260
261   /// Use plugin manager for features creation
262   ConstructionPlugin_Plane();
263
264   /// Customize presentation of the feature
265   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs);
266
267 protected:
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();
278 };
279
280 #endif