X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fline.cpp;fp=src%2Fbase%2Fline.cpp;h=918d6e7c0da31ee29c075e7fbc91289de71cc30f;hb=16354e0421b316a62c6b9f7b0b4f3b8cf6f06284;hp=7b8404c2b46f9208268fb793a94bb7fced4620e0;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/line.cpp b/src/base/line.cpp index 7b8404c..918d6e7 100644 --- a/src/base/line.cpp +++ b/src/base/line.cpp @@ -25,8 +25,8 @@ /** * Constructor. */ -RS_Line::RS_Line(RS_EntityContainer * parent, const RS_LineData & d): - RS_AtomicEntity(parent), data(d) +Line::Line(EntityContainer * parent, const LineData & d): + AtomicEntity(parent), data(d) { calculateBorders(); } @@ -34,68 +34,68 @@ RS_Line::RS_Line(RS_EntityContainer * parent, const RS_LineData & d): /** * Destructor. */ -RS_Line::~RS_Line() +Line::~Line() { } -RS_Entity * RS_Line::clone() +Entity * Line::clone() { - RS_Line * l = new RS_Line(*this); + Line * l = new Line(*this); l->initId(); return l; } -void RS_Line::calculateBorders() +void Line::calculateBorders() { minV = Vector::minimum(data.startpoint, data.endpoint); maxV = Vector::maximum(data.startpoint, data.endpoint); } /** @return RS2::EntityLine */ -RS2::EntityType RS_Line::rtti() const +RS2::EntityType Line::rtti() const { return RS2::EntityLine; } /** @return true */ -bool RS_Line::isEdge() const +bool Line::isEdge() const { return true; } /** @return Copy of data that defines the line. */ -RS_LineData RS_Line::getData() const +LineData Line::getData() const { return data; } -VectorSolutions RS_Line::getRefPoints() +VectorSolutions Line::getRefPoints() { VectorSolutions ret(data.startpoint, data.endpoint); return ret; } /** @return Start point of the entity */ -Vector RS_Line::getStartpoint() const +Vector Line::getStartpoint() const { return data.startpoint; } /** @return End point of the entity */ -Vector RS_Line::getEndpoint() const +Vector Line::getEndpoint() const { return data.endpoint; } /** Sets the startpoint */ -void RS_Line::setStartpoint(Vector s) +void Line::setStartpoint(Vector s) { data.startpoint = s; calculateBorders(); } /** Sets the endpoint */ -void RS_Line::setEndpoint(Vector e) +void Line::setEndpoint(Vector e) { data.endpoint = e; calculateBorders(); @@ -105,7 +105,7 @@ void RS_Line::setEndpoint(Vector e) * @return Direction 1. The angle at which the line starts at * the startpoint. */ -double RS_Line::getDirection1() const +double Line::getDirection1() const { return getAngle1(); } @@ -114,12 +114,12 @@ double RS_Line::getDirection1() const * @return Direction 2. The angle at which the line starts at * the endpoint. */ -double RS_Line::getDirection2() const +double Line::getDirection2() const { return getAngle2(); } -Vector RS_Line::getNearestEndpoint(const Vector & coord, double * dist) +Vector Line::getNearestEndpoint(const Vector & coord, double * dist) { double dist1, dist2; Vector * nearerPoint; @@ -145,8 +145,8 @@ Vector RS_Line::getNearestEndpoint(const Vector & coord, double * dist) return *nearerPoint; } -Vector RS_Line::getNearestPointOnEntity(const Vector & coord, - bool onEntity, double * dist, RS_Entity ** entity) +Vector Line::getNearestPointOnEntity(const Vector & coord, + bool onEntity, double * dist, Entity ** entity) { if (entity != NULL) *entity = this; @@ -182,7 +182,7 @@ Vector RS_Line::getNearestPointOnEntity(const Vector & coord, } } -Vector RS_Line::getNearestCenter(const Vector & coord, double * dist) +Vector Line::getNearestCenter(const Vector & coord, double * dist) { Vector p = (data.startpoint + data.endpoint) / 2.0; @@ -192,12 +192,12 @@ Vector RS_Line::getNearestCenter(const Vector & coord, double * dist) return p; } -Vector RS_Line::getNearestMiddle(const Vector & coord, double * dist) +Vector Line::getNearestMiddle(const Vector & coord, double * dist) { return getNearestCenter(coord, dist); } -Vector RS_Line::getNearestDist(double distance, const Vector & coord, double * dist) +Vector Line::getNearestDist(double distance, const Vector & coord, double * dist) { double a1 = getAngle1(); @@ -235,7 +235,7 @@ Vector RS_Line::getNearestDist(double distance, const Vector & coord, double * d return *nearerPoint; } -Vector RS_Line::getNearestDist(double distance, bool startp) +Vector Line::getNearestDist(double distance, bool startp) { double a1 = getAngle1(); @@ -251,7 +251,7 @@ Vector RS_Line::getNearestDist(double distance, bool startp) return ret; } -/*Vector RS_Line::getNearestRef(const Vector& coord, double* dist) +/*Vector Line::getNearestRef(const Vector& coord, double* dist) { double d1, d2, d; Vector p; @@ -273,10 +273,10 @@ Vector RS_Line::getNearestDist(double distance, bool startp) return p; }*/ -double RS_Line::getDistanceToPoint(const Vector & coord, RS_Entity ** entity, +double Line::getDistanceToPoint(const Vector & coord, Entity ** entity, RS2::ResolveLevel /*level*/, double /*solidDist*/) { - RS_DEBUG->print("RS_Line::getDistanceToPoint"); + DEBUG->print("Line::getDistanceToPoint"); if (entity != NULL) *entity = this; @@ -286,7 +286,7 @@ double RS_Line::getDistanceToPoint(const Vector & coord, RS_Entity ** entity, if (dist < 1.0e-4) { - RS_DEBUG->print("RS_Line::getDistanceToPoint: OK1"); + DEBUG->print("Line::getDistanceToPoint: OK1"); return dist; } @@ -294,7 +294,7 @@ double RS_Line::getDistanceToPoint(const Vector & coord, RS_Entity ** entity, if (dist < 1.0e-4) { - RS_DEBUG->print("RS_Line::getDistanceToPoint: OK2"); + DEBUG->print("Line::getDistanceToPoint: OK2"); return dist; } @@ -306,46 +306,46 @@ double RS_Line::getDistanceToPoint(const Vector & coord, RS_Entity ** entity, if (ae.magnitude() < 1.0e-6 || ea.magnitude() < 1.0e-6) { - RS_DEBUG->print("RS_Line::getDistanceToPoint: OK2a"); + DEBUG->print("Line::getDistanceToPoint: OK2a"); return dist; } // Orthogonal projection from both sides: - Vector ba = ae * Vector::dotP(ae, ap) / RS_Math::pow(ae.magnitude(), 2); - Vector be = ea * Vector::dotP(ea, ep) / RS_Math::pow(ea.magnitude(), 2); + Vector ba = ae * Vector::dotP(ae, ap) / Math::pow(ae.magnitude(), 2); + Vector be = ea * Vector::dotP(ea, ep) / Math::pow(ea.magnitude(), 2); // Check if the projection is outside this line: if (ba.magnitude() > ae.magnitude() || be.magnitude() > ea.magnitude()) { // return distance to endpoint getNearestEndpoint(coord, &dist); - RS_DEBUG->print("RS_Line::getDistanceToPoint: OK3"); + DEBUG->print("Line::getDistanceToPoint: OK3"); return dist; } - //RS_DEBUG->print("ba: %f", ba.magnitude()); - //RS_DEBUG->print("ae: %f", ae.magnitude()); + //DEBUG->print("ba: %f", ba.magnitude()); + //DEBUG->print("ae: %f", ae.magnitude()); Vector cp = Vector::crossP(ap, ae); dist = cp.magnitude() / ae.magnitude(); - RS_DEBUG->print("RS_Line::getDistanceToPoint: OK4"); + DEBUG->print("Line::getDistanceToPoint: OK4"); return dist; } -void RS_Line::moveStartpoint(const Vector & pos) +void Line::moveStartpoint(const Vector & pos) { data.startpoint = pos; calculateBorders(); } -void RS_Line::moveEndpoint(const Vector & pos) +void Line::moveEndpoint(const Vector & pos) { data.endpoint = pos; calculateBorders(); } -RS2::Ending RS_Line::getTrimPoint(const Vector & coord, const Vector & trimPoint) +RS2::Ending Line::getTrimPoint(const Vector & coord, const Vector & trimPoint) { double angEl = getAngle1(); double angM = trimPoint.angleTo(coord); @@ -363,7 +363,7 @@ RS2::Ending RS_Line::getTrimPoint(const Vector & coord, const Vector & trimPoint return RS2::EndingEnd; } -void RS_Line::reverse() +void Line::reverse() { Vector v = data.startpoint; data.startpoint = data.endpoint; @@ -371,20 +371,20 @@ void RS_Line::reverse() } /** @return the center point of the line. */ -Vector RS_Line::getMiddlepoint() +Vector Line::getMiddlepoint() { return (data.startpoint + data.endpoint) / 2.0; } /** Sets the y coordinate of the startpoint */ -void RS_Line::setStartpointY(double val) +void Line::setStartpointY(double val) { data.startpoint.y = val; calculateBorders(); } /** Sets the y coordinate of the endpoint */ -void RS_Line::setEndpointY(double val) +void Line::setEndpointY(double val) { data.endpoint.y = val; calculateBorders(); @@ -393,7 +393,7 @@ void RS_Line::setEndpointY(double val) /** * @return The length of the line. */ -double RS_Line::getLength() +double Line::getLength() { return data.startpoint.distanceTo(data.endpoint); } @@ -401,7 +401,7 @@ double RS_Line::getLength() /** * @return The angle of the line (from start to endpoint). */ -double RS_Line::getAngle1() const +double Line::getAngle1() const { return data.startpoint.angleTo(data.endpoint); } @@ -409,12 +409,12 @@ double RS_Line::getAngle1() const /** * @return The angle of the line (from end to startpoint). */ -double RS_Line::getAngle2() const +double Line::getAngle2() const { return data.endpoint.angleTo(data.startpoint); } -bool RS_Line::hasEndpointsWithinWindow(Vector v1, Vector v2) +bool Line::hasEndpointsWithinWindow(Vector v1, Vector v2) { if (data.startpoint.isInWindow(v1, v2) || data.endpoint.isInWindow(v1, v2)) return true; @@ -422,43 +422,43 @@ bool RS_Line::hasEndpointsWithinWindow(Vector v1, Vector v2) return false; } -void RS_Line::move(Vector offset) +void Line::move(Vector offset) { - RS_DEBUG->print("RS_Line::move1: sp: %f/%f, ep: %f/%f", + DEBUG->print("Line::move1: sp: %f/%f, ep: %f/%f", data.startpoint.x, data.startpoint.y, data.endpoint.x, data.endpoint.y); - RS_DEBUG->print("RS_Line::move1: offset: %f/%f", offset.x, offset.y); + DEBUG->print("Line::move1: offset: %f/%f", offset.x, offset.y); data.startpoint.move(offset); data.endpoint.move(offset); calculateBorders(); - RS_DEBUG->print("RS_Line::move2: sp: %f/%f, ep: %f/%f", + DEBUG->print("Line::move2: sp: %f/%f, ep: %f/%f", data.startpoint.x, data.startpoint.y, data.endpoint.x, data.endpoint.y); } -void RS_Line::rotate(Vector center, double angle) +void Line::rotate(Vector center, double angle) { - RS_DEBUG->print("RS_Line::rotate"); - RS_DEBUG->print("RS_Line::rotate1: sp: %f/%f, ep: %f/%f", + DEBUG->print("Line::rotate"); + DEBUG->print("Line::rotate1: sp: %f/%f, ep: %f/%f", data.startpoint.x, data.startpoint.y, data.endpoint.x, data.endpoint.y); data.startpoint.rotate(center, angle); data.endpoint.rotate(center, angle); - RS_DEBUG->print("RS_Line::rotate2: sp: %f/%f, ep: %f/%f", + DEBUG->print("Line::rotate2: sp: %f/%f, ep: %f/%f", data.startpoint.x, data.startpoint.y, data.endpoint.x, data.endpoint.y); calculateBorders(); - RS_DEBUG->print("RS_Line::rotate: OK"); + DEBUG->print("Line::rotate: OK"); } -void RS_Line::scale(Vector center, Vector factor) +void Line::scale(Vector center, Vector factor) { - RS_DEBUG->print("RS_Line::scale1: sp: %f/%f, ep: %f/%f", + DEBUG->print("Line::scale1: sp: %f/%f, ep: %f/%f", data.startpoint.x, data.startpoint.y, data.endpoint.x, data.endpoint.y); data.startpoint.scale(center, factor); data.endpoint.scale(center, factor); - RS_DEBUG->print("RS_Line::scale2: sp: %f/%f, ep: %f/%f", + DEBUG->print("Line::scale2: sp: %f/%f, ep: %f/%f", data.startpoint.x, data.startpoint.y, data.endpoint.x, data.endpoint.y); calculateBorders(); } -void RS_Line::mirror(Vector axisPoint1, Vector axisPoint2) +void Line::mirror(Vector axisPoint1, Vector axisPoint2) { data.startpoint.mirror(axisPoint1, axisPoint2); data.endpoint.mirror(axisPoint1, axisPoint2); @@ -468,7 +468,7 @@ void RS_Line::mirror(Vector axisPoint1, Vector axisPoint2) /** * Stretches the given range of the entity by the given offset. */ -void RS_Line::stretch(Vector firstCorner, Vector secondCorner, Vector offset) +void Line::stretch(Vector firstCorner, Vector secondCorner, Vector offset) { if (getStartpoint().isInWindow(firstCorner, secondCorner)) moveStartpoint(getStartpoint() + offset); @@ -477,7 +477,7 @@ void RS_Line::stretch(Vector firstCorner, Vector secondCorner, Vector offset) moveEndpoint(getEndpoint() + offset); } -void RS_Line::moveRef(const Vector& ref, const Vector& offset) +void Line::moveRef(const Vector& ref, const Vector& offset) { if (ref.distanceTo(data.startpoint)<1.0e-4) { moveStartpoint(data.startpoint+offset); @@ -487,11 +487,11 @@ void RS_Line::moveRef(const Vector& ref, const Vector& offset) } } -void RS_Line::draw(PaintInterface * painter, GraphicView * view, double patternOffset) +void Line::draw(PaintInterface * painter, GraphicView * view, double patternOffset) { if (!painter || !view) //{ -//printf("RS_Line::draw(): Bailing out!!! painter=%08X, view=%08X\n", painter, view); +//printf("Line::draw(): Bailing out!!! painter=%08X, view=%08X\n", painter, view); return; //} @@ -501,33 +501,33 @@ void RS_Line::draw(PaintInterface * painter, GraphicView * view, double patternO || view->getDrawingMode() == RS2::ModePreview || styleFactor < 0.0) { -//printf("RS_Line::draw(): Drawing line...\n"); +//printf("Line::draw(): Drawing line...\n"); painter->drawLine(view->toGui(getStartpoint()), view->toGui(getEndpoint())); return; } // Pattern: #if 0 - RS_LineTypePattern * pat; + LineTypePattern * pat; if (isSelected()) pat = &patternSelected; else pat = view->getPattern(getPen().getLineType()); #else - RS_LineTypePattern * pat = (isSelected() ? &patternSelected : view->getPattern(getPen().getLineType())); + LineTypePattern * pat = (isSelected() ? &patternSelected : view->getPattern(getPen().getLineType())); #endif if (!pat) { -//printf("RS_Line::draw(): Pattern == NULL!\n"); - RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Line::draw: Invalid line pattern"); +//printf("Line::draw(): Pattern == NULL!\n"); + DEBUG->print(Debug::D_WARNING, "Line::draw: Invalid line pattern"); return; } -//printf("RS_Line::draw(): Drawing a patterned line...(?)\n"); +//printf("Line::draw(): Drawing a patterned line...(?)\n"); // Pen to draw pattern is always solid: - RS_Pen pen = painter->getPen(); + Pen pen = painter->getPen(); pen.setLineType(RS2::SolidLine); painter->setPen(pen); @@ -564,7 +564,7 @@ void RS_Line::draw(PaintInterface * painter, GraphicView * view, double patternO //if (patternOffset<0.0) { // patternOffset+=patternSegmentLength; //} - //RS_DEBUG->print("pattern. offset: %f", patternOffset); + //DEBUG->print("pattern. offset: %f", patternOffset); Vector patternOffsetVec; patternOffsetVec.setPolar(patternOffset, angle); @@ -616,7 +616,7 @@ void RS_Line::draw(PaintInterface * painter, GraphicView * view, double patternO curP += dp[i]; tot += fabs(pat->pattern[i] * styleFactor); - //RS_DEBUG->print("pattern. tot: %f", tot); + //DEBUG->print("pattern. tot: %f", tot); i++; @@ -633,7 +633,7 @@ void RS_Line::draw(PaintInterface * painter, GraphicView * view, double patternO /** * Dumps the point's data to stdout. */ -std::ostream & operator<<(std::ostream & os, const RS_Line & l) +std::ostream & operator<<(std::ostream & os, const Line & l) { os << " Line: " << l.getData() << "\n"; return os;