QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
REllipse.h
Go to the documentation of this file.
1 #ifndef RELLIPSE_H
2 #define RELLIPSE_H
3 
4 #include "RShape.h"
5 #include "RDirected.h"
6 #include "RLine.h"
7 #include "RVector.h"
8 
9 class RBox;
10 
20 class REllipse: public RShape, public RDirected {
21 public:
22  REllipse();
23  REllipse(const RVector& center,
24  const RVector& majorPoint,
25  double ratio,
26  double startParam, double endParam,
27  bool reversed);
28  virtual ~REllipse();
29 
30  static REllipse createInscribed(const QList<RVector>& quad);
31  static REllipse createFromEquation(double a, double b, double c);
32 
33  virtual REllipse* clone() const {
34  return new REllipse(*this);
35  }
36 
37  bool isValid();
38 
39  virtual void to2D();
40 
41  virtual RBox getBoundingBox() const;
42 
43  virtual QList<RVector> getEndPoints() const;
44  virtual QList<RVector> getMiddlePoints() const;
45  virtual QList<RVector> getCenterPoints() const;
46  virtual QList<RVector> getPointsWithDistanceToEnd(
47  double distance, RS::From from = RS::FromAny) const;
48 
49  virtual RVector getVectorTo(const RVector& point,
50  bool limited = true) const;
51 
52  void moveStartPoint(const RVector& pos, bool changeAngleOnly=false);
53  void moveEndPoint(const RVector& pos, bool changeAngleOnly=false);
54 
55  QList<RVector> getFoci() const;
56 
57  RVector getCenter() const;
58  void setCenter(const RVector& vector);
59  RVector getMajorPoint() const;
60  RVector getMinorPoint() const;
61  void setMajorPoint(const RVector& vector);
62  void setMinorPoint(const RVector &p);
63  bool switchMajorMinor();
64  double getRatio() const;
65  void setRatio(double radius);
66 
67  double getStartParam() const;
68  void setStartParam(double startParam);
69 
70  double getEndParam() const;
71  void setEndParam(double endParam);
72 
73  double getStartAngle() const;
74  void setStartAngle(double a);
75 
76  double angleToParam(double a) const;
77 
78  double getEndAngle() const;
79  void setEndAngle(double a);
80 
81  double getAngleLength(bool allowForZeroLength = false) const;
82 
83  bool isReversed() const;
84  void setReversed(bool reversed);
85 
86  double getDirection1() const;
87  double getDirection2() const;
88 
89  virtual RVector getStartPoint() const;
90  virtual RVector getEndPoint() const;
91  double getMajorRadius() const;
92  double getMinorRadius() const;
93  double getAngle() const;
94  void setAngle(double a);
95  bool isFullEllipse() const;
96  bool isCircular() const;
97  double getLength() const;
98  double getSimpsonLength(double f1, double f2) const;
99 
100  double getParamTo(const RVector& pos);
101  double getRadiusAt(double angle);
102  RVector getPointAt(double angle);
103 
104  virtual bool move(const RVector& offset);
105  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
106  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
107  virtual bool mirror(const RLine& axis);
108 
109  virtual bool reverse();
110 
111  virtual RS::Ending getTrimEnd(const RVector& coord, const RVector& trimPoint);
112  virtual void trimStartPoint(const RVector& p);
113  virtual void trimEndPoint(const RVector& p);
114 
115  void correctMajorMinor();
116  double getSweep() const;
117 
118  QList<RVector> getBoxCorners();
119 
120  QList<RLine> getTangents(const RVector& point) const;
121 
122 protected:
123  virtual void print(QDebug dbg) const;
124 
125 public:
140  double ratio;
145  double startParam;
150  double endParam;
155  bool reversed;
156 };
157 
161 Q_DECLARE_METATYPE(QSharedPointer<REllipse>)
162 Q_DECLARE_METATYPE(QSharedPointer<REllipse>*)
163 
164 #endif