Salome HOME
Add resilt() and selectFace()
[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 length
131   SKETCHAPI_EXPORT
132   std::shared_ptr<ModelAPI_Feature> setLength(
133       const ModelHighAPI_RefAttr & theLine,
134       const ModelHighAPI_Double & theValue);
135
136   /// Set parallel
137   SKETCHAPI_EXPORT
138   std::shared_ptr<ModelAPI_Feature> setParallel(
139       const ModelHighAPI_RefAttr & theLine1,
140       const ModelHighAPI_RefAttr & theLine2);
141
142   /// Set perpendicular
143   SKETCHAPI_EXPORT
144   std::shared_ptr<ModelAPI_Feature> setPerpendicular(
145       const ModelHighAPI_RefAttr & theLine1,
146       const ModelHighAPI_RefAttr & theLine2);
147
148   // TODO(spo): set* (constraints)
149
150   // TODO(spo): addMirror
151
152   /// Set constraint value
153   SKETCHAPI_EXPORT
154   void setValue(
155       const std::shared_ptr<ModelAPI_Feature> & theConstraint,
156       const ModelHighAPI_Double & theValue);
157
158   // TODO(spo): setText. Is it necessary as setValue accepts text expressions?
159
160   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
161   /// Select face
162   SKETCHAPI_EXPORT
163   std::list<ModelHighAPI_Selection> selectFace() const;
164
165 protected:
166   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
167
168 };
169
170 //! Pointer on Sketch object
171 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
172
173 /**\ingroup CPPHighAPI
174  * \brief Create Sketch feature
175  */
176 SKETCHAPI_EXPORT
177 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
178                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
179
180 /**\ingroup CPPHighAPI
181  * \brief Create Sketch feature
182  */
183 SKETCHAPI_EXPORT
184 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
185                     const ModelHighAPI_Selection & theExternal);
186
187 /**\ingroup CPPHighAPI
188  * \brief Create Sketch feature
189  */
190 SKETCHAPI_EXPORT
191 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
192                     const std::string & theExternalName);
193
194 //--------------------------------------------------------------------------------------
195 //--------------------------------------------------------------------------------------
196 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */