QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RArc.h
Go to the documentation of this file.
1 
20 #ifndef RARC_H
21 #define RARC_H
22 
23 #include "../core_global.h"
24 
25 #include "RDirected.h"
26 #include "RShape.h"
27 #include "RVector.h"
28 
29 class RBox;
30 class RPolyline;
31 
41 class QCADCORE_EXPORT RArc: public RShape, public RDirected {
42 public:
43  RArc();
44  RArc(const RVector& center, double radius, double startAngle,
45  double endAngle, bool reversed = false);
46  virtual ~RArc();
47 
48  virtual RArc* clone() const {
49  return new RArc(*this);
50  }
51 
52  virtual void to2D();
53 
54  bool isValid() const;
55  bool isFullCircle() const;
56 
57  static RArc createFrom3Points(const RVector& startPoint,
58  const RVector& point,
59  const RVector& endPoint);
60  static RArc createFrom2PBulge(const RVector& startPoint,
61  const RVector& endPoint,
62  double bulge);
63  static RArc createTangential(const RVector& startPoint,
64  const RVector& pos,
65  double direction,
66  double radius);
67 
68  virtual RBox getBoundingBox() const;
69 
70  virtual QList<RVector> getEndPoints() const;
71  virtual QList<RVector> getMiddlePoints() const;
72  virtual QList<RVector> getCenterPoints() const;
73  virtual QList<RVector> getPointsWithDistanceToEnd(
74  double distance, RS::From from = RS::FromAny) const;
75 
76  virtual RVector getVectorTo(const RVector& point,
77  bool limited = true) const;
78 
79  RVector getCenter() const;
80  void setCenter(const RVector& vector);
81  double getRadius() const;
82  void setRadius(double radius);
83  double getStartAngle() const;
84  void setStartAngle(double startAngle);
85  double getEndAngle() const;
86  void setEndAngle(double endAngle);
87  bool isReversed() const;
88  void setReversed(bool reversed);
89  double getAngleLength(bool allowForZeroLength = false) const;
90  bool isAngleWithinArc(double a) {
91  return RMath::isAngleBetween(a, startAngle, endAngle, reversed);
92  }
93 
94  double getDiameter() const;
95  void setDiameter(double d);
96  void setLength(double l);
97  double getArea() const;
98  void setArea(double a);
99 
100  double getDirection1() const;
101  double getDirection2() const;
102 
103  RS::Side getSideOfPoint(const RVector& point) const;
104 
105  double getSweep() const;
106  double getLength() const;
107 
108  virtual RVector getStartPoint() const;
109  virtual RVector getEndPoint() const;
110  RVector getMiddlePoint() const;
111 
112  void moveStartPoint(const RVector& pos);
113  void moveEndPoint(const RVector& pos);
114  double getBulge() const;
115 
116  virtual bool move(const RVector& offset);
117  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
118  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
119  virtual bool mirror(const RLine& axis);
120  virtual bool reverse();
121  virtual bool stretch(const RPolyline& area, const RVector& offset);
122 
123  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
124 
125  virtual RS::Ending getTrimEnd(const RVector& coord, const RVector& trimPoint);
126  virtual void trimStartPoint(const RVector& p);
127  virtual void trimEndPoint(const RVector& p);
128  virtual double getDistanceFromStart(const RVector& p) const;
129 
130  RPolyline approximateWithLines(double segmentLength);
131 
132 protected:
133  virtual void print(QDebug dbg) const;
134 
135 public:
145  double radius;
150  double startAngle;
155  double endAngle;
160  bool reversed;
161 };
162 
163 Q_DECLARE_METATYPE(const RArc*)
166 Q_DECLARE_METATYPE(QSharedPointer<RArc>)
167 Q_DECLARE_METATYPE(QSharedPointer<RArc>*)
168 
169 #endif