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 
48  virtual RShape::Type getShapeType() const {
49  return Line;
50  }
51 
52  virtual RLine* clone() const {
53  return new RLine(*this);
54  }
55 
56  virtual bool isDirected() const {
57  return true;
58  }
59 
60  virtual void setZ(double z);
61 
62  virtual QList<RVector> getVectorProperties() const;
63 
64  bool isValid() const;
65 
66  virtual RBox getBoundingBox() const;
67 
68  virtual QList<RVector> getEndPoints() const;
69  virtual QList<RVector> getMiddlePoints() const;
70  virtual QList<RVector> getCenterPoints() const;
71  virtual QList<RVector> getPointsWithDistanceToEnd(
72  double distance, int from = RS::FromAny) const;
73  virtual QList<RVector> getPointCloud(double segmentLength) 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, bool fromStart = true);
91  void setAngle(double a);
92 
93  bool isParallel(const RLine& line) const;
94 
95  bool isVertical(double tolerance = RS::PointTolerance) const;
96  bool isHorizontal(double tolerance = RS::PointTolerance) const;
97 
98  virtual double getDirection1() const;
99  virtual double getDirection2() const;
100 
101  virtual RS::Side getSideOfPoint(const RVector& point) const;
102 
103  void clipToXY(const RBox& box);
104 
105  virtual bool move(const RVector& offset);
106  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
107  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
108  virtual bool mirror(const RLine& axis);
109  virtual bool flipHorizontal();
110  virtual bool flipVertical();
111  virtual bool reverse();
112  virtual bool stretch(const RPolyline& area, const RVector& offset);
113 
114  virtual bool moveTo(const RVector& dest);
115 
116  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
117 
118  virtual RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint);
119  virtual bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
120  virtual bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
121  virtual bool trimStartPoint(double trimDist) {
122  return RShape::trimStartPoint(trimDist);
123  }
124  virtual bool trimEndPoint(double trimDist) {
125  return RShape::trimEndPoint(trimDist);
126  }
127  virtual double getDistanceFromStart(const RVector& p) const;
128 
129  virtual QList<QSharedPointer<RShape> > getOffsetShapes(double distance, int number, RS::Side side, const RVector& position = RVector::invalid) {
130  return RShape::getOffsetLines(*this, distance, number, side, position);
131  }
132 
133  virtual QList<QSharedPointer<RShape> > splitAt(const QList<RVector>& points) const;
134 
135 protected:
136  virtual void print(QDebug dbg) const;
137 
138 public:
149 };
150 
154 Q_DECLARE_METATYPE(QSharedPointer<RLine>)
155 Q_DECLARE_METATYPE(QSharedPointer<RLine>*)
156 
157 #endif
RShape::splitAt
virtual QList< QSharedPointer< RShape > > splitAt(const QList< RVector > &points) const
Definition: RShape.cpp:2114
RLine::getOffsetShapes
virtual QList< QSharedPointer< RShape > > getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RLine.h:129
RShape::getTransformed
virtual QSharedPointer< RShape > getTransformed(const QTransform &transform) const =0
RShape::trimEndPoint
virtual bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RShape.h:322
RShape::getLength
virtual double getLength() const =0
RShape::move
virtual bool move(const RVector &offset)=0
RShape::stretch
virtual bool stretch(const RBox &area, const RVector &offset)
Definition: RShape.cpp:1740
RShape::getOffsetLines
static QList< QSharedPointer< RShape > > getOffsetLines(const RShape &shape, double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RShape.cpp:1950
RShape::getMiddlePoints
virtual QList< RVector > getMiddlePoints() const =0
RLine::isDirected
virtual bool isDirected() const
Definition: RLine.h:56
RS::Side
Side
Side used for side of a point relativ to an entity (right hand or left hand side)
Definition: RS.h:204
RS::PointTolerance
static const double PointTolerance
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RS.h:696
RVector
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
RLine::getShapeType
virtual RShape::Type getShapeType() const
Definition: RLine.h:48
RS::Ending
Ending
Entity ending.
Definition: RS.h:214
RS::FromStart
@ FromStart
Definition: RS.h:263
RShape::getVectorProperties
virtual QList< RVector > getVectorProperties() const
Definition: RShape.h:165
RS.h
RShape::getCenterPoints
virtual QList< RVector > getCenterPoints() const =0
RLine::clone
virtual RLine * clone() const
Definition: RLine.h:52
RLine
Low-level mathematical representation of a line.
Definition: RLine.h:41
RShape::getTrimEnd
virtual RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RShape.h:339
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
RLine::trimEndPoint
virtual bool trimEndPoint(double trimDist)
Definition: RLine.h:124
RLine::endPoint
RVector endPoint
Getter function for this property: getEndPoint Setter function for this property: setEndPoint
Definition: RLine.h:148
RShape::trimStartPoint
virtual bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RShape.h:303
RShape.h
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::getDirection1
virtual double getDirection1() const
Definition: RShape.h:271
RShape::getDistanceFromStart
virtual double getDistanceFromStart(const RVector &p) const
Definition: RShape.h:350
RShape::getPointCloud
virtual QList< RVector > getPointCloud(double segmentLength) const =0
RShape::getBoundingBox
virtual RBox getBoundingBox() const =0
RShape::getSideOfPoint
virtual RS::Side getSideOfPoint(const RVector &point) const
Definition: RShape.h:278
RShape::getEndPoints
virtual QList< RVector > getEndPoints() const =0
RMAXDOUBLE
#define RMAXDOUBLE
Definition: RMath.h:63
RShape::getStartPoint
virtual RVector getStartPoint() const
Definition: RShape.h:283
RShape::mirror
virtual bool mirror(const RLine &axis)=0
RShape::getPointsWithDistanceToEnd
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, int from=RS::FromAny) const =0
RShape::setZ
virtual void setZ(double z)=0
RS::FromAny
@ FromAny
Start or end.
Definition: RS.h:265
RShape::getDirection2
virtual double getDirection2() const
Definition: RShape.h:274
RShape::print
virtual void print(QDebug dbg) const
Definition: RShape.cpp:1759
RShape::getMiddlePoint
virtual RVector getMiddlePoint() const
Definition: RShape.h:289
RLine::trimStartPoint
virtual bool trimStartPoint(double trimDist)
Definition: RLine.h:121
RShape::reverse
virtual bool reverse()
Definition: RShape.h:293
RBox
Represents a box e.g.
Definition: RBox.h:43
RVector::invalid
static const RVector invalid
invalid vector
Definition: RVector.h:322
RLine::startPoint
RVector startPoint
Getter function for this property: getStartPoint Setter function for this property: setStartPoint
Definition: RLine.h:143
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::getEndPoint
virtual RVector getEndPoint() const
Definition: RShape.h:286
RPolyline
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
RShape::flipVertical
virtual bool flipVertical()
Definition: RShape.cpp:1736
QCADCORE_EXPORT
#define QCADCORE_EXPORT
Definition: core_global.h:10
RShape::Line
@ Line
Definition: RShape.h:77
RShape::rotate
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0