/**
* Constructor.
*/
-RS_Polyline::RS_Polyline(RS_EntityContainer * parent): RS_EntityContainer(parent),
+Polyline::Polyline(EntityContainer * parent): EntityContainer(parent),
closingEntity(NULL), nextBulge(0.0)
{
}
* 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;
/**
* 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();
}
/** @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;
}
/** @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;
}
/**
* Removes the last vertex of this polyline.
*/
-void RS_Polyline::removeLastVertex()
+void Polyline::removeLastVertex()
{
- RS_Entity * last = lastEntity();
+ Entity * last = lastEntity();
if (last != NULL)
{
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");
}
}
* @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:
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;
}
}
* @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)<RS_TOLERANCE) {
if (prepend==false) {
- entity = new RS_Line(this, RS_LineData(data.endpoint, v));
+ entity = new Line(this, LineData(data.endpoint, v));
}
else {
- entity = new RS_Line(this, RS_LineData(v, data.startpoint));
+ entity = new Line(this, LineData(v, data.startpoint));
}
entity->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;
}
// 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) {
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);
}
/**
* 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)
closingEntity = createVertex(data.startpoint, nextBulge);
if (closingEntity!=NULL)
{
- RS_EntityContainer::addEntity(closingEntity);
+ EntityContainer::addEntity(closingEntity);
//data.endpoint = data.startpoint;
}
}
/**
* @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();
}
}
/**
* 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())
{
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);
*
* 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;
delete entity;
}
-/*virtual*/ void RS_Polyline::setNextBulge(double bulge)
+/*virtual*/ void Polyline::setNextBulge(double bulge)
{
nextBulge = bulge;
}
/**
* 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);
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());
}
}
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;
-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);
//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);
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;