Changed QString("%1").arg() to QString().number() in VEllipticalArc
--HG-- branch : feature
This commit is contained in:
parent
e1981a56c5
commit
088f0a6987
|
@ -223,8 +223,8 @@ QPointF VEllipticalArc::GetPoint (qreal angle) const
|
||||||
*/
|
*/
|
||||||
qreal VEllipticalArc::AngleArc() const
|
qreal VEllipticalArc::AngleArc() const
|
||||||
{
|
{
|
||||||
if ((qFuzzyCompare(d->f1+1, 0+1) && qFuzzyCompare(d->f2, 360)) ||
|
if ((qFuzzyIsNull(d->f1) && qFuzzyCompare(d->f2, 360)) ||
|
||||||
(qFuzzyCompare(d->f1, 360) && qFuzzyCompare(d->f2+1, 0+1)))
|
(qFuzzyCompare(d->f1, 360) && qFuzzyIsNull(d->f2)))
|
||||||
{
|
{
|
||||||
return 360;
|
return 360;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define VELLIPTICALARC_P
|
#define VELLIPTICALARC_P
|
||||||
|
|
||||||
#include <QSharedData>
|
#include <QSharedData>
|
||||||
|
#include <../vmisc/vabstractapplication.h>
|
||||||
#include "vpointf.h"
|
#include "vpointf.h"
|
||||||
|
|
||||||
class VEllipticalArcData : public QSharedData
|
class VEllipticalArcData : public QSharedData
|
||||||
|
@ -22,9 +23,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle)
|
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle)
|
||||||
: f1(f1), f2(f2), formulaF1(QString("%1").arg(f1)), formulaF2(QString("%1").arg(f2)),
|
: f1(f1), f2(f2), formulaF1(QString().number(qApp->fromPixel(f1))),
|
||||||
radius1(radius1), radius2(radius2),
|
formulaF2(QString().number(qApp->fromPixel(f2))), radius1(radius1), radius2(radius2),
|
||||||
formulaRadius1(QString("%1").arg(radius1)), formulaRadius2(QString("%1").arg(radius2)),
|
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
|
||||||
|
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
|
||||||
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
|
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -37,9 +39,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle)
|
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle)
|
||||||
: f1(f1), f2(0), formulaF1(QString("%1").arg(f1)), formulaF2("0"),
|
: f1(f1), f2(0), formulaF1(QString().number(qApp->fromPixel(f1))), formulaF2("0"),
|
||||||
radius1(radius1), radius2(radius2),
|
radius1(radius1), radius2(radius2),
|
||||||
formulaRadius1(QString("%1").arg(radius1)), formulaRadius2(QString("%1").arg(radius2)),
|
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
|
||||||
|
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
|
||||||
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
|
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
# File with common stuff for whole project
|
# File with common stuff for whole project
|
||||||
include(../../../common.pri)
|
include(../../../common.pri)
|
||||||
|
|
||||||
|
QT += widgets
|
||||||
|
|
||||||
# Name of library
|
# Name of library
|
||||||
TARGET = vgeometry
|
TARGET = vgeometry
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ void TST_VEllipticalArc::CompareTwoWays()
|
||||||
|
|
||||||
const qreal eps = length*0.5/100; // computing error
|
const qreal eps = length*0.5/100; // computing error
|
||||||
const QString errorMsg =
|
const QString errorMsg =
|
||||||
QString("Difference between real and computing lengthes bigger than eps = %1.").arg(eps);
|
QString("Difference between real and computing lengthes bigger than eps = %1.").number(eps);
|
||||||
QVERIFY2(qAbs(arc1.GetLength() - length) <= eps, qUtf8Printable(errorMsg));
|
QVERIFY2(qAbs(arc1.GetLength() - length) <= eps, qUtf8Printable(errorMsg));
|
||||||
QVERIFY2(qAbs(arc2.GetLength() - length) <= eps, qUtf8Printable(errorMsg));
|
QVERIFY2(qAbs(arc2.GetLength() - length) <= eps, qUtf8Printable(errorMsg));
|
||||||
QVERIFY2(qAbs(arc1.GetLength() - arc2.GetLength()) <= eps, qUtf8Printable(errorMsg));
|
QVERIFY2(qAbs(arc1.GetLength() - arc2.GetLength()) <= eps, qUtf8Printable(errorMsg));
|
||||||
|
@ -84,7 +84,7 @@ void TST_VEllipticalArc::NegativeArc()
|
||||||
|
|
||||||
const qreal eps = 1; // computing error
|
const qreal eps = 1; // computing error
|
||||||
const QString errorMsg =
|
const QString errorMsg =
|
||||||
QString("Difference between real and computing lengthes bigger than eps = %1.").arg(eps);
|
QString("Difference between real and computing lengthes bigger than eps = %1.").number(eps);
|
||||||
|
|
||||||
QVERIFY2(qAbs(arc.GetLength() + length) <= eps, qUtf8Printable(errorMsg));
|
QVERIFY2(qAbs(arc.GetLength() + length) <= eps, qUtf8Printable(errorMsg));
|
||||||
QVERIFY2(arc.GetEndAngle() - f2 <= eps, qUtf8Printable(errorMsg));
|
QVERIFY2(arc.GetEndAngle() - f2 <= eps, qUtf8Printable(errorMsg));
|
||||||
|
@ -242,7 +242,7 @@ void TST_VEllipticalArc::TestGetPoints1()
|
||||||
const qreal equationRes = p.rx()*p.rx()/(radius1*radius1) + p.ry()*p.ry()/(radius2*radius2);
|
const qreal equationRes = p.rx()*p.rx()/(radius1*radius1) + p.ry()*p.ry()/(radius2*radius2);
|
||||||
const qreal diff = qAbs(equationRes - 1);
|
const qreal diff = qAbs(equationRes - 1);
|
||||||
const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse."
|
const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse."
|
||||||
"diff = '%1' > eps = '%2'").arg(diff).arg(eps);
|
"diff = '%1' > eps = '%2'").number(diff).number(eps);
|
||||||
QVERIFY2( diff <= eps, qUtf8Printable(errorMsg));
|
QVERIFY2( diff <= eps, qUtf8Printable(errorMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,8 +313,8 @@ void TST_VEllipticalArc::TestGetPoints2()
|
||||||
const QString errorMsg = QString("Broken the first rule, part 2. Distance from the any point to the focus1"
|
const QString errorMsg = QString("Broken the first rule, part 2. Distance from the any point to the focus1"
|
||||||
" plus distance from this point to the focus2 should be the same. Problem"
|
" plus distance from this point to the focus2 should be the same. Problem"
|
||||||
" with point '%1'. The disired distance is '%2', but resulting distance"
|
" with point '%1'. The disired distance is '%2', but resulting distance"
|
||||||
" is '%3'. Difference is '%4' and it biggest than eps "
|
" is '%3'. Difference is '%4' and it biggest than eps '%5')").number(i)
|
||||||
"('%5')").arg(i).arg(distance).arg(resultingDistance).arg(diff).arg(eps);
|
.number(distance).number(resultingDistance).number(diff).number(eps);
|
||||||
QVERIFY2( diff <= eps, qUtf8Printable(errorMsg));
|
QVERIFY2( diff <= eps, qUtf8Printable(errorMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user