Merged develop into feature
--HG-- branch : feature
This commit is contained in:
commit
364de552e5
|
@ -50,7 +50,7 @@ VFSplinePoint::VFSplinePoint()
|
||||||
* @param kAsm2 coefficient of length second control line.
|
* @param kAsm2 coefficient of length second control line.
|
||||||
* @param angle2 second angle control line.
|
* @param angle2 second angle control line.
|
||||||
*/
|
*/
|
||||||
VFSplinePoint::VFSplinePoint(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
|
VFSplinePoint::VFSplinePoint(const VPointF &pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
|
||||||
:d(new VFSplinePointData(pSpline, kAsm1, angle1, kAsm2, angle2))
|
:d(new VFSplinePointData(pSpline, kAsm1, angle1, kAsm2, angle2))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -195,8 +195,9 @@ VSplinePoint::VSplinePoint()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VSplinePoint::VSplinePoint(VPointF pSpline, qreal angle1, const QString &angle1F, qreal angle2, const QString &angle2F,
|
VSplinePoint::VSplinePoint(const VPointF &pSpline, qreal angle1, const QString &angle1F, qreal angle2,
|
||||||
qreal length1, const QString &length1F, qreal length2, const QString &length2F)
|
const QString &angle2F, qreal length1, const QString &length1F, qreal length2,
|
||||||
|
const QString &length2F)
|
||||||
: d(new VSplinePointData(pSpline, angle1, angle1F, angle2, angle2F, length1, length1F, length2, length2F))
|
: d(new VSplinePointData(pSpline, angle1, angle1F, angle2, angle2F, length1, length1F, length2, length2F))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ class VFSplinePoint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VFSplinePoint();
|
VFSplinePoint();
|
||||||
VFSplinePoint(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
|
VFSplinePoint(const VPointF &pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
|
||||||
VFSplinePoint(const VFSplinePoint &point);
|
VFSplinePoint(const VFSplinePoint &point);
|
||||||
VFSplinePoint &operator=(const VFSplinePoint &point);
|
VFSplinePoint &operator=(const VFSplinePoint &point);
|
||||||
~VFSplinePoint();
|
~VFSplinePoint();
|
||||||
|
@ -79,7 +79,7 @@ class VSplinePoint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VSplinePoint();
|
VSplinePoint();
|
||||||
VSplinePoint(VPointF pSpline, qreal angle1, const QString &angle1F, qreal angle2, const QString &angle2F,
|
VSplinePoint(const VPointF &pSpline, qreal angle1, const QString &angle1F, qreal angle2, const QString &angle2F,
|
||||||
qreal length1, const QString &length1F, qreal length2, const QString &length2F);
|
qreal length1, const QString &length1F, qreal length2, const QString &length2F);
|
||||||
VSplinePoint(const VSplinePoint &point);
|
VSplinePoint(const VSplinePoint &point);
|
||||||
VSplinePoint &operator=(const VSplinePoint &point);
|
VSplinePoint &operator=(const VSplinePoint &point);
|
||||||
|
|
|
@ -51,7 +51,8 @@ SOURCES += \
|
||||||
tst_findpoint.cpp \
|
tst_findpoint.cpp \
|
||||||
tst_vellipticalarc.cpp \
|
tst_vellipticalarc.cpp \
|
||||||
tst_vcubicbezierpath.cpp \
|
tst_vcubicbezierpath.cpp \
|
||||||
tst_vgobject.cpp
|
tst_vgobject.cpp \
|
||||||
|
tst_vsplinepath.cpp
|
||||||
|
|
||||||
win32-msvc*:SOURCES += stable.cpp
|
win32-msvc*:SOURCES += stable.cpp
|
||||||
|
|
||||||
|
@ -73,7 +74,8 @@ HEADERS += \
|
||||||
tst_findpoint.h \
|
tst_findpoint.h \
|
||||||
tst_vellipticalarc.h \
|
tst_vellipticalarc.h \
|
||||||
tst_vcubicbezierpath.h \
|
tst_vcubicbezierpath.h \
|
||||||
tst_vgobject.h
|
tst_vgobject.h \
|
||||||
|
tst_vsplinepath.h
|
||||||
|
|
||||||
# Set using ccache. Function enable_ccache() defined in common.pri.
|
# Set using ccache. Function enable_ccache() defined in common.pri.
|
||||||
$$enable_ccache()
|
$$enable_ccache()
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "tst_vabstractcurve.h"
|
#include "tst_vabstractcurve.h"
|
||||||
#include "tst_vcubicbezierpath.h"
|
#include "tst_vcubicbezierpath.h"
|
||||||
#include "tst_vgobject.h"
|
#include "tst_vgobject.h"
|
||||||
|
#include "tst_vsplinepath.h"
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
|
||||||
|
@ -66,6 +67,7 @@ int main(int argc, char** argv)
|
||||||
ASSERT_TEST(new TST_VPoster());
|
ASSERT_TEST(new TST_VPoster());
|
||||||
ASSERT_TEST(new TST_VAbstractDetail());
|
ASSERT_TEST(new TST_VAbstractDetail());
|
||||||
ASSERT_TEST(new TST_VSpline());
|
ASSERT_TEST(new TST_VSpline());
|
||||||
|
ASSERT_TEST(new TST_VSplinePath());
|
||||||
ASSERT_TEST(new TST_NameRegExp());
|
ASSERT_TEST(new TST_NameRegExp());
|
||||||
ASSERT_TEST(new TST_VLayoutDetail());
|
ASSERT_TEST(new TST_VLayoutDetail());
|
||||||
ASSERT_TEST(new TST_VArc());
|
ASSERT_TEST(new TST_VArc());
|
||||||
|
|
137
src/test/ValentinaTest/tst_vsplinepath.cpp
Normal file
137
src/test/ValentinaTest/tst_vsplinepath.cpp
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 10 9, 2016
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2016 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "tst_vsplinepath.h"
|
||||||
|
#include "../vgeometry/vsplinepath.h"
|
||||||
|
#include "../vmisc/logging.h"
|
||||||
|
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
TST_VSplinePath::TST_VSplinePath(QObject *parent)
|
||||||
|
: QObject (parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_VSplinePath::TestRotation_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QVector<VSplinePoint>>("originPoints");
|
||||||
|
QTest::addColumn<QPointF>("originPoint");
|
||||||
|
QTest::addColumn<qreal>("degrees");
|
||||||
|
QTest::addColumn<QString>("prefix");
|
||||||
|
QTest::addColumn<QVector<VSplinePoint>>("rotatedPoints");
|
||||||
|
|
||||||
|
QVector<VSplinePoint> originPoints;
|
||||||
|
|
||||||
|
{
|
||||||
|
VPointF pSpline(30, 39.999874015748034, "X", 5.0000125984251973, 9.9999874015748045);
|
||||||
|
VSplinePoint p(pSpline, 89.208600000000004, "89.2086", 269.20859999999999, "269.209", 0, "0",
|
||||||
|
153.33618897637794, "4.05702");
|
||||||
|
originPoints.append(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
VPointF pSpline(198.77104389529981, 249.18158602595835, "X", 5.0000125984251973, 9.9999874015748045);
|
||||||
|
VSplinePoint p(pSpline, 146.43199999999999, "146.432", 326.43200000000002, "326.432",
|
||||||
|
36.387590551181106, "0.962755", 60.978897637795278, "1.6134");
|
||||||
|
originPoints.append(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
VPointF pSpline(820.42771653543309, 417.95262992125987, "X", 5.0000125984251973, 9.9999874015748045);
|
||||||
|
VSplinePoint p(pSpline, 173.39500000000001, "173.395", 353.39499999999998, "353.395",
|
||||||
|
381.23716535433073, "10.0869", 0, "0");
|
||||||
|
originPoints.append(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<VSplinePoint> rotatedPoints;
|
||||||
|
|
||||||
|
{
|
||||||
|
VPointF pSpline(-347.55140568256883, 400.53936590535034, "X", 5.0000125984251973, 9.9999874015748045);
|
||||||
|
VSplinePoint p(pSpline, 176.56789999999998, "176.568", 356.56790000000001, "356.568", 0, "0",
|
||||||
|
153.33618897637794, "4.05702");
|
||||||
|
rotatedPoints.append(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
VPointF pSpline(-130.81610509751462, 241.58508512833563, "X", 5.0000125984251973, 9.9999874015748045);
|
||||||
|
VSplinePoint p(pSpline, 233.79130000000001, "233.791", 53.791300000000014, "53.7913",
|
||||||
|
36.387590551181141, "0.962755", 60.978897637795207, "1.6134");
|
||||||
|
rotatedPoints.append(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
VPointF pSpline(66.417055567032421, -371.63572683892357, "X", 5.0000125984251973, 9.9999874015748045);
|
||||||
|
VSplinePoint p(pSpline, 260.7543, "260.754", 80.754300000000015, "80.7543", 381.23716535433078, "10.0869", 0,
|
||||||
|
"0");
|
||||||
|
rotatedPoints.append(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTest::newRow("Test spline path 1") << originPoints << QPointF(30, 417.95262992125987) << 87.359300000000005 << "a2"
|
||||||
|
<< rotatedPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_VSplinePath::TestRotation()
|
||||||
|
{
|
||||||
|
QFETCH(QVector<VSplinePoint>, originPoints);
|
||||||
|
QFETCH(QPointF, originPoint);
|
||||||
|
QFETCH(qreal, degrees);
|
||||||
|
QFETCH(QString, prefix);
|
||||||
|
QFETCH(QVector<VSplinePoint>, rotatedPoints);
|
||||||
|
|
||||||
|
const VSplinePath rotatedPath(rotatedPoints);
|
||||||
|
|
||||||
|
const VSplinePath originPath(originPoints);
|
||||||
|
const VSplinePath res = originPath.Rotate(originPoint, degrees, prefix);
|
||||||
|
|
||||||
|
QCOMPARE(originPath.GetLength(), res.GetLength());
|
||||||
|
QCOMPARE(rotatedPath.GetLength(), res.GetLength());
|
||||||
|
QCOMPARE(rotatedPath.CountPoints(), res.CountPoints());
|
||||||
|
|
||||||
|
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
|
||||||
|
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
|
||||||
|
|
||||||
|
const QVector<VSplinePoint> resPoints = res.GetSplinePath();
|
||||||
|
|
||||||
|
for (int i=0; i < resPoints.size(); ++i)
|
||||||
|
{
|
||||||
|
const VSplinePoint resPoint = resPoints.at(i);
|
||||||
|
const VSplinePoint rotatedPoint = rotatedPoints.at(i);
|
||||||
|
|
||||||
|
QCOMPARE(rotatedPoint.Angle1(), resPoint.Angle1());
|
||||||
|
QCOMPARE(rotatedPoint.Angle2(), resPoint.Angle2());
|
||||||
|
QCOMPARE(rotatedPoint.Length1(), resPoint.Length1());
|
||||||
|
QCOMPARE(rotatedPoint.Length2(), resPoint.Length2());
|
||||||
|
QCOMPARE(rotatedPoint.P().toQPointF().toPoint(), resPoint.P().toQPointF().toPoint());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
46
src/test/ValentinaTest/tst_vsplinepath.h
Normal file
46
src/test/ValentinaTest/tst_vsplinepath.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 10 9, 2016
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2016 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TST_VSPLINEPATH_H
|
||||||
|
#define TST_VSPLINEPATH_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class TST_VSplinePath : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TST_VSplinePath(QObject *parent = nullptr);
|
||||||
|
private slots:
|
||||||
|
void TestRotation_data();
|
||||||
|
void TestRotation();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(TST_VSplinePath)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TST_VSPLINEPATH_H
|
Loading…
Reference in New Issue
Block a user