Salome HOME
Added option to create Construction Point by intersection of line and plane.
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Point.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ConstructionPlugin_Point.h
4 // Created:     3 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef ConstructionPlugin_Point_H_
8 #define ConstructionPlugin_Point_H_
9
10 #include "ConstructionPlugin.h"
11
12 #include <GeomAPI_ICustomPrs.h>
13 #include <ModelAPI_Feature.h>
14 #include <ModelAPI_Result.h>
15
16 class GeomAPI_Vertex;
17
18 /// \class ConstructionPlugin_Point
19 /// \ingroup Plugins
20 /// \brief Feature for creation of the new part in PartSet.
21 class ConstructionPlugin_Point: public ModelAPI_Feature, public GeomAPI_ICustomPrs
22 {
23 public:
24   /// Returns the kind of a feature.
25   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind();
26
27   /// Point kind.
28   inline static const std::string& ID()
29   {
30     static const std::string CONSTRUCTION_POINT_KIND("Point");
31     return CONSTRUCTION_POINT_KIND;
32   }
33
34   /// Attribute name for creation method.
35   inline static const std::string& CREATION_METHOD()
36   {
37     static const std::string MY_CREATION_METHOD_ID("creation_method");
38     return MY_CREATION_METHOD_ID;
39   }
40
41   /// Attribute name for creation method.
42   inline static const std::string& CREATION_METHOD_BY_XYZ()
43   {
44     static const std::string MY_CREATION_METHOD_ID("by_xyz");
45     return MY_CREATION_METHOD_ID;
46   }
47
48   /// Attribute name for creation method.
49   inline static const std::string& CREATION_METHOD_BY_DISTANCE_ON_EDGE()
50   {
51     static const std::string MY_CREATION_METHOD_ID("by_distance_on_edge");
52     return MY_CREATION_METHOD_ID;
53   }
54
55   /// Attribute name for creation method.
56   inline static const std::string& CREATION_METHOD_BY_PROJECTION()
57   {
58     static const std::string MY_CREATION_METHOD_ID("by_projection");
59     return MY_CREATION_METHOD_ID;
60   }
61
62   /// Attribute name for creation method.
63   inline static const std::string& CREATION_METHOD_BY_LINES_INTERSECTION()
64   {
65     static const std::string MY_CREATION_METHOD_ID("by_lines_intersection");
66     return MY_CREATION_METHOD_ID;
67   }
68
69   /// Attribute name for creation method.
70   inline static const std::string& CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()
71   {
72     static const std::string MY_CREATION_METHOD_ID("by_line_and_plane_intersection");
73     return MY_CREATION_METHOD_ID;
74   }
75
76   /// Attribute name for X coordinate.
77   inline static const std::string& X()
78   {
79     static const std::string POINT_ATTR_X("x");
80     return POINT_ATTR_X;
81   }
82
83   /// Attribute name for Y coordinate.
84   inline static const std::string& Y()
85   {
86     static const std::string POINT_ATTR_Y("y");
87     return POINT_ATTR_Y;
88   }
89
90   /// Attribute name for Z coordinate.
91   inline static const std::string& Z()
92   {
93     static const std::string POINT_ATTR_Z("z");
94     return POINT_ATTR_Z;
95   }
96
97   /// Attribute name for selected edge.
98   inline static const std::string& EDGE()
99   {
100     static const std::string ATTR_ID("edge");
101     return ATTR_ID;
102   }
103
104   /// Attribute name for distance.
105   inline static const std::string& DISTANCE_VALUE()
106   {
107     static const std::string ATTR_ID("value");
108     return ATTR_ID;
109   }
110
111   /// Attribute name for percent flag.
112   inline static const std::string& DISTANCE_PERCENT()
113   {
114     static const std::string ATTR_ID("percent");
115     return ATTR_ID;
116   }
117
118   /// Attribute name for reverse flag.
119   inline static const std::string& REVERSE()
120   {
121     static const std::string ATTR_ID("reverse");
122     return ATTR_ID;
123   }
124
125   /// Attribute name for point.
126   inline static const std::string& POINT()
127   {
128     static const std::string ATTR_ID("point");
129     return ATTR_ID;
130   }
131
132   /// Attribute name for plane.
133   inline static const std::string& PLANE()
134   {
135     static const std::string ATTR_ID("plane");
136     return ATTR_ID;
137   }
138
139   /// Attribute name for selected first line.
140   inline static const std::string& FIRST_LINE()
141   {
142     static const std::string ATTR_ID("first_line");
143     return ATTR_ID;
144   }
145
146   /// Attribute name for selected second line.
147   inline static const std::string& SECOND_LINE()
148   {
149     static const std::string ATTR_ID("second_line");
150     return ATTR_ID;
151   }
152
153   /// Attribute name for selected intersection line.
154   inline static const std::string& INTERSECTION_LINE()
155   {
156     static const std::string ATTR_ID("intersection_line");
157     return ATTR_ID;
158   }
159
160   /// Attribute name for selected intersection plane.
161   inline static const std::string& INTERSECTION_PLANE()
162   {
163     static const std::string ATTR_ID("intersection_plane");
164     return ATTR_ID;
165   }
166
167   /// Creates a new part document if needed.
168   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
169
170   /// Request for initialization of data model of the feature: adding all attributes.
171   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
172
173   /// Construction result is allways recomuted on the fly.
174   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
175
176   /// Use plugin manager for features creation
177   ConstructionPlugin_Point();
178
179   /// Customize presentation of the feature
180   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
181                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
182
183 private:
184   std::shared_ptr<GeomAPI_Vertex> createByXYZ();
185   std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
186   std::shared_ptr<GeomAPI_Vertex> createByProjection();
187   std::shared_ptr<GeomAPI_Vertex> createByLinesIntersection();
188   std::shared_ptr<GeomAPI_Vertex> createByLineAndPlaneIntersection();
189
190 };
191
192 #endif