/**
* Constructor.
*/
-RS_Ellipse::RS_Ellipse(RS_EntityContainer * parent, const RS_EllipseData & d):
- RS_AtomicEntity(parent), data(d)
+Ellipse::Ellipse(EntityContainer * parent, const EllipseData & d):
+ AtomicEntity(parent), data(d)
{
//calculateEndpoints();
calculateBorders();
}
-/*virtual*/ RS_Ellipse::~RS_Ellipse()
+/*virtual*/ Ellipse::~Ellipse()
{
}
-/*virtual*/ RS_Entity * RS_Ellipse::clone()
+/*virtual*/ Entity * Ellipse::clone()
{
- RS_Ellipse * e = new RS_Ellipse(*this);
+ Ellipse * e = new Ellipse(*this);
e->initId();
return e;
}
/** @return RS2::EntityEllipse */
-/*virtual*/ RS2::EntityType RS_Ellipse::rtti() const
+/*virtual*/ RS2::EntityType Ellipse::rtti() const
{
return RS2::EntityEllipse;
}
/**
* @return Start point of the entity.
*/
-/*virtual*/ Vector RS_Ellipse::getStartpoint() const
+/*virtual*/ Vector Ellipse::getStartpoint() const
{
Vector p;
p.set(data.center.x + cos(data.angle1) * getMajorRadius(),
/**
* @return End point of the entity.
*/
-/*virtual*/ Vector RS_Ellipse::getEndpoint() const
+/*virtual*/ Vector Ellipse::getEndpoint() const
{
Vector p;
p.set(data.center.x + cos(data.angle2) * getMajorRadius(),
return p;
}
-void RS_Ellipse::moveStartpoint(const Vector & pos)
+void Ellipse::moveStartpoint(const Vector & pos)
{
data.angle1 = getEllipseAngle(pos);
//data.angle1 = data.center.angleTo(pos);
calculateBorders();
}
-void RS_Ellipse::moveEndpoint(const Vector & pos)
+void Ellipse::moveEndpoint(const Vector & pos)
{
data.angle2 = getEllipseAngle(pos);
//data.angle2 = data.center.angleTo(pos);
calculateBorders();
}
-RS2::Ending RS_Ellipse::getTrimPoint(const Vector & coord, const Vector & trimPoint)
+RS2::Ending Ellipse::getTrimPoint(const Vector & coord, const Vector & trimPoint)
{
double angEl = getEllipseAngle(trimPoint);
double angM = getEllipseAngle(coord);
- if (RS_Math::getAngleDifference(angM, angEl) > M_PI)
+ if (Math::getAngleDifference(angM, angEl) > M_PI)
//if (data.reversed) {
// return RS2::EndingEnd;
//}
//}
}
-double RS_Ellipse::getEllipseAngle(const Vector & pos)
+double Ellipse::getEllipseAngle(const Vector & pos)
{
Vector m = pos;
m.rotate(data.center, -data.majorP.angle());
}
/** @return Copy of data that defines the ellipse. **/
-RS_EllipseData RS_Ellipse::getData()
+EllipseData Ellipse::getData()
{
return data;
}
-VectorSolutions RS_Ellipse::getRefPoints()
+VectorSolutions Ellipse::getRefPoints()
{
VectorSolutions ret(getStartpoint(), getEndpoint(), data.center);
return ret;
* @retval true if the arc is reversed (clockwise),
* @retval false otherwise
*/
-bool RS_Ellipse::isReversed() const
+bool Ellipse::isReversed() const
{
return data.reversed;
}
/** sets the reversed status. */
-void RS_Ellipse::setReversed(bool r)
+void Ellipse::setReversed(bool r)
{
data.reversed = r;
}
/** @return The rotation angle of this ellipse */
-double RS_Ellipse::getAngle() const
+double Ellipse::getAngle() const
{
return data.majorP.angle();
}
/** @return The start angle of this arc */
-double RS_Ellipse::getAngle1()
+double Ellipse::getAngle1()
{
return data.angle1;
}
/** Sets new start angle. */
-void RS_Ellipse::setAngle1(double a1)
+void Ellipse::setAngle1(double a1)
{
data.angle1 = a1;
}
/** @return The end angle of this arc */
-double RS_Ellipse::getAngle2()
+double Ellipse::getAngle2()
{
return data.angle2;
}
/** Sets new end angle. */
-void RS_Ellipse::setAngle2(double a2)
+void Ellipse::setAngle2(double a2)
{
data.angle2 = a2;
}
/** @return The center point (x) of this arc */
-Vector RS_Ellipse::getCenter()
+Vector Ellipse::getCenter()
{
return data.center;
}
/** Sets new center. */
-void RS_Ellipse::setCenter(const Vector & c)
+void Ellipse::setCenter(const Vector & c)
{
data.center = c;
}
/** @return The endpoint of the major axis (relative to center). */
-Vector RS_Ellipse::getMajorP()
+Vector Ellipse::getMajorP()
{
return data.majorP;
}
/** Sets new major point (relative to center). */
-void RS_Ellipse::setMajorP(const Vector & p)
+void Ellipse::setMajorP(const Vector & p)
{
data.majorP = p;
}
/** @return The ratio of minor to major axis */
-double RS_Ellipse::getRatio()
+double Ellipse::getRatio()
{
return data.ratio;
}
/** Sets new ratio. */
-void RS_Ellipse::setRatio(double r)
+void Ellipse::setRatio(double r)
{
data.ratio = r;
}
/**
* @return Angle length in rad.
*/
-/*virtual*/ double RS_Ellipse::getAngleLength() const
+/*virtual*/ double Ellipse::getAngleLength() const
{
if (isReversed())
return data.angle1 - data.angle2;
}
/** @return The major radius of this ellipse. Same as getRadius() */
-double RS_Ellipse::getMajorRadius() const
+double Ellipse::getMajorRadius() const
{
return data.majorP.magnitude();
}
/** @return The minor radius of this ellipse */
-double RS_Ellipse::getMinorRadius() const
+double Ellipse::getMinorRadius() const
{
return data.majorP.magnitude() * data.ratio;
}
* Recalculates the endpoints using the angles and the radius.
*/
/*
- void RS_Ellipse::calculateEndpoints() {
+ void Ellipse::calculateEndpoints() {
double angle = data.majorP.angle();
double radius1 = getMajorRadius();
double radius2 = getMinorRadius();
*
* @todo Fix that - the algorithm used is really bad / slow.
*/
-void RS_Ellipse::calculateBorders()
+void Ellipse::calculateBorders()
{
- RS_DEBUG->print("RS_Ellipse::calculateBorders");
+ DEBUG->print("Ellipse::calculateBorders");
double radius1 = getMajorRadius();
double radius2 = getMinorRadius();
a += 0.03;
}
- while (RS_Math::isAngleBetween(RS_Math::correctAngle(a), a1, a2, false)
+ while (Math::isAngleBetween(Math::correctAngle(a), a1, a2, false)
&& a < 4 * M_PI);
minV.set(minX, minY);
maxV.set(maxX, maxY);
- RS_DEBUG->print("RS_Ellipse::calculateBorders: OK");
+ DEBUG->print("Ellipse::calculateBorders: OK");
}
-Vector RS_Ellipse::getNearestEndpoint(const Vector & coord, double * dist)
+Vector Ellipse::getNearestEndpoint(const Vector & coord, double * dist)
{
double dist1, dist2;
Vector nearerPoint;
return nearerPoint;
}
-Vector RS_Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, RS_Entity * * entity)
+Vector Ellipse::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, Entity * * entity)
{
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity");
+ DEBUG->print("Ellipse::getNearestPointOnEntity");
Vector ret(false);
for (i = 0; i < iMax; i++)
{
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: i: %d", i);
+ DEBUG->print("Ellipse::getNearestPointOnEntity: i: %d", i);
double dTpASqr = dT + dA * dA;
double dTpBSqr = dT + dB * dB;
double dInvTpASqr = 1.0 / dTpASqr;
double dXDivASqr = dXDivA * dXDivA;
double dYDivBSqr = dYDivB * dYDivB;
double dF = dXDivASqr + dYDivBSqr - 1.0;
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: dF: %f", dF);
+ DEBUG->print("Ellipse::getNearestPointOnEntity: dF: %f", dF);
if (fabs(dF) < dEpsilon)
{
rdX = dXDivA * dA;
rdY = dYDivB * dB;
riIFinal = i;
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 1: %f,%f", rdX, rdY);
+ DEBUG->print("Ellipse::getNearestPointOnEntity: rdX,rdY 1: %f,%f", rdX, rdY);
break;
}
double dFDer = 2.0 * (dXDivASqr * dInvTpASqr + dYDivBSqr * dInvTpBSqr);
double dRatio = dF / dFDer;
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: dRatio: %f", dRatio);
+ DEBUG->print("Ellipse::getNearestPointOnEntity: dRatio: %f", dRatio);
if (fabs(dRatio) < dEpsilon)
{
rdX = dXDivA * dA;
rdY = dYDivB * dB;
riIFinal = i;
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY);
+ DEBUG->print("Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY);
break;
}
dT += dRatio;
if (i == iMax)
{
// failed to converge:
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: failed");
+ DEBUG->print("Ellipse::getNearestPointOnEntity: failed");
dDistance = RS_MAXDOUBLE;
}
else
double dDelta1 = rdY - dV;
dDistance = sqrt(dDelta0 * dDelta0 + dDelta1 * dDelta1);
ret = Vector(rdX, rdY);
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY);
- RS_DEBUG->print("RS_Ellipse::getNearestPointOnEntity: ret: %f,%f", ret.x, ret.y);
+ DEBUG->print("Ellipse::getNearestPointOnEntity: rdX,rdY 2: %f,%f", rdX, rdY);
+ DEBUG->print("Ellipse::getNearestPointOnEntity: ret: %f,%f", ret.x, ret.y);
}
if (dist != NULL)
double a2 = data.center.angleTo(getEndpoint());
double a = data.center.angleTo(ret);
- if (!RS_Math::isAngleBetween(a, a1, a2, data.reversed))
+ if (!Math::isAngleBetween(a, a1, a2, data.reversed))
ret = Vector(false);
}
}
* @retval true if the given point is on this entity.
* @retval false otherwise
*/
-bool RS_Ellipse::isPointOnEntity(const Vector & coord, double tolerance)
+bool Ellipse::isPointOnEntity(const Vector & coord, double tolerance)
{
double dist = getDistanceToPoint(coord, NULL, RS2::ResolveNone);
return (dist <= tolerance);
}
-Vector RS_Ellipse::getNearestCenter(const Vector & coord, double * dist)
+Vector Ellipse::getNearestCenter(const Vector & coord, double * dist)
{
if (dist != NULL)
*dist = coord.distanceTo(data.center);
/**
* @todo Implement this.
*/
-Vector RS_Ellipse::getNearestMiddle(const Vector & /*coord*/, double * dist)
+Vector Ellipse::getNearestMiddle(const Vector & /*coord*/, double * dist)
{
if (dist != NULL)
*dist = RS_MAXDOUBLE;
return Vector(false);
}
-Vector RS_Ellipse::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
+Vector Ellipse::getNearestDist(double /*distance*/, const Vector & /*coord*/, double * dist)
{
if (dist != NULL)
*dist = RS_MAXDOUBLE;
return Vector(false);
}
-double RS_Ellipse::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel, double /*solidDist*/)
+double Ellipse::getDistanceToPoint(const Vector & coord, Entity * * entity, RS2::ResolveLevel, double /*solidDist*/)
{
double dist = RS_MAXDOUBLE;
getNearestPointOnEntity(coord, true, &dist, entity);
return dist;
}
-void RS_Ellipse::move(Vector offset)
+void Ellipse::move(Vector offset)
{
data.center.move(offset);
//calculateEndpoints();
calculateBorders();
}
-void RS_Ellipse::rotate(Vector center, double angle)
+void Ellipse::rotate(Vector center, double angle)
{
data.center.rotate(center, angle);
data.majorP.rotate(angle);
calculateBorders();
}
-void RS_Ellipse::scale(Vector center, Vector factor)
+void Ellipse::scale(Vector center, Vector factor)
{
data.center.scale(center, factor);
data.majorP.scale(factor);
/**
* @todo deal with angles correctly
*/
-void RS_Ellipse::mirror(Vector axisPoint1, Vector axisPoint2)
+void Ellipse::mirror(Vector axisPoint1, Vector axisPoint2)
{
Vector mp = data.center + data.majorP;
calculateBorders();
}
-void RS_Ellipse::moveRef(const Vector & ref, const Vector & offset)
+void Ellipse::moveRef(const Vector & ref, const Vector & offset)
{
Vector startpoint = getStartpoint();
Vector endpoint = getEndpoint();
moveEndpoint(endpoint + offset);
}
-void RS_Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
+void Ellipse::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
if (!painter || !view)
return;
}
// Pattern:
- RS_LineTypePattern * pat;
+ LineTypePattern * pat;
if (isSelected())
pat = &patternSelected;
return;
// Pen to draw pattern is always solid:
- RS_Pen pen = painter->getPen();
+ Pen pen = painter->getPen();
pen.setLineType(RS2::SolidLine);
painter->setPen(pen);
do
{
- curR = sqrt(RS_Math::pow(getMinorRadius() * cos(curA), 2.0)
- + RS_Math::pow(getMajorRadius() * sin(curA), 2.0));
+ curR = sqrt(Math::pow(getMinorRadius() * cos(curA), 2.0)
+ + Math::pow(getMajorRadius() * sin(curA), 2.0));
if (curR > 1.0e-6)
{
/**
* Dumps the point's data to stdout.
*/
-std::ostream & operator<<(std::ostream & os, const RS_Ellipse & a)
+std::ostream & operator<<(std::ostream & os, const Ellipse & a)
{
os << " Ellipse: " << a.data << "\n";
return os;