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 RCircle* clone() const {
47  return new RCircle(*this);
48  }
49 
50  static RCircle createFrom2Points(const RVector& p1, const RVector& p2);
51  static RCircle createFrom3Points(const RVector& p1, const RVector& p2, const RVector& p3);
52 
53  bool isValid() const {
54  return center.isValid();
55  }
56 
57  virtual void to2D();
58 
59  virtual RBox getBoundingBox() const;
60  virtual double getLength() const;
61 
62  virtual QList<RVector> getEndPoints() const;
63  virtual QList<RVector> getMiddlePoints() const;
64  virtual QList<RVector> getCenterPoints() const;
65  virtual QList<RVector> getPointsWithDistanceToEnd(
66  double distance, RS::From from = RS::FromAny) const;
67 
68  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
69 
70  virtual RVector getVectorTo(const RVector& point,
71  bool limited = true, double strictRange = RMAXDOUBLE) const;
72 
73  RVector getCenter() const;
74  void setCenter(const RVector& vector);
75  double getRadius() const;
76  void setRadius(double radius);
77 
78  double getDiameter() const;
79  void setDiameter(double d);
80  double getCircumference() const;
81  void setCircumference(double c);
82  double getArea() const;
83  void setArea(double a);
84 
85  bool contains(const RVector& p) const;
86  //bool touchesCircleInternally(const RCircle& other) const;
87 
88  virtual bool move(const RVector& offset);
89  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
90  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
91  virtual bool mirror(const RLine& axis);
92  virtual bool flipHorizontal();
93  virtual bool flipVertical();
94 
95  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
96 
97 protected:
98  virtual void print(QDebug dbg) const;
99 
100 public:
110  double radius;
111 };
112 
116 Q_DECLARE_METATYPE(QSharedPointer<RCircle>)
117 Q_DECLARE_METATYPE(QSharedPointer<RCircle>*)
118 
119 #endif
Represents a box e.g.
Definition: RBox.h:43
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
RVector center
Getter function for this property: getCenter.
Definition: RCircle.h:105
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0
#define QCADCORE_EXPORT
Definition: core_global.h:10
virtual RCircle * clone() const
Definition: RCircle.h:46
virtual double getLength() const =0
virtual RBox getBoundingBox() const =0
Start or end.
Definition: RS.h:187
virtual bool move(const RVector &offset)=0
virtual bool flipHorizontal()
Definition: RShape.cpp:1600
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:135
bool isValid() const
Definition: RVector.cpp:44
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, RS::From from=RS::FromAny) const =0
Q_DECLARE_METATYPE(RMath *)
virtual QList< RVector > getMiddlePoints() const =0
bool isValid() const
Definition: RCircle.h:53
#define RMAXDOUBLE
Definition: RMath.h:50
Definition: RS.h:185
virtual bool mirror(const RLine &axis)=0
Low-level mathematical representation of a line.
Definition: RLine.h:42
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:184
virtual bool flipVertical()
Definition: RShape.cpp:1604
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
double radius
Getter function for this property: getRadius.
Definition: RCircle.h:110
#define RDEFAULT_RVECTOR
Definition: RVector.h:37