SHAPER  9.12.0
SketchAPI_MacroEllipse.h
1 // Copyright (C) 2014-2023 CEA, EDF
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_MacroEllipse_H_
21 #define SketchAPI_MacroEllipse_H_
22 
23 #include "SketchAPI.h"
24 #include "SketchAPI_SketchEntity.h"
25 
26 #include <SketchPlugin_MacroEllipse.h>
27 
29 class SketchAPI_Point;
30 class SketchAPI_Line;
31 
36 {
37 public:
39  SKETCHAPI_EXPORT
40  explicit SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
41  bool callInitialize = true);
42 
44  SKETCHAPI_EXPORT
45  SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
46  double theX1, double theY1,
47  double theX2, double theY2,
48  double theX3, double theY3,
49  bool byCenter = true);
50 
52  SKETCHAPI_EXPORT
53  SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
54  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
55  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
56  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
57  bool byCenter = true);
58 
60  SKETCHAPI_EXPORT
61  SketchAPI_MacroEllipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
62  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
63  const ModelHighAPI_RefAttr& thePoint1Ref,
64  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
65  const ModelHighAPI_RefAttr& thePoint2Ref,
66  const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
67  const ModelHighAPI_RefAttr& thePoint3Ref,
68  bool byCenter = true);
69 
71  SKETCHAPI_EXPORT
72  virtual ~SketchAPI_MacroEllipse();
73 
74  INTERFACE_1(SketchPlugin_MacroEllipse::ID(),
75  ellipseType, SketchPlugin_MacroEllipse::ELLIPSE_TYPE(),
77 
78 
79  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> center();
81  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> focus1();
83  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> focus2();
85  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> majorAxisStart();
87  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> majorAxisEnd();
89  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> minorAxisStart();
91  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> minorAxisEnd();
93  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Line> majorAxis();
95  SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Line> minorAxis();
96 
97 protected:
98  // find a parent sketch
99  void storeSketch(const std::shared_ptr<ModelAPI_Feature>& theFeature);
100 
101 private:
103  void setByCenterAndPassedPoints(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
104  const ModelHighAPI_RefAttr& theCenterRef,
105  const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisPoint,
106  const ModelHighAPI_RefAttr& theMajorAxisPointRef,
107  const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint,
108  const ModelHighAPI_RefAttr& thePassedPointRef);
110  void setByMajorAxisAndPassedPoint(const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisStart,
111  const ModelHighAPI_RefAttr& theMajorAxisStartRef,
112  const std::shared_ptr<GeomAPI_Pnt2d>& theMajorAxisEnd,
113  const ModelHighAPI_RefAttr& theMajorAxisEndRef,
114  const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint,
115  const ModelHighAPI_RefAttr& thePassedPointRef);
116 
118  void collectAuxiliary();
119 
120 private:
121  CompositeFeaturePtr mySketch;
122  std::shared_ptr<SketchAPI_Point> myCenter;
123  std::shared_ptr<SketchAPI_Point> myFocus1;
124  std::shared_ptr<SketchAPI_Point> myFocus2;
125  std::shared_ptr<SketchAPI_Point> myMajorAxisStart;
126  std::shared_ptr<SketchAPI_Point> myMajorAxisEnd;
127  std::shared_ptr<SketchAPI_Point> myMinorAxisStart;
128  std::shared_ptr<SketchAPI_Point> myMinorAxisEnd;
129  std::shared_ptr<SketchAPI_Line> myMajorAxis;
130  std::shared_ptr<SketchAPI_Line> myMinorAxis;
131 };
132 
134 typedef std::shared_ptr<SketchAPI_MacroEllipse> MacroEllipsePtr;
135 
136 #endif // SketchAPI_MacroEllipse_H_
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
API for the attribute that contains std (null terminated) string.
Definition: ModelAPI_AttributeString.h:33
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39
Class for filling ModelAPI_AttributeRefAttr.
Definition: ModelHighAPI_RefAttr.h:41
Interface for Line feature.
Definition: SketchAPI_Line.h:39
Interface for Ellipse feature.
Definition: SketchAPI_MacroEllipse.h:36
std::shared_ptr< SketchAPI_Line > majorAxis()
Return created auxiliary major axis.
Definition: SketchAPI_MacroEllipse.cpp:243
std::shared_ptr< SketchAPI_Point > minorAxisStart()
Return created auxiliary point - start of minor axis.
Definition: SketchAPI_MacroEllipse.cpp:229
std::shared_ptr< SketchAPI_Point > majorAxisEnd()
Return created auxiliary point - end of major axis.
Definition: SketchAPI_MacroEllipse.cpp:222
std::shared_ptr< SketchAPI_Point > center()
Return created auxiliary center point.
Definition: SketchAPI_MacroEllipse.cpp:194
std::shared_ptr< SketchAPI_Line > minorAxis()
Return created auxiliary minor axis.
Definition: SketchAPI_MacroEllipse.cpp:250
virtual std::shared_ptr< ModelAPI_AttributeString > ellipseType() const
Ellipse type.
Definition: SketchAPI_MacroEllipse.h:76
std::shared_ptr< SketchAPI_Point > focus1()
Return created auxiliary focus in the positive direction of major axis.
Definition: SketchAPI_MacroEllipse.cpp:201
std::shared_ptr< SketchAPI_Point > majorAxisStart()
Return created auxiliary point - start of major axis.
Definition: SketchAPI_MacroEllipse.cpp:215
virtual ~SketchAPI_MacroEllipse()
Destructor.
Definition: SketchAPI_MacroEllipse.cpp:107
std::shared_ptr< SketchAPI_Point > minorAxisEnd()
Return created auxiliary point - end of minor axis.
Definition: SketchAPI_MacroEllipse.cpp:236
SketchAPI_MacroEllipse(const std::shared_ptr< ModelAPI_Feature > &theFeature, bool callInitialize=true)
Constructor without values.
Definition: SketchAPI_MacroEllipse.cpp:35
std::shared_ptr< SketchAPI_Point > focus2()
Return created auxiliary focus in the negative direction of major axis.
Definition: SketchAPI_MacroEllipse.cpp:208
Interface for Point feature.
Definition: SketchAPI_Point.h:39
Base class for Sketch feature interfaces.
Definition: SketchAPI_SketchEntity.h:38
static const std::string & ID()
Ellipse feature kind.
Definition: SketchPlugin_MacroEllipse.h:40