]> Shamusworld >> Repos - architektonas/blob - src/base/polyline.h
Bugfixes related to removing Snapper class.
[architektonas] / src / base / polyline.h
1 #ifndef __POLYLINE_H__
2 #define __POLYLINE_H__
3
4 #include "entity.h"
5 #include "entitycontainer.h"
6
7 /**
8  * Holds the data that defines a polyline.
9  */
10 class PolylineData: public Flags
11 {
12         public:
13                 PolylineData()
14                 {
15                         startpoint = endpoint = Vector(false);
16                 }
17
18                 PolylineData(const Vector & startpoint, const Vector & endpoint, bool closed)
19                 {
20                         this->startpoint = startpoint;
21                         this->endpoint = endpoint;
22
23                         if (closed)
24                                 setFlag(RS2::FlagClosed);
25                 }
26
27                 friend class Polyline;
28
29                 friend std::ostream & operator<<(std::ostream & os, const PolylineData & pd)
30                 {
31                         os << "(" << pd.startpoint << "/" << pd.endpoint << ")";
32                         return os;
33                 }
34
35         private:
36                 Vector startpoint;
37                 Vector endpoint;
38 };
39
40 /**
41  * Class for a poly line entity (lots of connected lines and arcs).
42  *
43  * @author Andrew Mustun
44  */
45 class Polyline: public EntityContainer
46 {
47         public:
48                 Polyline(EntityContainer * parent = NULL);
49                 Polyline(EntityContainer * parent, const PolylineData & d);
50                 virtual ~Polyline();
51
52                 virtual Entity * clone();
53                 virtual RS2::EntityType rtti() const;
54                 PolylineData getData() const;
55                 void setStartpoint(Vector & v);
56                 Vector getStartpoint();
57                 void setEndpoint(Vector & v);
58                 Vector getEndpoint();
59                 double getClosingBulge();
60                 void updateEndpoints();
61                 bool isClosed() const;
62                 void setClosed(bool cl);
63
64                 virtual VectorSolutions getRefPoints();
65                 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
66                 virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
67                 virtual Entity * addVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
68                 virtual void setNextBulge(double bulge);
69                 virtual void addEntity(Entity * entity);
70                 //virtual void addSegment(Entity* entity);
71                 virtual void removeLastVertex();
72                 virtual void endPolyline();
73                 //virtual void reorder();
74                 virtual void move(Vector offset);
75                 virtual void rotate(Vector center, double angle);
76                 virtual void scale(Vector center, Vector factor);
77                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
78                 virtual void moveRef(const Vector& ref, const Vector& offset);
79                 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
80                 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
81
82                 friend std::ostream & operator<<(std::ostream & os, const Polyline & l);
83
84         protected:
85                 virtual Entity * createVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
86
87         protected:
88                 PolylineData data;
89                 Entity * closingEntity;
90                 double nextBulge;
91 };
92
93 #endif