1 /****************************************************************************
2 ** $Id: rs_point.cpp 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 **********************************************************************/
29 #include "rs_graphicview.h"
30 //#include "rs_painter.h"
31 #include "paintintf.h"
34 * Default constructor.
36 RS_Point::RS_Point(RS_EntityContainer * parent, const RS_PointData & d):
37 RS_AtomicEntity(parent), data(d)
42 /*virtual*/ RS_Entity * RS_Point::clone()
44 RS_Point * p = new RS_Point(*this);
49 /** @return RS_ENTITY_POINT */
50 /*virtual*/ RS2::EntityType RS_Point::rtti() const
52 return RS2::EntityPoint;
56 * @return Start point of the entity.
58 /*virtual*/ Vector RS_Point::getStartpoint() const
64 * @return End point of the entity.
66 /*virtual*/ Vector RS_Point::getEndpoint() const
71 /** @return Copy of data that defines the point. */
72 RS_PointData RS_Point::getData() const
77 /** @return Position of the point */
78 Vector RS_Point::getPos()
83 /** Sets a new position for this point. */
84 void RS_Point::setPos(const Vector & pos)
89 void RS_Point::calculateBorders()
91 minV = maxV = data.pos;
94 VectorSolutions RS_Point::getRefPoints()
96 VectorSolutions ret(data.pos);
100 Vector RS_Point::getNearestEndpoint(const Vector & coord, double * dist)
103 *dist = data.pos.distanceTo(coord);
108 Vector RS_Point::getNearestPointOnEntity(const Vector & coord,
109 bool /*onEntity*/, double * dist, RS_Entity ** entity)
112 *dist = data.pos.distanceTo(coord);
120 Vector RS_Point::getNearestCenter(const Vector & coord, double * dist)
123 *dist = data.pos.distanceTo(coord);
128 Vector RS_Point::getNearestMiddle(const Vector & coord, double * dist)
131 *dist = data.pos.distanceTo(coord);
136 Vector RS_Point::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
139 *dist = RS_MAXDOUBLE;
141 return Vector(false);
144 double RS_Point::getDistanceToPoint(const Vector & coord, RS_Entity ** entity,
145 RS2::ResolveLevel /*level*/, double /*solidDist*/)
150 return data.pos.distanceTo(coord);
153 void RS_Point::moveStartpoint(const Vector & pos)
159 void RS_Point::move(Vector offset)
161 data.pos.move(offset);
165 void RS_Point::rotate(Vector center, double angle)
167 data.pos.rotate(center, angle);
171 void RS_Point::scale(Vector center, Vector factor)
173 data.pos.scale(center, factor);
177 void RS_Point::mirror(Vector axisPoint1, Vector axisPoint2)
179 data.pos.mirror(axisPoint1, axisPoint2);
183 //void RS_Point::draw(RS_Painter * painter, RS_GraphicView * view, double /*patternOffset*/)
184 void RS_Point::draw(PaintInterface * painter, RS_GraphicView * view, double /*patternOffset*/)
186 if (painter == NULL || view == NULL)
189 painter->drawPoint(view->toGui(getPos()));
193 * Dumps the point's data to stdout.
195 std::ostream & operator<<(std::ostream & os, const RS_Point & p)
197 os << " Point: " << p.getData() << "\n";