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