X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Farc.cpp;fp=src%2Fbase%2Farc.cpp;h=1a62eba9e81c8f7096e6082d56d5215e5cd0013e;hb=16354e0421b316a62c6b9f7b0b4f3b8cf6f06284;hp=e21a998eeee7bb365420609f22616e398097bac5;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/arc.cpp b/src/base/arc.cpp index e21a998..1a62eba 100644 --- a/src/base/arc.cpp +++ b/src/base/arc.cpp @@ -28,98 +28,98 @@ /** * Default constructor. */ -RS_Arc::RS_Arc(RS_EntityContainer * parent, const RS_ArcData & d): - RS_AtomicEntity(parent), data(d) +Arc::Arc(EntityContainer * parent, const ArcData & d): + AtomicEntity(parent), data(d) { calculateEndpoints(); calculateBorders(); } -/*virtual*/ RS_Arc::~RS_Arc() +/*virtual*/ Arc::~Arc() { } -/*virtual*/ RS_Entity * RS_Arc::clone() +/*virtual*/ Entity * Arc::clone() { - RS_Arc * a = new RS_Arc(*this); + Arc * a = new Arc(*this); a->initId(); return a; } /** @return RS2::EntityArc */ -/*virtual*/ RS2::EntityType RS_Arc::rtti() const +/*virtual*/ RS2::EntityType Arc::rtti() const { return RS2::EntityArc; } /** @return true */ -/*virtual*/ bool RS_Arc::isEdge() const +/*virtual*/ bool Arc::isEdge() const { return true; } /** @return Copy of data that defines the arc. **/ -RS_ArcData RS_Arc::getData() const +ArcData Arc::getData() const { return data; } -/*virtual*/ VectorSolutions RS_Arc::getRefPoints() +/*virtual*/ VectorSolutions Arc::getRefPoints() { VectorSolutions ret(startpoint, endpoint, data.center); return ret; } /** Sets new arc parameters. **/ -void RS_Arc::setData(RS_ArcData d) +void Arc::setData(ArcData d) { data = d; } /** @return The center point (x) of this arc */ -Vector RS_Arc::getCenter() const +Vector Arc::getCenter() const { return data.center; } /** Sets new center. */ -void RS_Arc::setCenter(const Vector & c) +void Arc::setCenter(const Vector & c) { data.center = c; } /** @return The radius of this arc */ -double RS_Arc::getRadius() const +double Arc::getRadius() const { return data.radius; } /** Sets new radius. */ -void RS_Arc::setRadius(double r) +void Arc::setRadius(double r) { data.radius = r; } /** @return The start angle of this arc */ -double RS_Arc::getAngle1() const +double Arc::getAngle1() const { return data.angle1; } /** Sets new start angle. */ -void RS_Arc::setAngle1(double a1) +void Arc::setAngle1(double a1) { data.angle1 = a1; } /** @return The end angle of this arc */ -double RS_Arc::getAngle2() const +double Arc::getAngle2() const { return data.angle2; } /** Sets new end angle. */ -void RS_Arc::setAngle2(double a2) +void Arc::setAngle2(double a2) { data.angle2 = a2; } @@ -128,49 +128,49 @@ void RS_Arc::setAngle2(double a2) * @return Direction 1. The angle at which the arc starts at * the startpoint. */ -double RS_Arc::getDirection1() const +double Arc::getDirection1() const { if (!data.reversed) - return RS_Math::correctAngle(data.angle1 + M_PI / 2.0); + return Math::correctAngle(data.angle1 + M_PI / 2.0); - return RS_Math::correctAngle(data.angle1 - M_PI / 2.0); + return Math::correctAngle(data.angle1 - M_PI / 2.0); } /** * @return Direction 2. The angle at which the arc starts at * the endpoint. */ -double RS_Arc::getDirection2() const +double Arc::getDirection2() const { if (!data.reversed) - return RS_Math::correctAngle(data.angle2 - M_PI / 2.0); + return Math::correctAngle(data.angle2 - M_PI / 2.0); - return RS_Math::correctAngle(data.angle2 + M_PI / 2.0); + return Math::correctAngle(data.angle2 + M_PI / 2.0); } /** * @retval true if the arc is reversed (clockwise), * @retval false otherwise */ -bool RS_Arc::isReversed() const +bool Arc::isReversed() const { return data.reversed; } /** sets the reversed status. */ -void RS_Arc::setReversed(bool r) +void Arc::setReversed(bool r) { data.reversed = r; } /** @return Start point of the entity. */ -/*virtual*/ Vector RS_Arc::getStartpoint() const +/*virtual*/ Vector Arc::getStartpoint() const { return startpoint; } /** @return End point of the entity. */ -/*virtual*/ Vector RS_Arc::getEndpoint() const +/*virtual*/ Vector Arc::getEndpoint() const { return endpoint; } @@ -182,7 +182,7 @@ void RS_Arc::setReversed(bool r) * @param p2 2nd point. * @param p3 3rd point. */ -bool RS_Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3) +bool Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3) { if (p1.distanceTo(p2) > RS_TOLERANCE && p2.distanceTo(p3) > RS_TOLERANCE @@ -201,19 +201,19 @@ bool RS_Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p a2 = p2.angleTo(p3) + M_PI / 2.0; dir2.setPolar(100.0, a2); - RS_ConstructionLineData d1(mp1, mp1 + dir1); - RS_ConstructionLineData d2(mp2, mp2 + dir2); - RS_ConstructionLine midLine1(NULL, d1); - RS_ConstructionLine midLine2(NULL, d2); + ConstructionLineData d1(mp1, mp1 + dir1); + ConstructionLineData d2(mp2, mp2 + dir2); + ConstructionLine midLine1(NULL, d1); + ConstructionLine midLine2(NULL, d2); VectorSolutions sol = - RS_Information::getIntersection(&midLine1, &midLine2); + Information::getIntersection(&midLine1, &midLine2); data.center = sol.get(0); data.radius = data.center.distanceTo(p3); data.angle1 = data.center.angleTo(p1); data.angle2 = data.center.angleTo(p3); - data.reversed = RS_Math::isAngleBetween(data.center.angleTo(p2), + data.reversed = Math::isAngleBetween(data.center.angleTo(p2), data.angle1, data.angle2, true); if (sol.get(0).valid && data.radius < 1.0e14 @@ -225,14 +225,14 @@ bool RS_Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p } else { - RS_DEBUG->print("RS_Arc::createFrom3P(): " + DEBUG->print("Arc::createFrom3P(): " "Cannot create an arc with inf radius."); return false; } } else { - RS_DEBUG->print("RS_Arc::createFrom3P(): " + DEBUG->print("Arc::createFrom3P(): " "Cannot create an arc with radius 0.0."); return false; } @@ -245,7 +245,7 @@ bool RS_Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p * @retval true Successfully created arc * @retval false Cannot creats arc (radius to small or endpoint to far away) */ -bool RS_Arc::createFrom2PDirectionRadius(const Vector & startPoint, const Vector & endPoint, double direction1, double radius) +bool Arc::createFrom2PDirectionRadius(const Vector & startPoint, const Vector & endPoint, double direction1, double radius) { Vector ortho; ortho.setPolar(radius, direction1 + M_PI / 2.0); @@ -262,7 +262,7 @@ bool RS_Arc::createFrom2PDirectionRadius(const Vector & startPoint, const Vector data.angle2 = data.center.angleTo(endPoint); data.reversed = false; - double diff = RS_Math::correctAngle(getDirection1() - direction1); + double diff = Math::correctAngle(getDirection1() - direction1); if (fabs(diff - M_PI) < 1.0e-1) data.reversed = true; @@ -276,7 +276,7 @@ bool RS_Arc::createFrom2PDirectionRadius(const Vector & startPoint, const Vector /** * Creates an arc from its startpoint, endpoint and bulge. */ -bool RS_Arc::createFrom2PBulge(const Vector & startPoint, const Vector & endPoint, double bulge) +bool Arc::createFrom2PBulge(const Vector & startPoint, const Vector & endPoint, double bulge) { data.reversed = (bulge < 0.0); double alpha = atan(bulge) * 4.0; @@ -287,7 +287,7 @@ bool RS_Arc::createFrom2PBulge(const Vector & startPoint, const Vector & endPoin // alpha can't be 0.0 at this point data.radius = fabs(dist / sin(alpha / 2.0)); - double wu = fabs(RS_Math::pow(data.radius, 2.0) - RS_Math::pow(dist, 2.0)); + double wu = fabs(Math::pow(data.radius, 2.0) - Math::pow(dist, 2.0)); double h = sqrt(wu); double angle = startPoint.angleTo(endPoint); @@ -313,7 +313,7 @@ bool RS_Arc::createFrom2PBulge(const Vector & startPoint, const Vector & endPoin /** * Recalculates the endpoints using the angles and the radius. */ -void RS_Arc::calculateEndpoints() +void Arc::calculateEndpoints() { startpoint.set(data.center.x + cos(data.angle1) * data.radius, data.center.y + sin(data.angle1) * data.radius); @@ -321,7 +321,7 @@ void RS_Arc::calculateEndpoints() data.center.y + sin(data.angle2) * data.radius); } -void RS_Arc::calculateBorders() +void Arc::calculateBorders() { double minX = std::min(startpoint.x, endpoint.x); double minY = std::min(startpoint.y, endpoint.y); @@ -360,7 +360,7 @@ void RS_Arc::calculateBorders() maxV.set(maxX, maxY); } -Vector RS_Arc::getNearestEndpoint(const Vector & coord, double * dist) +Vector Arc::getNearestEndpoint(const Vector & coord, double * dist) { double dist1, dist2; Vector * nearerPoint; @@ -384,7 +384,7 @@ Vector RS_Arc::getNearestEndpoint(const Vector & coord, double * dist) return *nearerPoint; } -Vector RS_Arc::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, RS_Entity * * entity) +Vector Arc::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, Entity * * entity) { Vector vec(false); @@ -393,7 +393,7 @@ Vector RS_Arc::getNearestPointOnEntity(const Vector & coord, bool onEntity, doub double angle = (coord - data.center).angle(); - if (onEntity == false || RS_Math::isAngleBetween(angle, + if (onEntity == false || Math::isAngleBetween(angle, data.angle1, data.angle2, isReversed())) { vec.setPolar(data.radius, angle); @@ -406,14 +406,14 @@ Vector RS_Arc::getNearestPointOnEntity(const Vector & coord, bool onEntity, doub return vec; } -Vector RS_Arc::getNearestCenter(const Vector & coord, double * dist) +Vector Arc::getNearestCenter(const Vector & coord, double * dist) { if (dist != NULL) *dist = coord.distanceTo(data.center); return data.center; } -Vector RS_Arc::getNearestMiddle(const Vector & coord, double * dist) +Vector Arc::getNearestMiddle(const Vector & coord, double * dist) { Vector ret = getMiddlepoint(); @@ -422,7 +422,7 @@ Vector RS_Arc::getNearestMiddle(const Vector & coord, double * dist) return ret; } -Vector RS_Arc::getNearestDist(double distance, const Vector & coord, double * dist) +Vector Arc::getNearestDist(double distance, const Vector & coord, double * dist) { if (data.radius < 1.0e-6) { @@ -473,7 +473,7 @@ Vector RS_Arc::getNearestDist(double distance, const Vector & coord, double * di return *nearerPoint; } -Vector RS_Arc::getNearestDist(double distance, bool startp) +Vector Arc::getNearestDist(double distance, bool startp) { if (data.radius < 1.0e-6) return Vector(false); @@ -503,7 +503,7 @@ Vector RS_Arc::getNearestDist(double distance, bool startp) return p; } -double RS_Arc::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel, double) +double Arc::getDistanceToPoint(const Vector & coord, Entity * * entity, RS2::ResolveLevel, double) { if (entity != NULL) *entity = this; @@ -518,7 +518,7 @@ double RS_Arc::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS if (dist < 1.0e-4) return dist; - if (RS_Math::isAngleBetween(data.center.angleTo(coord), + if (Math::isAngleBetween(data.center.angleTo(coord), data.angle1, data.angle2, isReversed())) @@ -527,7 +527,7 @@ double RS_Arc::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS return RS_MAXDOUBLE; } -void RS_Arc::moveStartpoint(const Vector & pos) +void Arc::moveStartpoint(const Vector & pos) { // polyline arcs: move point not angle: //if (parent!=NULL && parent->rtti()==RS2::EntityPolyline) { @@ -543,7 +543,7 @@ void RS_Arc::moveStartpoint(const Vector & pos) }*/ } -void RS_Arc::moveEndpoint(const Vector & pos) +void Arc::moveEndpoint(const Vector & pos) { // polyline arcs: move point not angle: //if (parent!=NULL && parent->rtti()==RS2::EntityPolyline) { @@ -559,26 +559,26 @@ void RS_Arc::moveEndpoint(const Vector & pos) }*/ } -void RS_Arc::trimStartpoint(const Vector & pos) +void Arc::trimStartpoint(const Vector & pos) { data.angle1 = data.center.angleTo(pos); calculateEndpoints(); calculateBorders(); } -void RS_Arc::trimEndpoint(const Vector & pos) +void Arc::trimEndpoint(const Vector & pos) { data.angle2 = data.center.angleTo(pos); calculateEndpoints(); calculateBorders(); } -RS2::Ending RS_Arc::getTrimPoint(const Vector & coord, const Vector & trimPoint) +RS2::Ending Arc::getTrimPoint(const Vector & coord, const Vector & trimPoint) { double angEl = data.center.angleTo(trimPoint); double angM = data.center.angleTo(coord); - if (RS_Math::getAngleDifference(angM, angEl) > M_PI) + if (Math::getAngleDifference(angM, angEl) > M_PI) { if (data.reversed) return RS2::EndingEnd; @@ -594,7 +594,7 @@ RS2::Ending RS_Arc::getTrimPoint(const Vector & coord, const Vector & trimPoint) } } -void RS_Arc::reverse() +void Arc::reverse() { double a = data.angle1; data.angle1 = data.angle2; @@ -604,25 +604,25 @@ void RS_Arc::reverse() calculateBorders(); } -void RS_Arc::move(Vector offset) +void Arc::move(Vector offset) { data.center.move(offset); calculateEndpoints(); calculateBorders(); } -void RS_Arc::rotate(Vector center, double angle) +void Arc::rotate(Vector center, double angle) { - RS_DEBUG->print("RS_Arc::rotate"); + DEBUG->print("Arc::rotate"); data.center.rotate(center, angle); - data.angle1 = RS_Math::correctAngle(data.angle1 + angle); - data.angle2 = RS_Math::correctAngle(data.angle2 + angle); + data.angle1 = Math::correctAngle(data.angle1 + angle); + data.angle2 = Math::correctAngle(data.angle2 + angle); calculateEndpoints(); calculateBorders(); - RS_DEBUG->print("RS_Arc::rotate: OK"); + DEBUG->print("Arc::rotate: OK"); } -void RS_Arc::scale(Vector center, Vector factor) +void Arc::scale(Vector center, Vector factor) { // negative scaling: mirroring if (factor.x < 0.0) @@ -643,7 +643,7 @@ void RS_Arc::scale(Vector center, Vector factor) calculateBorders(); } -void RS_Arc::mirror(Vector axisPoint1, Vector axisPoint2) +void Arc::mirror(Vector axisPoint1, Vector axisPoint2) { data.center.mirror(axisPoint1, axisPoint2); data.reversed = (!data.reversed); @@ -668,7 +668,7 @@ void RS_Arc::mirror(Vector axisPoint1, Vector axisPoint2) calculateBorders(); } -void RS_Arc::moveRef(const Vector & ref, const Vector & offset) +void Arc::moveRef(const Vector & ref, const Vector & offset) { if (ref.distanceTo(startpoint) < 1.0e-4) moveStartpoint(startpoint + offset); @@ -678,7 +678,7 @@ void RS_Arc::moveRef(const Vector & ref, const Vector & offset) moveEndpoint(endpoint + offset); } -void RS_Arc::stretch(Vector firstCorner, Vector secondCorner, Vector offset) +void Arc::stretch(Vector firstCorner, Vector secondCorner, Vector offset) { if (getMin().isInWindow(firstCorner, secondCorner) && getMax().isInWindow(firstCorner, secondCorner)) @@ -697,7 +697,7 @@ void RS_Arc::stretch(Vector firstCorner, Vector secondCorner, Vector offset) } } -void RS_Arc::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/) +void Arc::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/) { if (painter == NULL || view == NULL) return; @@ -727,7 +727,7 @@ void RS_Arc::draw(PaintInterface * painter, GraphicView * view, double /*pattern } // Pattern: - RS_LineTypePattern * pat; + LineTypePattern * pat; if (isSelected()) pat = &patternSelected; @@ -741,7 +741,7 @@ void RS_Arc::draw(PaintInterface * painter, GraphicView * view, double /*pattern return; // Pen to draw pattern is always solid: - RS_Pen pen = painter->getPen(); + Pen pen = painter->getPen(); pen.setLineType(RS2::SolidLine); painter->setPen(pen); @@ -812,7 +812,7 @@ void RS_Arc::draw(PaintInterface * painter, GraphicView * view, double /*pattern /** * @return Middle point of the entity. */ -Vector RS_Arc::getMiddlepoint() const +Vector Arc::getMiddlepoint() const { double a; Vector ret; @@ -830,7 +830,7 @@ Vector RS_Arc::getMiddlepoint() const /** * @return Angle length in rad. */ -double RS_Arc::getAngleLength() const +double Arc::getAngleLength() const { double ret = 0.0; @@ -859,7 +859,7 @@ double RS_Arc::getAngleLength() const /** * @return Length of the arc. */ -double RS_Arc::getLength() +double Arc::getLength() { return getAngleLength() * data.radius; } @@ -867,7 +867,7 @@ double RS_Arc::getLength() /** * Gets the arc's bulge (tangens of angle length divided by 4). */ -double RS_Arc::getBulge() const +double Arc::getBulge() const { double bulge = tan(fabs(getAngleLength()) / 4.0); @@ -879,7 +879,7 @@ double RS_Arc::getBulge() const /** * Dumps the point's data to stdout. */ -std::ostream & operator<<(std::ostream & os, const RS_Arc & a) +std::ostream & operator<<(std::ostream & os, const Arc & a) { os << " Arc: " << a.data << "\n"; return os;