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