Rotation VSpline and VSplinePath classes.
--HG-- branch : feature
This commit is contained in:
parent
8713c628dc
commit
2717382d71
|
@ -103,12 +103,26 @@ VSpline::VSpline(VPointF p1, VPointF p4, qreal angle1, const QString &angle1Form
|
|||
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
|
||||
const QString &c2LengthFormula, quint32 idObject, Draw mode)
|
||||
: VAbstractCubicBezier(GOType::Spline, idObject, mode),
|
||||
d(new VSplineData(p1, p4, angle1, angle1Formula, angle2,angle2Formula, c1Length, c1LengthFormula, c2Length,
|
||||
d(new VSplineData(p1, p4, angle1, angle1Formula, angle2, angle2Formula, c1Length, c1LengthFormula, c2Length,
|
||||
c2LengthFormula))
|
||||
{
|
||||
CreateName();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
|
||||
{
|
||||
const VPointF p1 = GetP1().Rotate(originPoint, degrees);
|
||||
const VPointF p4 = GetP4().Rotate(originPoint, degrees);
|
||||
|
||||
const QPointF p2 = VPointF::RotatePF(originPoint, GetP2(), degrees);
|
||||
const QPointF p3 = VPointF::RotatePF(originPoint, GetP3(), degrees);
|
||||
|
||||
VSpline spl(p1, p2, p3, p4);
|
||||
spl.setName(name() + prefix);
|
||||
return spl;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSpline::~VSpline()
|
||||
{}
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
VSpline (VPointF p1, VPointF p4, qreal angle1, const QString &angle1Formula, qreal angle2,
|
||||
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
|
||||
const QString &c2LengthFormula, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||
VSpline Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
|
||||
virtual ~VSpline();
|
||||
VSpline &operator=(const VSpline &spl);
|
||||
|
||||
|
|
|
@ -57,12 +57,7 @@ VSplinePath::VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve, qui
|
|||
return;
|
||||
}
|
||||
|
||||
QVector<VSplinePoint> newPoints;
|
||||
for (int i=0; i < points.size(); ++i)
|
||||
{
|
||||
newPoints.append(VSplinePoint());
|
||||
}
|
||||
|
||||
QVector<VSplinePoint> newPoints(points.size());
|
||||
for (qint32 i = 1; i <= points.size()-1; ++i)
|
||||
{
|
||||
const VFSplinePoint &p1 = points.at(i-1);
|
||||
|
@ -106,6 +101,30 @@ VSplinePath::VSplinePath(const VSplinePath &splPath)
|
|||
d(splPath.d)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSplinePath VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
|
||||
{
|
||||
QVector<VSplinePoint> newPoints(CountPoints());
|
||||
for (qint32 i = 1; i <= CountSubSpl(); ++i)
|
||||
{
|
||||
const VSplinePoint &p1 = d->path.at(i-1);
|
||||
const VSplinePoint &p2 = d->path.at(i);
|
||||
VSpline spl = GetSpline(i).Rotate(originPoint, degrees);
|
||||
|
||||
newPoints[i-1].SetP(p1.P());
|
||||
newPoints[i-1].SetAngle2(p1.Angle2(), spl.GetStartAngleFormula());
|
||||
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
|
||||
|
||||
newPoints[i].SetP(p2.P());
|
||||
newPoints[i].SetAngle1(p2.Angle1(), spl.GetEndAngleFormula());
|
||||
newPoints[i].SetLength1(spl.GetC2Length(), spl.GetC2LengthFormula());
|
||||
}
|
||||
|
||||
VSplinePath splPath(newPoints);
|
||||
splPath.setName(name() + prefix);
|
||||
return splPath;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSplinePath::~VSplinePath()
|
||||
{}
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
Draw mode = Draw::Calculation);
|
||||
VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||
VSplinePath(const VSplinePath& splPath);
|
||||
VSplinePath Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
|
||||
virtual ~VSplinePath() Q_DECL_OVERRIDE;
|
||||
|
||||
VSplinePath &operator=(const VSplinePath &path);
|
||||
|
|
Loading…
Reference in New Issue
Block a user