QCAD
Open Source 2D CAD
RXLine.h
Go to the documentation of this file.
1 
20 #ifndef RXLINE_H
21 #define RXLINE_H
22 
23 #include "../core_global.h"
24 
25 #include "RLine.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 RXLine: public RShape {
43 public:
44  RXLine();
45  RXLine(const RLine& line);
46  RXLine(const RVector& basePoint, const RVector& directionVector);
47  RXLine(const RVector& basePoint, double angle, double distance);
48  virtual ~RXLine();
49 
50  virtual RShape::Type getShapeType() const {
51  return XLine;
52  }
53 
54  RLine getLineShape() const {
55  return RLine(basePoint, basePoint + directionVector);
56  }
57 
58  virtual RXLine* clone() const {
59  return new RXLine(*this);
60  }
61 
62  virtual bool isDirected() const {
63  return true;
64  }
65 
66  RBox getBoundingBox() const;
67 
68  virtual void setZ(double z);
69 
70  virtual QList<RVector> getVectorProperties() const;
71 
72  virtual QList<RVector> getEndPoints() const;
73  virtual QList<RVector> getMiddlePoints() const;
74  virtual QList<RVector> getCenterPoints() const;
75  virtual QList<RVector> getPointsWithDistanceToEnd(
76  double distance, int from = RS::FromAny) const;
77 
78  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
79 
80  virtual RVector getVectorTo(const RVector& point, bool limited = true, double strictRange = RMAXDOUBLE) const;
81 
82  RVector getBasePoint() const;
83  void setBasePoint(const RVector& vector);
84  RVector getSecondPoint() const;
85  void setSecondPoint(const RVector& vector);
86  RVector getDirectionVector() const;
87  void setDirectionVector(const RVector& vector);
88 
89  virtual RVector getMiddlePoint() const;
90 
91  double getLength() const;
92  void setLength(double l);
93  double getAngle() const;
94  void setAngle(double a);
95 
96  virtual double getDirection1() const;
97  virtual double getDirection2() const;
98 
99  virtual RS::Side getSideOfPoint(const RVector& point) const;
100 
101  virtual RVector getStartPoint() const;
102  virtual RVector getEndPoint() const;
103 
104  virtual bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
105  virtual bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
106  virtual bool trimStartPoint(double trimDist) {
107  return RShape::trimStartPoint(trimDist);
108  }
109  virtual bool trimEndPoint(double trimDist) {
110  return RShape::trimEndPoint(trimDist);
111  }
112  virtual RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint);
113  virtual double getDistanceFromStart(const RVector& p) const;
114 
115  virtual RLine getClippedLine(const RBox& box) const;
116 
117  virtual bool move(const RVector& offset);
118  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
119  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
120  virtual bool mirror(const RLine& axis);
121  virtual bool reverse();
122  virtual bool stretch(const RPolyline& area, const RVector& offset);
123 
124  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
125 
126  virtual QList<QSharedPointer<RShape> > getOffsetShapes(double distance, int number, RS::Side side, const RVector& position = RVector::invalid) {
127  return RShape::getOffsetLines(*this, distance, number, side, position);
128  }
129 
130  virtual QList<QSharedPointer<RShape> > splitAt(const QList<RVector>& points) const;
131 
132 protected:
133  virtual void print(QDebug dbg) const;
134 
135 public:
146 };
147 
151 Q_DECLARE_METATYPE(QSharedPointer<RXLine>)
152 Q_DECLARE_METATYPE(QSharedPointer<RXLine>*)
153 
154 #endif
Represents a box e.g.
Definition: RBox.h:43
Ending
Entity ending.
Definition: RS.h:204
RLine getLineShape() const
Definition: RXLine.h:54
virtual RVector getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const =0
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:272
virtual QList< RVector > getEndPoints() const =0
RVector directionVector
Getter function for this property: getDirectionVector.
Definition: RXLine.h:145
virtual RVector getEndPoint() const
Definition: RShape.h:255
virtual QList< RVector > getVectorProperties() const
Definition: RShape.h:145
virtual bool reverse()
Definition: RShape.h:262
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
Definition: RShape.h:64
RVector basePoint
Getter function for this property: getBasePoint.
Definition: RXLine.h:140
virtual bool trimEndPoint(double trimDist)
Definition: RXLine.h:109
virtual double getLength() const =0
virtual RBox getBoundingBox() const =0
virtual RXLine * clone() const
Definition: RXLine.h:58
Start or end.
Definition: RS.h:255
virtual bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RShape.h:291
virtual double getDirection1() const
Definition: RShape.h:240
Side
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:194
virtual bool move(const RVector &offset)=0
virtual double getDirection2() const
Definition: RShape.h:243
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:213
virtual QList< QSharedPointer< RShape > > splitAt(const QList< RVector > &points) const
Definition: RShape.cpp:2091
virtual bool stretch(const RBox &area, const RVector &offset)
Definition: RShape.cpp:1725
Q_DECLARE_METATYPE(RMath *)
virtual RVector getMiddlePoint() const
Definition: RShape.h:258
virtual QList< RVector > getMiddlePoints() const =0
virtual bool isDirected() const
Definition: RXLine.h:62
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:1927
virtual RShape::Type getShapeType() const
Definition: RXLine.h:50
Low-level mathematical representation of an infinite line.
Definition: RXLine.h:42
Definition: RS.h:253
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:247
virtual RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RShape.h:308
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:252
virtual QList< QSharedPointer< RShape > > getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RXLine.h:126
virtual bool scale(double scaleFactor, const RVector &center=RVector())
Definition: RShape.cpp:1736
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual QList< RVector > getCenterPoints() const =0
virtual void print(QDebug dbg) const
Definition: RShape.cpp:1740
static const RVector invalid
invalid vector
Definition: RVector.h:322
virtual RVector getStartPoint() const
Definition: RShape.h:252
virtual void setZ(double z)=0
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
virtual bool trimStartPoint(double trimDist)
Definition: RXLine.h:106
virtual double getDistanceFromStart(const RVector &p) const
Definition: RShape.h:319