1 /****************************************************************************
2 ** $Id: rs_line.h 1907 2004-09-04 19:56:42Z 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_atomicentity.h"
33 * Holds the data that defines a line.
39 * Default constructor. Leaves the data object uninitialized.
43 RS_LineData(const Vector & start, const Vector & end): startpoint(start), endpoint(end)
45 // this->startpoint = startpoint;
46 // this->endpoint = endpoint;
50 friend class RS_ActionDrawLine;
52 friend std::ostream & operator<<(std::ostream & os, const RS_LineData & ld)
54 os << "(" << ld.startpoint << "/" << ld.endpoint << ")";
64 * Class for a line entity.
66 * @author Andrew Mustun
68 class RS_Line: public RS_AtomicEntity
71 //RS_Line(RS_EntityContainer* parent);
72 //RS_Line(const RS_Line& l);
73 RS_Line(RS_EntityContainer * parent, const RS_LineData & d);
76 virtual RS_Entity * clone();
77 virtual RS2::EntityType rtti() const;
78 virtual bool isEdge() const;
79 RS_LineData getData() const;
81 virtual VectorSolutions getRefPoints();
82 virtual Vector getStartpoint() const;
83 virtual Vector getEndpoint() const;
84 void setStartpoint(Vector s);
85 void setEndpoint(Vector e);
86 double getDirection1() const;
87 double getDirection2() const;
88 virtual void moveStartpoint(const Vector & pos);
89 virtual void moveEndpoint(const Vector & pos);
90 virtual RS2::Ending getTrimPoint(const Vector & coord, const Vector & trimPoint);
91 virtual void reverse();
92 Vector getMiddlepoint();
93 void setStartpointY(double val);
94 void setEndpointY(double val);
95 virtual bool hasEndpointsWithinWindow(Vector v1, Vector v2);
96 virtual double getLength();
97 virtual double getAngle1() const;
98 virtual double getAngle2() const;
100 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
101 virtual Vector getNearestPointOnEntity(const Vector & coord,
102 bool onEntity = true, double * dist = NULL, RS_Entity ** entity = NULL);
103 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
104 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
105 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
106 virtual Vector getNearestDist(double distance, bool startp);
107 //virtual Vector getNearestRef(const Vector& coord,
108 // double* dist = NULL);
109 virtual double getDistanceToPoint(const Vector & coord,
110 RS_Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone,
111 double solidDist = RS_MAXDOUBLE);
113 virtual void move(Vector offset);
114 virtual void rotate(Vector center, double angle);
115 virtual void scale(Vector center, Vector factor);
116 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
117 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
118 virtual void moveRef(const Vector & ref, const Vector & offset);
120 // virtual void draw(RS_Painter * painter, RS_GraphicView * view, double patternOffset = 0.0);
121 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
123 friend std::ostream & operator<<(std::ostream & os, const RS_Line & l);
125 virtual void calculateBorders();