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 "RArc.h"
26 #include "RShape.h"
27 #include "RVector.h"
28 
29 class RBox;
30 
41 public:
42  RCircle();
43  RCircle(double cx, double cy, const double radius);
44  RCircle(const RVector& center, const double radius);
45  virtual ~RCircle();
46 
47  virtual RShape::Type getShapeType() const {
48  return Circle;
49  }
50 
51  virtual RCircle* clone() const {
52  return new RCircle(*this);
53  }
54 
55  static RCircle createFrom2Points(const RVector& p1, const RVector& p2);
56  static RCircle createFrom3Points(const RVector& p1, const RVector& p2, const RVector& p3);
57 
58  RArc toArc(double startAngle=0.0) const;
59 
60  bool isValid() const {
61  return center.isValid();
62  }
63 
64  virtual void setZ(double z);
65 
66  virtual QList<RVector> getVectorProperties() const;
67  virtual QList<double> getDoubleProperties() const;
68 
69  virtual RBox getBoundingBox() const;
70  virtual double getLength() const;
71 
72  virtual QList<RVector> getEndPoints() const;
73  virtual QList<RVector> getMiddlePoints() const;
74  virtual QList<RVector> getCenterPoints() const;
75  virtual QList<RVector> getArcReferencePoints() const;
76  virtual QList<RVector> getPointsWithDistanceToEnd(
77  double distance, int from = RS::FromAny) const;
78  virtual QList<RVector> getPointCloud(double segmentLength) const;
79 
80  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
81  RVector getPointAtAngle(double a) const;
82 
83  virtual RVector getVectorTo(const RVector& point,
84  bool limited = true, double strictRange = RMAXDOUBLE) const;
85 
86  RVector getCenter() const;
87  void setCenter(const RVector& vector);
88  double getRadius() const;
89  void setRadius(double radius);
90 
91  double getDiameter() const;
92  void setDiameter(double d);
93  double getCircumference() const;
94  void setCircumference(double c);
95  double getArea() const;
96  void setArea(double a);
97 
98  bool contains(const RVector& p) const;
99  //bool touchesCircleInternally(const RCircle& other) const;
100 
101  virtual bool move(const RVector& offset);
102  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
103  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
104  virtual bool mirror(const RLine& axis);
105  virtual bool flipHorizontal();
106  virtual bool flipVertical();
107 
108  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
109 
110  QList<RLine> getTangents(const RVector& point) const;
111 
112  virtual QList<QSharedPointer<RShape> > getOffsetShapes(double distance, int number, RS::Side side, const RVector& position = RVector::invalid) {
113  return RShape::getOffsetArcs(*this, distance, number, side, position);
114  }
115 
116  virtual QList<QSharedPointer<RShape> > splitAt(const QList<RVector>& points) const;
117 
118 protected:
119  virtual void print(QDebug dbg) const;
120 
121 public:
131  double radius;
132 };
133 
137 Q_DECLARE_METATYPE(QSharedPointer<RCircle>)
138 Q_DECLARE_METATYPE(QSharedPointer<RCircle>*)
139 
140 #endif
RShape::splitAt
virtual QList< QSharedPointer< RShape > > splitAt(const QList< RVector > &points) const
Definition: RShape.cpp:2114
RShape::getOffsetArcs
static QList< QSharedPointer< RShape > > getOffsetArcs(const RShape &shape, double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RShape.cpp:1994
RShape::getTransformed
virtual QSharedPointer< RShape > getTransformed(const QTransform &transform) const =0
RCircle::center
RVector center
Getter function for this property: getCenter Setter function for this property: setCenter
Definition: RCircle.h:126
RShape::getLength
virtual double getLength() const =0
RShape::move
virtual bool move(const RVector &offset)=0
RShape::getMiddlePoints
virtual QList< RVector > getMiddlePoints() const =0
RS::Side
Side
Side used for side of a point relativ to an entity (right hand or left hand side)
Definition: RS.h:204
RVector
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
RS::FromStart
@ FromStart
Definition: RS.h:263
RShape::getVectorProperties
virtual QList< RVector > getVectorProperties() const
Definition: RShape.h:165
RShape::getCenterPoints
virtual QList< RVector > getCenterPoints() const =0
RCircle::clone
virtual RCircle * clone() const
Definition: RCircle.h:51
RArc
Low-level mathematical representation of an arc.
Definition: RArc.h:40
RLine
Low-level mathematical representation of a line.
Definition: RLine.h:41
RCircle::getOffsetShapes
virtual QList< QSharedPointer< RShape > > getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RCircle.h:112
RShape::Type
Type
Definition: RShape.h:74
RShape::scale
virtual bool scale(double scaleFactor, const RVector &center=RVector())
Definition: RShape.cpp:1755
RShape
Interface for geometrical shape classes.
Definition: RShape.h:72
RShape.h
RCircle::getShapeType
virtual RShape::Type getShapeType() const
Definition: RCircle.h:47
RDEFAULT_RVECTOR
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
RShape::getVectorTo
virtual RVector getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const =0
RVector.h
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(RMath *)
RShape::flipHorizontal
virtual bool flipHorizontal()
Definition: RShape.cpp:1732
RShape::getDoubleProperties
virtual QList< double > getDoubleProperties() const
Definition: RShape.h:167
RVector::isValid
bool isValid() const
Definition: RVector.cpp:59
RShape::getPointCloud
virtual QList< RVector > getPointCloud(double segmentLength) const =0
RCircle::radius
double radius
Getter function for this property: getRadius Setter function for this property: setRadius
Definition: RCircle.h:131
RShape::getBoundingBox
virtual RBox getBoundingBox() const =0
RShape::getEndPoints
virtual QList< RVector > getEndPoints() const =0
RMAXDOUBLE
#define RMAXDOUBLE
Definition: RMath.h:63
RShape::getArcReferencePoints
virtual QList< RVector > getArcReferencePoints() const
Definition: RShape.h:211
RShape::mirror
virtual bool mirror(const RLine &axis)=0
RShape::getPointsWithDistanceToEnd
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, int from=RS::FromAny) const =0
RArc.h
RCircle::isValid
bool isValid() const
Definition: RCircle.h:60
RShape::setZ
virtual void setZ(double z)=0
RS::FromAny
@ FromAny
Start or end.
Definition: RS.h:265
RShape::print
virtual void print(QDebug dbg) const
Definition: RShape.cpp:1759
RShape::Circle
@ Circle
Definition: RShape.h:79
RCircle
Low-level mathematical representation of a circle.
Definition: RCircle.h:40
RBox
Represents a box e.g.
Definition: RBox.h:43
RVector::invalid
static const RVector invalid
invalid vector
Definition: RVector.h:322
RS::From
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:262
RShape::getAngleAt
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:244
RShape::flipVertical
virtual bool flipVertical()
Definition: RShape.cpp:1736
QCADCORE_EXPORT
#define QCADCORE_EXPORT
Definition: core_global.h:10
RShape::rotate
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0