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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/01/2010 Added this text. :-)
17 #include "graphicview.h"
18 #include "paintintf.h"
21 * Default constructor.
23 RS_Point::RS_Point(RS_EntityContainer * parent, const RS_PointData & d):
24 RS_AtomicEntity(parent), data(d)
29 /*virtual*/ RS_Entity * RS_Point::clone()
31 RS_Point * p = new RS_Point(*this);
36 /** @return RS_ENTITY_POINT */
37 /*virtual*/ RS2::EntityType RS_Point::rtti() const
39 return RS2::EntityPoint;
43 * @return Start point of the entity.
45 /*virtual*/ Vector RS_Point::getStartpoint() const
51 * @return End point of the entity.
53 /*virtual*/ Vector RS_Point::getEndpoint() const
58 /** @return Copy of data that defines the point. */
59 RS_PointData RS_Point::getData() const
64 /** @return Position of the point */
65 Vector RS_Point::getPos()
70 /** Sets a new position for this point. */
71 void RS_Point::setPos(const Vector & pos)
76 void RS_Point::calculateBorders()
78 minV = maxV = data.pos;
81 VectorSolutions RS_Point::getRefPoints()
83 VectorSolutions ret(data.pos);
87 Vector RS_Point::getNearestEndpoint(const Vector & coord, double * dist)
90 *dist = data.pos.distanceTo(coord);
95 Vector RS_Point::getNearestPointOnEntity(const Vector & coord,
96 bool /*onEntity*/, double * dist, RS_Entity ** entity)
99 *dist = data.pos.distanceTo(coord);
107 Vector RS_Point::getNearestCenter(const Vector & coord, double * dist)
110 *dist = data.pos.distanceTo(coord);
115 Vector RS_Point::getNearestMiddle(const Vector & coord, double * dist)
118 *dist = data.pos.distanceTo(coord);
123 Vector RS_Point::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
126 *dist = RS_MAXDOUBLE;
128 return Vector(false);
131 double RS_Point::getDistanceToPoint(const Vector & coord, RS_Entity ** entity,
132 RS2::ResolveLevel /*level*/, double /*solidDist*/)
137 return data.pos.distanceTo(coord);
140 void RS_Point::moveStartpoint(const Vector & pos)
146 void RS_Point::move(Vector offset)
148 data.pos.move(offset);
152 void RS_Point::rotate(Vector center, double angle)
154 data.pos.rotate(center, angle);
158 void RS_Point::scale(Vector center, Vector factor)
160 data.pos.scale(center, factor);
164 void RS_Point::mirror(Vector axisPoint1, Vector axisPoint2)
166 data.pos.mirror(axisPoint1, axisPoint2);
170 void RS_Point::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
172 if (painter == NULL || view == NULL)
175 painter->drawPoint(view->toGui(getPos()));
179 * Dumps the point's data to stdout.
181 std::ostream & operator<<(std::ostream & os, const RS_Point & p)
183 os << " Point: " << p.getData() << "\n";