]> Shamusworld >> Repos - architektonas/blobdiff - src/base/spline.cpp
Removed unnecessary RS_ prefix from classes and whatnot.
[architektonas] / src / base / spline.cpp
index c28a2323d59a4e428ff40cd18bcbe97199dd6dd6..37d9ee0bddb8ace7bc7c23d59c045ce7087b8650 100644 (file)
@@ -24,8 +24,8 @@
 /**
  * Constructor.
  */
-RS_Spline::RS_Spline(RS_EntityContainer * parent, const RS_SplineData & d):
-       RS_EntityContainer(parent), data(d)
+Spline::Spline(EntityContainer * parent, const SplineData & d):
+       EntityContainer(parent), data(d)
 {
        calculateBorders();
 }
@@ -33,13 +33,13 @@ RS_Spline::RS_Spline(RS_EntityContainer * parent, const RS_SplineData & d):
 /**
  * Destructor.
  */
-RS_Spline::~RS_Spline()
+Spline::~Spline()
 {
 }
 
-RS_Entity * RS_Spline::clone()
+Entity * Spline::clone()
 {
-       RS_Spline * l = new RS_Spline(*this);
+       Spline * l = new Spline(*this);
 #warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!"
 //     l->entities.setAutoDelete(entities.autoDelete());
        l->initId();
@@ -48,44 +48,44 @@ RS_Entity * RS_Spline::clone()
 }
 
 /**    @return RS2::EntitySpline */
-/*virtual*/ RS2::EntityType RS_Spline::rtti() const
+/*virtual*/ RS2::EntityType Spline::rtti() const
 {
        return RS2::EntitySpline;
 }
 
 /** @return false */
-/*virtual*/ bool RS_Spline::isEdge() const
+/*virtual*/ bool Spline::isEdge() const
 {
        return false;
 }
 
 /** @return Copy of data that defines the spline. */
-RS_SplineData RS_Spline::getData() const
+SplineData Spline::getData() const
 {
        return data;
 }
 
 /** Sets the splines degree (1-3). */
-void RS_Spline::setDegree(int deg)
+void Spline::setDegree(int deg)
 {
        if (deg >= 1 && deg <= 3)
                data.degree = deg;
 }
 
 /** @return Degree of this spline curve (1-3).*/
-int RS_Spline::getDegree()
+int Spline::getDegree()
 {
        return data.degree;
 }
 
 /** @return 0. */
-int RS_Spline::getNumberOfKnots()
+int Spline::getNumberOfKnots()
 {
        return 0;
 }
 
 /** @return Number of control points. */
-int RS_Spline::getNumberOfControlPoints()
+int Spline::getNumberOfControlPoints()
 {
        return data.controlPoints.count();
 }
@@ -94,7 +94,7 @@ int RS_Spline::getNumberOfControlPoints()
  * @retval true if the spline is closed.
  * @retval false otherwise.
  */
-bool RS_Spline::isClosed()
+bool Spline::isClosed()
 {
        return data.closed;
 }
@@ -102,13 +102,13 @@ bool RS_Spline::isClosed()
 /**
  * Sets the closed falg of this spline.
  */
-void RS_Spline::setClosed(bool c)
+void Spline::setClosed(bool c)
 {
        data.closed = c;
        update();
 }
 
-void RS_Spline::calculateBorders()
+void Spline::calculateBorders()
 {
     /*minV = Vector::minimum(data.startpoint, data.endpoint);
     maxV = Vector::maximum(data.startpoint, data.endpoint);
@@ -123,7 +123,7 @@ void RS_Spline::calculateBorders()
     */
 }
 
-VectorSolutions RS_Spline::getRefPoints()
+VectorSolutions Spline::getRefPoints()
 {
        VectorSolutions ret(data.controlPoints.count());
 
@@ -138,25 +138,25 @@ VectorSolutions RS_Spline::getRefPoints()
        return ret;
 }
 
-Vector RS_Spline::getNearestRef(const Vector & coord, double * dist)
+Vector Spline::getNearestRef(const Vector & coord, double * dist)
 {
        //return getRefPoints().getClosest(coord, dist);
-       return RS_Entity::getNearestRef(coord, dist);
+       return Entity::getNearestRef(coord, dist);
 }
 
-Vector RS_Spline::getNearestSelectedRef(const Vector & coord, double * dist)
+Vector Spline::getNearestSelectedRef(const Vector & coord, double * dist)
 {
        //return getRefPoints().getClosest(coord, dist);
-       return RS_Entity::getNearestSelectedRef(coord, dist);
+       return Entity::getNearestSelectedRef(coord, dist);
 }
 
 /**
  * Updates the internal polygon of this spline. Called when the
  * spline or it's data, position, .. changes.
  */
