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 "RDirected.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 RLine: public RShape, public RDirected {
43 public:
44  RLine();
45  RLine(double x1, double y1, double x2, double y2);
46  RLine(const RVector& startPoint, const RVector& endPoint);
47  RLine(const RVector& startPoint, double angle, double distance);
48  virtual ~RLine();
49 
50  virtual RLine* clone() const {
51  return new RLine(*this);
52  }
53 
54  virtual void to2D();
55 
56  bool isValid() const;
57 
58  virtual RBox getBoundingBox() const;
59 
60  virtual QList<RVector> getEndPoints() const;
61  virtual QList<RVector> getMiddlePoints() const;
62  virtual QList<RVector> getCenterPoints() const;
63  virtual QList<RVector> getPointsWithDistanceToEnd(
64  double distance, RS::From from = RS::FromAny) const;
65 
66  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
67 
68  virtual RVector getVectorTo(const RVector& point,
69  bool limited = true, double strictRange = RMAXDOUBLE) const;
70 
71  virtual RVector getStartPoint() const;
72  void setStartPoint(const RVector& vector);
73  virtual RVector getEndPoint() const;
74  void setEndPoint(const RVector& vector);
75 
76  RVector getMiddlePoint() const;
77 
78  double getLength() const;
79  double getAngle() const;
80 
81  void setLength(double l);
82  void setAngle(double a);
83 
84  virtual double getDirection1() const;
85  virtual double getDirection2() const;
86 
87  RS::Side getSideOfPoint(const RVector& point) const;
88 
89  void clipToXY(const RBox& box);
90 
91  virtual bool move(const RVector& offset);
92  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
93  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
94  virtual bool mirror(const RLine& axis);
95  virtual bool flipHorizontal();
96  virtual bool flipVertical();
97  virtual bool reverse();
98  virtual bool stretch(const RPolyline& area, const RVector& offset);
99 
100  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
101 
102  virtual RS::Ending getTrimEnd(const RVector& coord, const RVector& trimPoint);
103  virtual void trimStartPoint(const RVector& p);
104  virtual void trimEndPoint(const RVector& p);
105  virtual double getDistanceFromStart(const RVector& p) const;
106 
107 protected:
108  virtual void print(QDebug dbg) const;
109 
110 public:
121 };
122 
126 Q_DECLARE_METATYPE(QSharedPointer<RLine>)
127 Q_DECLARE_METATYPE(QSharedPointer<RLine>*)
128 
129 #endif
Represents a box e.g.
Definition: RBox.h:43
Ending
Entity ending.
Definition: RS.h:136
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 QList< RVector > getEndPoints() const =0
virtual RLine * clone() const
Definition: RLine.h:50
virtual double getDirection1() const =0
virtual RVector getEndPoint() const =0
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0
#define QCADCORE_EXPORT
Definition: core_global.h:10
RVector startPoint
Getter function for this property: getStartPoint.
Definition: RLine.h:115
virtual void trimStartPoint(const RVector &p)=0
virtual RS::Ending getTrimEnd(const RVector &coord, const RVector &trimPoint)=0
virtual double getLength() const =0
virtual RBox getBoundingBox() const =0
Start or end.
Definition: RS.h:187
Side
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:129
virtual double getDistanceFromStart(const RVector &p) const
Definition: RDirected.h:61
virtual bool move(const RVector &offset)=0
virtual bool flipHorizontal()
Definition: RShape.cpp:1600
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:135
virtual bool stretch(const RBox &area, const RVector &offset)
Definition: RShape.cpp:1608
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, RS::From from=RS::FromAny) const =0
Q_DECLARE_METATYPE(RMath *)
virtual void trimEndPoint(const RVector &p)=0
RVector endPoint
Getter function for this property: getEndPoint.
Definition: RLine.h:120
virtual QList< RVector > getMiddlePoints() const =0
#define RMAXDOUBLE
Definition: RMath.h:50
Definition: RS.h:185
virtual bool mirror(const RLine &axis)=0
Low-level mathematical representation of a line.
Definition: RLine.h:42
virtual RVector getStartPoint() const =0
virtual bool reverse()=0
virtual QSharedPointer< RShape > getTransformed(const QTransform &transform) const =0
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RDirected.h:36
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:184
virtual double getDirection2() const =0
virtual bool flipVertical()
Definition: RShape.cpp:1604
virtual bool scale(double scaleFactor, const RVector &center=RVector())
Definition: RShape.cpp:1619
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:1623
#define RDEFAULT_RVECTOR
Definition: RVector.h:37