Salome HOME
Issue #2149 Split does not highlight the selected edge
[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 std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
276
277   /// Add trim
278   SKETCHAPI_EXPORT
279   std::shared_ptr<ModelHighAPI_Interface> addTrim(
280       const ModelHighAPI_Reference& theFeature,
281       const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
282
283   /// Set angle
284   SKETCHAPI_EXPORT
285   std::shared_ptr<ModelHighAPI_Interface> setAngle(
286       const ModelHighAPI_RefAttr & theLine1,
287       const ModelHighAPI_RefAttr & theLine2,
288       const ModelHighAPI_Double & theValue);
289
290   /// Set complementary angle
291   SKETCHAPI_EXPORT
292   std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
293       const ModelHighAPI_RefAttr & theLine1,
294       const ModelHighAPI_RefAttr & theLine2,
295       const ModelHighAPI_Double & theValue);
296
297   /// Set backward angle (= 360 - angle)
298   SKETCHAPI_EXPORT
299   std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
300       const ModelHighAPI_RefAttr & theLine1,
301       const ModelHighAPI_RefAttr & theLine2,
302       const ModelHighAPI_Double & theValue);
303
304   /// Set coincident
305   SKETCHAPI_EXPORT
306   std::shared_ptr<ModelHighAPI_Interface> setCoincident(
307       const ModelHighAPI_RefAttr & thePoint1,
308       const ModelHighAPI_RefAttr & thePoint2);
309
310   /// Set collinear
311   SKETCHAPI_EXPORT
312   std::shared_ptr<ModelHighAPI_Interface> setCollinear(
313       const ModelHighAPI_RefAttr & theLine1,
314       const ModelHighAPI_RefAttr & theLine2);
315
316   /// Set distance
317   SKETCHAPI_EXPORT
318   std::shared_ptr<ModelHighAPI_Interface> setDistance(
319       const ModelHighAPI_RefAttr & thePoint,
320       const ModelHighAPI_RefAttr & thePointOrLine,
321       const ModelHighAPI_Double & theValue);
322
323   /// Set equal
324   SKETCHAPI_EXPORT
325   std::shared_ptr<ModelHighAPI_Interface> setEqual(
326       const ModelHighAPI_RefAttr & theObject1,
327       const ModelHighAPI_RefAttr & theObject2);
328
329   /// Set fillet
330   SKETCHAPI_EXPORT
331   std::shared_ptr<ModelHighAPI_Interface> setFillet(
332       const ModelHighAPI_RefAttr & thePoint);
333
334   /// Set fillet with additional radius constraint
335   SKETCHAPI_EXPORT
336   std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
337       const ModelHighAPI_RefAttr & thePoint,
338       const ModelHighAPI_Double & theRadius);
339
340   /// Set fixed
341   SKETCHAPI_EXPORT
342   std::shared_ptr<ModelHighAPI_Interface> setFixed(
343       const ModelHighAPI_RefAttr & theObject);
344
345   /// Set horizontal
346   SKETCHAPI_EXPORT
347   std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
348       const ModelHighAPI_RefAttr & theLine);
349
350   /// Set length
351   SKETCHAPI_EXPORT
352   std::shared_ptr<ModelHighAPI_Interface> setLength(
353       const ModelHighAPI_RefAttr & theLine,
354       const ModelHighAPI_Double & theValue);
355
356   /// Set middle
357   SKETCHAPI_EXPORT
358   std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
359       const ModelHighAPI_RefAttr & thePoint,
360       const ModelHighAPI_RefAttr & theLine);
361
362   /// Set parallel
363   SKETCHAPI_EXPORT
364   std::shared_ptr<ModelHighAPI_Interface> setParallel(
365       const ModelHighAPI_RefAttr & theLine1,
366       const ModelHighAPI_RefAttr & theLine2);
367
368   /// Set perpendicular
369   SKETCHAPI_EXPORT
370   std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
371       const ModelHighAPI_RefAttr & theLine1,
372       const ModelHighAPI_RefAttr & theLine2);
373
374   /// Set radius
375   SKETCHAPI_EXPORT
376   std::shared_ptr<ModelHighAPI_Interface> setRadius(
377       const ModelHighAPI_RefAttr & theCircleOrArc,
378       const ModelHighAPI_Double & theValue);
379
380   /// Set tangent
381   SKETCHAPI_EXPORT
382   std::shared_ptr<ModelHighAPI_Interface> setTangent(
383       const ModelHighAPI_RefAttr & theLine,
384       const ModelHighAPI_RefAttr & theCircle);
385
386   /// Set vertical
387   SKETCHAPI_EXPORT
388   std::shared_ptr<ModelHighAPI_Interface> setVertical(
389       const ModelHighAPI_RefAttr & theLine);
390
391   /// Set constraint value
392   SKETCHAPI_EXPORT
393   void setValue(
394       const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
395       const ModelHighAPI_Double & theValue);
396
397   SKETCHAPI_EXPORT
398   std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
399
400   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
401   /// Select face
402   SKETCHAPI_EXPORT
403   std::list<ModelHighAPI_Selection> selectFace() const;
404
405   /// Dump wrapped feature
406   SKETCHAPI_EXPORT
407   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
408
409 protected:
410   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
411
412 };
413
414 //! Pointer on Sketch object
415 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
416
417 /**\ingroup CPPHighAPI
418  * \brief Create Sketch feature
419  */
420 SKETCHAPI_EXPORT
421 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
422                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
423
424 /**\ingroup CPPHighAPI
425  * \brief Create Sketch feature
426  */
427 SKETCHAPI_EXPORT
428 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
429                     const ModelHighAPI_Selection & theExternal);
430
431 /**\ingroup CPPHighAPI
432  * \brief Create Sketch feature
433  */
434 SKETCHAPI_EXPORT
435 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
436                     const std::string & theExternalName);
437
438 /**\ingroup CPPHighAPI
439  * \brief Create Sketch feature
440  */
441 SKETCHAPI_EXPORT
442 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
443                     std::shared_ptr<ModelAPI_Object> thePlaneObject);
444
445 //--------------------------------------------------------------------------------------
446 //--------------------------------------------------------------------------------------
447 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */