Salome HOME
Add setAngle, setCollinear, setEqual, setMiddlePoint, setRadius, setTangent
[modules/shaper.git] / src / SketchAPI / SketchAPI_Sketch.h
1 // Name   : SketchAPI_Sketch.h
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
8 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
9
10 //--------------------------------------------------------------------------------------
11 #include "SketchAPI.h"
12
13 #include <list>
14
15 #include <SketchPlugin_Sketch.h>
16 #include <SketchPlugin_SketchEntity.h>
17
18 #include <ModelHighAPI_Interface.h>
19 #include <ModelHighAPI_Macro.h>
20 //--------------------------------------------------------------------------------------
21 class ModelAPI_CompositeFeature;
22 class ModelHighAPI_Double;
23 class ModelHighAPI_RefAttr;
24 class ModelHighAPI_Selection;
25 class SketchAPI_Arc;
26 class SketchAPI_Circle;
27 class SketchAPI_Line;
28 class SketchAPI_Point;
29 //--------------------------------------------------------------------------------------
30 /**\class SketchAPI_Sketch
31  * \ingroup CPPHighAPI
32  * \brief Interface for Sketch feature
33  */
34 class SketchAPI_Sketch : public ModelHighAPI_Interface
35 {
36 public:
37   /// Constructor without values
38   SKETCHAPI_EXPORT
39   explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
40   /// Constructor with values
41   SKETCHAPI_EXPORT
42   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
43                    const std::shared_ptr<GeomAPI_Ax3> & thePlane);
44   /// Constructor with values
45   SKETCHAPI_EXPORT
46   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
47                    const ModelHighAPI_Selection & theExternal);
48   /// Destructor
49   SKETCHAPI_EXPORT
50   virtual ~SketchAPI_Sketch();
51
52   INTERFACE_7(SketchPlugin_Sketch::ID(),
53               origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
54               dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
55               normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
56               features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
57               external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
58               solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
59               solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
60   )
61
62   /// Set plane
63   SKETCHAPI_EXPORT
64   void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
65
66   /// Set external
67   SKETCHAPI_EXPORT
68   void setExternal(const ModelHighAPI_Selection & theExternal);
69
70   // TODO(spo): addIntersection
71
72   /// Add point
73   SKETCHAPI_EXPORT
74   std::shared_ptr<SketchAPI_Point> addPoint(
75       double theX, double theY);
76   /// Add point
77   SKETCHAPI_EXPORT
78   std::shared_ptr<SketchAPI_Point> addPoint(
79       const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
80   /// Add point
81   SKETCHAPI_EXPORT
82   std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
83   /// Add point
84   SKETCHAPI_EXPORT
85   std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
86
87   /// Add line
88   SKETCHAPI_EXPORT
89   std::shared_ptr<SketchAPI_Line> addLine(
90       double theX1, double theY1, double theX2, double theY2);
91   /// Add line
92   SKETCHAPI_EXPORT
93   std::shared_ptr<SketchAPI_Line> addLine(
94       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
95       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
96   /// Add line
97   SKETCHAPI_EXPORT
98   std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
99   /// Add line
100   SKETCHAPI_EXPORT
101   std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
102
103   /// Add circle
104   SKETCHAPI_EXPORT
105   std::shared_ptr<SketchAPI_Circle> addCircle(
106       double theCenterX, double theCenterY,
107       double theRadius);
108   /// Add circle
109   SKETCHAPI_EXPORT
110   std::shared_ptr<SketchAPI_Circle> addCircle(
111       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
112       double theRadius);
113   /// Add circle
114   SKETCHAPI_EXPORT
115   std::shared_ptr<SketchAPI_Circle> addCircle(
116       double theX1, double theY1,
117       double theX2, double theY2,
118       double theX3, double theY3);
119   /// Add circle
120   SKETCHAPI_EXPORT
121   std::shared_ptr<SketchAPI_Circle> addCircle(
122       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
123       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
124       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
125   /// Add circle
126   SKETCHAPI_EXPORT
127   std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
128   /// Add circle
129   SKETCHAPI_EXPORT
130   std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
131
132   /// Add arc
133   SKETCHAPI_EXPORT
134   std::shared_ptr<SketchAPI_Arc> addArc(
135       double theCenterX, double theCenterY,
136       double theStartX, double theStartY,
137       double theEndX, double theEndY,
138       bool theInversed);
139
140   /// Add arc
141   SKETCHAPI_EXPORT
142   std::shared_ptr<SketchAPI_Arc> addArc(
143       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
144       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
145       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
146       bool theInversed);
147
148   /// Add arc
149   SKETCHAPI_EXPORT
150   std::shared_ptr<SketchAPI_Arc> addArc(
151       double theStartX, double theStartY,
152       double theEndX, double theEndY,
153       double thePassedX, double thePassedY);
154
155   /// Add arc
156   SKETCHAPI_EXPORT
157   std::shared_ptr<SketchAPI_Arc> addArc(
158       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
159       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
160       const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
161
162   /// Add arc
163   SKETCHAPI_EXPORT
164   std::shared_ptr<SketchAPI_Arc> addArc(
165       const ModelHighAPI_RefAttr& theTangentPoint,
166       double theEndX, double theEndY,
167       bool theInversed);
168
169   /// Add arc
170   SKETCHAPI_EXPORT
171   std::shared_ptr<SketchAPI_Arc> addArc(
172       const ModelHighAPI_RefAttr& theTangentPoint,
173       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
174       bool theInversed);
175
176   /// Add arc
177   SKETCHAPI_EXPORT
178   std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
179
180   /// Add arc
181   SKETCHAPI_EXPORT
182   std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
183
184   /// Set angle
185   SKETCHAPI_EXPORT
186   std::shared_ptr<ModelAPI_Feature> setAngle(
187       const ModelHighAPI_RefAttr & theLine1,
188       const ModelHighAPI_RefAttr & theLine2,
189       const ModelHighAPI_Double & theValue);
190
191   /// Set coincident
192   SKETCHAPI_EXPORT
193   std::shared_ptr<ModelAPI_Feature> setCoincident(
194       const ModelHighAPI_RefAttr & thePoint1,
195       const ModelHighAPI_RefAttr & thePoint2);
196
197   /// Set collinear
198   SKETCHAPI_EXPORT
199   std::shared_ptr<ModelAPI_Feature> setCollinear(
200       const ModelHighAPI_RefAttr & theLine1,
201       const ModelHighAPI_RefAttr & theLine2);
202
203   /// Set distance
204   SKETCHAPI_EXPORT
205   std::shared_ptr<ModelAPI_Feature> setDistance(
206       const ModelHighAPI_RefAttr & thePoint,
207       const ModelHighAPI_RefAttr & thePointOrLine,
208       const ModelHighAPI_Double & theValue);
209
210   /// Set equal
211   SKETCHAPI_EXPORT
212   std::shared_ptr<ModelAPI_Feature> setEqual(
213       const ModelHighAPI_RefAttr & theObject1,
214       const ModelHighAPI_RefAttr & theObject2);
215
216   /// Set fillet
217   SKETCHAPI_EXPORT
218   std::shared_ptr<ModelAPI_Feature> setFillet(
219       const std::list<ModelHighAPI_RefAttr> & thePoints,
220       const ModelHighAPI_Double & theRadius);
221
222   /// Set horizontal
223   SKETCHAPI_EXPORT
224   std::shared_ptr<ModelAPI_Feature> setHorizontal(
225       const ModelHighAPI_RefAttr & theLine);
226
227   /// Set length
228   SKETCHAPI_EXPORT
229   std::shared_ptr<ModelAPI_Feature> setLength(
230       const ModelHighAPI_RefAttr & theLine,
231       const ModelHighAPI_Double & theValue);
232
233   /// Set middle
234   SKETCHAPI_EXPORT
235   std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
236       const ModelHighAPI_RefAttr & thePoint,
237       const ModelHighAPI_RefAttr & theLine);
238
239   // TODO(spo): setMirror
240
241   /// Set parallel
242   SKETCHAPI_EXPORT
243   std::shared_ptr<ModelAPI_Feature> setParallel(
244       const ModelHighAPI_RefAttr & theLine1,
245       const ModelHighAPI_RefAttr & theLine2);
246
247   /// Set perpendicular
248   SKETCHAPI_EXPORT
249   std::shared_ptr<ModelAPI_Feature> setPerpendicular(
250       const ModelHighAPI_RefAttr & theLine1,
251       const ModelHighAPI_RefAttr & theLine2);
252
253   /// Set radius
254   SKETCHAPI_EXPORT
255   std::shared_ptr<ModelAPI_Feature> setRadius(
256       const ModelHighAPI_RefAttr & theCircleOrArc,
257       const ModelHighAPI_Double & theValue);
258
259   /// Set rigid
260   SKETCHAPI_EXPORT
261   std::shared_ptr<ModelAPI_Feature> setRigid(
262       const ModelHighAPI_RefAttr & theObject);
263
264   /// Set tangent
265   SKETCHAPI_EXPORT
266   std::shared_ptr<ModelAPI_Feature> setTangent(
267       const ModelHighAPI_RefAttr & theLine,
268       const ModelHighAPI_RefAttr & theCircle);
269
270   /// Set vertical
271   SKETCHAPI_EXPORT
272   std::shared_ptr<ModelAPI_Feature> setVertical(
273       const ModelHighAPI_RefAttr & theLine);
274
275   // TODO(spo): addRectagle, projection, Translation, Rotation
276
277   /// Set constraint value
278   SKETCHAPI_EXPORT
279   void setValue(
280       const std::shared_ptr<ModelAPI_Feature> & theConstraint,
281       const ModelHighAPI_Double & theValue);
282
283   // TODO(spo): setText. Is it necessary as setValue accepts text expressions?
284
285   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
286   /// Select face
287   SKETCHAPI_EXPORT
288   std::list<ModelHighAPI_Selection> selectFace() const;
289
290 protected:
291   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
292
293 };
294
295 //! Pointer on Sketch object
296 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
297
298 /**\ingroup CPPHighAPI
299  * \brief Create Sketch feature
300  */
301 SKETCHAPI_EXPORT
302 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
303                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
304
305 /**\ingroup CPPHighAPI
306  * \brief Create Sketch feature
307  */
308 SKETCHAPI_EXPORT
309 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
310                     const ModelHighAPI_Selection & theExternal);
311
312 /**\ingroup CPPHighAPI
313  * \brief Create Sketch feature
314  */
315 SKETCHAPI_EXPORT
316 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
317                     const std::string & theExternalName);
318
319 //--------------------------------------------------------------------------------------
320 //--------------------------------------------------------------------------------------
321 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */