-class RS_Ellipse : public RS_AtomicEntity {
-public:
- RS_Ellipse(RS_EntityContainer* parent,
- const RS_EllipseData& d);
- virtual ~RS_Ellipse() {}
-
- virtual RS_Entity* clone() {
- RS_Ellipse* e = new RS_Ellipse(*this);
- e->initId();
- return e;
- }
-
- /** @return RS2::EntityEllipse */
- virtual RS2::EntityType rtti() const {
- return RS2::EntityEllipse;
- }
-
-
- /**
- * @return Start point of the entity.
- */
- virtual Vector getStartpoint() const {
- Vector p;
- p.set(data.center.x + cos(data.angle1) * getMajorRadius(),
- data.center.y + sin(data.angle1) * getMinorRadius());
- p.rotate(data.center, getAngle());
- return p;
- }
- /**
- * @return End point of the entity.
- */
- virtual Vector getEndpoint() const {
- Vector p;
- p.set(data.center.x + cos(data.angle2) * getMajorRadius(),
- data.center.y + sin(data.angle2) * getMinorRadius());
- p.rotate(data.center, getAngle());
- return p;
- }
-
- virtual void moveStartpoint(const Vector& pos);
- virtual void moveEndpoint(const Vector& pos);
-
- virtual RS2::Ending getTrimPoint(const Vector& coord,
- const Vector& trimPoint);
-
- double getEllipseAngle(const Vector& pos);
-
- /** @return Copy of data that defines the ellipse. **/
- RS_EllipseData getData() {
- return data;
- }
-
- virtual VectorSolutions getRefPoints();
-
- /**
- * @retval true if the arc is reversed (clockwise),
- * @retval false otherwise
- */
- bool isReversed() const {
- return data.reversed;
- }
- /** sets the reversed status. */
- void setReversed(bool r) {
- data.reversed = r;
- }
-
- /** @return The rotation angle of this ellipse */
- double getAngle() const {
- return data.majorP.angle();
- }
-
- /** @return The start angle of this arc */
- double getAngle1() {
- return data.angle1;
- }
- /** Sets new start angle. */
- void setAngle1(double a1) {
- data.angle1 = a1;
- }
- /** @return The end angle of this arc */
- double getAngle2() {
- return data.angle2;
- }
- /** Sets new end angle. */
- void setAngle2(double a2) {
- data.angle2 = a2;
- }
-
-
- /** @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 endpoint of the major axis (relative to center). */
- Vector getMajorP() {
- return data.majorP;
- }
- /** Sets new major point (relative to center). */
- void setMajorP(const Vector& p) {
- data.majorP = p;
- }
-
- /** @return The ratio of minor to major axis */
- double getRatio() {
- return data.ratio;
- }
- /** Sets new ratio. */
- void setRatio(double r) {
- data.ratio = r;
- }
-
-
- /**
- * @return Angle length in rad.
- */
- virtual double getAngleLength() const {
- if (isReversed()) {
- return data.angle1-data.angle2;
- } else {
- return data.angle2-data.angle1;
- }
- }
-
- /** @return The major radius of this ellipse. Same as getRadius() */
- double getMajorRadius() const {
- return data.majorP.magnitude();
- }
-
- /** @return The minor radius of this ellipse */
- double getMinorRadius() const {
- return data.majorP.magnitude()*data.ratio;
- }
-
- 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 double getDistanceToPoint(const Vector& coord,
- RS_Entity** entity=NULL,
- RS2::ResolveLevel level=RS2::ResolveNone,
- double solidDist = RS_MAXDOUBLE);
- virtual bool isPointOnEntity(const Vector& coord,
- double tolerance=RS_TOLERANCE);
-
- 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_Ellipse & a);
-
- //virtual void calculateEndpoints();
- virtual void calculateBorders();
-
-protected:
- RS_EllipseData data;
+class RS_Ellipse: public RS_AtomicEntity
+{
+ public:
+ RS_Ellipse(RS_EntityContainer * parent, const RS_EllipseData & d);
+ virtual ~RS_Ellipse();
+
+ virtual RS_Entity * clone();
+ virtual RS2::EntityType rtti() const;
+ virtual Vector getStartpoint() const;
+ virtual Vector getEndpoint() const;
+ virtual void moveStartpoint(const Vector & pos);
+ virtual void moveEndpoint(const Vector & pos);
+ virtual RS2::Ending getTrimPoint(const Vector & coord, const Vector & trimPoint);
+ double getEllipseAngle(const Vector & pos);
+ RS_EllipseData getData();
+ virtual VectorSolutions getRefPoints();
+ bool isReversed() const;
+ void setReversed(bool r);
+ double getAngle() const;
+ double getAngle1();
+ void setAngle1(double a1);
+ double getAngle2();
+ void setAngle2(double a2);
+ Vector getCenter();
+ void setCenter(const Vector & c);
+ Vector getMajorP();
+ void setMajorP(const Vector & p);
+ double getRatio();
+ void setRatio(double r);
+ virtual double getAngleLength() const;
+ double getMajorRadius() const;
+ double getMinorRadius() const;
+
+ 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 double getDistanceToPoint(const Vector & coord, RS_Entity ** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
+ virtual bool isPointOnEntity(const Vector & coord, double tolerance = RS_TOLERANCE);
+
+ 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_Ellipse & a);
+
+ //virtual void calculateEndpoints();
+ virtual void calculateBorders();
+
+ protected:
+ RS_EllipseData data;