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