Salome HOME
Task 2.12. New entities: ellipses and arcs of ellipses (issue #3003)
[modules/shaper.git] / src / SketchAPI / SketchAPI_Ellipse.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef SketchAPI_Ellipse_H_
21 #define SketchAPI_Ellipse_H_
22
23 #include "SketchAPI.h"
24 #include "SketchAPI_SketchEntity.h"
25
26 #include <SketchPlugin_Ellipse.h>
27
28 class ModelHighAPI_Selection;
29
30 /// \class SketchAPI_Ellipse
31 /// \ingroup CPPHighAPI
32 /// \brief Interface for Ellipse feature.
33 class SketchAPI_Ellipse : public SketchAPI_SketchEntity
34 {
35 public:
36   /// Constructor without values.
37   SKETCHAPI_EXPORT
38   explicit SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature);
39
40   /// Constructor with values.
41   SKETCHAPI_EXPORT
42   SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
43                     double theCenterX, double theCenterY,
44                     double theFocusX, double theFocusY,
45                     double theMinorRadius);
46
47   /// Constructor with values.
48   SKETCHAPI_EXPORT
49   SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
50                     const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
51                     const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
52                     double theMinorRadius);
53
54   /// Constructor with external.
55   SKETCHAPI_EXPORT
56   SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
57                     const ModelHighAPI_Selection& theExternal);
58
59   /// Constructor with external.
60   SKETCHAPI_EXPORT
61   SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
62                     const std::string& theExternalName);
63
64   /// Destructor.
65   SKETCHAPI_EXPORT
66   virtual ~SketchAPI_Ellipse();
67
68   INTERFACE_10(SketchPlugin_Ellipse::ID(),
69                center, SketchPlugin_Ellipse::CENTER_ID(),
70                GeomDataAPI_Point2D, /** Center point */,
71                firstFocus, SketchPlugin_Ellipse::FIRST_FOCUS_ID(),
72                GeomDataAPI_Point2D, /** Focus in positive direction of a major axis */,
73                secondFocus, SketchPlugin_Ellipse::SECOND_FOCUS_ID(),
74                GeomDataAPI_Point2D, /** Focus in negative direction of a major axis */,
75                majorAxisNegative, SketchPlugin_Ellipse::MAJOR_AXIS_START_ID(),
76                GeomDataAPI_Point2D, /** Start point of major axis */,
77                majorAxisPositive, SketchPlugin_Ellipse::MAJOR_AXIS_END_ID(),
78                GeomDataAPI_Point2D, /** End point of major axis */,
79                minorAxisNegative, SketchPlugin_Ellipse::MINOR_AXIS_START_ID(),
80                GeomDataAPI_Point2D, /** Start point of minor axis */,
81                minorAxisPositive, SketchPlugin_Ellipse::MINOR_AXIS_END_ID(),
82                GeomDataAPI_Point2D, /** End point of minor axis */,
83                majorRadius, SketchPlugin_Ellipse::MAJOR_RADIUS_ID(),
84                ModelAPI_AttributeDouble, /** Major radius */,
85                minorRadius, SketchPlugin_Ellipse::MINOR_RADIUS_ID(),
86                ModelAPI_AttributeDouble, /** Minor radius */,
87                external, SketchPlugin_Ellipse::EXTERNAL_ID(),
88                ModelAPI_AttributeSelection, /** External */)
89
90   /// Set by center, focus and radius.
91   SKETCHAPI_EXPORT
92   void setByCenterFocusAndRadius(double theCenterX, double theCenterY,
93                                  double theFocusX, double theFocusY,
94                                  double theMinorRadius);
95
96   /// Set by center, focus and radius.
97   SKETCHAPI_EXPORT
98   void setByCenterFocusAndRadius(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
99                                  const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
100                                  double theMinorRadius);
101
102   /// Set by external.
103   SKETCHAPI_EXPORT
104   void setByExternal(const ModelHighAPI_Selection& theExternal);
105
106   /// Set by external name.
107   SKETCHAPI_EXPORT
108   void setByExternalName(const std::string& theExternalName);
109
110   /// Set center.
111   SKETCHAPI_EXPORT
112   void setCenter(double theX, double theY);
113
114   /// Set center.
115   SKETCHAPI_EXPORT
116   void setCenter(const std::shared_ptr<GeomAPI_Pnt2d> & theCenter);
117
118   /// Set focus.
119   SKETCHAPI_EXPORT
120   void setFocus(double theX, double theY);
121
122   /// Set focus.
123   SKETCHAPI_EXPORT
124   void setFocus(const std::shared_ptr<GeomAPI_Pnt2d> & theCenter);
125
126   /// Set radius.
127   SKETCHAPI_EXPORT
128   void setMinorRadius(double theRadius);
129
130   /// Return major axis of the ellipse
131   SKETCHAPI_EXPORT
132   ModelHighAPI_Selection majorAxis() const;
133
134   /// Return minor axis of the ellipse
135   SKETCHAPI_EXPORT
136   ModelHighAPI_Selection minorAxis() const;
137
138   /// Create construction elements (focuses, axes etc.).
139   /// Empty value for each parameter shows that the corresponding feature has been removed.
140   /// Value "aux" marks this feature as auxiliary.
141   /// And the name of the feature shows that it is a regular feature.
142   SKETCHAPI_EXPORT
143   std::list<std::shared_ptr<SketchAPI_SketchEntity> > construction(
144       const std::string& center = std::string(),
145       const std::string& firstFocus = std::string(),
146       const std::string& secondFocus = std::string(),
147       const std::string& majorAxisStart = std::string(),
148       const std::string& majorAxisEnd = std::string(),
149       const std::string& minorAxisStart = std::string(),
150       const std::string& minorAxisEnd = std::string(),
151       const std::string& majorAxis = std::string(),
152       const std::string& minorAxis = std::string()) const;
153
154   /// Dump wrapped feature
155   SKETCHAPI_EXPORT
156   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
157 };
158
159 /// Pointer on Ellipse object.
160 typedef std::shared_ptr<SketchAPI_Ellipse> EllipsePtr;
161
162 #endif // SketchPlugin_Ellipse_H_