QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RLine.h
Go to the documentation of this file.
1 
20 #ifndef RLINE_H
21 #define RLINE_H
22 
23 #include "../core_global.h"
24 
25 #include "RDirected.h"
26 #include "RS.h"
27 #include "RShape.h"
28 #include "RVector.h"
29 
30 class RBox;
31 class RPolyline;
32 
42 class QCADCORE_EXPORT RLine: public RShape, public RDirected {
43 public:
44  RLine();
45  RLine(double x1, double y1, double x2, double y2);
46  RLine(const RVector& startPoint, const RVector& endPoint);
47  RLine(const RVector& startPoint, double angle, double distance);
48  virtual ~RLine();
49 
50  virtual RLine* clone() const {
51  return new RLine(*this);
52  }
53 
54  virtual void to2D();
55 
56  bool isValid() const;
57 
58  virtual RBox getBoundingBox() const;
59 
60  virtual QList<RVector> getEndPoints() const;
61  virtual QList<RVector> getMiddlePoints() const;
62  virtual QList<RVector> getCenterPoints() const;
63  virtual QList<RVector> getPointsWithDistanceToEnd(
64  double distance, RS::From from = RS::FromAny) const;
65 
66  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
67 
68  virtual RVector getVectorTo(const RVector& point,
69  bool limited = true, double strictRange = RMAXDOUBLE) const;
70 
71  virtual RVector getStartPoint() const;
72  void setStartPoint(const RVector& vector);
73  virtual RVector getEndPoint() const;
74  void setEndPoint(const RVector& vector);
75 
76  RVector getMiddlePoint() const;
77 
78  double getLength() const;
79  double getAngle() const;
80 
81  void setLength(double l);
82  void setAngle(double a);
83 
84  virtual double getDirection1() const;
85  virtual double getDirection2() const;
86 
87  RS::Side getSideOfPoint(const RVector& point) const;
88 
89  void clipToXY(const RBox& box);
90 
91  virtual bool move(const RVector& offset);
92  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
93  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
94  virtual bool mirror(const RLine& axis);
95  virtual bool flipHorizontal();
96  virtual bool flipVertical();
97  virtual bool reverse();
98  virtual bool stretch(const RPolyline& area, const RVector& offset);
99 
100  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
101 
102  virtual RS::Ending getTrimEnd(const RVector& coord, const RVector& trimPoint);
103  virtual void trimStartPoint(const RVector& p);
104  virtual void trimEndPoint(const RVector& p);
105  virtual double getDistanceFromStart(const RVector& p) const;
106 
107 protected:
108  virtual void print(QDebug dbg) const;
109 
110 public:
121 };
122 
126 Q_DECLARE_METATYPE(QSharedPointer<RLine>)
127 Q_DECLARE_METATYPE(QSharedPointer<RLine>*)
128 
129 #endif