4 #include "rs_atomicentity.h"
7 * Holds the data that defines a circle.
14 RS_CircleData(const Vector& center,
17 this->center = center;
18 this->radius = radius;
22 center = Vector(false);
27 return (center.valid && radius>RS_TOLERANCE);
30 friend class RS_Circle;
32 friend std::ostream& operator << (std::ostream& os,
33 const RS_CircleData& ad) {
34 os << "(" << ad.center <<
48 * Class for a circle entity.
50 * @author Andrew Mustun
52 class RS_Circle : public RS_AtomicEntity
55 RS_Circle (RS_EntityContainer* parent,
56 const RS_CircleData& d);
57 virtual ~RS_Circle() {}
59 virtual RS_Entity* clone() {
60 RS_Circle* c = new RS_Circle(*this);
65 /** @return RS2::EntityCircle */
66 virtual RS2::EntityType rtti() const {
67 return RS2::EntityCircle;
70 virtual bool isEdge() const {
74 /** @return Copy of data that defines the circle. **/
75 RS_CircleData getData() {
79 virtual VectorSolutions getRefPoints();
81 virtual Vector getStartpoint() const {
82 return data.center + Vector(data.radius, 0.0);
84 virtual Vector getEndpoint() const {
85 return data.center + Vector(data.radius, 0.0);
88 * @return Direction 1. The angle at which the arc starts at
91 double getDirection1() const {
95 * @return Direction 2. The angle at which the arc starts at
98 double getDirection2() const {
102 /** @return The center point (x) of this arc */
106 /** Sets new center. */
107 void setCenter(const Vector& c) {
110 /** @return The radius of this arc */
114 /** Sets new radius. */
115 void setRadius(double r) {
118 double getAngleLength() const;
119 virtual double getLength();
121 bool createFromCR(const Vector& c, double r);
122 bool createFrom2P(const Vector& p1, const Vector& p2);
123 bool createFrom3P(const Vector& p1, const Vector& p2,
126 virtual Vector getNearestEndpoint(const Vector& coord,
127 double* dist = NULL);
128 virtual Vector getNearestPointOnEntity(const Vector& coord,
129 bool onEntity = true, double* dist = NULL, RS_Entity** entity=NULL);
130 virtual Vector getNearestCenter(const Vector& coord,
131 double* dist = NULL);
132 virtual Vector getNearestMiddle(const Vector& coord,
133 double* dist = NULL);
134 virtual Vector getNearestDist(double distance,
136 double* dist = NULL);
137 virtual Vector getNearestDist(double distance,
139 virtual double getDistanceToPoint(const Vector& coord,
140 RS_Entity** entity=NULL,
141 RS2::ResolveLevel level=RS2::ResolveNone,
142 double solidDist = RS_MAXDOUBLE);
144 virtual void move(Vector offset);
145 virtual void rotate(Vector center, double angle);
146 virtual void scale(Vector center, Vector factor);
147 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
148 virtual void moveRef(const Vector& ref, const Vector& offset);
150 // virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
151 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
153 friend std::ostream & operator<<(std::ostream & os, const RS_Circle & a);
155 virtual void calculateBorders();