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