Salome HOME
Rename setRigid to setFixed for C++HighAPI
[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   // TODO(spo): addIntersection
79
80   /// Add point
81   SKETCHAPI_EXPORT
82   std::shared_ptr<SketchAPI_Point> addPoint(
83       double theX, double theY);
84   /// Add point
85   SKETCHAPI_EXPORT
86   std::shared_ptr<SketchAPI_Point> addPoint(
87       const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
88   /// Add point
89   SKETCHAPI_EXPORT
90   std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
91   /// Add point
92   SKETCHAPI_EXPORT
93   std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
94
95   /// Add intersection point
96   SKETCHAPI_EXPORT
97   std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
98   /// Add point
99   SKETCHAPI_EXPORT
100   std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const std::string & theExternalName);
101
102   /// Add line
103   SKETCHAPI_EXPORT
104   std::shared_ptr<SketchAPI_Line> addLine(
105       double theX1, double theY1, double theX2, double theY2);
106   /// Add line
107   SKETCHAPI_EXPORT
108   std::shared_ptr<SketchAPI_Line> addLine(
109       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
110       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
111   /// Add line
112   SKETCHAPI_EXPORT
113   std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
114   /// Add line
115   SKETCHAPI_EXPORT
116   std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
117
118   /// Add rectangle
119   SKETCHAPI_EXPORT
120   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
121       double theX1, double theY1, double theX2, double theY2);
122   /// Add rectangle
123   SKETCHAPI_EXPORT
124   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
125       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
126       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
127
128   /// Add circle
129   SKETCHAPI_EXPORT
130   std::shared_ptr<SketchAPI_Circle> addCircle(
131       double theCenterX, double theCenterY,
132       double theRadius);
133   /// Add circle
134   SKETCHAPI_EXPORT
135   std::shared_ptr<SketchAPI_Circle> addCircle(
136       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
137       double theRadius);
138   /// Add circle
139   SKETCHAPI_EXPORT
140   std::shared_ptr<SketchAPI_Circle> addCircle(
141       double theX1, double theY1,
142       double theX2, double theY2,
143       double theX3, double theY3);
144   /// Add circle
145   SKETCHAPI_EXPORT
146   std::shared_ptr<SketchAPI_Circle> addCircle(
147       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
148       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
149       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
150   /// Add circle
151   SKETCHAPI_EXPORT
152   std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
153   /// Add circle
154   SKETCHAPI_EXPORT
155   std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
156
157   /// Add arc
158   SKETCHAPI_EXPORT
159   std::shared_ptr<SketchAPI_Arc> addArc(
160       double theCenterX, double theCenterY,
161       double theStartX, double theStartY,
162       double theEndX, double theEndY,
163       bool theInversed);
164
165   /// Add arc
166   SKETCHAPI_EXPORT
167   std::shared_ptr<SketchAPI_Arc> addArc(
168       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
169       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
170       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
171       bool theInversed);
172
173   /// Add arc
174   SKETCHAPI_EXPORT
175   std::shared_ptr<SketchAPI_Arc> addArc(
176       double theStartX, double theStartY,
177       double theEndX, double theEndY,
178       double thePassedX, double thePassedY);
179
180   /// Add arc
181   SKETCHAPI_EXPORT
182   std::shared_ptr<SketchAPI_Arc> addArc(
183       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
184       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
185       const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
186
187   /// Add arc
188   SKETCHAPI_EXPORT
189   std::shared_ptr<SketchAPI_Arc> addArc(
190       const ModelHighAPI_RefAttr& theTangentPoint,
191       double theEndX, double theEndY,
192       bool theInversed);
193
194   /// Add arc
195   SKETCHAPI_EXPORT
196   std::shared_ptr<SketchAPI_Arc> addArc(
197       const ModelHighAPI_RefAttr& theTangentPoint,
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(const ModelHighAPI_Selection & theExternal);
204
205   /// Add arc
206   SKETCHAPI_EXPORT
207   std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
208
209   /// Add projection
210   SKETCHAPI_EXPORT
211   std::shared_ptr<SketchAPI_Projection> addProjection(
212       const ModelHighAPI_Selection & theExternalFeature);
213
214   /// Add mirror
215   SKETCHAPI_EXPORT
216   std::shared_ptr<SketchAPI_Mirror> addMirror(
217       const ModelHighAPI_RefAttr & theMirrorLine,
218       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
219
220   /// Add translation
221   SKETCHAPI_EXPORT
222   std::shared_ptr<SketchAPI_Translation> addTranslation(
223       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
224       const ModelHighAPI_RefAttr & thePoint1,
225       const ModelHighAPI_RefAttr & thePoint2,
226       const ModelHighAPI_Integer & theNumberOfObjects,
227       bool theFullValue = false);
228
229   /// Add rotation
230   SKETCHAPI_EXPORT
231   std::shared_ptr<SketchAPI_Rotation> addRotation(
232       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
233       const ModelHighAPI_RefAttr & theCenter,
234       const ModelHighAPI_Double & theAngle,
235       const ModelHighAPI_Integer & theNumberOfObjects,
236       bool theFullValue = false);
237
238   /// Set angle
239   SKETCHAPI_EXPORT
240   std::shared_ptr<ModelAPI_Feature> setAngle(
241       const ModelHighAPI_RefAttr & theLine1,
242       const ModelHighAPI_RefAttr & theLine2,
243       const ModelHighAPI_Double & theValue);
244
245   /// Set coincident
246   SKETCHAPI_EXPORT
247   std::shared_ptr<ModelAPI_Feature> setCoincident(
248       const ModelHighAPI_RefAttr & thePoint1,
249       const ModelHighAPI_RefAttr & thePoint2);
250
251   /// Set collinear
252   SKETCHAPI_EXPORT
253   std::shared_ptr<ModelAPI_Feature> setCollinear(
254       const ModelHighAPI_RefAttr & theLine1,
255       const ModelHighAPI_RefAttr & theLine2);
256
257   /// Set distance
258   SKETCHAPI_EXPORT
259   std::shared_ptr<ModelAPI_Feature> setDistance(
260       const ModelHighAPI_RefAttr & thePoint,
261       const ModelHighAPI_RefAttr & thePointOrLine,
262       const ModelHighAPI_Double & theValue);
263
264   /// Set equal
265   SKETCHAPI_EXPORT
266   std::shared_ptr<ModelAPI_Feature> setEqual(
267       const ModelHighAPI_RefAttr & theObject1,
268       const ModelHighAPI_RefAttr & theObject2);
269
270   /// Set fillet
271   SKETCHAPI_EXPORT
272   std::shared_ptr<ModelAPI_Feature> setFillet(
273       const std::list<ModelHighAPI_RefAttr> & thePoints,
274       const ModelHighAPI_Double & theRadius);
275
276   /// Set fixed
277   SKETCHAPI_EXPORT
278   std::shared_ptr<ModelAPI_Feature> setFixed(
279       const ModelHighAPI_RefAttr & theObject);
280
281   /// Set horizontal
282   SKETCHAPI_EXPORT
283   std::shared_ptr<ModelAPI_Feature> setHorizontal(
284       const ModelHighAPI_RefAttr & theLine);
285
286   /// Set length
287   SKETCHAPI_EXPORT
288   std::shared_ptr<ModelAPI_Feature> setLength(
289       const ModelHighAPI_RefAttr & theLine,
290       const ModelHighAPI_Double & theValue);
291
292   /// Set middle
293   SKETCHAPI_EXPORT
294   std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
295       const ModelHighAPI_RefAttr & thePoint,
296       const ModelHighAPI_RefAttr & theLine);
297
298   /// Set parallel
299   SKETCHAPI_EXPORT
300   std::shared_ptr<ModelAPI_Feature> setParallel(
301       const ModelHighAPI_RefAttr & theLine1,
302       const ModelHighAPI_RefAttr & theLine2);
303
304   /// Set perpendicular
305   SKETCHAPI_EXPORT
306   std::shared_ptr<ModelAPI_Feature> setPerpendicular(
307       const ModelHighAPI_RefAttr & theLine1,
308       const ModelHighAPI_RefAttr & theLine2);
309
310   /// Set radius
311   SKETCHAPI_EXPORT
312   std::shared_ptr<ModelAPI_Feature> setRadius(
313       const ModelHighAPI_RefAttr & theCircleOrArc,
314       const ModelHighAPI_Double & theValue);
315
316   /// Set tangent
317   SKETCHAPI_EXPORT
318   std::shared_ptr<ModelAPI_Feature> setTangent(
319       const ModelHighAPI_RefAttr & theLine,
320       const ModelHighAPI_RefAttr & theCircle);
321
322   /// Set vertical
323   SKETCHAPI_EXPORT
324   std::shared_ptr<ModelAPI_Feature> setVertical(
325       const ModelHighAPI_RefAttr & theLine);
326
327   /// Set constraint value
328   SKETCHAPI_EXPORT
329   void setValue(
330       const std::shared_ptr<ModelAPI_Feature> & theConstraint,
331       const ModelHighAPI_Double & theValue);
332
333   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
334   /// Select face
335   SKETCHAPI_EXPORT
336   std::list<ModelHighAPI_Selection> selectFace() const;
337
338 protected:
339   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
340
341 };
342
343 //! Pointer on Sketch object
344 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
345
346 /**\ingroup CPPHighAPI
347  * \brief Create Sketch feature
348  */
349 SKETCHAPI_EXPORT
350 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
351                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
352
353 /**\ingroup CPPHighAPI
354  * \brief Create Sketch feature
355  */
356 SKETCHAPI_EXPORT
357 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
358                     const ModelHighAPI_Selection & theExternal);
359
360 /**\ingroup CPPHighAPI
361  * \brief Create Sketch feature
362  */
363 SKETCHAPI_EXPORT
364 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
365                     const std::string & theExternalName);
366
367 //--------------------------------------------------------------------------------------
368 //--------------------------------------------------------------------------------------
369 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */