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 projection
213   SKETCHAPI_EXPORT
214   std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
215
216   /// Add mirror
217   SKETCHAPI_EXPORT
218   std::shared_ptr<SketchAPI_Mirror> addMirror(
219       const ModelHighAPI_RefAttr & theMirrorLine,
220       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
221
222   /// Add translation
223   SKETCHAPI_EXPORT
224   std::shared_ptr<SketchAPI_Translation> addTranslation(
225       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
226       const ModelHighAPI_RefAttr & thePoint1,
227       const ModelHighAPI_RefAttr & thePoint2,
228       const ModelHighAPI_Integer & theNumberOfObjects,
229       bool theFullValue = false);
230
231   /// Add rotation
232   SKETCHAPI_EXPORT
233   std::shared_ptr<SketchAPI_Rotation> addRotation(
234       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
235       const ModelHighAPI_RefAttr & theCenter,
236       const ModelHighAPI_Double & theAngle,
237       const ModelHighAPI_Integer & theNumberOfObjects,
238       bool theFullValue = false);
239
240   /// Set angle
241   SKETCHAPI_EXPORT
242   std::shared_ptr<ModelAPI_Feature> setAngle(
243       const ModelHighAPI_RefAttr & theLine1,
244       const ModelHighAPI_RefAttr & theLine2,
245       const ModelHighAPI_Double & theValue);
246
247   /// Set complementary angle
248   SKETCHAPI_EXPORT
249   std::shared_ptr<ModelAPI_Feature> setAngleComplementary(
250       const ModelHighAPI_RefAttr & theLine1,
251       const ModelHighAPI_RefAttr & theLine2,
252       const ModelHighAPI_Double & theValue);
253
254   /// Set backward angle (= 360 - angle)
255   SKETCHAPI_EXPORT
256   std::shared_ptr<ModelAPI_Feature> setAngleBackward(
257       const ModelHighAPI_RefAttr & theLine1,
258       const ModelHighAPI_RefAttr & theLine2,
259       const ModelHighAPI_Double & theValue);
260
261   /// Set coincident
262   SKETCHAPI_EXPORT
263   std::shared_ptr<ModelAPI_Feature> setCoincident(
264       const ModelHighAPI_RefAttr & thePoint1,
265       const ModelHighAPI_RefAttr & thePoint2);
266
267   /// Set collinear
268   SKETCHAPI_EXPORT
269   std::shared_ptr<ModelAPI_Feature> setCollinear(
270       const ModelHighAPI_RefAttr & theLine1,
271       const ModelHighAPI_RefAttr & theLine2);
272
273   /// Set distance
274   SKETCHAPI_EXPORT
275   std::shared_ptr<ModelAPI_Feature> setDistance(
276       const ModelHighAPI_RefAttr & thePoint,
277       const ModelHighAPI_RefAttr & thePointOrLine,
278       const ModelHighAPI_Double & theValue);
279
280   /// Set equal
281   SKETCHAPI_EXPORT
282   std::shared_ptr<ModelAPI_Feature> setEqual(
283       const ModelHighAPI_RefAttr & theObject1,
284       const ModelHighAPI_RefAttr & theObject2);
285
286   /// Set fillet
287   SKETCHAPI_EXPORT
288   std::shared_ptr<ModelAPI_Feature> setFillet(
289       const std::list<ModelHighAPI_RefAttr> & thePoints,
290       const ModelHighAPI_Double & theRadius);
291
292   /// Set fixed
293   SKETCHAPI_EXPORT
294   std::shared_ptr<ModelAPI_Feature> setFixed(
295       const ModelHighAPI_RefAttr & theObject);
296
297   /// Set horizontal
298   SKETCHAPI_EXPORT
299   std::shared_ptr<ModelAPI_Feature> setHorizontal(
300       const ModelHighAPI_RefAttr & theLine);
301
302   /// Set length
303   SKETCHAPI_EXPORT
304   std::shared_ptr<ModelAPI_Feature> setLength(
305       const ModelHighAPI_RefAttr & theLine,
306       const ModelHighAPI_Double & theValue);
307
308   /// Set middle
309   SKETCHAPI_EXPORT
310   std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
311       const ModelHighAPI_RefAttr & thePoint,
312       const ModelHighAPI_RefAttr & theLine);
313
314   /// Set parallel
315   SKETCHAPI_EXPORT
316   std::shared_ptr<ModelAPI_Feature> setParallel(
317       const ModelHighAPI_RefAttr & theLine1,
318       const ModelHighAPI_RefAttr & theLine2);
319
320   /// Set perpendicular
321   SKETCHAPI_EXPORT
322   std::shared_ptr<ModelAPI_Feature> setPerpendicular(
323       const ModelHighAPI_RefAttr & theLine1,
324       const ModelHighAPI_RefAttr & theLine2);
325
326   /// Set radius
327   SKETCHAPI_EXPORT
328   std::shared_ptr<ModelAPI_Feature> setRadius(
329       const ModelHighAPI_RefAttr & theCircleOrArc,
330       const ModelHighAPI_Double & theValue);
331
332   /// Set tangent
333   SKETCHAPI_EXPORT
334   std::shared_ptr<ModelAPI_Feature> setTangent(
335       const ModelHighAPI_RefAttr & theLine,
336       const ModelHighAPI_RefAttr & theCircle);
337
338   /// Set vertical
339   SKETCHAPI_EXPORT
340   std::shared_ptr<ModelAPI_Feature> setVertical(
341       const ModelHighAPI_RefAttr & theLine);
342
343   /// Set constraint value
344   SKETCHAPI_EXPORT
345   void setValue(
346       const std::shared_ptr<ModelAPI_Feature> & theConstraint,
347       const ModelHighAPI_Double & theValue);
348
349   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
350   /// Select face
351   SKETCHAPI_EXPORT
352   std::list<ModelHighAPI_Selection> selectFace() const;
353
354   /// Dump wrapped feature
355   SKETCHAPI_EXPORT
356   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
357
358 protected:
359   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
360
361 };
362
363 //! Pointer on Sketch object
364 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
365
366 /**\ingroup CPPHighAPI
367  * \brief Create Sketch feature
368  */
369 SKETCHAPI_EXPORT
370 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
371                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
372
373 /**\ingroup CPPHighAPI
374  * \brief Create Sketch feature
375  */
376 SKETCHAPI_EXPORT
377 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
378                     const ModelHighAPI_Selection & theExternal);
379
380 /**\ingroup CPPHighAPI
381  * \brief Create Sketch feature
382  */
383 SKETCHAPI_EXPORT
384 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
385                     const std::string & theExternalName);
386
387 //--------------------------------------------------------------------------------------
388 //--------------------------------------------------------------------------------------
389 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */