4 #include "atomicentity.h"
7 * Holds the data that defines a line.
13 * Default constructor. Leaves the data object uninitialized.
16 LineData(const Vector & start, const Vector & end): startpoint(start), endpoint(end) {}
19 friend class ActionDrawLine;
21 friend std::ostream & operator<<(std::ostream & os, const LineData & ld)
23 os << "(" << ld.startpoint << "/" << ld.endpoint << ")";
33 * Class for a line entity.
35 * @author Andrew Mustun
37 class Line: public AtomicEntity
40 Line(EntityContainer * parent, const LineData & d);
43 virtual Entity * clone();
44 virtual RS2::EntityType rtti() const;
45 virtual bool isEdge() const;
46 LineData getData() const;
48 virtual VectorSolutions getRefPoints();
49 virtual Vector getStartpoint() const;
50 virtual Vector getEndpoint() const;
51 void setStartpoint(Vector s);
52 void setEndpoint(Vector e);
53 double getDirection1() const;
54 double getDirection2() const;
55 virtual void moveStartpoint(const Vector & pos);
56 virtual void moveEndpoint(const Vector & pos);
57 virtual RS2::Ending getTrimPoint(const Vector & coord, const Vector & trimPoint);
58 virtual void reverse();
59 Vector getMiddlepoint();
60 void setStartpointY(double val);
61 void setEndpointY(double val);
62 virtual bool hasEndpointsWithinWindow(Vector v1, Vector v2);
63 virtual double getLength();
64 virtual double getAngle1() const;
65 virtual double getAngle2() const;
67 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
68 virtual Vector getNearestPointOnEntity(const Vector & coord,
69 bool onEntity = true, double * dist = NULL, Entity ** entity = NULL);
70 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
71 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
72 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
73 virtual Vector getNearestDist(double distance, bool startp);
74 //virtual Vector getNearestRef(const Vector& coord, double* dist = NULL);
75 virtual double getDistanceToPoint(const Vector & coord,
76 Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone,
77 double solidDist = RS_MAXDOUBLE);
79 virtual void move(Vector offset);
80 virtual void rotate(Vector center, double angle);
81 virtual void scale(Vector center, Vector factor);
82 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
83 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
84 virtual void moveRef(const Vector & ref, const Vector & offset);
85 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
87 friend std::ostream & operator<<(std::ostream & os, const Line & l);
89 virtual void calculateBorders();