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 getShapeType() 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 bool moveTo(const RVector& dest);
113 
114  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
115 
116  virtual RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint);
117  virtual bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
118  virtual bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
119  virtual bool trimStartPoint(double trimDist) {
120  return RShape::trimStartPoint(trimDist);
121  }
122  virtual bool trimEndPoint(double trimDist) {
123  return RShape::trimEndPoint(trimDist);
124  }
125  virtual double getDistanceFromStart(const RVector& p) const;
126 
127  virtual QList<QSharedPointer<RShape> > getOffsetShapes(double distance, int number, RS::Side side, const RVector& position = RVector::invalid) {
128  return RShape::getOffsetLines(*this, distance, number, side, position);
129  }
130 
131  virtual QList<QSharedPointer<RShape> > splitAt(const QList<RVector>& points) const;
132 
133 protected:
134  virtual void print(QDebug dbg) const;
135 
136 public:
147 };
148 
152 Q_DECLARE_METATYPE(QSharedPointer<RLine>)
153 Q_DECLARE_METATYPE(QSharedPointer<RLine>*)
154 
155 #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:266
virtual QList< RVector > getEndPoints() const =0
virtual RVector getEndPoint() const
Definition: RShape.h:249
virtual QList< RVector > getVectorProperties() const
Definition: RShape.h:141
virtual RLine * clone() const
Definition: RLine.h:53
virtual RShape::Type getShapeType() const
Definition: RLine.h:49
virtual bool reverse()
Definition: RShape.h:256
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:141
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:127
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:285
virtual double getDirection1() const
Definition: RShape.h:234
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:1696
virtual double getDirection2() const
Definition: RShape.h:237
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:208
static const double PointTolerance
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RS.h:576
virtual bool isDirected() const
Definition: RLine.h:57
virtual QList< QSharedPointer< RShape > > splitAt(const QList< RVector > &points) const
Definition: RShape.cpp:2070
virtual bool stretch(const RBox &area, const RVector &offset)
Definition: RShape.cpp:1704
Q_DECLARE_METATYPE(RMath *)
virtual RVector getMiddlePoint() const
Definition: RShape.h:252
RVector endPoint
Getter function for this property: getEndPoint.
Definition: RLine.h:146
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:1906
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:241
virtual RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RShape.h:302
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:1700
virtual bool scale(double scaleFactor, const RVector &center=RVector())
Definition: RShape.cpp:1715
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
virtual bool trimEndPoint(double trimDist)
Definition: RLine.h:122
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual QList< RVector > getCenterPoints() const =0
virtual void print(QDebug dbg) const
Definition: RShape.cpp:1719
static const RVector invalid
invalid vector
Definition: RVector.h:317
virtual bool trimStartPoint(double trimDist)
Definition: RLine.h:119
virtual RVector getStartPoint() const
Definition: RShape.h:246
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
virtual double getDistanceFromStart(const RVector &p) const
Definition: RShape.h:313