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 "rs_graphicview.h"
18 //#include "rs_painter.h"
19 #include "paintintf.h"
22 * Default constructor.
24 RS_Point::RS_Point(RS_EntityContainer * parent, const RS_PointData & d):
25 RS_AtomicEntity(parent), data(d)
30 /*virtual*/ RS_Entity * RS_Point::clone()
32 RS_Point * p = new RS_Point(*this);
37 /** @return RS_ENTITY_POINT */
38 /*virtual*/ RS2::EntityType RS_Point::rtti() const
40 return RS2::EntityPoint;
44 * @return Start point of the entity.
46 /*virtual*/ Vector RS_Point::getStartpoint() const
52 * @return End point of the entity.
54 /*virtual*/ Vector RS_Point::getEndpoint() const
59 /** @return Copy of data that defines the point. */
60 RS_PointData RS_Point::getData() const
65 /** @return Position of the point */
66 Vector RS_Point::getPos()
71 /** Sets a new position for this point. */
72 void RS_Point::setPos(const Vector & pos)
77 void RS_Point::calculateBorders()
79 minV = maxV = data.pos;
82 VectorSolutions RS_Point::getRefPoints()
84 VectorSolutions ret(data.pos);
88 Vector RS_Point::getNearestEndpoint(const Vector & coord, double * dist)
91 *dist = data.pos.distanceTo(coord);
96 Vector RS_Point::getNearestPointOnEntity(const Vector & coord,
97 bool /*onEntity*/, double * dist, RS_Entity ** entity)
100 *dist = data.pos.distanceTo(coord);
108 Vector RS_Point::getNearestCenter(const Vector & coord, double * dist)
111 *dist = data.pos.distanceTo(coord);
116 Vector RS_Point::getNearestMiddle(const Vector & coord, double * dist)
119 *dist = data.pos.distanceTo(coord);
124 Vector RS_Point::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
127 *dist = RS_MAXDOUBLE;
129 return Vector(false);
132 double RS_Point::getDistanceToPoint(const Vector & coord, RS_Entity ** entity,
133 RS2::ResolveLevel /*level*/, double /*solidDist*/)
138 return data.pos.distanceTo(coord);
141 void RS_Point::moveStartpoint(const Vector & pos)
147 void RS_Point::move(Vector offset)
149 data.pos.move(offset);
153 void RS_Point::rotate(Vector center, double angle)
155 data.pos.rotate(center, angle);
159 void RS_Point::scale(Vector center, Vector factor)
161 data.pos.scale(center, factor);
165 void RS_Point::mirror(Vector axisPoint1, Vector axisPoint2)
167 data.pos.mirror(axisPoint1, axisPoint2);
171 //void RS_Point::draw(RS_Painter * painter, RS_GraphicView * view, double /*patternOffset*/)
172 void RS_Point::draw(PaintInterface * painter, RS_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";