]> Shamusworld >> Repos - architektonas/blob - src/base/rs_line.h
Removed more QC_ madness...
[architektonas] / src / base / rs_line.h
1 #ifndef RS_LINE_H
2 #define RS_LINE_H
3
4 #include "rs_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,
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);
86
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);
93
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);
96
97                 friend std::ostream & operator<<(std::ostream & os, const RS_Line & l);
98
99                 virtual void calculateBorders();
100
101         protected:
102                 RS_LineData data;
103                 //Vector startpoint;
104                 //Vector endpoint;
105 };
106
107 #endif