]> Shamusworld >> Repos - architektonas/blobdiff - src/base/rs_circle.h
Refactoring: Moved RS_GraphicView to GraphicView.
[architektonas] / src / base / rs_circle.h
index ce31de8d3c4471797650da50aa42cfc4001f0a77..d272ad8fea66d26b0f29e9663226aebfd987da8d 100644 (file)
  */
 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