X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Frs_circle.h;h=d272ad8fea66d26b0f29e9663226aebfd987da8d;hb=27d4a138d23453e93a833e9347444b828a971cb4;hp=ce31de8d3c4471797650da50aa42cfc4001f0a77;hpb=16ce54abf01ca3032e42a5bb11a4afcf9014dcca;p=architektonas diff --git a/src/base/rs_circle.h b/src/base/rs_circle.h index ce31de8..d272ad8 100644 --- a/src/base/rs_circle.h +++ b/src/base/rs_circle.h @@ -8,154 +8,93 @@ */ class RS_CircleData { -public: - RS_CircleData() {} - - RS_CircleData(const Vector& center, - double radius) { - - this->center = center; - this->radius = radius; - } - - void reset() { - center = Vector(false); - radius = 0.0; - } - - bool isValid() { - return (center.valid && radius>RS_TOLERANCE); - } - - friend class RS_Circle; - - friend std::ostream& operator << (std::ostream& os, - const RS_CircleData& ad) { - os << "(" << ad.center << - "/" << ad.radius << - ")"; - return os; - } - -public: - Vector center; - double radius; + public: + RS_CircleData() + { + } + + RS_CircleData(const Vector & center, double radius) + { + this->center = center; + this->radius = radius; + } + + void reset() + { + center = Vector(false); + radius = 0.0; + } + + bool isValid() + { + return (center.valid && radius > RS_TOLERANCE); + } + + friend class RS_Circle; + + friend std::ostream & operator<<(std::ostream & os, const RS_CircleData & ad) + { + os << "(" << ad.center << "/" << ad.radius << ")"; + return os; + } + + public: + Vector center; + double radius; }; - - /** * Class for a circle entity. * * @author Andrew Mustun */ -class RS_Circle : public RS_AtomicEntity +class RS_Circle: public RS_AtomicEntity { -public: - RS_Circle (RS_EntityContainer* parent, - const RS_CircleData& d); - virtual ~RS_Circle() {} - - virtual RS_Entity* clone() { - RS_Circle* c = new RS_Circle(*this); - c->initId(); - return c; - } - - /** @return RS2::EntityCircle */ - virtual RS2::EntityType rtti() const { - return RS2::EntityCircle; - } - /** @return true */ - virtual bool isEdge() const { - return true; - } - - /** @return Copy of data that defines the circle. **/ - RS_CircleData getData() { - return data; - } - - virtual VectorSolutions getRefPoints(); - - virtual Vector getStartpoint() const { - return data.center + Vector(data.radius, 0.0); - } - virtual Vector getEndpoint() const { - return data.center + Vector(data.radius, 0.0); - } - /** - * @return Direction 1. The angle at which the arc starts at - * the startpoint. - */ - double getDirection1() const { - return M_PI/2.0; - } - /** - * @return Direction 2. The angle at which the arc starts at - * the endpoint. - */ - double getDirection2() const { - return M_PI/2.0*3.0; - } - - /** @return The center point (x) of this arc */ - Vector getCenter() { - return data.center; - } - /** Sets new center. */ - void setCenter(const Vector& c) { - data.center = c; - } - /** @return The radius of this arc */ - double getRadius() { - return data.radius; - } - /** Sets new radius. */ - void setRadius(double r) { - data.radius = r; - } - double getAngleLength() const; - virtual double getLength(); - - bool createFromCR(const Vector& c, double r); - bool createFrom2P(const Vector& p1, const Vector& p2); - bool createFrom3P(const Vector& p1, const Vector& p2, - const Vector& p3); - - virtual Vector getNearestEndpoint(const Vector& coord, - double* dist = NULL); - virtual Vector getNearestPointOnEntity(const Vector& coord, - bool onEntity = true, double* dist = NULL, RS_Entity** entity=NULL); - virtual Vector getNearestCenter(const Vector& coord, - double* dist = NULL); - virtual Vector getNearestMiddle(const Vector& coord, - double* dist = NULL); - virtual Vector getNearestDist(double distance, - const Vector& coord, - double* dist = NULL); - virtual Vector getNearestDist(double distance, - bool startp); - virtual double getDistanceToPoint(const Vector& coord, - RS_Entity** entity=NULL, - RS2::ResolveLevel level=RS2::ResolveNone, - double solidDist = RS_MAXDOUBLE); - - virtual void move(Vector offset); - virtual void rotate(Vector center, double angle); - virtual void scale(Vector center, Vector factor); - virtual void mirror(Vector axisPoint1, Vector axisPoint2); - virtual void moveRef(const Vector& ref, const Vector& offset); - -// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0); - virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0); - - friend std::ostream & operator<<(std::ostream & os, const RS_Circle & a); - - virtual void calculateBorders(); - -protected: - RS_CircleData data; + public: + RS_Circle (RS_EntityContainer * parent, const RS_CircleData & d); + virtual ~RS_Circle(); + + virtual RS_Entity * clone(); + virtual RS2::EntityType rtti() const; + virtual bool isEdge() const; + RS_CircleData getData(); + virtual VectorSolutions getRefPoints(); + virtual Vector getStartpoint() const; + virtual Vector getEndpoint() const; + double getDirection1() const; + double getDirection2() const; + Vector getCenter(); + void setCenter(const Vector & c); + double getRadius(); + void setRadius(double r); + double getAngleLength() const; + virtual double getLength(); + + bool createFromCR(const Vector & c, double r); + bool createFrom2P(const Vector & p1, const Vector & p2); + bool createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3); + virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL); + virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true, + double * dist = NULL, RS_Entity ** entity = NULL); + virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL); + virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL); + virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL); + virtual Vector getNearestDist(double distance, bool startp); + virtual double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE); + + virtual void move(Vector offset); + virtual void rotate(Vector center, double angle); + virtual void scale(Vector center, Vector factor); + virtual void mirror(Vector axisPoint1, Vector axisPoint2); + virtual void moveRef(const Vector & ref, const Vector & offset); + virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0); + + friend std::ostream & operator<<(std::ostream & os, const RS_Circle & a); + + virtual void calculateBorders(); + + protected: + RS_CircleData data; }; #endif