]> Shamusworld >> Repos - architektonas/blob - src/base/rs_constructionline.h
Initial import
[architektonas] / src / base / rs_constructionline.h
1 #ifndef RS_CONSTRUCTIONLINE_H
2 #define RS_CONSTRUCTIONLINE_H
3
4 #include "rs_atomicentity.h"
5 #include "vector.h"
6
7 /**
8  * Holds the data that defines a construction line (a line
9  * which is not limited to both directions).
10  */
11 class RS_ConstructionLineData
12 {
13 public:
14     /**
15      * Default constructor. Leaves the data object uninitialized.
16      */
17     RS_ConstructionLineData() {}
18
19     RS_ConstructionLineData(const Vector& point1,
20                             const Vector& point2) {
21
22         this->point1 = point1;
23         this->point2 = point2;
24     }
25
26     friend class RS_ConstructionLine;
27
28     friend std::ostream& operator << (std::ostream& os,
29                                       const RS_ConstructionLineData& ld) {
30
31         os << "(" << ld.point1 <<
32         "/" << ld.point2 <<
33         ")";
34         return os;
35     }
36
37 private:
38     Vector point1;
39     Vector point2;
40 };
41
42
43 /**
44  * Class for a construction line entity.
45  *
46  * @author Andrew Mustun
47  */
48 class RS_ConstructionLine : public RS_AtomicEntity {
49 public:
50     RS_ConstructionLine(RS_EntityContainer* parent,
51                         const RS_ConstructionLineData& d);
52
53     virtual RS_Entity* clone();
54
55     virtual ~RS_ConstructionLine();
56
57     /** @return RS2::EntityConstructionLine */
58     virtual RS2::EntityType rtti() const {
59         return RS2::EntityConstructionLine;
60     }
61
62         /**
63          * @todo
64          * @return Start point of the entity.
65          */
66     virtual Vector getStartpoint() const {
67         return Vector(false);
68     }
69     /**
70          * @todo
71          * @return End point of the entity.
72          */
73     virtual Vector getEndpoint() const {
74         return Vector(false);
75     }
76
77     /** @return Copy of data that defines the line. */
78     RS_ConstructionLineData getData() const {
79         return data;
80     }
81
82     /** @return First definition point. */
83     Vector getPoint1() const {
84         return data.point1;
85     }
86     /** @return Second definition point. */
87     Vector getPoint2() const {
88         return data.point2;
89     }
90
91     virtual Vector getNearestEndpoint(const Vector& coord,
92                                          double* dist = NULL);
93     virtual Vector getNearestPointOnEntity(const Vector& coord,
94             bool onEntity = true, double* dist = NULL, RS_Entity** entity=NULL);
95     virtual Vector getNearestCenter(const Vector& coord,
96                                        double* dist = NULL);
97     virtual Vector getNearestMiddle(const Vector& coord,
98                                        double* dist = NULL);
99     virtual Vector getNearestDist(double distance,
100                                      const Vector& coord,
101                                      double* dist = NULL);
102     virtual double getDistanceToPoint(const Vector& coord,
103                                       RS_Entity** entity=NULL,
104                                       RS2::ResolveLevel level=RS2::ResolveNone,
105                                                                           double solidDist = RS_MAXDOUBLE);
106
107     virtual void move(Vector offset);
108     virtual void rotate(Vector center, double angle);
109     virtual void scale(Vector center, Vector factor);
110     virtual void mirror(Vector axisPoint1, Vector axisPoint2);
111
112 //    virtual void draw(RS_Painter* /*painter*/, RS_GraphicView* /*view*/,
113     virtual void draw(PaintInterface * /*painter*/, RS_GraphicView* /*view*/,
114                 double /*patternOffset*/) {}
115
116     friend std::ostream& operator << (std::ostream& os,
117                                       const RS_ConstructionLine& l);
118
119     virtual void calculateBorders();
120
121 protected:
122     RS_ConstructionLineData data;
123 };
124
125 #endif