QCAD
Open Source 2D CAD
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, double strictRange = RMAXDOUBLE) 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 // virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
119 
120  double getParamTo(const RVector& pos) const;
121  double getRadiusAt(double angle) const;
122  RVector getPointAt(double angle) const;
123  RVector getMiddlePoint() const;
124 
125  virtual bool move(const RVector& offset);
126  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
127  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
128  virtual bool mirror(const RLine& axis);
129 
130  virtual bool reverse();
131 
132  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
133 
134  virtual RS::Ending getTrimEnd(const RVector& coord, const RVector& trimPoint);
135  virtual void trimStartPoint(const RVector& p);
136  virtual void trimEndPoint(const RVector& p);
137 
138  void correctMajorMinor();
139  double getSweep() const;
140 
141  QList<RVector> getBoxCorners();
142 
143  QList<RLine> getTangents(const RVector& point) const;
144 
145 protected:
146  virtual void print(QDebug dbg) const;
147 
148 public:
163  double ratio;
168  double startParam;
173  double endParam;
178  bool reversed;
179 };
180 
184 Q_DECLARE_METATYPE(QSharedPointer<REllipse>)
185 Q_DECLARE_METATYPE(QSharedPointer<REllipse>*)
186 
187 #endif
Represents a box e.g.
Definition: RBox.h:43
Ending
Entity ending.
Definition: RS.h:136
virtual RVector getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const =0
virtual void to2D()=0
Flattens this shape to the X/Y plane.
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual QList< RVector > getEndPoints() const =0
virtual double getDirection1() const =0
virtual RVector getEndPoint() const =0
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0
#define QCADCORE_EXPORT
Definition: core_global.h:10
double startParam
Getter function for this property: getStartParam.
Definition: REllipse.h:168
double endParam
Getter function for this property: getEndParam.
Definition: REllipse.h:173
virtual void trimStartPoint(const RVector &p)=0
virtual RS::Ending getTrimEnd(const RVector &coord, const RVector &trimPoint)=0
virtual double getLength() const =0
virtual RBox getBoundingBox() const =0
Start or end.
Definition: RS.h:187
virtual bool move(const RVector &offset)=0
double ratio
Getter function for this property: getRatio.
Definition: REllipse.h:163
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, RS::From from=RS::FromAny) const =0
Q_DECLARE_METATYPE(RMath *)
Low-level mathematical representation of an ellipse or ellipse arc.
Definition: REllipse.h:41
virtual void trimEndPoint(const RVector &p)=0
virtual QList< RVector > getMiddlePoints() const =0
RVector center
Getter function for this property: getCenter.
Definition: REllipse.h:153
#define RMAXDOUBLE
Definition: RMath.h:50
virtual bool mirror(const RLine &axis)=0
Low-level mathematical representation of a line.
Definition: RLine.h:42
virtual RVector getStartPoint() const =0
virtual bool reverse()=0
virtual QSharedPointer< RShape > getTransformed(const QTransform &transform) const =0
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RDirected.h:36
bool reversed
Getter function for this property: isReversed.
Definition: REllipse.h:178
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:184
virtual double getDirection2() const =0
virtual bool scale(double scaleFactor, const RVector &center=RVector())
Definition: RShape.cpp:1619
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual QList< RVector > getCenterPoints() const =0
virtual void print(QDebug dbg) const
Definition: RShape.cpp:1623
virtual REllipse * clone() const
Definition: REllipse.h:51
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
RVector majorPoint
Getter function for this property: getMajorPoint.
Definition: REllipse.h:158