Salome HOME
Task 2.4. Ability to modify the radius of circles and arcs of circle with the mouse
[modules/shaper.git] / src / SketchAPI / SketchAPI_Sketch.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name   : SketchAPI_Sketch.h
3 // Purpose:
4 //
5 // History:
6 // 07/06/16 - Sergey POKHODENKO - Creation of the file
7
8 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
9 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
10
11 //--------------------------------------------------------------------------------------
12 #include "SketchAPI.h"
13
14 #include <list>
15
16 #include <SketchPlugin_Sketch.h>
17 #include <SketchPlugin_SketchEntity.h>
18
19 #include <ModelHighAPI_Interface.h>
20 #include <ModelHighAPI_Macro.h>
21 //--------------------------------------------------------------------------------------
22 class ModelAPI_CompositeFeature;
23 class ModelAPI_Object;
24 class ModelHighAPI_Double;
25 class ModelHighAPI_Integer;
26 class ModelHighAPI_RefAttr;
27 class ModelHighAPI_Reference;
28 class ModelHighAPI_Selection;
29 class SketchAPI_Arc;
30 class SketchAPI_MacroArc;
31 class SketchAPI_Circle;
32 class SketchAPI_MacroCircle;
33 class SketchAPI_IntersectionPoint;
34 class SketchAPI_Line;
35 class SketchAPI_Mirror;
36 class SketchAPI_Point;
37 class SketchAPI_Projection;
38 class SketchAPI_Rectangle;
39 class SketchAPI_Rotation;
40 class SketchAPI_Translation;
41 //--------------------------------------------------------------------------------------
42 /**\class SketchAPI_Sketch
43  * \ingroup CPPHighAPI
44  * \brief Interface for Sketch feature
45  */
46 class SketchAPI_Sketch : public ModelHighAPI_Interface
47 {
48 public:
49   /// Constructor without values
50   SKETCHAPI_EXPORT
51   explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
52   /// Constructor with values
53   SKETCHAPI_EXPORT
54   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
55                    const std::shared_ptr<GeomAPI_Ax3> & thePlane);
56   /// Constructor with values
57   SKETCHAPI_EXPORT
58   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
59                    const ModelHighAPI_Selection & theExternal);
60   /// Constructor with values
61   SKETCHAPI_EXPORT
62   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
63                    std::shared_ptr<ModelAPI_Object> thePlaneObject);
64   /// Destructor
65   SKETCHAPI_EXPORT
66   virtual ~SketchAPI_Sketch();
67
68   INTERFACE_7(SketchPlugin_Sketch::ID(),
69               origin, SketchPlugin_Sketch::ORIGIN_ID(),
70               GeomDataAPI_Point, /** Origin point */,
71               dirX, SketchPlugin_Sketch::DIRX_ID(),
72               GeomDataAPI_Dir, /** Direction of X */,
73               normal, SketchPlugin_Sketch::NORM_ID(),
74               GeomDataAPI_Dir, /** Normal */,
75               features, SketchPlugin_Sketch::FEATURES_ID(),
76               ModelAPI_AttributeRefList, /** Features */,
77               external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
78               ModelAPI_AttributeSelection, /** External */,
79               solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
80               ModelAPI_AttributeString, /** Solver error */,
81               solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
82               ModelAPI_AttributeString, /** Solver DOF */
83   )
84
85   /// Set plane
86   SKETCHAPI_EXPORT
87   void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
88
89   /// Set external
90   SKETCHAPI_EXPORT
91   void setExternal(const ModelHighAPI_Selection & theExternal);
92
93   /// Set external
94   SKETCHAPI_EXPORT
95   void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
96
97   /// Add point
98   SKETCHAPI_EXPORT
99   std::shared_ptr<SketchAPI_Point> addPoint(
100       double theX, double theY);
101   /// Add point
102   SKETCHAPI_EXPORT
103   std::shared_ptr<SketchAPI_Point> addPoint(
104       const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
105   /// Add point
106   SKETCHAPI_EXPORT
107   std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
108   /// Add point
109   SKETCHAPI_EXPORT
110   std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
111
112   /// Add intersection point
113   SKETCHAPI_EXPORT
114   std::shared_ptr<SketchAPI_IntersectionPoint>
115     addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
116   /// Add point
117   SKETCHAPI_EXPORT
118   std::shared_ptr<SketchAPI_IntersectionPoint>
119     addIntersectionPoint(const std::string & theExternalName);
120
121   /// Add line
122   SKETCHAPI_EXPORT
123   std::shared_ptr<SketchAPI_Line> addLine(
124       double theX1, double theY1, double theX2, double theY2);
125   /// Add line
126   SKETCHAPI_EXPORT
127   std::shared_ptr<SketchAPI_Line> addLine(
128       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
129       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
130   /// Add line
131   SKETCHAPI_EXPORT
132   std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
133   /// Add line
134   SKETCHAPI_EXPORT
135   std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
136
137   /// Add rectangle
138   SKETCHAPI_EXPORT
139   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
140       double theX1, double theY1, double theX2, double theY2);
141   /// Add rectangle
142   SKETCHAPI_EXPORT
143   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
144       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
145       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
146
147   /// Add circle
148   SKETCHAPI_EXPORT
149   std::shared_ptr<SketchAPI_Circle> addCircle(
150       double theCenterX, double theCenterY,
151       double theRadius);
152   /// Add circle
153   SKETCHAPI_EXPORT
154   std::shared_ptr<SketchAPI_Circle> addCircle(
155       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
156       double theRadius);
157   /// Add circle
158   SKETCHAPI_EXPORT
159   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
160       double theCenterX, double theCenterY,
161       double thePassedX, double thePassedY);
162   /// Add circle
163   SKETCHAPI_EXPORT
164   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
165       const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
166       const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
167   /// Add circle
168   SKETCHAPI_EXPORT
169   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
170       double theX1, double theY1,
171       double theX2, double theY2,
172       double theX3, double theY3);
173   /// Add circle
174   SKETCHAPI_EXPORT
175   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
176       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
177       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
178       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
179   /// Add circle
180   SKETCHAPI_EXPORT
181   std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
182   /// Add circle
183   SKETCHAPI_EXPORT
184   std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
185
186   /// Add arc
187   SKETCHAPI_EXPORT
188   std::shared_ptr<SketchAPI_Arc> addArc(
189       double theCenterX, double theCenterY,
190       double theStartX, double theStartY,
191       double theEndX, double theEndY,
192       bool theInversed);
193
194   /// Add arc
195   SKETCHAPI_EXPORT
196   std::shared_ptr<SketchAPI_Arc> addArc(
197       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
198       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
199       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
200       bool theInversed);
201
202   /// Add arc
203   SKETCHAPI_EXPORT
204   std::shared_ptr<SketchAPI_MacroArc> addArc(
205       double theStartX, double theStartY,
206       double theEndX, double theEndY,
207       double thePassedX, double thePassedY);
208
209   /// Add arc
210   SKETCHAPI_EXPORT
211   std::shared_ptr<SketchAPI_MacroArc> addArc(
212       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
213       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
214       const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
215
216   /// Add arc
217   SKETCHAPI_EXPORT
218   std::shared_ptr<SketchAPI_MacroArc> addArc(
219       const ModelHighAPI_RefAttr& theTangentPoint,
220       double theEndX, double theEndY,
221       bool theInversed);
222
223   /// Add arc
224   SKETCHAPI_EXPORT
225   std::shared_ptr<SketchAPI_MacroArc> addArc(
226       const ModelHighAPI_RefAttr& theTangentPoint,
227       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
228       bool theInversed);
229
230   /// Add arc
231   SKETCHAPI_EXPORT
232   std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
233
234   /// Add arc
235   SKETCHAPI_EXPORT
236   std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
237
238   /// Add projection
239   SKETCHAPI_EXPORT
240   std::shared_ptr<SketchAPI_Projection> addProjection(
241       const ModelHighAPI_Selection & theExternalFeature);
242
243   /// Add projection
244   SKETCHAPI_EXPORT
245   std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
246
247   /// Add mirror
248   SKETCHAPI_EXPORT
249   std::shared_ptr<SketchAPI_Mirror> addMirror(
250       const ModelHighAPI_RefAttr & theMirrorLine,
251       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
252
253   /// Add translation
254   SKETCHAPI_EXPORT
255   std::shared_ptr<SketchAPI_Translation> addTranslation(
256       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
257       const ModelHighAPI_RefAttr & thePoint1,
258       const ModelHighAPI_RefAttr & thePoint2,
259       const ModelHighAPI_Integer & theNumberOfObjects,
260       bool theFullValue = false);
261
262   /// Add rotation
263   SKETCHAPI_EXPORT
264   std::shared_ptr<SketchAPI_Rotation> addRotation(
265       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
266       const ModelHighAPI_RefAttr & theCenter,
267       const ModelHighAPI_Double & theAngle,
268       const ModelHighAPI_Integer & theNumberOfObjects,
269       bool theFullValue = false);
270
271   /// Add split
272   SKETCHAPI_EXPORT
273   std::shared_ptr<ModelHighAPI_Interface> addSplit(
274       const ModelHighAPI_Reference& theFeature,
275       const ModelHighAPI_RefAttr& thePoint1,
276       const ModelHighAPI_RefAttr& thePoint2);
277
278   /// Add trim
279   SKETCHAPI_EXPORT
280   std::shared_ptr<ModelHighAPI_Interface> addTrim(
281       const ModelHighAPI_Reference& theFeature,
282       const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
283
284   /// Set angle
285   SKETCHAPI_EXPORT
286   std::shared_ptr<ModelHighAPI_Interface> setAngle(
287       const ModelHighAPI_RefAttr & theLine1,
288       const ModelHighAPI_RefAttr & theLine2,
289       const ModelHighAPI_Double & theValue);
290
291   /// Set complementary angle
292   SKETCHAPI_EXPORT
293   std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
294       const ModelHighAPI_RefAttr & theLine1,
295       const ModelHighAPI_RefAttr & theLine2,
296       const ModelHighAPI_Double & theValue);
297
298   /// Set backward angle (= 360 - angle)
299   SKETCHAPI_EXPORT
300   std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
301       const ModelHighAPI_RefAttr & theLine1,
302       const ModelHighAPI_RefAttr & theLine2,
303       const ModelHighAPI_Double & theValue);
304
305   /// Set coincident
306   SKETCHAPI_EXPORT
307   std::shared_ptr<ModelHighAPI_Interface> setCoincident(
308       const ModelHighAPI_RefAttr & thePoint1,
309       const ModelHighAPI_RefAttr & thePoint2);
310
311   /// Set collinear
312   SKETCHAPI_EXPORT
313   std::shared_ptr<ModelHighAPI_Interface> setCollinear(
314       const ModelHighAPI_RefAttr & theLine1,
315       const ModelHighAPI_RefAttr & theLine2);
316
317   /// Set distance
318   SKETCHAPI_EXPORT
319   std::shared_ptr<ModelHighAPI_Interface> setDistance(
320       const ModelHighAPI_RefAttr & thePoint,
321       const ModelHighAPI_RefAttr & thePointOrLine,
322       const ModelHighAPI_Double & theValue);
323
324   /// Set horizontal distance
325   SKETCHAPI_EXPORT
326   std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
327       const ModelHighAPI_RefAttr & thePoint1,
328       const ModelHighAPI_RefAttr & thePoint2,
329       const ModelHighAPI_Double & theValue);
330
331   /// Set vertical distance
332   SKETCHAPI_EXPORT
333   std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
334       const ModelHighAPI_RefAttr & thePoint1,
335       const ModelHighAPI_RefAttr & thePoint2,
336       const ModelHighAPI_Double & theValue);
337
338   /// Set equal
339   SKETCHAPI_EXPORT
340   std::shared_ptr<ModelHighAPI_Interface> setEqual(
341       const ModelHighAPI_RefAttr & theObject1,
342       const ModelHighAPI_RefAttr & theObject2);
343
344   /// Set fillet
345   SKETCHAPI_EXPORT
346   std::shared_ptr<ModelHighAPI_Interface> setFillet(
347       const ModelHighAPI_RefAttr & thePoint);
348
349   /// Set fillet with additional radius constraint
350   SKETCHAPI_EXPORT
351   std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
352       const ModelHighAPI_RefAttr & thePoint,
353       const ModelHighAPI_Double & theRadius);
354
355   /// Set fixed
356   SKETCHAPI_EXPORT
357   std::shared_ptr<ModelHighAPI_Interface> setFixed(
358       const ModelHighAPI_RefAttr & theObject);
359
360   /// Set horizontal
361   SKETCHAPI_EXPORT
362   std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
363       const ModelHighAPI_RefAttr & theLine);
364
365   /// Set length
366   SKETCHAPI_EXPORT
367   std::shared_ptr<ModelHighAPI_Interface> setLength(
368       const ModelHighAPI_RefAttr & theLine,
369       const ModelHighAPI_Double & theValue);
370
371   /// Set middle
372   SKETCHAPI_EXPORT
373   std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
374       const ModelHighAPI_RefAttr & thePoint,
375       const ModelHighAPI_RefAttr & theLine);
376
377   /// Set parallel
378   SKETCHAPI_EXPORT
379   std::shared_ptr<ModelHighAPI_Interface> setParallel(
380       const ModelHighAPI_RefAttr & theLine1,
381       const ModelHighAPI_RefAttr & theLine2);
382
383   /// Set perpendicular
384   SKETCHAPI_EXPORT
385   std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
386       const ModelHighAPI_RefAttr & theLine1,
387       const ModelHighAPI_RefAttr & theLine2);
388
389   /// Set radius
390   SKETCHAPI_EXPORT
391   std::shared_ptr<ModelHighAPI_Interface> setRadius(
392       const ModelHighAPI_RefAttr & theCircleOrArc,
393       const ModelHighAPI_Double & theValue);
394
395   /// Set tangent
396   SKETCHAPI_EXPORT
397   std::shared_ptr<ModelHighAPI_Interface> setTangent(
398       const ModelHighAPI_RefAttr & theLine,
399       const ModelHighAPI_RefAttr & theCircle);
400
401   /// Set vertical
402   SKETCHAPI_EXPORT
403   std::shared_ptr<ModelHighAPI_Interface> setVertical(
404       const ModelHighAPI_RefAttr & theLine);
405
406   /// Set constraint value
407   SKETCHAPI_EXPORT
408   void setValue(
409       const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
410       const ModelHighAPI_Double & theValue);
411
412   /// Move point or sketch feature
413   SKETCHAPI_EXPORT
414   void move(const ModelHighAPI_RefAttr& theMovedEntity,
415             const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
416
417   /// Move point or sketch feature
418   SKETCHAPI_EXPORT
419   void move(const ModelHighAPI_RefAttr& theMovedEntity,
420             double theTargetX, double theTargetY);
421
422   SKETCHAPI_EXPORT
423   std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
424
425   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
426   /// Select face
427   SKETCHAPI_EXPORT
428   std::list<ModelHighAPI_Selection> selectFace() const;
429
430   /// Dump wrapped feature
431   SKETCHAPI_EXPORT
432   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
433
434 protected:
435   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
436
437 };
438
439 //! Pointer on Sketch object
440 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
441
442 /**\ingroup CPPHighAPI
443  * \brief Create Sketch feature
444  */
445 SKETCHAPI_EXPORT
446 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
447                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
448
449 /**\ingroup CPPHighAPI
450  * \brief Create Sketch feature
451  */
452 SKETCHAPI_EXPORT
453 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
454                     const ModelHighAPI_Selection & theExternal);
455
456 /**\ingroup CPPHighAPI
457  * \brief Create Sketch feature
458  */
459 SKETCHAPI_EXPORT
460 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
461                     const std::string & theExternalName);
462
463 /**\ingroup CPPHighAPI
464  * \brief Create Sketch feature
465  */
466 SKETCHAPI_EXPORT
467 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
468                     std::shared_ptr<ModelAPI_Object> thePlaneObject);
469
470 //--------------------------------------------------------------------------------------
471 //--------------------------------------------------------------------------------------
472 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */