diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index 5a20405d0..c2cdec515 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -32,7 +32,7 @@ #include "../vmisc/vabstractapplication.h" #include "../vmisc/logging.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "visualization/visualization.h" +#include "../../visualization/visualization.h" #include "../ifc/xml/vabstractpattern.h" #include diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index bcf1e17ae..04f1716bd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -133,6 +133,11 @@ QPointF VToolPointOfIntersectionCurves::FindPoint(const QVector &curve1 const QVector &curve2Points, VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint) { + if (curve1Points.isEmpty() || curve2Points.isEmpty()) + { + return QPointF(); + } + QVector intersections; for ( auto i = 0; i < curve1Points.count()-1; ++i ) { diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index 4c1513c87..19be562c6 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -33,7 +33,7 @@ #include "../ifc/xml/vabstractpattern.h" #include "../vmisc/vabstractapplication.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "visualization/visualization.h" +#include "../visualization/visualization.h" class QDomElement; class QLineF; diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index a11102d45..a9c6f8ff8 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -53,7 +53,8 @@ SOURCES += \ tst_misc.cpp \ tst_vcommandline.cpp \ tst_tstranslation.cpp \ - tst_vdetail.cpp + tst_vdetail.cpp \ + tst_findpoint.cpp HEADERS += \ tst_vposter.h \ @@ -74,7 +75,8 @@ HEADERS += \ tst_misc.h \ tst_vcommandline.h \ tst_tstranslation.h \ - tst_vdetail.h + tst_vdetail.h \ + tst_findpoint.h # Set using ccache. Function enable_ccache() defined in common.pri. $$enable_ccache() @@ -145,6 +147,24 @@ CONFIG(debug, debug|release){ } } +#VTools static library (depend on VWidgets, VMisc, VPatternDB) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vtools/$${DESTDIR}/ -lvtools + +INCLUDEPATH += $$PWD/../../libs/vtools +DEPENDPATH += $$PWD/../../libs/vtools + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/vtools.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/libvtools.a + +#VWidgets static library +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets + +INCLUDEPATH += $$PWD/../../libs/vwidgets +DEPENDPATH += $$PWD/../../libs/vwidgets + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a + # VFormat static library (depend on VPatternDB, IFC) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat diff --git a/src/test/ValentinaTest/qttestmainlambda.cpp b/src/test/ValentinaTest/qttestmainlambda.cpp index 703998357..bad3060f0 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -45,6 +45,7 @@ #include "tst_vcommandline.h" #include "tst_tstranslation.h" #include "tst_vdetail.h" +#include "tst_findpoint.h" int main(int argc, char** argv) { @@ -59,6 +60,7 @@ int main(int argc, char** argv) delete obj; }; + ASSERT_TEST(new TST_FindPoint()); ASSERT_TEST(new TST_VDetail()); ASSERT_TEST(new TST_VPoster()); ASSERT_TEST(new TST_VAbstractDetail()); diff --git a/src/test/ValentinaTest/tst_findpoint.cpp b/src/test/ValentinaTest/tst_findpoint.cpp new file mode 100644 index 000000000..31f10b20d --- /dev/null +++ b/src/test/ValentinaTest/tst_findpoint.cpp @@ -0,0 +1,167 @@ +/************************************************************************ + ** + ** @file tst_findpoint.cpp + ** @author Roman Telezhynskyi + ** @date 25 1, 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 + ** 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 . + ** + *************************************************************************/ + +#include "tst_findpoint.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +TST_FindPoint::TST_FindPoint(QObject *parent) : + QObject(parent) +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_FindPoint::TestPointOfIntersectionCurves_data() +{ + QTest::addColumn>("curve1Points"); + QTest::addColumn>("curve2Points"); + QTest::addColumn("vCross"); + QTest::addColumn("hCross"); + QTest::addColumn("expect"); + + QVector points1; + QVector points2; + + VCrossCurvesPoint v = VCrossCurvesPoint::HighestPoint; + HCrossCurvesPoint h = HCrossCurvesPoint::LeftPoint; + QPointF p; + + QTest::newRow("Empty lists of points") << points1 << points2 << static_cast(v) << static_cast(h) << p; + + points1.clear(); + points1.append(QPointF(10, 10)); + points1.append(QPointF(15, 20)); + points1.append(QPointF(10, 30)); + + points2.clear(); + points2.append(QPointF(30, 10)); + points2.append(QPointF(25, 20)); + points2.append(QPointF(30, 30)); + QTest::newRow("No intersections") << points1 << points2 << static_cast(v) << static_cast(h) << p; + + points1.clear(); + points1.append(QPointF(10, 10)); + points1.append(QPointF(20, 20)); + points1.append(QPointF(10, 30)); + + points2.clear(); + points2.append(QPointF(30, 10)); + points2.append(QPointF(20, 20)); + points2.append(QPointF(30, 30)); + + p = QPointF(20, 20); + QTest::newRow("One intersection point") << points1 << points2 << static_cast(v) << static_cast(h) << p; + + points1.clear(); + points1.append(QPointF(10, 10)); + points1.append(QPointF(25, 20)); + points1.append(QPointF(10, 30)); + + points2.clear(); + points2.append(QPointF(25, 10)); + points2.append(QPointF(15, 20)); + points2.append(QPointF(25, 30)); + + p = QPointF(19, 16); + + h = HCrossCurvesPoint::LeftPoint; + QTest::newRow("Two intersection points (highest point, leftmost point)") << points1 << points2 + << static_cast(v) + << static_cast(h) << p; + + h = HCrossCurvesPoint::RightPoint; + QTest::newRow("Two intersection points (highest point, rightmost point)") << points1 << points2 + << static_cast(v) + << static_cast(h) << p; + + v = VCrossCurvesPoint::LowestPoint; + p = QPointF(19, 24); + + h = HCrossCurvesPoint::LeftPoint; + QTest::newRow("Two intersection points (lowest point, leftmost point)") << points1 << points2 + << static_cast(v) + << static_cast(h) << p; + + h = HCrossCurvesPoint::RightPoint; + QTest::newRow("Two intersection points (lowest point, rightmost point)") << points1 << points2 + << static_cast(v) + << static_cast(h) << p; + + points1.clear(); + points1.append(QPointF(10, 10)); + points1.append(QPointF(20, 25)); + points1.append(QPointF(30, 10)); + + points2.clear(); + points2.append(QPointF(10, 30)); + points2.append(QPointF(20, 15)); + points2.append(QPointF(30, 30)); + + h = HCrossCurvesPoint::LeftPoint; + p = QPointF(16.6667, 20); + + v = VCrossCurvesPoint::HighestPoint; + QTest::newRow("Two intersection points (leftmost point, highest point)") << points1 << points2 + << static_cast(v) + << static_cast(h) << p; + + v = VCrossCurvesPoint::LowestPoint; + QTest::newRow("Two intersection points (leftmost point, lowest point)") << points1 << points2 + << static_cast(v) + << static_cast(h) << p; + + h = HCrossCurvesPoint::RightPoint; + p = QPointF(23.3333, 20); + + v = VCrossCurvesPoint::HighestPoint; + QTest::newRow("Two intersection points (rightmost point, highest point)") << points1 << points2 + << static_cast(v) + << static_cast(h) << p; + + v = VCrossCurvesPoint::LowestPoint; + QTest::newRow("Two intersection points (rightmost point, lowest point)") << points1 << points2 + << static_cast(v) + << static_cast(h) << p; +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_FindPoint::TestPointOfIntersectionCurves() +{ + QFETCH(QVector, curve1Points); + QFETCH(QVector, curve2Points); + QFETCH(int, vCross); + QFETCH(int, hCross); + QFETCH(QPointF, expect); + + const QPointF result = VToolPointOfIntersectionCurves::FindPoint(curve1Points, curve2Points, + static_cast(vCross), + static_cast(hCross)); + QCOMPARE(result.toPoint(), expect.toPoint()); +} diff --git a/src/test/ValentinaTest/tst_findpoint.h b/src/test/ValentinaTest/tst_findpoint.h new file mode 100644 index 000000000..08d26676e --- /dev/null +++ b/src/test/ValentinaTest/tst_findpoint.h @@ -0,0 +1,46 @@ +/************************************************************************ + ** + ** @file tst_findpoint.h + ** @author Roman Telezhynskyi + ** @date 25 1, 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 + ** 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 . + ** + *************************************************************************/ + +#ifndef TST_FINDPOINT_H +#define TST_FINDPOINT_H + +#include + +class TST_FindPoint : public QObject +{ + Q_OBJECT +public: + explicit TST_FindPoint(QObject *parent = nullptr); + +private slots: + void TestPointOfIntersectionCurves_data(); + void TestPointOfIntersectionCurves(); + +}; + +#endif // TST_FINDPOINT_H