5 #include "entitycontainer.h"
8 * Holds the data that defines a polyline.
10 class PolylineData: public Flags
15 startpoint = endpoint = Vector(false);
18 PolylineData(const Vector & startpoint, const Vector & endpoint, bool closed)
20 this->startpoint = startpoint;
21 this->endpoint = endpoint;
24 setFlag(RS2::FlagClosed);
27 friend class Polyline;
29 friend std::ostream & operator<<(std::ostream & os, const PolylineData & pd)
31 os << "(" << pd.startpoint << "/" << pd.endpoint << ")";
41 * Class for a poly line entity (lots of connected lines and arcs).
43 * @author Andrew Mustun
45 class Polyline: public EntityContainer
48 Polyline(EntityContainer * parent = NULL);
49 Polyline(EntityContainer * parent, const PolylineData & d);
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);
59 double getClosingBulge();
60 void updateEndpoints();
61 bool isClosed() const;
62 void setClosed(bool cl);
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);
82 friend std::ostream & operator<<(std::ostream & os, const Polyline & l);
85 virtual Entity * createVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
89 Entity * closingEntity;