4 #include "rs_atomicentity.h"
7 * Holds the data that defines a line.
13 * Default constructor. Leaves the data object uninitialized.
17 RS_LineData(const Vector & start, const Vector & end): startpoint(start), endpoint(end)
19 // this->startpoint = startpoint;
20 // this->endpoint = endpoint;
24 friend class RS_ActionDrawLine;
26 friend std::ostream & operator<<(std::ostream & os, const RS_LineData & ld)
28 os << "(" << ld.startpoint << "/" << ld.endpoint << ")";
38 * Class for a line entity.
40 * @author Andrew Mustun
42 class RS_Line: public RS_AtomicEntity
45 //RS_Line(RS_EntityContainer* parent);
46 //RS_Line(const RS_Line& l);
47 RS_Line(RS_EntityContainer * parent, const RS_LineData & d);
50 virtual RS_Entity * clone();
51 virtual RS2::EntityType rtti() const;
52 virtual bool isEdge() const;
53 RS_LineData getData() const;
55 virtual VectorSolutions getRefPoints();
56 virtual Vector getStartpoint() const;
57 virtual Vector getEndpoint() const;
58 void setStartpoint(Vector s);
59 void setEndpoint(Vector e);
60 double getDirection1() const;
61 double getDirection2() const;
62 virtual void moveStartpoint(const Vector & pos);
63 virtual void moveEndpoint(const Vector & pos);
64 virtual RS2::Ending getTrimPoint(const Vector & coord, const Vector & trimPoint);
65 virtual void reverse();
66 Vector getMiddlepoint();
67 void setStartpointY(double val);
68 void setEndpointY(double val);
69 virtual bool hasEndpointsWithinWindow(Vector v1, Vector v2);
70 virtual double getLength();
71 virtual double getAngle1() const;
72 virtual double getAngle2() const;
74 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
75 virtual Vector getNearestPointOnEntity(const Vector & coord,
76 bool onEntity = true, double * dist = NULL, RS_Entity ** entity = NULL);
77 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
78 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
79 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
80 virtual Vector getNearestDist(double distance, bool startp);
81 //virtual Vector getNearestRef(const Vector& coord,
82 // double* dist = NULL);
83 virtual double getDistanceToPoint(const Vector & coord,
84 RS_Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone,
85 double solidDist = RS_MAXDOUBLE);
87 virtual void move(Vector offset);
88 virtual void rotate(Vector center, double angle);
89 virtual void scale(Vector center, Vector factor);
90 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
91 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
92 virtual void moveRef(const Vector & ref, const Vector & offset);
94 // virtual void draw(RS_Painter * painter, RS_GraphicView * view, double patternOffset = 0.0);
95 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
97 friend std::ostream & operator<<(std::ostream & os, const RS_Line & l);
99 virtual void calculateBorders();