Added CutArc in VEllipticalArc
--HG-- branch : feature
This commit is contained in:
parent
22a3e9d1a0
commit
cafd3ee583
|
@ -71,18 +71,21 @@ VEllipticalArc::VEllipticalArc(VPointF center, qreal radius1, qreal radius2, qre
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VEllipticalArc::VEllipticalArc(qreal length, QString formulaLength, VPointF center, qreal radius1, qreal radius2,
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1, quint32 idObject, Draw mode)
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1, qreal rotationAngle,
|
||||
quint32 idObject, Draw mode)
|
||||
: VAbstractCurve(GOType::EllipticalArc, idObject, mode),
|
||||
d (new VEllipticalArcData(formulaLength, center, radius1, radius2, formulaRadius1, formulaRadius2, f1, formulaF1))
|
||||
d (new VEllipticalArcData(formulaLength, center, radius1, radius2, formulaRadius1, formulaRadius2,
|
||||
f1, formulaF1, rotationAngle))
|
||||
{
|
||||
EllipticalArcName();
|
||||
FindF2(length);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VEllipticalArc::VEllipticalArc(qreal length, VPointF center, qreal radius1, qreal radius2, qreal f1)
|
||||
VEllipticalArc::VEllipticalArc(qreal length, VPointF center, qreal radius1, qreal radius2, qreal f1,
|
||||
qreal rotationAngle)
|
||||
: VAbstractCurve(GOType::EllipticalArc, NULL_ID, Draw::Calculation),
|
||||
d (new VEllipticalArcData(center, radius1, radius2, f1))
|
||||
d (new VEllipticalArcData(center, radius1, radius2, f1, rotationAngle))
|
||||
{
|
||||
EllipticalArcName();
|
||||
FindF2(length);
|
||||
|
@ -325,12 +328,40 @@ QVector<QPointF> VEllipticalArc::GetPoints() const
|
|||
*/
|
||||
QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const
|
||||
{
|
||||
//Always need return two arcs, so we must correct wrong length.
|
||||
qreal len = 0;
|
||||
if (length < this->GetLength()*0.02)
|
||||
{
|
||||
len = this->GetLength()*0.02;
|
||||
}
|
||||
else if ( length > this->GetLength()*0.98)
|
||||
{
|
||||
len = this->GetLength()*0.98;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = length;
|
||||
}
|
||||
|
||||
// the first arc has given length and startAngle just like in the origin arc
|
||||
arc1 = VEllipticalArc (len, QString().setNum(length), d->center, d->radius1, d->radius2,
|
||||
d->formulaRadius1, d->formulaRadius2, d->f1, d->formulaF1, d->rotationAngle,
|
||||
getIdObject(), getMode());
|
||||
// the second arc has startAngle just like endAngle of the first arc
|
||||
// and it has endAngle just like endAngle of the origin arc
|
||||
arc2 = VEllipticalArc (d->center, d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
|
||||
arc1.GetEndAngle(), arc1.GetFormulaF2(), d->f2, d->formulaF2, d->rotationAngle,
|
||||
getIdObject(), getMode());
|
||||
return arc1.GetP1();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VEllipticalArc::CutArc(const qreal &length) const
|
||||
{
|
||||
VEllipticalArc arc1;
|
||||
VEllipticalArc arc2;
|
||||
return this->CutArc(length, arc1, arc2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -40,16 +40,17 @@ class VEllipticalArc : public VAbstractCurve
|
|||
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc)
|
||||
public:
|
||||
VEllipticalArc();
|
||||
VEllipticalArc (VPointF center, qreal radius1, qreal radius2, QString formulaRadius1, QString formulaRadius2, qreal f1,
|
||||
QString formulaF1, qreal f2, QString formulaF2, qreal rotationAngle, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||
VEllipticalArc (VPointF center, qreal radius1, qreal radius2, QString formulaRadius1, QString formulaRadius2,
|
||||
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qreal rotationAngle,
|
||||
quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||
|
||||
VEllipticalArc (VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
|
||||
|
||||
VEllipticalArc (qreal length, QString formulaLength, VPointF center, qreal radius1, qreal radius2,
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1,
|
||||
QString formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1,
|
||||
qreal rotationAngle, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||
|
||||
VEllipticalArc (qreal length, VPointF center, qreal radius1, qreal radius2, qreal f1);
|
||||
VEllipticalArc (qreal length, VPointF center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
|
||||
|
||||
VEllipticalArc(const VEllipticalArc &arc);
|
||||
|
||||
|
|
|
@ -29,24 +29,26 @@ public:
|
|||
{}
|
||||
|
||||
VEllipticalArcData (QString formulaLength, VPointF center, qreal radius1, qreal radius2,
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1)
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1,
|
||||
qreal rotationAngle)
|
||||
: f1(f1), f2(0), formulaF1(formulaF1), formulaF2("0"), radius1(radius1),radius2(radius2),
|
||||
formulaRadius1(formulaRadius1), formulaRadius2(formulaRadius2),
|
||||
center(center), isFlipped(false), formulaLength(formulaLength), rotationAngle(0)
|
||||
center(center), isFlipped(false), formulaLength(formulaLength), rotationAngle(rotationAngle)
|
||||
{}
|
||||
|
||||
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1)
|
||||
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle)
|
||||
: f1(f1), f2(0), formulaF1(QString("%1").arg(f1)), formulaF2("0"),
|
||||
radius1(radius1), radius2(radius2),
|
||||
formulaRadius1(QString("%1").arg(radius1)), formulaRadius2(QString("%1").arg(radius2)),
|
||||
center(center), isFlipped(false), formulaLength(), rotationAngle(0)
|
||||
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
|
||||
{}
|
||||
|
||||
VEllipticalArcData(const VEllipticalArcData &arc)
|
||||
: QSharedData(arc), f1(arc.f1), f2(arc.f2), formulaF1(arc.formulaF1), formulaF2(arc.formulaF2),
|
||||
radius1(arc.radius1), radius2(arc.radius2),
|
||||
formulaRadius1(arc.formulaRadius1), formulaRadius2(arc.formulaRadius2),
|
||||
center(arc.center), isFlipped(arc.isFlipped), formulaLength(arc.formulaLength), rotationAngle(arc.rotationAngle)
|
||||
center(arc.center), isFlipped(arc.isFlipped), formulaLength(arc.formulaLength),
|
||||
rotationAngle(arc.rotationAngle)
|
||||
{}
|
||||
|
||||
virtual ~VEllipticalArcData();
|
||||
|
|
|
@ -51,7 +51,7 @@ void TST_VEllipticalArc::CompareTwoWays()
|
|||
const qreal length = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h)))/4;
|
||||
|
||||
VEllipticalArc arc1(center, radius1, radius2, f1, f2, rotationAngle);
|
||||
VEllipticalArc arc2(length, center, radius1, radius2, f1);
|
||||
VEllipticalArc arc2(length, center, radius1, radius2, f1, rotationAngle);
|
||||
|
||||
const qreal eps = length*0.5/100; // computing error
|
||||
const QString errorMsg =
|
||||
|
@ -75,11 +75,12 @@ void TST_VEllipticalArc::NegativeArc()
|
|||
const qreal radius2 = 200;
|
||||
const qreal f1 = 1;
|
||||
const qreal f2 = 181;
|
||||
const qreal rotationAngle = 0;
|
||||
|
||||
const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2));
|
||||
const qreal length = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h)))/2;
|
||||
qreal l = -length;
|
||||
VEllipticalArc arc(l, center, radius1, radius2, f1);
|
||||
VEllipticalArc arc(l, center, radius1, radius2, f1, rotationAngle);
|
||||
|
||||
const qreal eps = 1; // computing error
|
||||
const QString errorMsg =
|
||||
|
|
Loading…
Reference in New Issue
Block a user