/**
* 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();
}
/**
* 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();
}
/** @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();
}
* @retval true if the spline is closed.
* @retval false otherwise.
*/
-bool RS_Spline::isClosed()
+bool Spline::isClosed()
{
return data.closed;
}
/**
* 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);
*/
}
-VectorSolutions RS_Spline::getRefPoints()
+VectorSolutions Spline::getRefPoints()
{
VectorSolutions ret(data.controlPoints.count());
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();
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;
}
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;
}
{
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);
}
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;
}
/*
-// 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;
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;
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;
return Vector(false);
}
-void RS_Spline::move(Vector offset)
+void Spline::move(Vector offset)
{
// Q3ValueList<Vector>::iterator it;
QList<Vector>::iterator it;
update();
}
-void RS_Spline::rotate(Vector center, double angle)
+void Spline::rotate(Vector center, double angle)
{
// Q3ValueList<Vector>::iterator it;
QList<Vector>::iterator it;
update();
}
-void RS_Spline::scale(Vector center, Vector factor)
+void Spline::scale(Vector center, Vector factor)
{
// Q3ValueList<Vector>::iterator it;
QList<Vector>::iterator it;
update();
}
-void RS_Spline::mirror(Vector axisPoint1, Vector axisPoint2)
+void Spline::mirror(Vector axisPoint1, Vector axisPoint2)
{
// Q3ValueList<Vector>::iterator it;
QList<Vector>::iterator it;
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;
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());
}
}
* 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;
}
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;
}
/**
* @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;
}
/**
* 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);
}
/**
* Removes the control point that was last added.
*/
-void RS_Spline::removeLastControlPoint()
+void Spline::removeLastControlPoint()
{
data.controlPoints.pop_back();
}
* 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;
/**
* 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;
/**
* 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;
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;
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;
/**
* 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;