]> Shamusworld >> Repos - architektonas/blob - src/base/constructionline.h
Bugfixes related to removing Snapper class.
[architektonas] / src / base / constructionline.h
1 #ifndef __CONSTRUCTIONLINE_H__
2 #define __CONSTRUCTIONLINE_H__
3
4 #include "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 ConstructionLineData
12 {
13         public:
14                 /**
15                  * Default constructor. Leaves the data object uninitialized.
16                  */
17                 ConstructionLineData() {}
18
19                 ConstructionLineData(const Vector & point1, const Vector & point2)
20                 {
21                         this->point1 = point1;
22                         this->point2 = point2;
23                 }
24
25                 friend class ConstructionLine;
26
27                 friend std::ostream & operator<<(std::ostream & os, const 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 ConstructionLine: public AtomicEntity
46 {
47         public:
48                 ConstructionLine(EntityContainer * parent, const ConstructionLineData & d);
49                 virtual ~ConstructionLine();
50
51                 virtual Entity * clone();
52                 virtual RS2::EntityType rtti() const;
53                 virtual Vector getStartpoint() const;
54                 virtual Vector getEndpoint() const;
55                 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, 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, 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*/, GraphicView * /*view*/,
72                         double /*patternOffset*/);
73
74                 friend std::ostream & operator<<(std::ostream & os, const ConstructionLine & l);
75                 virtual void calculateBorders();
76
77         protected:
78                 ConstructionLineData data;
79 };
80
81 #endif