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