Salome HOME
Some improvements in GUI
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Point.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_Point_H_
22 #define ConstructionPlugin_Point_H_
23
24 #include "ConstructionPlugin.h"
25
26 #include <GeomAPI_ICustomPrs.h>
27 #include <ModelAPI_Feature.h>
28 #include <ModelAPI_Result.h>
29
30 #include <math.h>
31
32 class GeomAPI_Vertex;
33
34 /// \class ConstructionPlugin_Point
35 /// \ingroup Plugins
36 /// \brief Feature for creation of the new part in PartSet.
37 class ConstructionPlugin_Point: public ModelAPI_Feature, public GeomAPI_ICustomPrs
38 {
39 public:
40   /// Returns the kind of a feature.
41   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind();
42
43   /// Point kind.
44   inline static const std::string& ID()
45   {
46     static const std::string CONSTRUCTION_POINT_KIND("Point");
47     return CONSTRUCTION_POINT_KIND;
48   }
49
50   /// Attribute name for creation method.
51   inline static const std::string& CREATION_METHOD()
52   {
53     static const std::string MY_CREATION_METHOD_ID("creation_method");
54     return MY_CREATION_METHOD_ID;
55   }
56
57   /// Attribute name for creation method.
58   inline static const std::string& CREATION_METHOD_BY_XYZ()
59   {
60     static const std::string MY_CREATION_METHOD_ID("by_xyz");
61     return MY_CREATION_METHOD_ID;
62   }
63
64   /// Attribute name for creation method.
65   inline static const std::string& CREATION_METHOD_BY_DISTANCE_ON_EDGE()
66   {
67     static const std::string MY_CREATION_METHOD_ID("by_distance_on_edge");
68     return MY_CREATION_METHOD_ID;
69   }
70
71   /// Attribute name for creation method.
72   inline static const std::string& CREATION_METHOD_BY_PROJECTION()
73   {
74     static const std::string MY_CREATION_METHOD_ID("by_projection");
75     return MY_CREATION_METHOD_ID;
76   }
77
78   /*
79   /// Attribute name for creation method.
80   inline static const std::string& CREATION_METHOD_BY_LINES_INTERSECTION()
81   {
82     static const std::string MY_CREATION_METHOD_ID("by_lines_intersection");
83     return MY_CREATION_METHOD_ID;
84   }
85   */
86
87   /// Attribute name for creation method.
88   inline static const std::string& CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()
89   {
90     static const std::string MY_CREATION_METHOD_ID("by_line_and_plane_intersection");
91     return MY_CREATION_METHOD_ID;
92   }
93
94   /// Attribute name for X coordinate.
95   inline static const std::string& X()
96   {
97     static const std::string POINT_ATTR_X("x");
98     return POINT_ATTR_X;
99   }
100
101   /// Attribute name for Y coordinate.
102   inline static const std::string& Y()
103   {
104     static const std::string POINT_ATTR_Y("y");
105     return POINT_ATTR_Y;
106   }
107
108   /// Attribute name for Z coordinate.
109   inline static const std::string& Z()
110   {
111     static const std::string POINT_ATTR_Z("z");
112     return POINT_ATTR_Z;
113   }
114
115   /// Attribute name for selected edge.
116   inline static const std::string& EDGE()
117   {
118     static const std::string ATTR_ID("edge");
119     return ATTR_ID;
120   }
121
122   /// Attribute name for offset type on selected edge.
123   inline static const std::string& OFFSET_TYPE()
124   {
125     static const std::string ATTR_ID("offset_type");
126     return ATTR_ID;
127   }
128
129   /// Attribute name for offset type by distance.
130   inline static const std::string& OFFSET_TYPE_BY_DISTANCE()
131   {
132     static const std::string ATTR_ID("offset_type_by_distance");
133     return ATTR_ID;
134   }
135
136   /// Attribute name for offset type by ratio.
137   inline static const std::string& OFFSET_TYPE_BY_RATIO()
138   {
139     static const std::string ATTR_ID("offset_type_by_ratio");
140     return ATTR_ID;
141   }
142
143   /// Attribute name for distance.
144   inline static const std::string& DISTANCE()
145   {
146     static const std::string ATTR_ID("distance");
147     return ATTR_ID;
148   }
149
150   /// Attribute name for percent flag.
151   inline static const std::string& RATIO()
152   {
153     static const std::string ATTR_ID("ratio");
154     return ATTR_ID;
155   }
156
157   /// Attribute name for reverse flag.
158   inline static const std::string& REVERSE()
159   {
160     static const std::string ATTR_ID("reverse");
161     return ATTR_ID;
162   }
163
164   /// Attribute name for point to projection.
165   inline static const std::string& POINT_TO_PROJECT()
166   {
167     static const std::string ATTR_ID("point_to_project");
168     return ATTR_ID;
169   }
170
171   /// Attribute name for projection type.
172   inline static const std::string& PROJECTION_TYPE()
173   {
174     static const std::string ATTR_ID("projection_type");
175     return ATTR_ID;
176   }
177
178   /// Attribute name for projection type on edge.
179   inline static const std::string& PROJECTION_TYPE_ON_EDGE()
180   {
181     static const std::string ATTR_ID("projection_type_on_edge");
182     return ATTR_ID;
183   }
184
185   /// Attribute name for projection type on face.
186   inline static const std::string& PROJECTION_TYPE_ON_FACE()
187   {
188     static const std::string ATTR_ID("projection_type_on_face");
189     return ATTR_ID;
190   }
191
192   /// Attribute name for edge for point projection.
193   inline static const std::string& EDGE_FOR_POINT_PROJECTION()
194   {
195     static const std::string ATTR_ID("edge_for_point_projection");
196     return ATTR_ID;
197   }
198
199   /// Attribute name for face for point projection.
200   inline static const std::string& FACE_FOR_POINT_PROJECTION()
201   {
202     static const std::string ATTR_ID("face_for_point_projection");
203     return ATTR_ID;
204   }
205
206   /*
207   /// Attribute name for selected first line.
208   inline static const std::string& FIRST_LINE()
209   {
210     static const std::string ATTR_ID("first_line");
211     return ATTR_ID;
212   }
213
214   /// Attribute name for selected second line.
215   inline static const std::string& SECOND_LINE()
216   {
217     static const std::string ATTR_ID("second_line");
218     return ATTR_ID;
219   }
220   */
221
222   /// Attribute name for selected intersection line.
223   inline static const std::string& INTERSECTION_LINE()
224   {
225     static const std::string ATTR_ID("intersection_line");
226     return ATTR_ID;
227   }
228
229   /// Attribute name for selected intersection plane.
230   inline static const std::string& INTERSECTION_PLANE()
231   {
232     static const std::string ATTR_ID("intersection_plane");
233     return ATTR_ID;
234   }
235
236   /// Attribute name for use offset for the intersection plane.
237   inline static const std::string& USE_OFFSET()
238   {
239     static const std::string ATTR_ID("use_offset");
240     return ATTR_ID;
241   }
242
243   /// Attribute name for offset for the intersection plane.
244   inline static const std::string& OFFSET()
245   {
246     static const std::string ATTR_ID("offset");
247     return ATTR_ID;
248   }
249
250   /// Attribute name for reverse offset for the intersection plane.
251   inline static const std::string& REVERSE_OFFSET()
252   {
253     static const std::string ATTR_ID("reverse_offset");
254     return ATTR_ID;
255   }
256
257   /// Creates a new part document if needed.
258   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
259
260   /// Request for initialization of data model of the feature: adding all attributes.
261   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
262
263   /// Construction result is allways recomuted on the fly.
264   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
265
266   /// Use plugin manager for features creation
267   ConstructionPlugin_Point();
268
269   /// Customize presentation of the feature
270   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
271                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
272
273 private:
274   std::shared_ptr<GeomAPI_Vertex> createByXYZ();
275   std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
276   std::shared_ptr<GeomAPI_Vertex> createByProjectionOnEdge();
277   std::shared_ptr<GeomAPI_Vertex> createByProjectionOnFace();
278   /*std::shared_ptr<GeomAPI_Vertex> createByLinesIntersection();*/
279   std::list<std::shared_ptr<GeomAPI_Vertex> > createByLineAndPlaneIntersection();
280
281 };
282
283 #endif