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 Point::Point(EntityContainer * parent, const PointData & d):
26 AtomicEntity(parent), data(d)
31 /*virtual*/ Entity * Point::clone()
33 Point * p = new Point(*this);
38 /** @return RS_ENTITY_POINT */
39 /*virtual*/ RS2::EntityType Point::rtti() const
41 return RS2::EntityPoint;
45 * @return Start point of the entity.
47 /*virtual*/ Vector Point::getStartpoint() const
53 * @return End point of the entity.
55 /*virtual*/ Vector Point::getEndpoint() const
60 /** @return Copy of data that defines the point. */
61 PointData Point::getData() const
66 /** @return Position of the point */
67 Vector Point::getPos()
72 /** Sets a new position for this point. */
73 void Point::setPos(const Vector & pos)
78 void Point::calculateBorders()
80 minV = maxV = data.pos;
83 VectorSolutions Point::getRefPoints()
85 VectorSolutions ret(data.pos);
89 Vector Point::getNearestEndpoint(const Vector & coord, double * dist)
92 *dist = data.pos.distanceTo(coord);
97 Vector Point::getNearestPointOnEntity(const Vector & coord,
98 bool /*onEntity*/, double * dist, Entity ** entity)
101 *dist = data.pos.distanceTo(coord);
109 Vector Point::getNearestCenter(const Vector & coord, double * dist)
112 *dist = data.pos.distanceTo(coord);
117 Vector Point::getNearestMiddle(const Vector & coord, double * dist)
120 *dist = data.pos.distanceTo(coord);
125 Vector Point::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
128 *dist = RS_MAXDOUBLE;
130 return Vector(false);
133 double Point::getDistanceToPoint(const Vector & coord, Entity ** entity,
134 RS2::ResolveLevel /*level*/, double /*solidDist*/)
139 return data.pos.distanceTo(coord);
142 void Point::moveStartpoint(const Vector & pos)
148 void Point::move(Vector offset)
150 data.pos.move(offset);
154 void Point::rotate(Vector center, double angle)
156 data.pos.rotate(center, angle);
160 void Point::scale(Vector center, Vector factor)
162 data.pos.scale(center, factor);
166 void Point::mirror(Vector axisPoint1, Vector axisPoint2)
168 data.pos.mirror(axisPoint1, axisPoint2);
172 void 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 Point & p)
185 os << " Point: " << p.getData() << "\n";