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