Salome HOME
346fe8022c3e87284628673020315ad7edd09c31
[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 class GeomAPI_Vertex;
31
32 /// \class ConstructionPlugin_Point
33 /// \ingroup Plugins
34 /// \brief Feature for creation of the new part in PartSet.
35 class ConstructionPlugin_Point: public ModelAPI_Feature, public GeomAPI_ICustomPrs
36 {
37 public:
38   /// Returns the kind of a feature.
39   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind();
40
41   /// Point kind.
42   inline static const std::string& ID()
43   {
44     static const std::string CONSTRUCTION_POINT_KIND("Point");
45     return CONSTRUCTION_POINT_KIND;
46   }
47
48   /// Attribute name for creation method.
49   inline static const std::string& CREATION_METHOD()
50   {
51     static const std::string MY_CREATION_METHOD_ID("creation_method");
52     return MY_CREATION_METHOD_ID;
53   }
54
55   /// Attribute name for creation method.
56   inline static const std::string& CREATION_METHOD_BY_XYZ()
57   {
58     static const std::string MY_CREATION_METHOD_ID("by_xyz");
59     return MY_CREATION_METHOD_ID;
60   }
61   /*
62   /// Attribute name for creation method.
63   inline static const std::string& CREATION_METHOD_BY_DISTANCE_ON_EDGE()
64   {
65     static const std::string MY_CREATION_METHOD_ID("by_distance_on_edge");
66     return MY_CREATION_METHOD_ID;
67   }
68
69   /// Attribute name for creation method.
70   inline static const std::string& CREATION_METHOD_BY_PROJECTION()
71   {
72     static const std::string MY_CREATION_METHOD_ID("by_projection");
73     return MY_CREATION_METHOD_ID;
74   }
75
76   /// Attribute name for creation method.
77   inline static const std::string& CREATION_METHOD_BY_LINES_INTERSECTION()
78   {
79     static const std::string MY_CREATION_METHOD_ID("by_lines_intersection");
80     return MY_CREATION_METHOD_ID;
81   }
82   */
83   /// Attribute name for creation method.
84   inline static const std::string& CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()
85   {
86     static const std::string MY_CREATION_METHOD_ID("by_line_and_plane_intersection");
87     return MY_CREATION_METHOD_ID;
88   }
89
90   /// Attribute name for X coordinate.
91   inline static const std::string& X()
92   {
93     static const std::string POINT_ATTR_X("x");
94     return POINT_ATTR_X;
95   }
96
97   /// Attribute name for Y coordinate.
98   inline static const std::string& Y()
99   {
100     static const std::string POINT_ATTR_Y("y");
101     return POINT_ATTR_Y;
102   }
103
104   /// Attribute name for Z coordinate.
105   inline static const std::string& Z()
106   {
107     static const std::string POINT_ATTR_Z("z");
108     return POINT_ATTR_Z;
109   }
110
111   /*/// Attribute name for selected edge.
112   inline static const std::string& EDGE()
113   {
114     static const std::string ATTR_ID("edge");
115     return ATTR_ID;
116   }
117
118   /// Attribute name for distance.
119   inline static const std::string& DISTANCE_VALUE()
120   {
121     static const std::string ATTR_ID("value");
122     return ATTR_ID;
123   }
124
125   /// Attribute name for percent flag.
126   inline static const std::string& DISTANCE_PERCENT()
127   {
128     static const std::string ATTR_ID("percent");
129     return ATTR_ID;
130   }
131
132   /// Attribute name for reverse flag.
133   inline static const std::string& REVERSE()
134   {
135     static const std::string ATTR_ID("reverse");
136     return ATTR_ID;
137   }
138
139   /// Attribute name for point.
140   inline static const std::string& POINT()
141   {
142     static const std::string ATTR_ID("point");
143     return ATTR_ID;
144   }
145
146   /// Attribute name for plane.
147   inline static const std::string& PLANE()
148   {
149     static const std::string ATTR_ID("plane");
150     return ATTR_ID;
151   }
152
153   /// Attribute name for selected first line.
154   inline static const std::string& FIRST_LINE()
155   {
156     static const std::string ATTR_ID("first_line");
157     return ATTR_ID;
158   }
159
160   /// Attribute name for selected second line.
161   inline static const std::string& SECOND_LINE()
162   {
163     static const std::string ATTR_ID("second_line");
164     return ATTR_ID;
165   }
166   */
167
168   /// Attribute name for selected intersection line.
169   inline static const std::string& INTERSECTION_LINE()
170   {
171     static const std::string ATTR_ID("intersection_line");
172     return ATTR_ID;
173   }
174
175   /// Attribute name for selected intersection plane.
176   inline static const std::string& INTERSECTION_PLANE()
177   {
178     static const std::string ATTR_ID("intersection_plane");
179     return ATTR_ID;
180   }
181
182   /// Attribute name for use offset for the intersection plane.
183   inline static const std::string& USE_OFFSET()
184   {
185     static const std::string ATTR_ID("use_offset");
186     return ATTR_ID;
187   }
188
189   /// Attribute name for offset for the intersection plane.
190   inline static const std::string& OFFSET()
191   {
192     static const std::string ATTR_ID("offset");
193     return ATTR_ID;
194   }
195
196   /// Attribute name for reverse offset for the intersection plane.
197   inline static const std::string& REVERSE_OFFSET()
198   {
199     static const std::string ATTR_ID("reverse_offset");
200     return ATTR_ID;
201   }
202
203   /// Creates a new part document if needed.
204   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
205
206   /// Request for initialization of data model of the feature: adding all attributes.
207   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
208
209   /// Construction result is allways recomuted on the fly.
210   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
211
212   /// Use plugin manager for features creation
213   ConstructionPlugin_Point();
214
215   /// Customize presentation of the feature
216   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
217                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
218
219 private:
220   std::shared_ptr<GeomAPI_Vertex> createByXYZ();
221   /*std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
222   std::shared_ptr<GeomAPI_Vertex> createByProjection();
223   std::shared_ptr<GeomAPI_Vertex> createByLinesIntersection();*/
224   std::shared_ptr<GeomAPI_Vertex> createByLineAndPlaneIntersection();
225
226 };
227
228 #endif