]> Shamusworld >> Repos - architektonas/blob - src/base/rs_polyline.h
Removed more QC_ madness...
[architektonas] / src / base / rs_polyline.h
1 #ifndef RS_POLYLINE_H
2 #define RS_POLYLINE_H
3
4 #include "rs_entity.h"
5 #include "rs_entitycontainer.h"
6
7 /**
8  * Holds the data that defines a polyline.
9  */
10 class RS_PolylineData: public RS_Flags
11 {
12         public:
13                 RS_PolylineData()
14                 {
15                         startpoint = endpoint = Vector(false);
16                 }
17
18                 RS_PolylineData(const Vector & startpoint, const Vector & endpoint, bool closed)
19                 {
20                         this->startpoint = startpoint;
21                         this->endpoint = endpoint;
22
23                         if (closed == true)
24                                 setFlag(RS2::FlagClosed);
25                 }
26
27                 friend class RS_Polyline;
28
29                 friend std::ostream & operator<<(std::ostream & os, const RS_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 RS_Polyline: public RS_EntityContainer
46 {
47         public:
48                 RS_Polyline(RS_EntityContainer * parent = NULL);
49                 RS_Polyline(RS_EntityContainer * parent, const RS_PolylineData & d);
50                 virtual ~RS_Polyline();
51
52                 virtual RS_Entity * clone();
53                 virtual RS2::EntityType rtti() const;
54                 RS_PolylineData getData() const;
55                 void setStartpoint(Vector & v);
56                 Vector getStartpoint();
57                 void setEndpoint(Vector & v);
58                 Vector getEndpoint();
59
60                 double getClosingBulge();
61                 void updateEndpoints();
62
63                 bool isClosed() const;
64                 void setClosed(bool cl);
65
66                 virtual VectorSolutions getRefPoints();
67                 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
68                 virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
69
70                 virtual RS_Entity * addVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
71                 virtual void setNextBulge(double bulge);
72                 virtual void addEntity(RS_Entity * entity);
73                 //virtual void addSegment(RS_Entity* entity);
74                 virtual void removeLastVertex();
75                 virtual void endPolyline();
76
77                 //virtual void reorder();
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 moveRef(const Vector& ref, const Vector& offset);
84                 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
85
86         //    virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
87                 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
88
89                 friend std::ostream & operator<<(std::ostream & os, const RS_Polyline & l);
90
91         protected:
92                 virtual RS_Entity * createVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
93
94         protected:
95                 RS_PolylineData data;
96                 RS_Entity * closingEntity;
97                 double nextBulge;
98 };
99
100 #endif