X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fellipse.cpp;h=5d4fbd5cd0895e11346228feb34aa18badcddc15;hb=2ee84c5948ede7fc2f7b4435c5edef42a030ac05;hp=030a73311819cbbfeda5887446678b519d1364e2;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/ellipse.cpp b/src/base/ellipse.cpp index 030a733..5d4fbd5 100644 --- a/src/base/ellipse.cpp +++ b/src/base/ellipse.cpp @@ -25,26 +25,26 @@ /** * Constructor. */ -RS_Ellipse::RS_Ellipse(RS_EntityContainer * parent, const RS_EllipseData & d): - RS_AtomicEntity(parent), data(d) +Ellipse::Ellipse(EntityContainer * parent, const EllipseData & d): + AtomicEntity(parent), data(d) { //calculateEndpoints(); calculateBorders(); } -/*virtual*/ RS_Ellipse::~RS_Ellipse() +/*virtual*/ Ellipse::~Ellipse() { } -/*virtual*/ RS_Entity * RS_Ellipse::clone() +/*virtual*/ Entity * Ellipse::clone() { - RS_Ellipse * e = new RS_Ellipse(*this); + Ellipse * e = new Ellipse(*this); e->initId(); return e; } /** @return RS2::EntityEllipse */ -/*virtual*/ RS2::EntityType RS_Ellipse::rtti() const +/*virtual*/ RS2::EntityType Ellipse::rtti() const { return RS2::EntityEllipse; } @@ -52,7 +52,7 @@ RS_Ellipse::RS_Ellipse(RS_EntityContainer * parent, const RS_EllipseData & d): /** * @return Start point of the entity. */ -/*virtual*/ Vector RS_Ellipse::getStartpoint() const +/*virtual*/ Vector Ellipse::getStartpoint() const { Vector p; p.set(data.center.x + cos(data.angle1) * getMajorRadius(), @@ -64,7 +64,7 @@ RS_Ellipse::RS_Ellipse(RS_EntityContainer * parent, const RS_EllipseData & d): /** * @return End point of the entity. */ -/*virtual*/ Vector RS_Ellipse::getEndpoint() const +/*virtual*/ Vector Ellipse::getEndpoint() const { Vector p; p.set(data.center.x + cos(data.angle2) * getMajorRadius(), @@ -73,7 +73,7 @@ RS_Ellipse::RS_Ellipse(RS_EntityContainer * parent, const RS_EllipseData & d): return p; } -void RS_Ellipse::moveStartpoint(const Vector & pos) +void Ellipse::moveStartpoint(const Vector & pos) { data.angle1 = getEllipseAngle(pos); //data.angle1 = data.center.angleTo(pos); @@ -81,7 +81,7 @@ void RS_Ellipse::moveStartpoint(const Vector & pos) calculateBorders(); } -void RS_Ellipse::moveEndpoint(const Vector & pos) +void Ellipse::moveEndpoint(const Vector & pos) { data.angle2 = getEllipseAngle(pos); //data.angle2 = data.center.angleTo(pos); @@ -89,12 +89,12 @@ void RS_Ellipse::moveEndpoint(const Vector & pos) calculateBorders(); } -RS2::Ending RS_Ellipse::getTrimPoint(const Vector & coord, const Vector & trimPoint) +RS2::Ending Ellipse::getTrimPoint(const Vector & coord, const Vector & trimPoint) { double angEl = getEllipseAngle(trimPoint); double angM = getEllipseAngle(coord); - if (RS_Math::getAngleDifference(angM, angEl) > M_PI) + if (Math::getAngleDifference(angM, angEl) > M_PI) //if (data.reversed) { // return RS2::EndingEnd; //} @@ -110,7 +110,7 @@ RS2::Ending RS_Ellipse::getTrimPoint(const Vector & coord, const Vector & trimPo //} } -double RS_Ellipse::getEllipseAngle(const Vector & pos) +double Ellipse::getEllipseAngle(const Vector & pos) { Vector m = pos; m.rotate(data.center, -data.majorP.angle()); @@ -120,12 +120,12 @@ double RS_Ellipse::getEllipseAngle(const Vector & pos) } /** @return Copy of data that defines the ellipse. **/ -RS_EllipseData RS_Ellipse::getData() +EllipseData Ellipse::getData() { return data; } -VectorSolutions RS_Ellipse::getRefPoints() +VectorSolutions Ellipse::getRefPoints() { VectorSolutions ret(getStartpoint(), getEndpoint(), data.center); return ret; @@ -135,79 +135,79 @@ VectorSolutions RS_Ellipse::getRefPoints() * @retval true if the arc is reversed (clockwise), * @retval false otherwise */ -bool RS_Ellipse::isReversed() const +bool Ellipse::isReversed() const { return data.reversed; } /** sets the reversed status. */ -void RS_Ellipse::setReversed(bool r) +void Ellipse::setReversed(bool r) { data.reversed = r; } /** @return The rotation angle of this ellipse */ -double RS_Ellipse::getAngle() const +double Ellipse::getAngle() const { return data.majorP.angle(); } /** @return The start angle of this arc */ -double RS_Ellipse::getAngle1() +double Ellipse::getAngle1() { return data.angle1; } /** Sets new start angle. */ -void RS_Ellipse::setAngle1(double a1) +void Ellipse::setAngle1(double a1) { data.angle1 = a1; } /** @return The end angle of this arc */ -double RS_Ellipse::getAngle2() +double Ellipse::getAngle2() { return data.angle2; } /** Sets new end angle. */ -void RS_Ellipse::setAngle2(double a2) +void Ellipse::setAngle2(double a2) { data.angle2 = a2; } /** @return The center point (x) of this arc */ -Vector RS_Ellipse::getCenter() +Vector Ellipse::getCenter() { return data.center; } /** Sets new center. */ -void RS_Ellipse::setCenter(const Vector & c) +void Ellipse::setCenter(const Vector & c) { data.center = c; } /** @return The endpoint of the major axis (relative to center). */ -Vector RS_Ellipse::getMajorP() +Vector Ellipse::getMajorP() { return data.majorP; } /** Sets new major point (relative to center). */ -void RS_Ellipse::setMajorP(const Vector & p) +void Ellipse::setMajorP(const Vector & p) { data.majorP = p; } /** @return The ratio of minor to major axis */ -double RS_Ellipse::getRatio() +double Ellipse::getRatio() { return data.ratio; } /** Sets new ratio. */ -void RS_Ellipse::setRatio(double r) +void Ellipse::setRatio(double r) { data.ratio = r; } @@ -215,7 +215,7 @@ void RS_Ellipse::setRatio(double r) /** * @return Angle length in rad. */ -/*virtual*/ double RS_Ellipse::getAngleLength() const +/*virtual*/ double Ellipse::getAngleLength() const { if (isReversed()) return data.angle1 - data.angle2; @@ -224,13 +224,13 @@ void RS_Ellipse::setRatio(double r) } /** @return The major radius of this ellipse. Same as getRadius() */ -double RS_Ellipse::getMajorRadius() const +double Ellipse::getMajorRadius() const { return data.majorP.magnitude(); } /** @return The minor radius of this ellipse */ -double RS_Ellipse::getMinorRadius() const +double Ellipse::getMinorRadius() const { return data.majorP.magnitude() * data.ratio; } @@ -239,7 +239,7 @@ double RS_Ellipse::getMinorRadius() const * Recalculates the endpoints using the angles and the radius. */ /* - void RS_Ellipse::calculateEndpoints() { + void Ellipse::calculateEndpoints() { double angle = data.majorP.angle(); double radius1 = getMajorRadius(); double radius2 = getMinorRadius(); @@ -258,9 +258,9 @@ double RS_Ellipse::getMinorRadius() const * * @todo Fix that - the algorithm used is really bad / slow. */ -void RS_Ellipse::calculateBorders() +void Ellipse::calculateBorders() { - RS_DEBUG->print("RS_Ellipse::calculateBorders"); + DEBUG->print("Ellipse::calculateBorders"); double radius1 = getMajorRadius(); double radius2 = getMinorRadius(); @@ -292,15 +292,15 @@ void RS_Ellipse::calculateBorders() a += 0.03; } - while (RS_Math::isAngleBetween(RS_Math::correctAngle(a), a1, a2, false) + while (Math::isAngleBetween(Math::correctAngle(a), a1, a2, false) && a < 4 * M_PI); minV.set(minX, minY); maxV.set(maxX, maxY); - RS_DEBUG->print("RS_Ellipse::calculateBorders: OK"); + DEBUG->print("Ellipse::calculateBorders: OK"); } -Vector RS_Ellipse::getNearestEndpoint(const Vector & coord, double * dist) +Vector Ellipse::getNearestEndpoint(const Vector & coord, double * dist) { double dist1, dist2; Vector nearerPoint; @@ -326,9 +326,9 @@ Vector RS_Ellipse::getNearestEndpoint(const Vector & coord, double * dist) return nearerPoint; } -Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, RS_Entity * * entity) +Vector Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, Entity * * entity) { - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity"); + DEBUG->print("Ellipse::getNearestPointOnEntity"); Vector ret(false); @@ -376,7 +376,7 @@ Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, for (i = 0; i < iMax; i++) { - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: i: %d", i); + DEBUG->print("Ellipse::getNearestPointOnEntity: i: %d", i); double dTpASqr = dT + dA * dA; double dTpBSqr = dT + dB * dB; double dInvTpASqr = 1.0 / dTpASqr; @@ -386,7 +386,7 @@ Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, double dXDivASqr = dXDivA * dXDivA; double dYDivBSqr = dYDivB * dYDivB; double dF = dXDivASqr + dYDivBSqr - 1.0; - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: dF: %f", dF); + DEBUG->print("Ellipse::getNearestPointOnEntity: dF: %f", dF); if (fabs(dF) < dEpsilon) { @@ -394,12 +394,12 @@ Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, rdX = dXDivA * dA; rdY = dYDivB * dB; riIFinal = i; - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 1: %f,%f", rdX, rdY); + DEBUG->print("Ellipse::getNearestPointOnEntity: rdX,rdY 1: %f,%f", rdX, rdY); break; } double dFDer = 2.0 * (dXDivASqr * dInvTpASqr + dYDivBSqr * dInvTpBSqr); double dRatio = dF / dFDer; - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: dRatio: %f", dRatio); + DEBUG->print("Ellipse::getNearestPointOnEntity: dRatio: %f", dRatio); if (fabs(dRatio) < dEpsilon) { @@ -407,7 +407,7 @@ Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, rdX = dXDivA * dA; rdY = dYDivB * dB; riIFinal = i; - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY); + DEBUG->print("Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY); break; } dT += dRatio; @@ -416,7 +416,7 @@ Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, if (i == iMax) { // failed to converge: - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: failed"); + DEBUG->print("Ellipse::getNearestPointOnEntity: failed"); dDistance = RS_MAXDOUBLE; } else @@ -425,8 +425,8 @@ Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, double dDelta1 = rdY - dV; dDistance = sqrt(dDelta0 * dDelta0 + dDelta1 * dDelta1); ret = Vector(rdX, rdY); - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY); - RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: ret: %f,%f", ret.x, ret.y); + DEBUG->print("Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY); + DEBUG->print("Ellipse::getNearestPointOnEntity: ret: %f,%f", ret.x, ret.y); } if (dist != NULL) @@ -457,7 +457,7 @@ Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, double a2 = data.center.angleTo(getEndpoint()); double a = data.center.angleTo(ret); - if (!RS_Math::isAngleBetween(a, a1, a2, data.reversed)) + if (!Math::isAngleBetween(a, a1, a2, data.reversed)) ret = Vector(false); } } @@ -471,13 +471,13 @@ Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, * @retval true if the given point is on this entity. * @retval false otherwise */ -bool RS_Ellipse::isPointOnEntity(const Vector & coord, double tolerance) +bool Ellipse::isPointOnEntity(const Vector & coord, double tolerance) { double dist = getDistanceToPoint(coord, NULL, RS2::ResolveNone); return (dist <= tolerance); } -Vector RS_Ellipse::getNearestCenter(const Vector & coord, double * dist) +Vector Ellipse::getNearestCenter(const Vector & coord, double * dist) { if (dist != NULL) *dist = coord.distanceTo(data.center); @@ -487,21 +487,21 @@ Vector RS_Ellipse::getNearestCenter(const Vector & coord, double * dist) /** * @todo Implement this. */ -Vector RS_Ellipse::getNearestMiddle(const Vector & /*coord*/, double * dist) +Vector Ellipse::getNearestMiddle(const Vector & /*coord*/, double * dist) { if (dist != NULL) *dist = RS_MAXDOUBLE; return Vector(false); } -Vector RS_Ellipse::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist) +Vector Ellipse::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist) { if (dist != NULL) *dist = RS_MAXDOUBLE; return Vector(false); } -double RS_Ellipse::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel, double /*solidDist*/) +double Ellipse::getDistanceToPoint(const Vector & coord, Entity * * entity, RS2::ResolveLevel, double /*solidDist*/) { double dist = RS_MAXDOUBLE; getNearestPointOnEntity(coord, true, &dist, entity); @@ -509,14 +509,14 @@ double RS_Ellipse::getDistanceToPoint(const Vector & coord, RS_Entity * * entity return dist; } -void RS_Ellipse::move(Vector offset) +void Ellipse::move(Vector offset) { data.center.move(offset); //calculateEndpoints(); calculateBorders(); } -void RS_Ellipse::rotate(Vector center, double angle) +void Ellipse::rotate(Vector center, double angle) { data.center.rotate(center, angle); data.majorP.rotate(angle); @@ -524,7 +524,7 @@ void RS_Ellipse::rotate(Vector center, double angle) calculateBorders(); } -void RS_Ellipse::scale(Vector center, Vector factor) +void Ellipse::scale(Vector center, Vector factor) { data.center.scale(center, factor); data.majorP.scale(factor); @@ -535,7 +535,7 @@ void RS_Ellipse::scale(Vector center, Vector factor) /** * @todo deal with angles correctly */ -void RS_Ellipse::mirror(Vector axisPoint1, Vector axisPoint2) +void Ellipse::mirror(Vector axisPoint1, Vector axisPoint2) { Vector mp = data.center + data.majorP; @@ -561,7 +561,7 @@ void RS_Ellipse::mirror(Vector axisPoint1, Vector axisPoint2) calculateBorders(); } -void RS_Ellipse::moveRef(const Vector & ref, const Vector & offset) +void Ellipse::moveRef(const Vector & ref, const Vector & offset) { Vector startpoint = getStartpoint(); Vector endpoint = getEndpoint(); @@ -574,7 +574,7 @@ void RS_Ellipse::moveRef(const Vector & ref, const Vector & offset) moveEndpoint(endpoint + offset); } -void RS_Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/) +void Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/) { if (!painter || !view) return; @@ -599,7 +599,7 @@ void RS_Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*pat } // Pattern: - RS_LineTypePattern * pat; + LineTypePattern * pat; if (isSelected()) pat = &patternSelected; @@ -610,7 +610,7 @@ void RS_Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*pat return; // Pen to draw pattern is always solid: - RS_Pen pen = painter->getPen(); + Pen pen = painter->getPen(); pen.setLineType(RS2::SolidLine); painter->setPen(pen); @@ -633,8 +633,8 @@ void RS_Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*pat do { - curR = sqrt(RS_Math::pow(getMinorRadius() * cos(curA), 2.0) - + RS_Math::pow(getMajorRadius() * sin(curA), 2.0)); + curR = sqrt(Math::pow(getMinorRadius() * cos(curA), 2.0) + + Math::pow(getMajorRadius() * sin(curA), 2.0)); if (curR > 1.0e-6) { @@ -667,7 +667,7 @@ void RS_Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*pat /** * Dumps the point's data to stdout. */ -std::ostream & operator<<(std::ostream & os, const RS_Ellipse & a) +std::ostream & operator<<(std::ostream & os, const Ellipse & a) { os << " Ellipse: " << a.data << "\n"; return os;