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