]> Shamusworld >> Repos - architektonas/blob - src/base/line.h
Removed unnecessary RS_ prefix from classes and whatnot.
[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 LineData
10 {
11         public:
12                 /**
13                 * Default constructor. Leaves the data object uninitialized.
14                 */
15                 LineData() {}
16                 LineData(const Vector & start, const Vector & end): startpoint(start), endpoint(end) {}
17
18                 friend class Line;
19                 friend class ActionDrawLine;
20
21                 friend std::ostream & operator<<(std::ostream & os, const LineData & ld)
22                 {
23                         os << "(" << ld.startpoint << "/" << ld.endpoint << ")";
24                         return os;
25                 }
26
27         public:
28                 Vector startpoint;
29                 Vector endpoint;
30 };
31
32 /**
33  * Class for a line entity.
34  *
35  * @author Andrew Mustun
36  */
37 class Line: public AtomicEntity
38 {
39         public:
40                 Line(EntityContainer * parent, const LineData & d);
41                 virtual ~Line();
42
43                 virtual Entity * clone();
44                 virtual RS2::EntityType rtti() const;
45                 virtual bool isEdge() const;
46                 LineData getData() const;
47
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;
66
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);
78
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);
86
87                 friend std::ostream & operator<<(std::ostream & os, const Line & l);
88
89                 virtual void calculateBorders();
90
91         protected:
92                 LineData data;
93 };
94
95 #endif