Open Source 2D CAD
Go to the documentation of this file.
20 #ifndef RXLINE_H
21 #define RXLINE_H
23 #include "../core_global.h"
25 #include "RLine.h"
26 #include "RS.h"
27 #include "RShape.h"
28 #include "RVector.h"
30 class RBox;
31 class RPolyline;
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();
50  virtual RShape::Type getShapeType() const {
51  return XLine;
52  }
54  RLine getLineShape() const {
55  return RLine(basePoint, basePoint + directionVector);
56  }
58  virtual RXLine* clone() const {
59  return new RXLine(*this);
60  }
62  virtual bool isDirected() const {
63  return true;
64  }
66  RBox getBoundingBox() const;
67  void to2D();
69  virtual QList<RVector> getVectorProperties() const;
71  virtual QList<RVector> getEndPoints() const;
72  virtual QList<RVector> getMiddlePoints() const;
73  virtual QList<RVector> getCenterPoints() const;
74  virtual QList<RVector> getPointsWithDistanceToEnd(
75  double distance, int from = RS::FromAny) const;
77  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
79  virtual RVector getVectorTo(const RVector& point, bool limited = true, double strictRange = RMAXDOUBLE) const;
81  RVector getBasePoint() const;
82  void setBasePoint(const RVector& vector);
83  RVector getSecondPoint() const;
84  void setSecondPoint(const RVector& vector);
85  RVector getDirectionVector() const;
86  void setDirectionVector(const RVector& vector);
88  virtual RVector getMiddlePoint() const;
90  double getLength() const;
91  void setLength(double l);
92  double getAngle() const;
93  void setAngle(double a);
95  virtual double getDirection1() const;
96  virtual double getDirection2() const;
98  virtual RS::Side getSideOfPoint(const RVector& point) const;
100  virtual RVector getStartPoint() const;
101  virtual RVector getEndPoint() const;
103  virtual bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
104  virtual bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false);
105  virtual bool trimStartPoint(double trimDist) {
106  return RShape::trimStartPoint(trimDist);
107  }
108  virtual bool trimEndPoint(double trimDist) {
109  return RShape::trimEndPoint(trimDist);
110  }
111  virtual RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint);
112  virtual double getDistanceFromStart(const RVector& p) const;
114  virtual RLine getClippedLine(const RBox& box) const;
116  virtual bool move(const RVector& offset);
117  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
118  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
119  virtual bool mirror(const RLine& axis);
120  virtual bool reverse();
121  virtual bool stretch(const RPolyline& area, const RVector& offset);
123  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
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  }
129  virtual QList<QSharedPointer<RShape> > splitAt(const QList<RVector>& points) const;
131 protected:
132  virtual void print(QDebug dbg) const;
134 public:
145 };
150 Q_DECLARE_METATYPE(QSharedPointer<RXLine>)
151 Q_DECLARE_METATYPE(QSharedPointer<RXLine>*)
153 #endif
Represents a box e.g.
Definition: RBox.h:43
Entity ending.
Definition: RS.h:152
RLine getLineShape() const
Definition: RXLine.h:54
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
RVector directionVector
Getter function for this property: getDirectionVector.
Definition: RXLine.h:144
virtual RVector getEndPoint() const
Definition: RShape.h:249
virtual QList< RVector > getVectorProperties() const
Definition: RShape.h:141
virtual bool reverse()
Definition: RShape.h:256
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0
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:139
virtual bool trimEndPoint(double trimDist)
Definition: RXLine.h:108
virtual double getLength() const =0
virtual RBox getBoundingBox() const =0
virtual RXLine * clone() const
Definition: RXLine.h:58
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 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 double getDirection2() const
Definition: RShape.h:237
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:208
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
virtual RVector getMiddlePoint() const
Definition: RShape.h:252
virtual QList< RVector > getMiddlePoints() const =0
virtual bool isDirected() const
Definition: RXLine.h:62
Definition: RShape.h:54
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
virtual RShape::Type getShapeType() const
Definition: RXLine.h:50
Low-level mathematical representation of an infinite line.
Definition: RXLine.h:42
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
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:200
virtual QList< QSharedPointer< RShape > > getOffsetShapes(double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
Definition: RXLine.h:125
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
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 RVector getStartPoint() const
Definition: RShape.h:246
Definition: RVector.h:37
virtual bool trimStartPoint(double trimDist)
Definition: RXLine.h:105
virtual double getDistanceFromStart(const RVector &p) const
Definition: RShape.h:313