-void RS_Spline::update()
+void Spline::update()
 {
-       RS_DEBUG->print("RS_Spline::update");
+       DEBUG->print("Spline::update");
 
        clear();
 
@@ -165,13 +165,13 @@ void RS_Spline::update()
 
        if (data.degree < 1 || data.degree > 3)
        {
-               RS_DEBUG->print("RS_Spline::update: invalid degree: %d", data.degree);
+               DEBUG->print("Spline::update: invalid degree: %d", data.degree);
                return;
        }
 
        if (data.controlPoints.count() < (uint)data.degree + 1)
        {
-               RS_DEBUG->print("RS_Spline::update: not enough control points");
+               DEBUG->print("Spline::update: not enough control points");
                return;
        }
 
@@ -207,7 +207,7 @@ void RS_Spline::update()
                b[i + 1] = (*it).y;
                b[i + 2] = 0.0;
 
-               RS_DEBUG->print("RS_Spline::update: b[%d]: %f/%f", i, b[i], b[i + 1]);
+               DEBUG->print("Spline::update: b[%d]: %f/%f", i, b[i], b[i + 1]);
                i += 3;
        }
 
@@ -229,9 +229,9 @@ void RS_Spline::update()
        {
                if (prev.valid)
                {
-                       RS_Line * line = new RS_Line(this, RS_LineData(prev, Vector(p[i], p[i + 1])));
+                       Line * line = new Line(this, LineData(prev, Vector(p[i], p[i + 1])));
                        line->setLayer(NULL);
-                       line->setPen(RS_Pen(RS2::FlagInvalid));
+                       line->setPen(Pen(RS2::FlagInvalid));
                        addEntity(line);
                }
 
@@ -245,7 +245,7 @@ void RS_Spline::update()
        delete[] p;
 }
 
-Vector RS_Spline::getNearestEndpoint(const Vector & coord, double * dist)
+Vector Spline::getNearestEndpoint(const Vector & coord, double * dist)
 {
     double minDist = RS_MAXDOUBLE;
     double d;
@@ -266,14 +266,14 @@ Vector RS_Spline::getNearestEndpoint(const Vector & coord, double * dist)
 }
 
 /*
-// The default implementation of RS_EntityContainer is inaccurate but
+// The default implementation of EntityContainer is inaccurate but
 //   has to do for now..
-Vector RS_Spline::getNearestPointOnEntity(const Vector& coord,
-        bool onEntity, double* dist, RS_Entity** entity) {
+Vector Spline::getNearestPointOnEntity(const Vector& coord,
+        bool onEntity, double* dist, Entity** entity) {
 }
 */
 
-Vector RS_Spline::getNearestCenter(const Vector & /*coord*/, double * dist)
+Vector Spline::getNearestCenter(const Vector & /*coord*/, double * dist)
 {
        if (dist != NULL)
                *dist = RS_MAXDOUBLE;
@@ -281,7 +281,7 @@ Vector RS_Spline::getNearestCenter(const Vector & /*coord*/, double * dist)
        return Vector(false);
 }
 
-Vector RS_Spline::getNearestMiddle(const Vector & /*coord*/, double * dist)
+Vector Spline::getNearestMiddle(const Vector & /*coord*/, double * dist)
 {
        if (dist!=NULL)
                *dist = RS_MAXDOUBLE;
@@ -289,7 +289,7 @@ Vector RS_Spline::getNearestMiddle(const Vector & /*coord*/, double * dist)
        return Vector(false);
 }
 
-Vector RS_Spline::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
+Vector Spline::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
 {
        if (dist != NULL)
                *dist = RS_MAXDOUBLE;
@@ -297,7 +297,7 @@ Vector RS_Spline::getNearestDist(double /*distance*/, const Vector & /*coord*/,
        return Vector(false);
 }
 
-void RS_Spline::move(Vector offset)
+void Spline::move(Vector offset)
 {
 //     Q3ValueList<Vector>::iterator it;
        QList<Vector>::iterator it;
@@ -308,7 +308,7 @@ void RS_Spline::move(Vector offset)
        update();
 }
 
-void RS_Spline::rotate(Vector center, double angle)
+void Spline::rotate(Vector center, double angle)
 {
 //     Q3ValueList<Vector>::iterator it;
        QList<Vector>::iterator it;
@@ -319,7 +319,7 @@ void RS_Spline::rotate(Vector center, double angle)
        update();
 }
 
-void RS_Spline::scale(Vector center, Vector factor)
+void Spline::scale(Vector center, Vector factor)
 {
 //     Q3ValueList<Vector>::iterator it;
        QList<Vector>::iterator it;
@@ -330,7 +330,7 @@ void RS_Spline::scale(Vector center, Vector factor)
        update();
 }
 
-void RS_Spline::mirror(Vector axisPoint1, Vector axisPoint2)
+void Spline::mirror(Vector axisPoint1, Vector axisPoint2)
 {
 //     Q3ValueList<Vector>::iterator it;
        QList<Vector>::iterator it;
@@ -341,7 +341,7 @@ void RS_Spline::mirror(Vector axisPoint1, Vector axisPoint2)
        update();
 }
 
-void RS_Spline::moveRef(const Vector & ref, const Vector & offset)
+void Spline::moveRef(const Vector & ref, const Vector & offset)
 {
 //     Q3ValueList<Vector>::iterator it;
        QList<Vector>::iterator it;
@@ -355,26 +355,26 @@ void RS_Spline::moveRef(const Vector & ref, const Vector & offset)
        update();
 }
 
-void RS_Spline::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
+void Spline::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
 {
        if (painter == NULL || view == NULL)
                return;
 
-       RS_Entity * e = firstEntity(RS2::ResolveNone);
+       Entity * e = firstEntity(RS2::ResolveNone);
        double offset = 0.0;
 
        if (e != NULL)
        {
                view->drawEntity(e);
                offset += e->getLength();
-               //RS_DEBUG->print("offset: %f\nlength was: %f", offset, e->getLength());
+               //DEBUG->print("offset: %f\nlength was: %f", offset, e->getLength());
        }
 
-       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, -offset);
                offset += e->getLength();
-               //RS_DEBUG->print("offset: %f\nlength was: %f", offset, e->getLength());
+               //DEBUG->print("offset: %f\nlength was: %f", offset, e->getLength());
        }
 }
 
