Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
[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 ModelAPI_Object;
23 class ModelHighAPI_Double;
24 class ModelHighAPI_Integer;
25 class ModelHighAPI_RefAttr;
26 class ModelHighAPI_Selection;
27 class SketchAPI_Arc;
28 class SketchAPI_Circle;
29 class SketchAPI_IntersectionPoint;
30 class SketchAPI_Line;
31 class SketchAPI_Mirror;
32 class SketchAPI_Point;
33 class SketchAPI_Projection;
34 class SketchAPI_Rectangle;
35 class SketchAPI_Rotation;
36 class SketchAPI_Translation;
37 //--------------------------------------------------------------------------------------
38 /**\class SketchAPI_Sketch
39  * \ingroup CPPHighAPI
40  * \brief Interface for Sketch feature
41  */
42 class SketchAPI_Sketch : public ModelHighAPI_Interface
43 {
44 public:
45   /// Constructor without values
46   SKETCHAPI_EXPORT
47   explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
48   /// Constructor with values
49   SKETCHAPI_EXPORT
50   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
51                    const std::shared_ptr<GeomAPI_Ax3> & thePlane);
52   /// Constructor with values
53   SKETCHAPI_EXPORT
54   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
55                    const ModelHighAPI_Selection & theExternal);
56   /// Destructor
57   SKETCHAPI_EXPORT
58   virtual ~SketchAPI_Sketch();
59
60   INTERFACE_7(SketchPlugin_Sketch::ID(),
61               origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
62               dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
63               normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
64               features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
65               external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
66               solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
67               solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
68   )
69
70   /// Set plane
71   SKETCHAPI_EXPORT
72   void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
73
74   /// Set external
75   SKETCHAPI_EXPORT
76   void setExternal(const ModelHighAPI_Selection & theExternal);
77
78   /// Add point
79   SKETCHAPI_EXPORT
80   std::shared_ptr<SketchAPI_Point> addPoint(
81       double theX, double theY);
82   /// Add point
83   SKETCHAPI_EXPORT
84   std::shared_ptr<SketchAPI_Point> addPoint(
85       const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
86   /// Add point
87   SKETCHAPI_EXPORT
88   std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
89   /// Add point
90   SKETCHAPI_EXPORT
91   std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
92
93   /// Add intersection point
94   SKETCHAPI_EXPORT
95   std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
96   /// Add point
97   SKETCHAPI_EXPORT
98   std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const std::string & theExternalName);
99
100   /// Add line
101   SKETCHAPI_EXPORT
102   std::shared_ptr<SketchAPI_Line> addLine(
103       double theX1, double theY1, double theX2, double theY2);
104   /// Add line
105   SKETCHAPI_EXPORT
106   std::shared_ptr<SketchAPI_Line> addLine(
107       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
108       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
109   /// Add line
110   SKETCHAPI_EXPORT
111   std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
112   /// Add line
113   SKETCHAPI_EXPORT
114   std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
115
116   /// Add rectangle
117   SKETCHAPI_EXPORT
118   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
119       double theX1, double theY1, double theX2, double theY2);
120   /// Add rectangle
121   SKETCHAPI_EXPORT
122   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
123       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
124       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
125
126   /// Add circle
127   SKETCHAPI_EXPORT
128   std::shared_ptr<SketchAPI_Circle> addCircle(
129       double theCenterX, double theCenterY,
130       double theRadius);
131   /// Add circle
132   SKETCHAPI_EXPORT
133   std::shared_ptr<SketchAPI_Circle> addCircle(
134       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
135       double theRadius);
136   /// Add circle
137   SKETCHAPI_EXPORT
138   std::shared_ptr<SketchAPI_Circle> addCircle(
139       double theX1, double theY1,
140       double theX2, double theY2,
141       double theX3, double theY3);
142   /// Add circle
143   SKETCHAPI_EXPORT
144   std::shared_ptr<SketchAPI_Circle> addCircle(
145       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
146       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
147       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
148   /// Add circle
149   SKETCHAPI_EXPORT
150   std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
151   /// Add circle
152   SKETCHAPI_EXPORT
153   std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
154
155   /// Add arc
156   SKETCHAPI_EXPORT
157   std::shared_ptr<SketchAPI_Arc> addArc(
158       double theCenterX, double theCenterY,
159       double theStartX, double theStartY,
160       double theEndX, double theEndY,
161       bool theInversed);
162
163   /// Add arc
164   SKETCHAPI_EXPORT
165   std::shared_ptr<SketchAPI_Arc> addArc(
166       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
167       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
168       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
169       bool theInversed);
170
171   /// Add arc
172   SKETCHAPI_EXPORT
173   std::shared_ptr<SketchAPI_Arc> addArc(
174       double theStartX, double theStartY,
175       double theEndX, double theEndY,
176       double thePassedX, double thePassedY);
177
178   /// Add arc
179   SKETCHAPI_EXPORT
180   std::shared_ptr<SketchAPI_Arc> addArc(
181       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
182       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
183       const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
184
185   /// Add arc
186   SKETCHAPI_EXPORT
187   std::shared_ptr<SketchAPI_Arc> addArc(
188       const ModelHighAPI_RefAttr& theTangentPoint,
189       double theEndX, double theEndY,
190       bool theInversed);
191
192   /// Add arc
193   SKETCHAPI_EXPORT
194   std::shared_ptr<SketchAPI_Arc> addArc(
195       const ModelHighAPI_RefAttr& theTangentPoint,
196       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
197       bool theInversed);
198
199   /// Add arc
200   SKETCHAPI_EXPORT
201   std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
202
203   /// Add arc
204   SKETCHAPI_EXPORT
205   std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
206
207   /// Add projection
208   SKETCHAPI_EXPORT
209   std::shared_ptr<SketchAPI_Projection> addProjection(
210       const ModelHighAPI_Selection & theExternalFeature);
211
212   /// Add mirror
213   SKETCHAPI_EXPORT
214   std::shared_ptr<SketchAPI_Mirror> addMirror(
215       const ModelHighAPI_RefAttr & theMirrorLine,
216       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
217
218   /// Add translation
219   SKETCHAPI_EXPORT
220   std::shared_ptr<SketchAPI_Translation> addTranslation(
221       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
222       const ModelHighAPI_RefAttr & thePoint1,
223       const ModelHighAPI_RefAttr & thePoint2,
224       const ModelHighAPI_Integer & theNumberOfObjects,
225       bool theFullValue = false);
226
227   /// Add rotation
228   SKETCHAPI_EXPORT
229   std::shared_ptr<SketchAPI_Rotation> addRotation(
230       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
231       const ModelHighAPI_RefAttr & theCenter,
232       const ModelHighAPI_Double & theAngle,
233       const ModelHighAPI_Integer & theNumberOfObjects,
234       bool theFullValue = false);
235
236   /// Set angle
237   SKETCHAPI_EXPORT
238   std::shared_ptr<ModelAPI_Feature> setAngle(
239       const ModelHighAPI_RefAttr & theLine1,
240       const ModelHighAPI_RefAttr & theLine2,
241       const ModelHighAPI_Double & theValue);
242
243   /// Set coincident
244   SKETCHAPI_EXPORT
245   std::shared_ptr<ModelAPI_Feature> setCoincident(
246       const ModelHighAPI_RefAttr & thePoint1,
247       const ModelHighAPI_RefAttr & thePoint2);
248
249   /// Set collinear
250   SKETCHAPI_EXPORT
251   std::shared_ptr<ModelAPI_Feature> setCollinear(
252       const ModelHighAPI_RefAttr & theLine1,
253       const ModelHighAPI_RefAttr & theLine2);
254
255   /// Set distance
256   SKETCHAPI_EXPORT
257   std::shared_ptr<ModelAPI_Feature> setDistance(
258       const ModelHighAPI_RefAttr & thePoint,
259       const ModelHighAPI_RefAttr & thePointOrLine,
260       const ModelHighAPI_Double & theValue);
261
262   /// Set equal
263   SKETCHAPI_EXPORT
264   std::shared_ptr<ModelAPI_Feature> setEqual(
265       const ModelHighAPI_RefAttr & theObject1,
266       const ModelHighAPI_RefAttr & theObject2);
267
268   /// Set fillet
269   SKETCHAPI_EXPORT
270   std::shared_ptr<ModelAPI_Feature> setFillet(
271       const std::list<ModelHighAPI_RefAttr> & thePoints,
272       const ModelHighAPI_Double & theRadius);
273
274   /// Set fixed
275   SKETCHAPI_EXPORT
276   std::shared_ptr<ModelAPI_Feature> setFixed(
277       const ModelHighAPI_RefAttr & theObject);
278
279   /// Set horizontal
280   SKETCHAPI_EXPORT
281   std::shared_ptr<ModelAPI_Feature> setHorizontal(
282       const ModelHighAPI_RefAttr & theLine);
283
284   /// Set length
285   SKETCHAPI_EXPORT
286   std::shared_ptr<ModelAPI_Feature> setLength(
287       const ModelHighAPI_RefAttr & theLine,
288       const ModelHighAPI_Double & theValue);
289
290   /// Set middle
291   SKETCHAPI_EXPORT
292   std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
293       const ModelHighAPI_RefAttr & thePoint,
294       const ModelHighAPI_RefAttr & theLine);
295
296   /// Set parallel
297   SKETCHAPI_EXPORT
298   std::shared_ptr<ModelAPI_Feature> setParallel(
299       const ModelHighAPI_RefAttr & theLine1,
300       const ModelHighAPI_RefAttr & theLine2);
301
302   /// Set perpendicular
303   SKETCHAPI_EXPORT
304   std::shared_ptr<ModelAPI_Feature> setPerpendicular(
305       const ModelHighAPI_RefAttr & theLine1,
306       const ModelHighAPI_RefAttr & theLine2);
307
308   /// Set radius
309   SKETCHAPI_EXPORT
310   std::shared_ptr<ModelAPI_Feature> setRadius(
311       const ModelHighAPI_RefAttr & theCircleOrArc,
312       const ModelHighAPI_Double & theValue);
313
314   /// Set tangent
315   SKETCHAPI_EXPORT
316   std::shared_ptr<ModelAPI_Feature> setTangent(
317       const ModelHighAPI_RefAttr & theLine,
318       const ModelHighAPI_RefAttr & theCircle);
319
320   /// Set vertical
321   SKETCHAPI_EXPORT
322   std::shared_ptr<ModelAPI_Feature> setVertical(
323       const ModelHighAPI_RefAttr & theLine);
324
325   /// Set constraint value
326   SKETCHAPI_EXPORT
327   void setValue(
328       const std::shared_ptr<ModelAPI_Feature> & theConstraint,
329       const ModelHighAPI_Double & theValue);
330
331   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
332   /// Select face
333   SKETCHAPI_EXPORT
334   std::list<ModelHighAPI_Selection> selectFace() const;
335
336   /// Dump wrapped feature
337   SKETCHAPI_EXPORT
338   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
339
340 protected:
341   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
342
343 };
344
345 //! Pointer on Sketch object
346 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
347
348 /**\ingroup CPPHighAPI
349  * \brief Create Sketch feature
350  */
351 SKETCHAPI_EXPORT
352 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
353                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
354
355 /**\ingroup CPPHighAPI
356  * \brief Create Sketch feature
357  */
358 SKETCHAPI_EXPORT
359 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
360                     const ModelHighAPI_Selection & theExternal);
361
362 /**\ingroup CPPHighAPI
363  * \brief Create Sketch feature
364  */
365 SKETCHAPI_EXPORT
366 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
367                     const std::string & theExternalName);
368
369 //--------------------------------------------------------------------------------------
370 //--------------------------------------------------------------------------------------
371 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */