QCAD
Open Source 2D CAD
RCircle.h
Go to the documentation of this file.
1 
20 #ifndef RCIRCLE_H
21 #define RCIRCLE_H
22 
23 #include "../core_global.h"
24 
25 #include "RShape.h"
26 #include "RVector.h"
27 
28 class RBox;
29 
40 public:
41  RCircle();
42  RCircle(double cx, double cy, const double radius);
43  RCircle(const RVector& center, const double radius);
44  virtual ~RCircle();
45 
46  virtual RShape::Type getType() const {
47  return Circle;
48  }
49 
50  virtual RCircle* clone() const {
51  return new RCircle(*this);
52  }
53 
54  static RCircle createFrom2Points(const RVector& p1, const RVector& p2);
55  static RCircle createFrom3Points(const RVector& p1, const RVector& p2, const RVector& p3);
56 
57  bool isValid() const {
58  return center.isValid();
59  }
60 
61  virtual void to2D();
62 
63  virtual QList<RVector> getVectorProperties() const;
64  virtual QList<double> getDoubleProperties() const;
65 
66  virtual RBox getBoundingBox() const;
67  virtual double getLength() const;
68 
69  virtual QList<RVector> getEndPoints() const;
70  virtual QList<RVector> getMiddlePoints() const;
71  virtual QList<RVector> getCenterPoints() const;
72  virtual QList<RVector> getPointsWithDistanceToEnd(
73  double distance, int from = RS::FromAny) const;
74 
75  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
76  RVector getPointAtAngle(double a) const;
77 
78  virtual RVector getVectorTo(const RVector& point,
79  bool limited = true, double strictRange = RMAXDOUBLE) const;
80 
81  RVector getCenter() const;
82  void setCenter(const RVector& vector);
83  double getRadius() const;
84  void setRadius(double radius);
85 
86  double getDiameter() const;
87  void setDiameter(double d);
88  double getCircumference() const;
89  void setCircumference(double c);
90  double getArea() const;
91  void setArea(double a);
92 
93  bool contains(const RVector& p) const;
94  //bool touchesCircleInternally(const RCircle& other) const;
95 
96  virtual bool move(const RVector& offset);
97  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
98  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
99  virtual bool mirror(const RLine& axis);
100  virtual bool flipHorizontal();
101  virtual bool flipVertical();
102 
103  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
104 
105  QList<RLine> getTangents(const RVector& point) const;
106 
107  virtual QList<QSharedPointer<RShape> > getOffsetShapes(double distance, int number, RS::Side side, const RVector& position = RVector::invalid) {
108  return RShape::getOffsetArcs(*this, distance, number, side, position);
109  }
110 
111  virtual QList<QSharedPointer<RShape> > splitAt(const QList<RVector>& points) const;
112 
113 protected:
114  virtual void print(QDebug dbg) const;
115 
116 public:
126  double radius;
127 };
128 
132 Q_DECLARE_METATYPE(QSharedPointer<RCircle>)
133 Q_DECLARE_METATYPE(QSharedPointer<RCircle>*)
134 
135 #endif
Represents a box e.g.
Definition: RBox.h:43
Definition: RShape.h:59
virtual RShape::Type getType() const
Definition: RCircle.h:46
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 QList< RVector > getVectorProperties() const
Definition: RShape.h:141
virtual QList< double > getDoubleProperties() const
Definition: RShape.h:143
RVector center
Getter function for this property: getCenter.
Definition: RCircle.h:121
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0
#define QCADCORE_EXPORT
Definition: core_global.h:10
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, int from=RS::FromAny) const =0
virtual QList< QSharedPointer< RShape > > getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RCircle.h:107
virtual RCircle * clone() const
Definition: RCircle.h:50
virtual double getLength() const =0
virtual RBox getBoundingBox() const =0
Start or end.
Definition: RS.h:203
Side
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:142
virtual bool move(const RVector &offset)=0
virtual bool flipHorizontal()
Definition: RShape.cpp:1691
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:208
virtual QList< QSharedPointer< RShape > > splitAt(const QList< RVector > &points) const
Definition: RShape.cpp:2065
bool isValid() const
Definition: RVector.cpp:58
Q_DECLARE_METATYPE(RMath *)
virtual QList< RVector > getMiddlePoints() const =0
Type
Definition: RShape.h:54
bool isValid() const
Definition: RCircle.h:57
#define RMAXDOUBLE
Definition: RMath.h:63
Definition: RS.h:201
virtual bool mirror(const RLine &axis)=0
Low-level mathematical representation of a line.
Definition: RLine.h:41
static QList< QSharedPointer< RShape > > getOffsetArcs(const RShape &shape, double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RShape.cpp:1945
virtual QSharedPointer< RShape > getTransformed(const QTransform &transform) const =0
Low-level mathematical representation of a circle.
Definition: RCircle.h:39
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:200
virtual bool flipVertical()
Definition: RShape.cpp:1695
virtual bool scale(double scaleFactor, const RVector &center=RVector())
Definition: RShape.cpp:1710
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual QList< RVector > getCenterPoints() const =0
virtual void print(QDebug dbg) const
Definition: RShape.cpp:1714
static const RVector invalid
invalid vector
Definition: RVector.h:313
double radius
Getter function for this property: getRadius.
Definition: RCircle.h:126
#define RDEFAULT_RVECTOR
Definition: RVector.h:37