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