QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
REllipse.h
Go to the documentation of this file.
1 
20 #ifndef RELLIPSE_H
21 #define RELLIPSE_H
22 
23 #include "../core_global.h"
24 
25 #include "RShape.h"
26 #include "RDirected.h"
27 #include "RLine.h"
28 #include "RVector.h"
29 
30 class RBox;
31 
41 class QCADCORE_EXPORT REllipse: public RShape, public RDirected {
42 public:
43  REllipse();
44  REllipse(const RVector& center,
45  const RVector& majorPoint,
46  double ratio,
47  double startParam, double endParam,
48  bool reversed);
49  virtual ~REllipse();
50 
51  virtual REllipse* clone() const {
52  return new REllipse(*this);
53  }
54 
55  bool isValid();
56 
57  virtual void to2D();
58 
59  virtual RBox getBoundingBox() const;
60 
61  virtual QList<RVector> getEndPoints() const;
62  virtual QList<RVector> getMiddlePoints() const;
63  virtual QList<RVector> getCenterPoints() const;
64  virtual QList<RVector> getPointsWithDistanceToEnd(
65  double distance, RS::From from = RS::FromAny) const;
66 
67  virtual RVector getVectorTo(const RVector& point,
68  bool limited = true) const;
69 
70  void moveStartPoint(const RVector& pos, bool changeAngleOnly=false);
71  void moveEndPoint(const RVector& pos, bool changeAngleOnly=false);
72 
73  QList<RVector> getFoci() const;
74 
75  RVector getCenter() const;
76  void setCenter(const RVector& vector);
77  RVector getMajorPoint() const;
78  RVector getMinorPoint() const;
79  void setMajorPoint(const RVector& vector);
80  void setMinorPoint(const RVector &p);
81  bool switchMajorMinor();
82  double getRatio() const;
83  void setRatio(double radius);
84 
85  double getStartParam() const;
86  void setStartParam(double startParam);
87 
88  double getEndParam() const;
89  void setEndParam(double endParam);
90 
91  double getStartAngle() const;
92  void setStartAngle(double a);
93 
94  double angleToParam(double a) const;
95 
96  double getEndAngle() const;
97  void setEndAngle(double a);
98 
99  double getAngleLength(bool allowForZeroLength = false) const;
100 
101  bool isReversed() const;
102  void setReversed(bool reversed);
103 
104  double getDirection1() const;
105  double getDirection2() const;
106 
107  virtual RVector getStartPoint() const;
108  virtual RVector getEndPoint() const;
109  double getMajorRadius() const;
110  double getMinorRadius() const;
111  double getAngle() const;
112  void setAngle(double a);
113  bool isFullEllipse() const;
114  bool isCircular() const;
115  double getLength() const;
116  double getSimpsonLength(double f1, double f2) const;
117 
118  double getParamTo(const RVector& pos) const;
119  double getRadiusAt(double angle) const;
120  RVector getPointAt(double angle) const;
121  RVector getMiddlePoint() const;
122 
123  virtual bool move(const RVector& offset);
124  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
125  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
126  virtual bool mirror(const RLine& axis);
127 
128  virtual bool reverse();
129 
130  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
131 
132  virtual RS::Ending getTrimEnd(const RVector& coord, const RVector& trimPoint);
133  virtual void trimStartPoint(const RVector& p);
134  virtual void trimEndPoint(const RVector& p);
135 
136  void correctMajorMinor();
137  double getSweep() const;
138 
139  QList<RVector> getBoxCorners();
140 
141  QList<RLine> getTangents(const RVector& point) const;
142 
143 protected:
144  virtual void print(QDebug dbg) const;
145 
146 public:
161  double ratio;
166  double startParam;
171  double endParam;
176  bool reversed;
177 };
178 
182 Q_DECLARE_METATYPE(QSharedPointer<REllipse>)
183 Q_DECLARE_METATYPE(QSharedPointer<REllipse>*)
184 
185 #endif