]> Shamusworld >> Repos - architektonas/blob - src/base/rs_polyline.h
Refactoring: Moved RS_GraphicView to GraphicView.
[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                 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 RS_Entity * addVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
68                 virtual void setNextBulge(double bulge);
69                 virtual void addEntity(RS_Entity * entity);
70                 //virtual void addSegment(RS_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 RS_Polyline & l);
83
84         protected:
85                 virtual RS_Entity * createVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
86
87         protected:
88                 RS_PolylineData data;
89                 RS_Entity * closingEntity;
90                 double nextBulge;
91 };
92
93 #endif