/**
* Default constructor.
*/
-RS_Arc::RS_Arc(RS_EntityContainer * parent, const RS_ArcData & d):
- RS_AtomicEntity(parent), data(d)
+Arc::Arc(EntityContainer * parent, const ArcData & d):
+ AtomicEntity(parent), data(d)
{
calculateEndpoints();
calculateBorders();
}
-/*virtual*/ RS_Arc::~RS_Arc()
+/*virtual*/ Arc::~Arc()
{
}
-/*virtual*/ RS_Entity * RS_Arc::clone()
+/*virtual*/ Entity * Arc::clone()
{
- RS_Arc * a = new RS_Arc(*this);
+ Arc * a = new Arc(*this);
a->initId();
return a;
}
/** @return RS2::EntityArc */
-/*virtual*/ RS2::EntityType RS_Arc::rtti() const
+/*virtual*/ RS2::EntityType Arc::rtti() const
{
return RS2::EntityArc;
}
/** @return true */
-/*virtual*/ bool RS_Arc::isEdge() const
+/*virtual*/ bool Arc::isEdge() const
{
return true;
}
/** @return Copy of data that defines the arc. **/
-RS_ArcData RS_Arc::getData() const
+ArcData Arc::getData() const
{
return data;
}
-/*virtual*/ VectorSolutions RS_Arc::getRefPoints()
+/*virtual*/ VectorSolutions Arc::getRefPoints()
{
VectorSolutions ret(startpoint, endpoint, data.center);
return ret;
}
/** Sets new arc parameters. **/
-void RS_Arc::setData(RS_ArcData d)
+void Arc::setData(ArcData d)
{
data = d;
}
/** @return The center point (x) of this arc */
-Vector RS_Arc::getCenter() const
+Vector Arc::getCenter() const
{
return data.center;
}
/** Sets new center. */
-void RS_Arc::setCenter(const Vector & c)
+void Arc::setCenter(const Vector & c)
{
data.center = c;
}
/** @return The radius of this arc */
-double RS_Arc::getRadius() const
+double Arc::getRadius() const
{
return data.radius;
}
/** Sets new radius. */
-void RS_Arc::setRadius(double r)
+void Arc::setRadius(double r)
{
data.radius = r;
}
/** @return The start angle of this arc */
-double RS_Arc::getAngle1() const
+double Arc::getAngle1() const
{
return data.angle1;
}
/** Sets new start angle. */
-void RS_Arc::setAngle1(double a1)
+void Arc::setAngle1(double a1)
{
data.angle1 = a1;
}
/** @return The end angle of this arc */
-double RS_Arc::getAngle2() const
+double Arc::getAngle2() const
{
return data.angle2;
}
/** Sets new end angle. */
-void RS_Arc::setAngle2(double a2)
+void Arc::setAngle2(double a2)
{
data.angle2 = a2;
}
* @return Direction 1. The angle at which the arc starts at
* the startpoint.
*/
-double RS_Arc::getDirection1() const
+double Arc::getDirection1() const
{
if (!data.reversed)
- return RS_Math::correctAngle(data.angle1 + M_PI / 2.0);
+ return Math::correctAngle(data.angle1 + M_PI / 2.0);
- return RS_Math::correctAngle(data.angle1 - M_PI / 2.0);
+ return Math::correctAngle(data.angle1 - M_PI / 2.0);
}
/**
* @return Direction 2. The angle at which the arc starts at
* the endpoint.
*/
-double RS_Arc::getDirection2() const
+double Arc::getDirection2() const
{
if (!data.reversed)
- return RS_Math::correctAngle(data.angle2 - M_PI / 2.0);
+ return Math::correctAngle(data.angle2 - M_PI / 2.0);
- return RS_Math::correctAngle(data.angle2 + M_PI / 2.0);
+ return Math::correctAngle(data.angle2 + M_PI / 2.0);
}
/**
* @retval true if the arc is reversed (clockwise),
* @retval false otherwise
*/
-bool RS_Arc::isReversed() const
+bool Arc::isReversed() const
{
return data.reversed;
}
/** sets the reversed status. */
-void RS_Arc::setReversed(bool r)
+void Arc::setReversed(bool r)
{
data.reversed = r;
}
/** @return Start point of the entity. */
-/*virtual*/ Vector RS_Arc::getStartpoint() const
+/*virtual*/ Vector Arc::getStartpoint() const
{
return startpoint;
}
/** @return End point of the entity. */
-/*virtual*/ Vector RS_Arc::getEndpoint() const
+/*virtual*/ Vector Arc::getEndpoint() const
{
return endpoint;
}
* @param p2 2nd point.
* @param p3 3rd point.
*/
-bool RS_Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3)
+bool Arc::createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3)
{
if (p1.distanceTo(p2) > RS_TOLERANCE
&& p2.distanceTo(p3) > RS_TOLERANCE
a2 = p2.angleTo(p3) + M_PI / 2.0;
dir2.setPolar(100.0, a2);
- RS_ConstructionLineData d1(mp1, mp1 + dir1);
- RS_ConstructionLineData d2(mp2, mp2 + dir2);
- RS_ConstructionLine midLine1(NULL, d1);
- RS_ConstructionLine midLine2(NULL, d2);
+ ConstructionLineData d1(mp1, mp1 + dir1);
+ ConstructionLineData d2(mp2, mp2 + dir2);
+ ConstructionLine midLine1(NULL, d1);
+ ConstructionLine midLine2(NULL, d2);
VectorSolutions sol =
- RS_Information::getIntersection(&midLine1, &midLine2);
+ Information::getIntersection(&midLine1, &midLine2);
data.center = sol.get(0);
data.radius = data.center.distanceTo(p3);
data.angle1 = data.center.angleTo(p1);
data.angle2 = data.center.angleTo(p3);
- data.reversed = RS_Math::isAngleBetween(data.center.angleTo(p2),
+ data.reversed = Math::isAngleBetween(data.center.angleTo(p2),
data.angle1, data.angle2, true);
if (sol.get(0).valid && data.radius < 1.0e14
}
else
{
- RS_DEBUG->print("RS_Arc::createFrom3P(): "
+ DEBUG->print("Arc::createFrom3P(): "
"Cannot create an arc with inf radius.");
return false;
}
}
else
{
- RS_DEBUG->print("RS_Arc::createFrom3P(): "
+ DEBUG->print("Arc::createFrom3P(): "
"Cannot create an arc with radius 0.0.");
return false;
}
* @retval true Successfully created arc
* @retval false Cannot creats arc (radius to small or endpoint to far away)
*/
-bool RS_Arc::createFrom2PDirectionRadius(const Vector & startPoint, const Vector & endPoint, double direction1, double radius)
+bool Arc::createFrom2PDirectionRadius(const Vector & startPoint, const Vector & endPoint, double direction1, double radius)
{
Vector ortho;
ortho.setPolar(radius, direction1 + M_PI / 2.0);
data.angle2 = data.center.angleTo(endPoint);
data.reversed = false;
- double diff = RS_Math::correctAngle(getDirection1() - direction1);
+ double diff = Math::correctAngle(getDirection1() - direction1);
if (fabs(diff - M_PI) < 1.0e-1)
data.reversed = true;
/**
* Creates an arc from its startpoint, endpoint and bulge.
*/
-bool RS_Arc::createFrom2PBulge(const Vector & startPoint, const Vector & endPoint, double bulge)
+bool Arc::createFrom2PBulge(const Vector & startPoint, const Vector & endPoint, double bulge)
{
data.reversed = (bulge < 0.0);
double alpha = atan(bulge) * 4.0;
// alpha can't be 0.0 at this point
data.radius = fabs(dist / sin(alpha / 2.0));
- double wu = fabs(RS_Math::pow(data.radius, 2.0) - RS_Math::pow(dist, 2.0));
+ double wu = fabs(Math::pow(data.radius, 2.0) - Math::pow(dist, 2.0));
double h = sqrt(wu);
double angle = startPoint.angleTo(endPoint);
/**
* Recalculates the endpoints using the angles and the radius.
*/
-void RS_Arc::calculateEndpoints()
+void Arc::calculateEndpoints()
{
startpoint.set(data.center.x + cos(data.angle1) * data.radius,
data.center.y + sin(data.angle1) * data.radius);
data.center.y + sin(data.angle2) * data.radius);
}
-void RS_Arc::calculateBorders()
+void Arc::calculateBorders()
{
double minX = std::min(startpoint.x, endpoint.x);
double minY = std::min(startpoint.y, endpoint.y);
maxV.set(maxX, maxY);
}
-Vector RS_Arc::getNearestEndpoint(const Vector & coord, double * dist)
+Vector Arc::getNearestEndpoint(const Vector & coord, double * dist)
{
double dist1, dist2;
Vector * nearerPoint;
return *nearerPoint;
}
-Vector RS_Arc::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, RS_Entity * * entity)
+Vector Arc::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, Entity * * entity)
{
Vector vec(false);
double angle = (coord - data.center).angle();
- if (onEntity == false || RS_Math::isAngleBetween(angle,
+ if (onEntity == false || Math::isAngleBetween(angle,
data.angle1, data.angle2, isReversed()))
{
vec.setPolar(data.radius, angle);
return vec;
}
-Vector RS_Arc::getNearestCenter(const Vector & coord, double * dist)
+Vector Arc::getNearestCenter(const Vector & coord, double * dist)
{
if (dist != NULL)
*dist = coord.distanceTo(data.center);
return data.center;
}
-Vector RS_Arc::getNearestMiddle(const Vector & coord, double * dist)
+Vector Arc::getNearestMiddle(const Vector & coord, double * dist)
{
Vector ret = getMiddlepoint();
return ret;
}
-Vector RS_Arc::getNearestDist(double distance, const Vector & coord, double * dist)
+Vector Arc::getNearestDist(double distance, const Vector & coord, double * dist)
{
if (data.radius < 1.0e-6)
{
return *nearerPoint;
}
-Vector RS_Arc::getNearestDist(double distance, bool startp)
+Vector Arc::getNearestDist(double distance, bool startp)
{
if (data.radius < 1.0e-6)
return Vector(false);
return p;
}
-double RS_Arc::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel, double)
+double Arc::getDistanceToPoint(const Vector & coord, Entity * * entity, RS2::ResolveLevel, double)
{
if (entity != NULL)
*entity = this;
if (dist < 1.0e-4)
return dist;
- if (RS_Math::isAngleBetween(data.center.angleTo(coord),
+ if (Math::isAngleBetween(data.center.angleTo(coord),
data.angle1, data.angle2,
isReversed()))
return RS_MAXDOUBLE;
}
-void RS_Arc::moveStartpoint(const Vector & pos)
+void Arc::moveStartpoint(const Vector & pos)
{
// polyline arcs: move point not angle:
//if (parent!=NULL && parent->rtti()==RS2::EntityPolyline) {
}*/
}
-void RS_Arc::moveEndpoint(const Vector & pos)
+void Arc::moveEndpoint(const Vector & pos)
{
// polyline arcs: move point not angle:
//if (parent!=NULL && parent->rtti()==RS2::EntityPolyline) {
}*/
}
-void RS_Arc::trimStartpoint(const Vector & pos)
+void Arc::trimStartpoint(const Vector & pos)
{
data.angle1 = data.center.angleTo(pos);
calculateEndpoints();
calculateBorders();
}
-void RS_Arc::trimEndpoint(const Vector & pos)
+void Arc::trimEndpoint(const Vector & pos)
{
data.angle2 = data.center.angleTo(pos);
calculateEndpoints();
calculateBorders();
}
-RS2::Ending RS_Arc::getTrimPoint(const Vector & coord, const Vector & trimPoint)
+RS2::Ending Arc::getTrimPoint(const Vector & coord, const Vector & trimPoint)
{
double angEl = data.center.angleTo(trimPoint);
double angM = data.center.angleTo(coord);
- if (RS_Math::getAngleDifference(angM, angEl) > M_PI)
+ if (Math::getAngleDifference(angM, angEl) > M_PI)
{
if (data.reversed)
return RS2::EndingEnd;
}
}
-void RS_Arc::reverse()
+void Arc::reverse()
{
double a = data.angle1;
data.angle1 = data.angle2;
calculateBorders();
}
-void RS_Arc::move(Vector offset)
+void Arc::move(Vector offset)
{
data.center.move(offset);
calculateEndpoints();
calculateBorders();
}
-void RS_Arc::rotate(Vector center, double angle)
+void Arc::rotate(Vector center, double angle)
{
- RS_DEBUG->print("RS_Arc::rotate");
+ DEBUG->print("Arc::rotate");
data.center.rotate(center, angle);
- data.angle1 = RS_Math::correctAngle(data.angle1 + angle);
- data.angle2 = RS_Math::correctAngle(data.angle2 + angle);
+ data.angle1 = Math::correctAngle(data.angle1 + angle);
+ data.angle2 = Math::correctAngle(data.angle2 + angle);
calculateEndpoints();
calculateBorders();
- RS_DEBUG->print("RS_Arc::rotate: OK");
+ DEBUG->print("Arc::rotate: OK");
}
-void RS_Arc::scale(Vector center, Vector factor)
+void Arc::scale(Vector center, Vector factor)
{
// negative scaling: mirroring
if (factor.x < 0.0)
calculateBorders();
}
-void RS_Arc::mirror(Vector axisPoint1, Vector axisPoint2)
+void Arc::mirror(Vector axisPoint1, Vector axisPoint2)
{
data.center.mirror(axisPoint1, axisPoint2);
data.reversed = (!data.reversed);
calculateBorders();
}
-void RS_Arc::moveRef(const Vector & ref, const Vector & offset)
+void Arc::moveRef(const Vector & ref, const Vector & offset)
{
if (ref.distanceTo(startpoint) < 1.0e-4)
moveStartpoint(startpoint + offset);
moveEndpoint(endpoint + offset);
}
-void RS_Arc::stretch(Vector firstCorner, Vector secondCorner, Vector offset)
+void Arc::stretch(Vector firstCorner, Vector secondCorner, Vector offset)
{
if (getMin().isInWindow(firstCorner, secondCorner)
&& getMax().isInWindow(firstCorner, secondCorner))
}
}
-void RS_Arc::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
+void Arc::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
if (painter == NULL || view == NULL)
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);
/**
* @return Middle point of the entity.
*/
-Vector RS_Arc::getMiddlepoint() const
+Vector Arc::getMiddlepoint() const
{
double a;
Vector ret;
/**
* @return Angle length in rad.
*/
-double RS_Arc::getAngleLength() const
+double Arc::getAngleLength() const
{
double ret = 0.0;
/**
* @return Length of the arc.
*/
-double RS_Arc::getLength()
+double Arc::getLength()
{
return getAngleLength() * data.radius;
}
/**
* Gets the arc's bulge (tangens of angle length divided by 4).
*/
-double RS_Arc::getBulge() const
+double Arc::getBulge() const
{
double bulge = tan(fabs(getAngleLength()) / 4.0);
/**
* Dumps the point's data to stdout.
*/
-std::ostream & operator<<(std::ostream & os, const RS_Arc & a)
+std::ostream & operator<<(std::ostream & os, const Arc & a)
{
os << " Arc: " << a.data << "\n";
return os;