1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SketchAPI_MacroEllipse_H_
21 #define SketchAPI_MacroEllipse_H_
23 #include "SketchAPI.h"
24 #include "SketchAPI_SketchEntity.h"
26 #include <SketchPlugin_MacroEllipse.h>
28 class ModelHighAPI_RefAttr;
29 class SketchAPI_Point;
32 /// \class SketchAPI_MacroEllipse
33 /// \ingroup CPPHighAPI
34 /// \brief Interface for Ellipse feature.
35 class SketchAPI_MacroEllipse: public SketchAPI_SketchEntity
38 /// Constructor without values.
40 explicit SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature);
42 /// Constructor with values.
44 SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
45 double theX1, double theY1,
46 double theX2, double theY2,
47 double theX3, double theY3,
48 bool byCenter = true);
50 /// Constructor with values.
52 SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
53 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
54 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
55 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
56 bool byCenter = true);
58 /// Constructor with values and/or references.
60 SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
61 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
62 const ModelHighAPI_RefAttr& thePoint1Ref,
63 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
64 const ModelHighAPI_RefAttr& thePoint2Ref,
65 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
66 const ModelHighAPI_RefAttr& thePoint3Ref,
67 bool byCenter = true);
71 virtual ~SketchAPI_MacroEllipse();
73 INTERFACE_1(SketchPlugin_MacroEllipse::ID(),
74 ellipseType, SketchPlugin_MacroEllipse::ELLIPSE_TYPE(),
75 ModelAPI_AttributeString, /** Ellipse type */)
77 /// Return created auxiliary center point
78 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> center();
79 /// Return created auxiliary focus in the positive direction of major axis
80 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> focus1();
81 /// Return created auxiliary focus in the negative direction of major axis
82 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> focus2();
83 /// Return created auxiliary point - start of major axis
84 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> majorAxisStart();
85 /// Return created auxiliary point - end of major axis
86 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> majorAxisEnd();
87 /// Return created auxiliary point - start of minor axis
88 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> minorAxisStart();
89 /// Return created auxiliary point - end of minor axis
90 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> minorAxisEnd();
91 /// Return created auxiliary major axis
92 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Line> majorAxis();
93 /// Return created auxiliary minor axis
94 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Line> minorAxis();
97 /// Set flag of creation by center, major semi-axis and passed point.
98 void setByCenterAndPassedPoints();
99 /// Set flag of creation by major axis and passed point.
100 void setByMajorAxisAndPassedPoint();
102 /// Set points of ellipse.
103 void initializePoints(double theMajorAxisX1, double theMajorAxisY1,
104 double theMajorAxisX2, double theMajorAxisY2,
105 double thePassedX, double thePassedY);
107 /// Set points of ellipse.
108 void initializePoints(const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint1,
109 const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint2,
110 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
112 /// Set points of ellipse.
113 void initializePoints(const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint1,
114 const ModelHighAPI_RefAttr& theMajorAxisPoint1Ref,
115 const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint2,
116 const ModelHighAPI_RefAttr& theMajorAxisPoint2Ref,
117 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint,
118 const ModelHighAPI_RefAttr& thePassedPointRef);
120 /// Collect auxiliary features
121 void collectAuxiliary();
124 CompositeFeaturePtr mySketch;
125 std::shared_ptr<SketchAPI_Point> myCenter;
126 std::shared_ptr<SketchAPI_Point> myFocus1;
127 std::shared_ptr<SketchAPI_Point> myFocus2;
128 std::shared_ptr<SketchAPI_Point> myMajorAxisStart;
129 std::shared_ptr<SketchAPI_Point> myMajorAxisEnd;
130 std::shared_ptr<SketchAPI_Point> myMinorAxisStart;
131 std::shared_ptr<SketchAPI_Point> myMinorAxisEnd;
132 std::shared_ptr<SketchAPI_Line> myMajorAxis;
133 std::shared_ptr<SketchAPI_Line> myMinorAxis;
136 /// Pointer on Circle object.
137 typedef std::shared_ptr<SketchAPI_MacroEllipse> MacroEllipsePtr;
139 #endif // SketchAPI_MacroEllipse_H_