QCAD
Open Source 2D CAD
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 "RS.h"
26 #include "RShape.h"
27 #include "RVector.h"
28 
29 class RBox;
30 class RPolyline;
31 
41 class QCADCORE_EXPORT RLine: public RShape {
42 public:
43  RLine();
44  RLine(double x1, double y1, double x2, double y2);
45  RLine(const RVector& startPoint, const RVector& endPoint);
46  RLine(const RVector& startPoint, double angle, double distance);
47  virtual ~RLine();
48 
49  virtual RShape::Type getType() const {
50  return Line;
51  }
52 
53  virtual RLine* clone() const {
54  return new RLine(*this);
55  }
56 
57  virtual bool isDirected() const {
58  return true;
59  }
60 
61  virtual void to2D();
62 
63  virtual QList<RVector> getVectorProperties() const;
64 
65  bool isValid() const;
66 
67  virtual RBox getBoundingBox() 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 
77  virtual RVector getVectorTo(const RVector& point,
78  bool limited = true, double strictRange = RMAXDOUBLE) const;
79 
80  virtual RVector getStartPoint() const;
81  void setStartPoint(const RVector& vector);
82  virtual RVector getEndPoint() const;
83  void setEndPoint(const RVector& vector);
84 
85  virtual RVector getMiddlePoint() const;
86 
87  double getLength() const;
88  double getAngle() const;
89 
90  void setLength(double l);
91  void setAngle(double a);
92 
93  bool isVertical(double tolerance = RS::PointTolerance) const;
94  bool isHorizontal(double tolerance = RS::PointTolerance) const;
95 
96  virtual double getDirection1() const;
97  virtual double getDirection2() const;
98 
99  virtual RS::Side getSideOfPoint(const RVector& point) const;
100 
101  void clipToXY(const RBox& box);
102 
103  virtual bool move(const RVector& offset);
104  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
105  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
106  virtual bool mirror(const RLine& axis);
107  virtual bool flipHorizontal();
108  virtual bool flipVertical();
109  virtual bool reverse();
110  virtual bool stretch(const RPolyline& area, const RVector& offset);
111 
112  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
113 
114  virtual RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint);
115  virtual bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
116  virtual bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
117  virtual bool trimStartPoint(double trimDist) {
118  return RShape::trimStartPoint(trimDist);
119  }
120  virtual bool trimEndPoint(double trimDist) {
121  return RShape::trimEndPoint(trimDist);
122  }
123  virtual double getDistanceFromStart(const RVector& p) const;
124 
125  virtual QList<QSharedPointer<RShape> > getOffsetShapes(double distance, int number, RS::Side side, const RVector& position = RVector::invalid) {
126  return RShape::getOffsetLines(*this, distance, number, side, position);
127  }
128 
129  virtual QList<QSharedPointer<RShape> > splitAt(const QList<RVector>& points) const;
130 
131 protected:
132  virtual void print(QDebug dbg) const;
133 
134 public:
145 };
146 
150 Q_DECLARE_METATYPE(QSharedPointer<RLine>)
151 Q_DECLARE_METATYPE(QSharedPointer<RLine>*)
152 
153 #endif
Represents a box e.g.
Definition: RBox.h:43
Ending
Entity ending.
Definition: RS.h:152
Definition: RShape.h:57
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 bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RShape.h:262
virtual RShape::Type getType() const
Definition: RLine.h:49
virtual QList< RVector > getEndPoints() const =0
virtual RVector getEndPoint() const
Definition: RShape.h:245
virtual QList< RVector > getVectorProperties() const
Definition: RShape.h:141
virtual RLine * clone() const
Definition: RLine.h:53
virtual bool reverse()
Definition: RShape.h:252
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
RVector startPoint
Getter function for this property: getStartPoint.
Definition: RLine.h:139
virtual double getLength() const =0
virtual QList< QSharedPointer< RShape > > getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RLine.h:125
virtual RBox getBoundingBox() const =0
Start or end.
Definition: RS.h:203
virtual bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RShape.h:281
virtual double getDirection1() const
Definition: RShape.h:230
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 getDirection2() const
Definition: RShape.h:233
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:208
static const double PointTolerance
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RS.h:553
virtual bool isDirected() const
Definition: RLine.h:57
virtual QList< QSharedPointer< RShape > > splitAt(const QList< RVector > &points) const
Definition: RShape.cpp:2065
virtual bool stretch(const RBox &area, const RVector &offset)
Definition: RShape.cpp:1699
Q_DECLARE_METATYPE(RMath *)
virtual RVector getMiddlePoint() const
Definition: RShape.h:248
RVector endPoint
Getter function for this property: getEndPoint.
Definition: RLine.h:144
virtual QList< RVector > getMiddlePoints() const =0
Type
Definition: RShape.h:54
#define RMAXDOUBLE
Definition: RMath.h:63
static QList< QSharedPointer< RShape > > getOffsetLines(const RShape &shape, double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RShape.cpp:1901
Definition: RS.h:201
virtual bool mirror(const RLine &axis)=0
Low-level mathematical representation of a line.
Definition: RLine.h:41
virtual RS::Side getSideOfPoint(const RVector &point) const
Definition: RShape.h:237
virtual RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RShape.h:298
virtual QSharedPointer< RShape > getTransformed(const QTransform &transform) const =0
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
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
virtual bool trimEndPoint(double trimDist)
Definition: RLine.h:120
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
virtual bool trimStartPoint(double trimDist)
Definition: RLine.h:117
virtual RVector getStartPoint() const
Definition: RShape.h:242
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
virtual double getDistanceFromStart(const RVector &p) const
Definition: RShape.h:309