]> Shamusworld >> Repos - architektonas/blob - src/base/line.h
Initial removal of unnecessary rs_ prefixes from files.
[architektonas] / src / base / line.h
1 #ifndef __LINE_H__
2 #define __LINE_H__
3
4 #include "atomicentity.h"
5
6 /**
7  * Holds the data that defines a line.
8  */
9 class RS_LineData
10 {
11         public:
12                 /**
13                 * Default constructor. Leaves the data object uninitialized.
14                 */
15                 RS_LineData() {}
16
17                 RS_LineData(const Vector & start, const Vector & end): startpoint(start), endpoint(end)
18                 {
19 //                      this->startpoint = startpoint;
20 //                      this->endpoint = endpoint;
21                 }
22
23                 friend class RS_Line;
24                 friend class RS_ActionDrawLine;
25
26                 friend std::ostream & operator<<(std::ostream & os, const RS_LineData & ld)
27                 {
28                         os << "(" << ld.startpoint << "/" << ld.endpoint << ")";
29                         return os;
30                 }
31
32         public:
33                 Vector startpoint;
34                 Vector endpoint;
35 };
36
37 /**
38  * Class for a line entity.
39  *
40  * @author Andrew Mustun
41  */
42 class RS_Line: public RS_AtomicEntity
43 {
44         public:
45                 //RS_Line(RS_EntityContainer* parent);
46                 //RS_Line(const RS_Line& l);
47                 RS_Line(RS_EntityContainer * parent, const RS_LineData & d);
48                 virtual ~RS_Line();
49
50                 virtual RS_Entity * clone();
51                 virtual RS2::EntityType rtti() const;
52                 virtual bool isEdge() const;
53                 RS_LineData getData() const;
54
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;
73
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, double* dist = NULL);
82                 virtual double getDistanceToPoint(const Vector & coord,
83                         RS_Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone,
84                         double solidDist = RS_MAXDOUBLE);
85
86                 virtual void move(Vector offset);
87                 virtual void rotate(Vector center, double angle);
88                 virtual void scale(Vector center, Vector factor);
89                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
90                 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
91                 virtual void moveRef(const Vector & ref, const Vector & offset);
92                 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
93
94                 friend std::ostream & operator<<(std::ostream & os, const RS_Line & l);
95
96                 virtual void calculateBorders();
97
98         protected:
99                 RS_LineData data;
100 };
101
102 #endif