@@ -382,7 +382,7 @@ void RS_Spline::draw(PaintInterface * painter, GraphicView * view, double /*patt
  * Todo: draw the spline, user patterns.
  */
 /*
-void RS_Spline::draw(RS_Painter* painter, GraphicView* view) {
+void Spline::draw(RS_Painter* painter, GraphicView* view) {
    if (painter==NULL || view==NULL) {
        return;
    }
@@ -419,7 +419,7 @@ void RS_Spline::draw(RS_Painter* painter, GraphicView* view) {
        b[i+1] = (*it).y;
        b[i+2] = 0.0;
 
-       RS_DEBUG->print("RS_Spline::draw: b[%d]: %f/%f", i, b[i], b[i+1]);
+       DEBUG->print("Spline::draw: b[%d]: %f/%f", i, b[i], b[i+1]);
        i+=3;
    }
 
@@ -449,8 +449,8 @@ void RS_Spline::draw(RS_Painter* painter, GraphicView* view) {
 /**
  * @return The reference points of the spline.
  */
-//Q3ValueList<Vector> RS_Spline::getControlPoints()
-QList<Vector> RS_Spline::getControlPoints()
+//Q3ValueList<Vector> Spline::getControlPoints()
+QList<Vector> Spline::getControlPoints()
 {
        return data.controlPoints;
 }
@@ -458,7 +458,7 @@ QList<Vector> RS_Spline::getControlPoints()
 /**
  * Appends the given point to the control points.
  */
-void RS_Spline::addControlPoint(const Vector & v)
+void Spline::addControlPoint(const Vector & v)
 {
        data.controlPoints.append(v);
 }
@@ -466,7 +466,7 @@ void RS_Spline::addControlPoint(const Vector & v)
 /**
  * Removes the control point that was last added.
  */
-void RS_Spline::removeLastControlPoint()
+void Spline::removeLastControlPoint()
 {
        data.controlPoints.pop_back();
 }
@@ -475,7 +475,7 @@ void RS_Spline::removeLastControlPoint()
  * Generates B-Spline open knot vector with multiplicity
  * equal to the order at the ends.
  */
-void RS_Spline::knot(int num, int order, int knotVector[])
+void Spline::knot(int num, int order, int knotVector[])
 {
        knotVector[1] = 0;
 
@@ -495,7 +495,7 @@ void RS_Spline::knot(int num, int order, int knotVector[])
 /**
  * Generates rational B-spline basis functions for an open knot vector.
  */
-void RS_Spline::rbasis(int c, double t, int npts, int x[], double h[], double r[])
+void Spline::rbasis(int c, double t, int npts, int x[], double h[], double r[])
 {
        int nplusc;
        int i, k;
@@ -563,7 +563,7 @@ void RS_Spline::rbasis(int c, double t, int npts, int x[], double h[], double r[
 /**
  * Generates a rational B-spline curve using a uniform open knot vector.
  */
-void RS_Spline::rbspline(int npts, int k, int p1, double b[], double h[], double p[])
+void Spline::rbspline(int npts, int k, int p1, double b[], double h[], double p[])
 {
        int i, j, icount, jcount;
        int i1;
@@ -628,7 +628,7 @@ void RS_Spline::rbspline(int npts, int k, int p1, double b[], double h[], double
        delete[] nbasis;
 }
 
-void RS_Spline::knotu(int num, int order, int knotVector[])
+void Spline::knotu(int num, int order, int knotVector[])
 {
        int nplusc = num + order;
        int nplus2 = num + 2;
@@ -638,7 +638,7 @@ void RS_Spline::knotu(int num, int order, int knotVector[])
                knotVector[i] = i - 1;
 }
 
-void RS_Spline::rbsplinu(int npts, int k, int p1, double b[], double h[], double p[])
+void Spline::rbsplinu(int npts, int k, int p1, double b[], double h[], double p[])
 {
        int i, j, icount, jcount;
        int i1;
@@ -731,7 +731,7 @@ void RS_Spline::rbsplinu(int npts, int k, int p1, double b[], double h[], double
 /**
  * Dumps the spline's data to stdout.
  */
-std::ostream & operator<<(std::ostream & os, const RS_Spline & l)
+std::ostream & operator<<(std::ostream & os, const Spline & l)
 {
        os << " Spline: " << l.getData() << "\n";
        return os;