]> Shamusworld >> Repos - architektonas/blob - src/base/rs_constructionline.h
Changed RS_Graphic to Drawing; this is less confusing as a drawing is
[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, const Vector & point2)
20                 {
21                         this->point1 = point1;
22                         this->point2 = point2;
23                 }
24
25                 friend class RS_ConstructionLine;
26
27                 friend std::ostream & operator<<(std::ostream & os, const RS_ConstructionLineData & ld)
28                 {
29                         os << "(" << ld.point1 <<
30                         "/" << ld.point2 <<
31                         ")";
32                         return os;
33                 }
34
35         private:
36                 Vector point1;
37                 Vector point2;
38 };
39
40 /**
41  * Class for a construction line entity.
42  *
43  * @author Andrew Mustun
44  */
45 class RS_ConstructionLine: public RS_AtomicEntity
46 {
47         public:
48                 RS_ConstructionLine(RS_EntityContainer * parent, const RS_ConstructionLineData & d);
49                 virtual ~RS_ConstructionLine();
50
51                 virtual RS_Entity * clone();
52                 virtual RS2::EntityType rtti() const;
53                 virtual Vector getStartpoint() const;
54                 virtual Vector getEndpoint() const;
55                 RS_ConstructionLineData getData() const;
56                 Vector getPoint1() const;
57                 Vector getPoint2() const;
58                 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
59                 virtual Vector getNearestPointOnEntity(const Vector & coord,
60                         bool onEntity = true, double * dist = NULL, RS_Entity ** entity = NULL);
61                 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
62                 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
63                 virtual Vector getNearestDist(double distance, const Vector & coord,
64                         double * dist = NULL);
65                 virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL,
66                         RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
67                 virtual void move(Vector offset);
68                 virtual void rotate(Vector center, double angle);
69                 virtual void scale(Vector center, Vector factor);
70                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
71                 virtual void draw(PaintInterface * /*painter*/, RS_GraphicView * /*view*/,
72                         double /*patternOffset*/) {}
73
74                 friend std::ostream & operator<<(std::ostream & os, const RS_ConstructionLine & l);
75                 virtual void calculateBorders();
76
77         protected:
78                 RS_ConstructionLineData data;
79 };
80
81 #endif