1 /****************************************************************************
2 ** $Id: rs_polyline.h 2367 2005-04-04 16:57:36Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
30 #include "rs_entity.h"
31 #include "rs_entitycontainer.h"
34 * Holds the data that defines a polyline.
36 class RS_PolylineData: public RS_Flags
41 startpoint = endpoint = Vector(false);
44 RS_PolylineData(const Vector & startpoint, const Vector & endpoint, bool closed)
46 this->startpoint = startpoint;
47 this->endpoint = endpoint;
50 setFlag(RS2::FlagClosed);
53 friend class RS_Polyline;
55 friend std::ostream & operator<<(std::ostream & os, const RS_PolylineData & pd)
57 os << "(" << pd.startpoint << "/" << pd.endpoint << ")";
67 * Class for a poly line entity (lots of connected lines and arcs).
69 * @author Andrew Mustun
71 class RS_Polyline: public RS_EntityContainer
74 RS_Polyline(RS_EntityContainer * parent = NULL);
75 RS_Polyline(RS_EntityContainer * parent, const RS_PolylineData & d);
76 virtual ~RS_Polyline();
78 virtual RS_Entity * clone();
79 virtual RS2::EntityType rtti() const;
80 RS_PolylineData getData() const;
81 void setStartpoint(Vector & v);
82 Vector getStartpoint();
83 void setEndpoint(Vector & v);
86 double getClosingBulge();
87 void updateEndpoints();
89 bool isClosed() const;
90 void setClosed(bool cl);
92 virtual VectorSolutions getRefPoints();
93 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
94 virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
96 virtual RS_Entity * addVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
97 virtual void setNextBulge(double bulge);
98 virtual void addEntity(RS_Entity * entity);
99 //virtual void addSegment(RS_Entity* entity);
100 virtual void removeLastVertex();
101 virtual void endPolyline();
103 //virtual void reorder();
105 virtual void move(Vector offset);
106 virtual void rotate(Vector center, double angle);
107 virtual void scale(Vector center, Vector factor);
108 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
109 virtual void moveRef(const Vector& ref, const Vector& offset);
110 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
112 // virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
113 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
115 friend std::ostream & operator<<(std::ostream & os, const RS_Polyline & l);
118 virtual RS_Entity * createVertex(const Vector & v, double bulge = 0.0, bool prepend = false);
121 RS_PolylineData data;
122 RS_Entity * closingEntity;