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