Salome HOME
Issue #2024: Redesign of circle and arc of circle
[modules/shaper.git] / src / SketchAPI / SketchAPI_Sketch.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name   : SketchAPI_Sketch.h
3 // Purpose:
4 //
5 // History:
6 // 07/06/16 - Sergey POKHODENKO - Creation of the file
7
8 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
9 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
10
11 //--------------------------------------------------------------------------------------
12 #include "SketchAPI.h"
13
14 #include <list>
15
16 #include <SketchPlugin_Sketch.h>
17 #include <SketchPlugin_SketchEntity.h>
18
19 #include <ModelHighAPI_Interface.h>
20 #include <ModelHighAPI_Macro.h>
21 //--------------------------------------------------------------------------------------
22 class ModelAPI_CompositeFeature;
23 class ModelAPI_Object;
24 class ModelHighAPI_Double;
25 class ModelHighAPI_Integer;
26 class ModelHighAPI_RefAttr;
27 class ModelHighAPI_Reference;
28 class ModelHighAPI_Selection;
29 class SketchAPI_Arc;
30 class SketchAPI_Circle;
31 class SketchAPI_MacroCircle;
32 class SketchAPI_IntersectionPoint;
33 class SketchAPI_Line;
34 class SketchAPI_Mirror;
35 class SketchAPI_Point;
36 class SketchAPI_Projection;
37 class SketchAPI_Rectangle;
38 class SketchAPI_Rotation;
39 class SketchAPI_Translation;
40 //--------------------------------------------------------------------------------------
41 /**\class SketchAPI_Sketch
42  * \ingroup CPPHighAPI
43  * \brief Interface for Sketch feature
44  */
45 class SketchAPI_Sketch : public ModelHighAPI_Interface
46 {
47 public:
48   /// Constructor without values
49   SKETCHAPI_EXPORT
50   explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
51   /// Constructor with values
52   SKETCHAPI_EXPORT
53   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
54                    const std::shared_ptr<GeomAPI_Ax3> & thePlane);
55   /// Constructor with values
56   SKETCHAPI_EXPORT
57   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
58                    const ModelHighAPI_Selection & theExternal);
59   /// Constructor with values
60   SKETCHAPI_EXPORT
61   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
62                    std::shared_ptr<ModelAPI_Object> thePlaneObject);
63   /// Destructor
64   SKETCHAPI_EXPORT
65   virtual ~SketchAPI_Sketch();
66
67   INTERFACE_7(SketchPlugin_Sketch::ID(),
68               origin, SketchPlugin_Sketch::ORIGIN_ID(),
69               GeomDataAPI_Point, /** Origin point */,
70               dirX, SketchPlugin_Sketch::DIRX_ID(),
71               GeomDataAPI_Dir, /** Direction of X */,
72               normal, SketchPlugin_Sketch::NORM_ID(),
73               GeomDataAPI_Dir, /** Normal */,
74               features, SketchPlugin_Sketch::FEATURES_ID(),
75               ModelAPI_AttributeRefList, /** Features */,
76               external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
77               ModelAPI_AttributeSelection, /** External */,
78               solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
79               ModelAPI_AttributeString, /** Solver error */,
80               solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
81               ModelAPI_AttributeString, /** Solver DOF */
82   )
83
84   /// Set plane
85   SKETCHAPI_EXPORT
86   void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
87
88   /// Set external
89   SKETCHAPI_EXPORT
90   void setExternal(const ModelHighAPI_Selection & theExternal);
91
92   /// Set external
93   SKETCHAPI_EXPORT
94   void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
95
96   /// Add point
97   SKETCHAPI_EXPORT
98   std::shared_ptr<SketchAPI_Point> addPoint(
99       double theX, double theY);
100   /// Add point
101   SKETCHAPI_EXPORT
102   std::shared_ptr<SketchAPI_Point> addPoint(
103       const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
104   /// Add point
105   SKETCHAPI_EXPORT
106   std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
107   /// Add point
108   SKETCHAPI_EXPORT
109   std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
110
111   /// Add intersection point
112   SKETCHAPI_EXPORT
113   std::shared_ptr<SketchAPI_IntersectionPoint>
114     addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
115   /// Add point
116   SKETCHAPI_EXPORT
117   std::shared_ptr<SketchAPI_IntersectionPoint>
118     addIntersectionPoint(const std::string & theExternalName);
119
120   /// Add line
121   SKETCHAPI_EXPORT
122   std::shared_ptr<SketchAPI_Line> addLine(
123       double theX1, double theY1, double theX2, double theY2);
124   /// Add line
125   SKETCHAPI_EXPORT
126   std::shared_ptr<SketchAPI_Line> addLine(
127       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
128       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
129   /// Add line
130   SKETCHAPI_EXPORT
131   std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
132   /// Add line
133   SKETCHAPI_EXPORT
134   std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
135
136   /// Add rectangle
137   SKETCHAPI_EXPORT
138   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
139       double theX1, double theY1, double theX2, double theY2);
140   /// Add rectangle
141   SKETCHAPI_EXPORT
142   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
143       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
144       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
145
146   /// Add circle
147   SKETCHAPI_EXPORT
148   std::shared_ptr<SketchAPI_Circle> addCircle(
149       double theCenterX, double theCenterY,
150       double theRadius);
151   /// Add circle
152   SKETCHAPI_EXPORT
153   std::shared_ptr<SketchAPI_Circle> addCircle(
154       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
155       double theRadius);
156   /// Add circle
157   SKETCHAPI_EXPORT
158   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
159       double theCenterX, double theCenterY,
160       double thePassedX, double thePassedY);
161   /// Add circle
162   SKETCHAPI_EXPORT
163   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
164       const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
165       const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
166   /// Add circle
167   SKETCHAPI_EXPORT
168   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
169       double theX1, double theY1,
170       double theX2, double theY2,
171       double theX3, double theY3);
172   /// Add circle
173   SKETCHAPI_EXPORT
174   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
175       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
176       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
177       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
178   /// Add circle
179   SKETCHAPI_EXPORT
180   std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
181   /// Add circle
182   SKETCHAPI_EXPORT
183   std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
184
185   /// Add arc
186   SKETCHAPI_EXPORT
187   std::shared_ptr<SketchAPI_Arc> addArc(
188       double theCenterX, double theCenterY,
189       double theStartX, double theStartY,
190       double theEndX, double theEndY,
191       bool theInversed);
192
193   /// Add arc
194   SKETCHAPI_EXPORT
195   std::shared_ptr<SketchAPI_Arc> addArc(
196       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
197       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
198       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
199       bool theInversed);
200
201   /// Add arc
202   SKETCHAPI_EXPORT
203   std::shared_ptr<SketchAPI_Arc> addArc(
204       double theStartX, double theStartY,
205       double theEndX, double theEndY,
206       double thePassedX, double thePassedY);
207
208   /// Add arc
209   SKETCHAPI_EXPORT
210   std::shared_ptr<SketchAPI_Arc> addArc(
211       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
212       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
213       const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
214
215   /// Add arc
216   SKETCHAPI_EXPORT
217   std::shared_ptr<SketchAPI_Arc> addArc(
218       const ModelHighAPI_RefAttr& theTangentPoint,
219       double theEndX, double theEndY,
220       bool theInversed);
221
222   /// Add arc
223   SKETCHAPI_EXPORT
224   std::shared_ptr<SketchAPI_Arc> addArc(
225       const ModelHighAPI_RefAttr& theTangentPoint,
226       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
227       bool theInversed);
228
229   /// Add arc
230   SKETCHAPI_EXPORT
231   std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
232
233   /// Add arc
234   SKETCHAPI_EXPORT
235   std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
236
237   /// Add projection
238   SKETCHAPI_EXPORT
239   std::shared_ptr<SketchAPI_Projection> addProjection(
240       const ModelHighAPI_Selection & theExternalFeature);
241
242   /// Add projection
243   SKETCHAPI_EXPORT
244   std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
245
246   /// Add mirror
247   SKETCHAPI_EXPORT
248   std::shared_ptr<SketchAPI_Mirror> addMirror(
249       const ModelHighAPI_RefAttr & theMirrorLine,
250       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
251
252   /// Add translation
253   SKETCHAPI_EXPORT
254   std::shared_ptr<SketchAPI_Translation> addTranslation(
255       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
256       const ModelHighAPI_RefAttr & thePoint1,
257       const ModelHighAPI_RefAttr & thePoint2,
258       const ModelHighAPI_Integer & theNumberOfObjects,
259       bool theFullValue = false);
260
261   /// Add rotation
262   SKETCHAPI_EXPORT
263   std::shared_ptr<SketchAPI_Rotation> addRotation(
264       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
265       const ModelHighAPI_RefAttr & theCenter,
266       const ModelHighAPI_Double & theAngle,
267       const ModelHighAPI_Integer & theNumberOfObjects,
268       bool theFullValue = false);
269
270   /// Add split
271   SKETCHAPI_EXPORT
272   std::shared_ptr<ModelHighAPI_Interface> addSplit(
273       const ModelHighAPI_Reference& theFeature,
274       const ModelHighAPI_RefAttr& thePoint1,
275       const ModelHighAPI_RefAttr& thePoint2);
276
277   /// Add trim
278   SKETCHAPI_EXPORT
279   std::shared_ptr<ModelHighAPI_Interface> addTrim(
280       const ModelHighAPI_Reference& theFeature,
281       const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
282
283   /// Set angle
284   SKETCHAPI_EXPORT
285   std::shared_ptr<ModelHighAPI_Interface> setAngle(
286       const ModelHighAPI_RefAttr & theLine1,
287       const ModelHighAPI_RefAttr & theLine2,
288       const ModelHighAPI_Double & theValue);
289
290   /// Set complementary angle
291   SKETCHAPI_EXPORT
292   std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
293       const ModelHighAPI_RefAttr & theLine1,
294       const ModelHighAPI_RefAttr & theLine2,
295       const ModelHighAPI_Double & theValue);
296
297   /// Set backward angle (= 360 - angle)
298   SKETCHAPI_EXPORT
299   std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
300       const ModelHighAPI_RefAttr & theLine1,
301       const ModelHighAPI_RefAttr & theLine2,
302       const ModelHighAPI_Double & theValue);
303
304   /// Set coincident
305   SKETCHAPI_EXPORT
306   std::shared_ptr<ModelHighAPI_Interface> setCoincident(
307       const ModelHighAPI_RefAttr & thePoint1,
308       const ModelHighAPI_RefAttr & thePoint2);
309
310   /// Set collinear
311   SKETCHAPI_EXPORT
312   std::shared_ptr<ModelHighAPI_Interface> setCollinear(
313       const ModelHighAPI_RefAttr & theLine1,
314       const ModelHighAPI_RefAttr & theLine2);
315
316   /// Set distance
317   SKETCHAPI_EXPORT
318   std::shared_ptr<ModelHighAPI_Interface> setDistance(
319       const ModelHighAPI_RefAttr & thePoint,
320       const ModelHighAPI_RefAttr & thePointOrLine,
321       const ModelHighAPI_Double & theValue);
322
323   /// Set equal
324   SKETCHAPI_EXPORT
325   std::shared_ptr<ModelHighAPI_Interface> setEqual(
326       const ModelHighAPI_RefAttr & theObject1,
327       const ModelHighAPI_RefAttr & theObject2);
328
329   /// Set fillet
330   SKETCHAPI_EXPORT
331   std::shared_ptr<ModelHighAPI_Interface> setFillet(
332       const ModelHighAPI_RefAttr & thePoint);
333
334   /// Set fillet with additional radius constraint
335   SKETCHAPI_EXPORT
336   std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
337       const ModelHighAPI_RefAttr & thePoint,
338       const ModelHighAPI_Double & theRadius);
339
340   /// Set fixed
341   SKETCHAPI_EXPORT
342   std::shared_ptr<ModelHighAPI_Interface> setFixed(
343       const ModelHighAPI_RefAttr & theObject);
344
345   /// Set horizontal
346   SKETCHAPI_EXPORT
347   std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
348       const ModelHighAPI_RefAttr & theLine);
349
350   /// Set length
351   SKETCHAPI_EXPORT
352   std::shared_ptr<ModelHighAPI_Interface> setLength(
353       const ModelHighAPI_RefAttr & theLine,
354       const ModelHighAPI_Double & theValue);
355
356   /// Set middle
357   SKETCHAPI_EXPORT
358   std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
359       const ModelHighAPI_RefAttr & thePoint,
360       const ModelHighAPI_RefAttr & theLine);
361
362   /// Set parallel
363   SKETCHAPI_EXPORT
364   std::shared_ptr<ModelHighAPI_Interface> setParallel(
365       const ModelHighAPI_RefAttr & theLine1,
366       const ModelHighAPI_RefAttr & theLine2);
367
368   /// Set perpendicular
369   SKETCHAPI_EXPORT
370   std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
371       const ModelHighAPI_RefAttr & theLine1,
372       const ModelHighAPI_RefAttr & theLine2);
373
374   /// Set radius
375   SKETCHAPI_EXPORT
376   std::shared_ptr<ModelHighAPI_Interface> setRadius(
377       const ModelHighAPI_RefAttr & theCircleOrArc,
378       const ModelHighAPI_Double & theValue);
379
380   /// Set tangent
381   SKETCHAPI_EXPORT
382   std::shared_ptr<ModelHighAPI_Interface> setTangent(
383       const ModelHighAPI_RefAttr & theLine,
384       const ModelHighAPI_RefAttr & theCircle);
385
386   /// Set vertical
387   SKETCHAPI_EXPORT
388   std::shared_ptr<ModelHighAPI_Interface> setVertical(
389       const ModelHighAPI_RefAttr & theLine);
390
391   /// Set constraint value
392   SKETCHAPI_EXPORT
393   void setValue(
394       const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
395       const ModelHighAPI_Double & theValue);
396
397   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
398   /// Select face
399   SKETCHAPI_EXPORT
400   std::list<ModelHighAPI_Selection> selectFace() const;
401
402   /// Dump wrapped feature
403   SKETCHAPI_EXPORT
404   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
405
406 protected:
407   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
408
409 };
410
411 //! Pointer on Sketch object
412 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
413
414 /**\ingroup CPPHighAPI
415  * \brief Create Sketch feature
416  */
417 SKETCHAPI_EXPORT
418 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
419                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
420
421 /**\ingroup CPPHighAPI
422  * \brief Create Sketch feature
423  */
424 SKETCHAPI_EXPORT
425 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
426                     const ModelHighAPI_Selection & theExternal);
427
428 /**\ingroup CPPHighAPI
429  * \brief Create Sketch feature
430  */
431 SKETCHAPI_EXPORT
432 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
433                     const std::string & theExternalName);
434
435 /**\ingroup CPPHighAPI
436  * \brief Create Sketch feature
437  */
438 SKETCHAPI_EXPORT
439 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
440                     std::shared_ptr<ModelAPI_Object> thePlaneObject);
441
442 //--------------------------------------------------------------------------------------
443 //--------------------------------------------------------------------------------------
444 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */