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