X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fpolyline.cpp;h=29f7a92b251739a317f50afaf10f5762cf8aa0ba;hb=e1d1cacbb43055988d0d9db632fdf05c0bea9543;hp=77fdbabfc108f0ab9522011be627198faf60b60e;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/polyline.cpp b/src/base/polyline.cpp index 77fdbab..29f7a92 100644 --- a/src/base/polyline.cpp +++ b/src/base/polyline.cpp @@ -25,7 +25,7 @@ /** * Constructor. */ -RS_Polyline::RS_Polyline(RS_EntityContainer * parent): RS_EntityContainer(parent), +Polyline::Polyline(EntityContainer * parent): EntityContainer(parent), closingEntity(NULL), nextBulge(0.0) { } @@ -34,8 +34,8 @@ RS_Polyline::RS_Polyline(RS_EntityContainer * parent): RS_EntityContainer(parent * Constructor. * @param d Polyline data */ -RS_Polyline::RS_Polyline(RS_EntityContainer* parent, const RS_PolylineData& d): - RS_EntityContainer(parent), data(d) +Polyline::Polyline(EntityContainer* parent, const PolylineData& d): + EntityContainer(parent), data(d) { closingEntity = NULL; nextBulge = 0.0; @@ -45,13 +45,13 @@ RS_Polyline::RS_Polyline(RS_EntityContainer* parent, const RS_PolylineData& d): /** * Destructor */ -RS_Polyline::~RS_Polyline() +Polyline::~Polyline() { } -/*virtual*/ RS_Entity * RS_Polyline::clone() +/*virtual*/ Entity * Polyline::clone() { - RS_Polyline * p = new RS_Polyline(*this); + Polyline * p = new Polyline(*this); #warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!" // p->entities.setAutoDelete(entities.autoDelete()); p->initId(); @@ -60,19 +60,19 @@ RS_Polyline::~RS_Polyline() } /** @return RS2::EntityPolyline */ -/*virtual*/ RS2::EntityType RS_Polyline::rtti() const +/*virtual*/ RS2::EntityType Polyline::rtti() const { return RS2::EntityPolyline; } /** @return Copy of data that defines the polyline. */ -RS_PolylineData RS_Polyline::getData() const +PolylineData Polyline::getData() const { return data; } /** sets a new start point of the polyline */ -void RS_Polyline::setStartpoint(Vector & v) +void Polyline::setStartpoint(Vector & v) { data.startpoint = v; @@ -81,19 +81,19 @@ void RS_Polyline::setStartpoint(Vector & v) } /** @return Start point of the entity */ -Vector RS_Polyline::getStartpoint() +Vector Polyline::getStartpoint() { return data.startpoint; } /** sets a new end point of the polyline */ -void RS_Polyline::setEndpoint(Vector & v) +void Polyline::setEndpoint(Vector & v) { data.endpoint = v; } /** @return End point of the entity */ -Vector RS_Polyline::getEndpoint() +Vector Polyline::getEndpoint() { return data.endpoint; } @@ -101,9 +101,9 @@ Vector RS_Polyline::getEndpoint() /** * Removes the last vertex of this polyline. */ -void RS_Polyline::removeLastVertex() +void Polyline::removeLastVertex() { - RS_Entity * last = lastEntity(); + Entity * last = lastEntity(); if (last != NULL) { @@ -113,9 +113,9 @@ void RS_Polyline::removeLastVertex() if (last != NULL) { if (last->isAtomic()) - data.endpoint = ((RS_AtomicEntity*)last)->getEndpoint(); + data.endpoint = ((AtomicEntity*)last)->getEndpoint(); else - RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Polyline::removeLastVertex: " + DEBUG->print(Debug::D_WARNING, "Polyline::removeLastVertex: " "polyline contains non-atomic entity"); } } @@ -135,9 +135,9 @@ void RS_Polyline::removeLastVertex() * @return Pointer to the entity that was addded or NULL if this * was the first vertex added. */ -RS_Entity * RS_Polyline::addVertex(const Vector & v, double bulge, bool prepend) +Entity * Polyline::addVertex(const Vector & v, double bulge, bool prepend) { - RS_Entity * entity = NULL; + Entity * entity = NULL; //static double nextBulge = 0.0; // very first vertex: @@ -153,11 +153,11 @@ RS_Entity * RS_Polyline::addVertex(const Vector & v, double bulge, bool prepend) entity = createVertex(v, nextBulge, prepend); if (entity!=NULL) { if (prepend==false) { - RS_EntityContainer::addEntity(entity); + EntityContainer::addEntity(entity); data.endpoint = v; } else { - RS_EntityContainer::insertEntity(0, entity); + EntityContainer::insertEntity(0, entity); data.startpoint = v; } } @@ -184,25 +184,25 @@ RS_Entity * RS_Polyline::addVertex(const Vector & v, double bulge, bool prepend) * @return Pointer to the entity that was created or NULL if this * was the first vertex added. */ -RS_Entity* RS_Polyline::createVertex(const Vector& v, double bulge, bool prepend) { +Entity* Polyline::createVertex(const Vector& v, double bulge, bool prepend) { - RS_Entity* entity=NULL; + Entity* entity=NULL; - RS_DEBUG->print("RS_Polyline::createVertex: %f/%f to %f/%f bulge: %f", + DEBUG->print("Polyline::createVertex: %f/%f to %f/%f bulge: %f", data.endpoint.x, data.endpoint.y, v.x, v.y, bulge); // create line for the polyline: if (fabs(bulge)setSelected(isSelected()); - entity->setPen(RS_Pen(RS2::FlagInvalid)); + entity->setPen(Pen(RS2::FlagInvalid)); entity->setLayer(NULL); - //RS_EntityContainer::addEntity(entity); + //EntityContainer::addEntity(entity); //data.endpoint = v; } @@ -231,7 +231,7 @@ RS_Entity* RS_Polyline::createVertex(const Vector& v, double bulge, bool prepend // alpha can't be 0.0 at this point radius = fabs(dist / sin(alpha/2.0)); - double wu = fabs(RS_Math::pow(radius, 2.0) - RS_Math::pow(dist, 2.0)); + double wu = fabs(Math::pow(radius, 2.0) - Math::pow(dist, 2.0)); double h = sqrt(wu); if (bulge>0.0) { @@ -259,13 +259,13 @@ RS_Entity* RS_Polyline::createVertex(const Vector& v, double bulge, bool prepend a2 = center.angleTo(data.startpoint); } - RS_ArcData d(center, radius, + ArcData d(center, radius, a1, a2, reversed); - entity = new RS_Arc(this, d); + entity = new Arc(this, d); entity->setSelected(isSelected()); - entity->setPen(RS_Pen(RS2::FlagInvalid)); + entity->setPen(Pen(RS2::FlagInvalid)); entity->setLayer(NULL); } @@ -275,13 +275,13 @@ RS_Entity* RS_Polyline::createVertex(const Vector& v, double bulge, bool prepend /** * Ends polyline and adds the last entity if the polyline is closed */ -void RS_Polyline::endPolyline() +void Polyline::endPolyline() { - RS_DEBUG->print("RS_Polyline::endPolyline"); + DEBUG->print("Polyline::endPolyline"); if (isClosed()) { - RS_DEBUG->print("RS_Polyline::endPolyline: adding closing entity"); + DEBUG->print("Polyline::endPolyline: adding closing entity"); // remove old closing entity: if (closingEntity!=NULL) @@ -293,7 +293,7 @@ void RS_Polyline::endPolyline() closingEntity = createVertex(data.startpoint, nextBulge); if (closingEntity!=NULL) { - RS_EntityContainer::addEntity(closingEntity); + EntityContainer::addEntity(closingEntity); //data.endpoint = data.startpoint; } } @@ -302,12 +302,12 @@ void RS_Polyline::endPolyline() /** * @return The bulge of the closing entity. */ -double RS_Polyline::getClosingBulge() +double Polyline::getClosingBulge() { if (isClosed()) { - RS_Entity* e = lastEntity(); + Entity* e = lastEntity(); if (e!=NULL && e->rtti()==RS2::EntityArc) { - return ((RS_Arc*)e)->getBulge(); + return ((Arc*)e)->getBulge(); } } @@ -317,17 +317,17 @@ double RS_Polyline::getClosingBulge() /** * Sets the polylines start and endpoint to match the first and last vertex. */ -void RS_Polyline::updateEndpoints() +void Polyline::updateEndpoints() { - RS_Entity * e1 = firstEntity(); + Entity * e1 = firstEntity(); if (e1 != NULL && e1->isAtomic()) { - Vector v = ((RS_AtomicEntity *)e1)->getStartpoint(); + Vector v = ((AtomicEntity *)e1)->getStartpoint(); setStartpoint(v); } - RS_Entity * e2 = lastEntity(); + Entity * e2 = lastEntity(); if (isClosed()) { @@ -336,18 +336,18 @@ void RS_Polyline::updateEndpoints() if (e2 != NULL && e2->isAtomic()) { - Vector v = ((RS_AtomicEntity *)e2)->getEndpoint(); + Vector v = ((AtomicEntity *)e2)->getEndpoint(); setEndpoint(v); } } /** @return true if the polyline is closed. false otherwise */ -bool RS_Polyline::isClosed() const +bool Polyline::isClosed() const { return data.getFlag(RS2::FlagClosed); } -void RS_Polyline::setClosed(bool cl) +void Polyline::setClosed(bool cl) { if (cl) data.setFlag(RS2::FlagClosed); @@ -361,9 +361,9 @@ void RS_Polyline::setClosed(bool cl) * * To add entities use addVertex() or addSegment() instead. */ -void RS_Polyline::addEntity(RS_Entity * entity) +void Polyline::addEntity(Entity * entity) { - RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Polyline::addEntity: should never be called"); + DEBUG->print(Debug::D_WARNING, "Polyline::addEntity: should never be called"); if (entity == NULL) return; @@ -371,7 +371,7 @@ void RS_Polyline::addEntity(RS_Entity * entity) delete entity; } -/*virtual*/ void RS_Polyline::setNextBulge(double bulge) +/*virtual*/ void Polyline::setNextBulge(double bulge) { nextBulge = bulge; } @@ -379,12 +379,12 @@ void RS_Polyline::addEntity(RS_Entity * entity) /** * Adds a segment to the polyline. */ -/*void RS_Polyline::addSegment(RS_Entity* entity) { - RS_EntityContainer::addEntity(entity); +/*void Polyline::addSegment(Entity* entity) { + EntityContainer::addEntity(entity); // TODO: reorder and check polyline }*/ -VectorSolutions RS_Polyline::getRefPoints() +VectorSolutions Polyline::getRefPoints() { VectorSolutions ret(count()+1); @@ -392,11 +392,11 @@ VectorSolutions RS_Polyline::getRefPoints() ret.set(0, data.startpoint); i++; - for (RS_Entity* e=firstEntity(RS2::ResolveNone); + for (Entity* e=firstEntity(RS2::ResolveNone); e!=NULL; e = nextEntity(RS2::ResolveNone), i++) { if (e->isAtomic()) { - ret.set(i, ((RS_AtomicEntity*)e)->getEndpoint()); + ret.set(i, ((AtomicEntity*)e)->getEndpoint()); } } @@ -405,22 +405,22 @@ VectorSolutions RS_Polyline::getRefPoints() return ret; } -Vector RS_Polyline::getNearestRef(const Vector& coord, +Vector Polyline::getNearestRef(const Vector& coord, double* dist) { - return RS_Entity::getNearestRef(coord, dist); + return Entity::getNearestRef(coord, dist); } -Vector RS_Polyline::getNearestSelectedRef(const Vector& coord, +Vector Polyline::getNearestSelectedRef(const Vector& coord, double* dist) { - return RS_Entity::getNearestSelectedRef(coord, dist); + return Entity::getNearestSelectedRef(coord, dist); } /* -void RS_Polyline::reorder() { +void Polyline::reorder() { // current point: Vector cp; @@ -433,39 +433,39 @@ void RS_Polyline::reorder() { -void RS_Polyline::move(Vector offset) { - RS_EntityContainer::move(offset); +void Polyline::move(Vector offset) { + EntityContainer::move(offset); data.startpoint.move(offset); data.endpoint.move(offset); } -void RS_Polyline::rotate(Vector center, double angle) { - RS_EntityContainer::rotate(center, angle); +void Polyline::rotate(Vector center, double angle) { + EntityContainer::rotate(center, angle); data.startpoint.rotate(center, angle); data.endpoint.rotate(center, angle); } -void RS_Polyline::scale(Vector center, Vector factor) { - RS_EntityContainer::scale(center, factor); +void Polyline::scale(Vector center, Vector factor) { + EntityContainer::scale(center, factor); data.startpoint.scale(center, factor); data.endpoint.scale(center, factor); } -void RS_Polyline::mirror(Vector axisPoint1, Vector axisPoint2) { - RS_EntityContainer::mirror(axisPoint1, axisPoint2); +void Polyline::mirror(Vector axisPoint1, Vector axisPoint2) { + EntityContainer::mirror(axisPoint1, axisPoint2); data.startpoint.mirror(axisPoint1, axisPoint2); data.endpoint.mirror(axisPoint1, axisPoint2); } -void RS_Polyline::moveRef(const Vector & ref, const Vector & offset) +void Polyline::moveRef(const Vector & ref, const Vector & offset) { - RS_EntityContainer::moveRef(ref, offset); + EntityContainer::moveRef(ref, offset); if (ref.distanceTo(data.startpoint) < 1.0e-4) data.startpoint.move(offset); @@ -476,7 +476,7 @@ void RS_Polyline::moveRef(const Vector & ref, const Vector & offset) //update(); } -void RS_Polyline::stretch(Vector firstCorner, Vector secondCorner, Vector offset) +void Polyline::stretch(Vector firstCorner, Vector secondCorner, Vector offset) { if (data.startpoint.isInWindow(firstCorner, secondCorner)) data.startpoint.move(offset); @@ -484,33 +484,33 @@ void RS_Polyline::stretch(Vector firstCorner, Vector secondCorner, Vector offset if (data.endpoint.isInWindow(firstCorner, secondCorner)) data.endpoint.move(offset); - RS_EntityContainer::stretch(firstCorner, secondCorner, offset); + EntityContainer::stretch(firstCorner, secondCorner, offset); } /** * Slightly optimized drawing for polylines. */ -void RS_Polyline::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/) +void Polyline::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/) { if (!painter || !view) return; // draw first entity and set correct pen: - RS_Entity * e = firstEntity(RS2::ResolveNone); + Entity * e = firstEntity(RS2::ResolveNone); view->drawEntity(e); // draw subsequent entities with same pen: - for(RS_Entity * e=nextEntity(RS2::ResolveNone); e!=NULL; e = nextEntity(RS2::ResolveNone)) + for(Entity * e=nextEntity(RS2::ResolveNone); e!=NULL; e = nextEntity(RS2::ResolveNone)) view->drawEntityPlain(e); } /** * Dumps the point's data to stdout. */ -std::ostream & operator<<(std::ostream & os, const RS_Polyline & l) +std::ostream & operator<<(std::ostream & os, const Polyline & l) { os << " Polyline: " << l.getData() << " {\n"; - os << (RS_EntityContainer &)l; + os << (EntityContainer &)l; os << "\n}\n"; return os;