3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 06/01/2010 Added this text. :-)
19 #include "graphicview.h"
20 #include "paintinterface.h"
23 * Default constructor.
25 RS_Point::RS_Point(RS_EntityContainer * parent, const RS_PointData & d):
26 RS_AtomicEntity(parent), data(d)
31 /*virtual*/ RS_Entity * RS_Point::clone()
33 RS_Point * p = new RS_Point(*this);
38 /** @return RS_ENTITY_POINT */
39 /*virtual*/ RS2::EntityType RS_Point::rtti() const
41 return RS2::EntityPoint;
45 * @return Start point of the entity.
47 /*virtual*/ Vector RS_Point::getStartpoint() const
53 * @return End point of the entity.
55 /*virtual*/ Vector RS_Point::getEndpoint() const
60 /** @return Copy of data that defines the point. */
61 RS_PointData RS_Point::getData() const
66 /** @return Position of the point */
67 Vector RS_Point::getPos()
72 /** Sets a new position for this point. */
73 void RS_Point::setPos(const Vector & pos)
78 void RS_Point::calculateBorders()
80 minV = maxV = data.pos;
83 VectorSolutions RS_Point::getRefPoints()
85 VectorSolutions ret(data.pos);
89 Vector RS_Point::getNearestEndpoint(const Vector & coord, double * dist)
92 *dist = data.pos.distanceTo(coord);
97 Vector RS_Point::getNearestPointOnEntity(const Vector & coord,
98 bool /*onEntity*/, double * dist, RS_Entity ** entity)
101 *dist = data.pos.distanceTo(coord);
109 Vector RS_Point::getNearestCenter(const Vector & coord, double * dist)
112 *dist = data.pos.distanceTo(coord);
117 Vector RS_Point::getNearestMiddle(const Vector & coord, double * dist)
120 *dist = data.pos.distanceTo(coord);
125 Vector RS_Point::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
128 *dist = RS_MAXDOUBLE;
130 return Vector(false);
133 double RS_Point::getDistanceToPoint(const Vector & coord, RS_Entity ** entity,
134 RS2::ResolveLevel /*level*/, double /*solidDist*/)
139 return data.pos.distanceTo(coord);
142 void RS_Point::moveStartpoint(const Vector & pos)
148 void RS_Point::move(Vector offset)
150 data.pos.move(offset);
154 void RS_Point::rotate(Vector center, double angle)
156 data.pos.rotate(center, angle);
160 void RS_Point::scale(Vector center, Vector factor)
162 data.pos.scale(center, factor);
166 void RS_Point::mirror(Vector axisPoint1, Vector axisPoint2)
168 data.pos.mirror(axisPoint1, axisPoint2);
172 void RS_Point::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
174 if (painter == NULL || view == NULL)
177 painter->drawPoint(view->toGui(getPos()));
181 * Dumps the point's data to stdout.
183 std::ostream & operator<<(std::ostream & os, const RS_Point & p)
185 os << " Point: " << p.getData() << "\n";