diff --git a/ChangeLog.txt b/ChangeLog.txt index 4fabf497c..b6fb43eec 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -54,6 +54,8 @@ - [#526] Dialog Detail is not on top after selection second object on Mac. - [#532] Unexpected error occurs when zoom out image. - [#537] Valentina crashes when use undo command. +- [#544] Error: Color Lines are black until touched. +- [#543] Detail loses details. # Version 0.4.4 April 12, 2016 - Updated measurement templates with all measurements. Added new template Aldrich/Women measurements. diff --git a/appveyor.yml b/appveyor.yml index 9aad5e0dc..6aad953df 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -121,7 +121,7 @@ init: # Path before - path - set QTDIR=C:\%QT5% - - set PATH=%QTDIR%\bin;C:\Tools\PsTools;C:\Windows\system32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Mercurial\ + - set PATH=%QTDIR%\bin;%QTDIR%\include;C:\Tools\PsTools;C:\Windows\system32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Mercurial\ # Installing various utilities #- if "%QMAKE_GENERATOR%" == "MinGW Makefiles" choco install -y InnoSetup #- if "%QMAKE_GENERATOR%" == "MinGW Makefiles" if "%PLATFORM%" == "x86" set PATH="C:\Program Files\Inno Setup 5";%PATH% @@ -181,4 +181,6 @@ notifications: - dismine@gmail.com - susan.spencer@gmail.com - zhuravska19@gmail.com + on_build_success: false + on_build_failure: true on_build_status_changed: true diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh new file mode 100755 index 000000000..c0d276445 --- /dev/null +++ b/scripts/cppcheck.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# This script helps run cppcheck with the same keys we have on codeship.com (except for key --platform=unix32). +# Please, run this script from folder /scripts. + +# Because we use the last available cppcheck version usually we build it manually. +CPPCHECK="../../../../cppcheck/cppcheck" +$CPPCHECK \ + -j4 -f -q \ + -U__INTEL_COMPILER_UPDATE \ + -UqApp \ + --template '{file}:{line}:{message}:{id}' \ + --inline-suppr \ + --platform=unix32 \ + --std=c++11 \ + --std=posix \ + --enable=all \ + --library=qt.cfg \ + --library=std.cfg \ + --library=posix.cfg \ + --inconclusive \ + --suppress=leakReturnValNotUsed:../src/app/valentina/core/vapplication.cpp \ + --suppress=unmatchedSuppression:../src/libs/ifc/xml/vdomdocument.cpp \ + --suppress=redundantCondition:../src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp \ + --suppress=unmatchedSuppression:../src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp \ + ../src diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 17d1333a0..c2b303348 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -35,15 +35,15 @@ #include "../vwidgets/vmaingraphicsview.h" #include "../version.h" #include "../vmisc/logging.h" +#include "../vmisc/vmath.h" #include "../qmuparser/qmuparsererror.h" #include "../mainwindow.h" -#include +#include #include #include #include #include -#include #include #include #include diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 99e9ba304..df271b77c 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -31,12 +31,7 @@ #include "../core/vapplication.h" #include "../ifc/xml/vdomdocument.h" #include "../vmisc/vsettings.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -# include -#endif +#include "../vmisc/vmath.h" #include #include diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 8ffd7f78d..f52e30881 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include const QString baseFilenameRegExp = QStringLiteral("^[\\w\\-. ]+$"); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index dda3a33a3..227e49c6a 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -59,7 +59,7 @@ #include "dialogs/vwidgetdetails.h" #include -#include +#include #include #include #include diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 5a78232f6..dae100813 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -41,6 +41,7 @@ #include "../ifc/xml/vpatternconverter.h" #include "../vmisc/undoevent.h" #include "../vmisc/vsettings.h" +#include "../vmisc/vmath.h" #include "../qmuparser/qmuparsererror.h" #include "../vgeometry/varc.h" #include "../vgeometry/vsplinepath.h" @@ -53,7 +54,6 @@ #include #include -#include #include const QString VPattern::AttrReadOnly = QStringLiteral("readOnly"); diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index 3ae81b1bb..9339eb5d8 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 723c0b177..2d1cf5568 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -28,7 +28,6 @@ #include "vabstractpattern.h" -#include #include #include #include diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 48ce29b1d..d2499b4fd 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -47,7 +47,6 @@ #include #include -#include #include #include #include diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 85bec67a9..98dbcc13b 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -30,7 +30,6 @@ #define VDOMDOCUMENT_H #include -#include #include #include #include diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp index 4d7164c87..68f8dccc3 100644 --- a/src/libs/qmuparser/qmuparser.cpp +++ b/src/libs/qmuparser/qmuparser.cpp @@ -21,8 +21,6 @@ #include "qmuparser.h" -#include -#include #include #include #include @@ -33,6 +31,7 @@ #include "qmuparserdef.h" #include "qmuparsererror.h" +#include "../vmisc/vmath.h" using namespace std; diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index 9c3ce6603..04d87ddb5 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -21,7 +21,6 @@ #include "qmuparserbase.h" -#include #include #include #include @@ -29,14 +28,14 @@ #include #include #include - -#include "qmudef.h" #ifdef QMUP_USE_OPENMP #include #endif -#include #include +#include "qmudef.h" +#include "../vmisc/vmath.h" + using namespace std; /** diff --git a/src/libs/qmuparser/qmuparserbytecode.cpp b/src/libs/qmuparser/qmuparserbytecode.cpp index 53d408a2a..0bc204bd3 100644 --- a/src/libs/qmuparser/qmuparserbytecode.cpp +++ b/src/libs/qmuparser/qmuparserbytecode.cpp @@ -21,9 +21,7 @@ #include "qmuparserbytecode.h" -#include #include -#include #include #include #include @@ -31,6 +29,7 @@ #include "qmudef.h" #include "qmuparsererror.h" +#include "../vmisc/vmath.h" namespace qmu { diff --git a/src/libs/qmuparser/qmuparsertest.cpp b/src/libs/qmuparser/qmuparsertest.cpp index 5426ee9d2..84cdb1128 100644 --- a/src/libs/qmuparser/qmuparsertest.cpp +++ b/src/libs/qmuparser/qmuparsertest.cpp @@ -21,11 +21,9 @@ #include "qmuparsertest.h" -#include #include #include #include -#include #include #include #include @@ -41,6 +39,7 @@ #include "qmudef.h" #include "qmuparser.h" #include "qmuparsererror.h" +#include "../vmisc/vmath.h" using namespace std; diff --git a/src/libs/qmuparser/qmuparsertokenreader.cpp b/src/libs/qmuparser/qmuparsertokenreader.cpp index 6fe8f40db..bfafef72c 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.cpp +++ b/src/libs/qmuparser/qmuparsertokenreader.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/src/libs/vdxf/dxflib/dl_extrusion.h b/src/libs/vdxf/dxflib/dl_extrusion.h index 46eb8bdff..dcde7bcdd 100644 --- a/src/libs/vdxf/dxflib/dl_extrusion.h +++ b/src/libs/vdxf/dxflib/dl_extrusion.h @@ -27,8 +27,7 @@ #include "dl_global.h" -#include - +#include "../vmisc/vmath.h" /** * Storing and passing around attributes. Attributes @@ -103,7 +102,7 @@ public: /** * @param dir vector. */ - void getDirection(double dir[]) const + void getDirection(double dir[]) const { dir[0]=direction[0]; dir[1]=direction[1]; diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index ea570f5ea..c16932982 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -28,11 +28,9 @@ #include "vdxfengine.h" -#include #include #include #include -#include #include #include #include @@ -49,6 +47,7 @@ #include "../vmisc/def.h" #include "../vmisc/diagnostic.h" +#include "../vmisc/vmath.h" #include "dxflib/dl_attributes.h" #include "dxflib/dl_codes.h" #include "dxflib/dl_dxf.h" @@ -65,11 +64,6 @@ class QPolygonF; class QRect; class QRectF; -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - //--------------------------------------------------------------------------------------------------------------------- static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() { diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index b6325cf36..a7c4857ec 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/libs/vgeometry/vabstractcubicbezier.cpp b/src/libs/vgeometry/vabstractcubicbezier.cpp index 5d658a7ec..35179a844 100644 --- a/src/libs/vgeometry/vabstractcubicbezier.cpp +++ b/src/libs/vgeometry/vabstractcubicbezier.cpp @@ -28,14 +28,13 @@ #include "vabstractcubicbezier.h" -#include -#include #include #include #include #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" #include "../vgeometry/vpointf.h" //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index 6e05af017..d50762799 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -28,7 +28,6 @@ #include "vabstractcurve.h" -#include #include #include #include diff --git a/src/libs/vgeometry/varc.cpp b/src/libs/vgeometry/varc.cpp index 5d3cb083f..56b1f18e4 100644 --- a/src/libs/vgeometry/varc.cpp +++ b/src/libs/vgeometry/varc.cpp @@ -28,11 +28,11 @@ #include "varc.h" -#include #include #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" #include "../ifc/ifcdef.h" #include "vabstractcurve.h" #include "varc_p.h" diff --git a/src/libs/vgeometry/vcubicbezier_p.h b/src/libs/vgeometry/vcubicbezier_p.h index f94c6931f..548b9ea21 100644 --- a/src/libs/vgeometry/vcubicbezier_p.h +++ b/src/libs/vgeometry/vcubicbezier_p.h @@ -31,11 +31,11 @@ #include #include -#include #include "vpointf.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/diagnostic.h" +#include "../vmisc/vmath.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") diff --git a/src/libs/vgeometry/vcubicbezierpath.cpp b/src/libs/vgeometry/vcubicbezierpath.cpp index 3ec8acbd2..496354a8a 100644 --- a/src/libs/vgeometry/vcubicbezierpath.cpp +++ b/src/libs/vgeometry/vcubicbezierpath.cpp @@ -28,21 +28,16 @@ #include "vcubicbezierpath.h" -#include #include #include #include "../ifc/exception/vexception.h" +#include "../vmisc/vmath.h" #include "vabstractcurve.h" #include "vcubicbezierpath_p.h" #include "vspline.h" #include "vsplinepoint.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - //--------------------------------------------------------------------------------------------------------------------- VCubicBezierPath::VCubicBezierPath(quint32 idObject, Draw mode) : VAbstractCubicBezierPath(GOType::CubicBezierPath, idObject, mode), diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index f58a89dbd..ce2dab7cf 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -28,12 +28,11 @@ #include "vellipticalarc.h" -#include -#include #include #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" #include "../ifc/ifcdef.h" #include "../vmisc/vabstractapplication.h" #include "vabstractcurve.h" diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index d5c1e8bdc..e9e91f1cd 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -28,8 +28,6 @@ #include "vgobject.h" -#include -#include #include #include #include @@ -37,9 +35,12 @@ #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" #include "../ifc/ifcdef.h" #include "vgobject_p.h" +double VGObject::accuracyPointOnLine = (0.5/*mm*/ / 25.4) * PrintDPI; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VGObject default constructor. @@ -505,14 +506,16 @@ double VGObject::PerpDotProduct(const QPointF &p1, const QPointF &p2, const QPoi * There is the floating-point accuraccy problem, so instead of checking against zero, some epsilon value has to be * used. Because the size of the pdp value depends on the length of the vectors, no static value can be used. One * approach is to compare the pdp/area value to the fraction of another area which also depends on the length of the - * line e1=(p1, p2), e.g. the area of the square with side e1 which is computed below + * line e1=(p1, p2), e.g. the minimal area calucalted with PerpDotProduc() if point still not on the line. This distance + * is controled by variable accuracyPointOnLine */ double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2) { - const double dx1 = p2.x() - p1.x(); - const double dy1 = p2.y() - p1.y(); - const double epsilon = 0.06 * (dx1 * dx1 + dy1 * dy1); //-V636 - return epsilon; + QLineF line(p1, p2); + line.setAngle(line.angle() + 90); + line.setLength(accuracyPointOnLine); // less than accuracy means the same point + + return qAbs(PerpDotProduct(p1, p2, line.p2())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h index ba8f8625a..19a6ddc18 100644 --- a/src/libs/vgeometry/vgobject.h +++ b/src/libs/vgeometry/vgobject.h @@ -91,6 +91,8 @@ public: static QVector GetReversePoints(const QVector &points); static int GetLengthContour(const QVector &contour, const QVector &newPoints); + + static double accuracyPointOnLine; private: QSharedDataPointer d; diff --git a/src/libs/vgeometry/vspline.cpp b/src/libs/vgeometry/vspline.cpp index 4ad845f8f..b4834b796 100644 --- a/src/libs/vgeometry/vspline.cpp +++ b/src/libs/vgeometry/vspline.cpp @@ -28,11 +28,11 @@ #include "vspline.h" -#include #include #include "vabstractcurve.h" #include "vspline_p.h" +#include "../vmisc/vmath.h" class QPointF; diff --git a/src/libs/vgeometry/vspline_p.h b/src/libs/vgeometry/vspline_p.h index 43d8fb532..8ff0535d4 100644 --- a/src/libs/vgeometry/vspline_p.h +++ b/src/libs/vgeometry/vspline_p.h @@ -31,10 +31,10 @@ #include #include -#include #include "vpointf.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/vmath.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") diff --git a/src/libs/vgeometry/vsplinepath.cpp b/src/libs/vgeometry/vsplinepath.cpp index 99bdffc71..e3376b348 100644 --- a/src/libs/vgeometry/vsplinepath.cpp +++ b/src/libs/vgeometry/vsplinepath.cpp @@ -31,14 +31,10 @@ #include #include "../ifc/exception/vexception.h" +#include "../vmisc/vmath.h" #include "vabstractcurve.h" #include "vsplinepath_p.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - //--------------------------------------------------------------------------------------------------------------------- /** * @brief VSplinePath constructor. diff --git a/src/libs/vgeometry/vsplinepoint_p.h b/src/libs/vgeometry/vsplinepoint_p.h index 3addb8385..980083196 100644 --- a/src/libs/vgeometry/vsplinepoint_p.h +++ b/src/libs/vgeometry/vsplinepoint_p.h @@ -30,7 +30,7 @@ #define VSPLINEPOINT_P_H #include -#include +#include #include "vpointf.h" #include "../vmisc/def.h" diff --git a/src/libs/vlayout/vabstractdetail.cpp b/src/libs/vlayout/vabstractdetail.cpp index 9f8f55f77..ab84771bc 100644 --- a/src/libs/vlayout/vabstractdetail.cpp +++ b/src/libs/vlayout/vabstractdetail.cpp @@ -28,7 +28,6 @@ #include "vabstractdetail.h" -#include #include #include #include diff --git a/src/libs/vlayout/vcontour.cpp b/src/libs/vlayout/vcontour.cpp index b5ccd2b80..3a703081f 100644 --- a/src/libs/vlayout/vcontour.cpp +++ b/src/libs/vlayout/vcontour.cpp @@ -28,7 +28,6 @@ #include "vcontour.h" -#include #include #include #include @@ -39,11 +38,7 @@ #include "vcontour_p.h" #include "vlayoutdetail.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif +#include "../vmisc/vmath.h" //--------------------------------------------------------------------------------------------------------------------- VContour::VContour() diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 62e300bed..fc4de3307 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -28,8 +28,6 @@ #include "vlayoutdetail.h" -#include -#include #include #include #include @@ -47,6 +45,7 @@ #include "../vpatterndb/vpatterninfogeometry.h" #include "../vpatterndb/vpatternpiecedata.h" +#include "../vmisc/vmath.h" #include "vlayoutdef.h" #include "vlayoutdetail_p.h" #include "vtextmanager.h" @@ -55,13 +54,6 @@ class QGraphicsPathItem; class QLineF; class VAbstractPattern; -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - -#include - //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::VLayoutDetail() :VAbstractDetail(), d(new VLayoutDetailData) diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index 5b5201403..ed0359639 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -28,12 +28,12 @@ #include "vlayoutgenerator.h" -#include #include #include #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" #include "vlayoutdetail.h" #include "vlayoutpaper.h" diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 0cabd0e84..c1288551d 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -28,7 +28,6 @@ #include "vposition.h" -#include #include #include #include @@ -48,11 +47,7 @@ #include #include "../vmisc/def.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif +#include "../vmisc/vmath.h" //--------------------------------------------------------------------------------------------------------------------- VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, volatile bool *stop, diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index 7378add1d..d413ab148 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -28,7 +28,6 @@ #include "vposter.h" -#include #include #include #include @@ -40,11 +39,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - +#include "../vmisc/vmath.h" #include "../vmisc/def.h" //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/backport/qmarginsf.cpp b/src/libs/vmisc/backport/qmarginsf.cpp index 9569b016f..8b3be1d22 100644 --- a/src/libs/vmisc/backport/qmarginsf.cpp +++ b/src/libs/vmisc/backport/qmarginsf.cpp @@ -36,7 +36,7 @@ #include #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) #include -#include +#include /*! \class QMarginsF diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index e5c7c22b9..d029584c9 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index 071ebb3fd..a25060989 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -28,7 +28,6 @@ #include "vabstractapplication.h" -#include #include #include #include diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 253ac8723..5d6e6818b 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -41,14 +40,10 @@ #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" class QDate; -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - const QString VCommonSettings::SettingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements"); const QString VCommonSettings::SettingPathsStandardMeasurements = QStringLiteral("paths/standard_measurements"); const QString VCommonSettings::SettingPathsTemplates = QStringLiteral("paths/templates"); diff --git a/src/libs/vmisc/vmath.h b/src/libs/vmisc/vmath.h index 77f02a9a7..2cda433fe 100644 --- a/src/libs/vmisc/vmath.h +++ b/src/libs/vmisc/vmath.h @@ -18,10 +18,12 @@ ** ****************************************************************************/ -#ifndef QMATH_H -#define QMATH_H +#ifndef VMATH_H +#define VMATH_H -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) +#include +#else #if 0 #pragma qt_class(QtMath) diff --git a/src/libs/vmisc/vsettings.cpp b/src/libs/vmisc/vsettings.cpp index 3075605a6..a00f73bed 100644 --- a/src/libs/vmisc/vsettings.cpp +++ b/src/libs/vmisc/vsettings.cpp @@ -39,14 +39,10 @@ #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" class QMarginsF; -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - Q_DECLARE_METATYPE(QMarginsF) const QString VSettings::SettingConfigurationLabelLanguage = QStringLiteral("configuration/label_language"); diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index ddd1e0954..0a402c99b 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -28,9 +28,7 @@ #include "vobjengine.h" -#include #include -#include #include #include #include @@ -45,6 +43,7 @@ #include #include "../vmisc/diagnostic.h" +#include "../vmisc/vmath.h" class QPaintDevice; class QPixmap; @@ -53,11 +52,6 @@ class QPointF; class QPolygonF; class QRectF; -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - #ifdef Q_CC_MSVC #include #endif /* Q_CC_MSVC */ diff --git a/src/libs/vpatterndb/variables/vlineangle.cpp b/src/libs/vpatterndb/variables/vlineangle.cpp index 6b117fb89..9f92841e8 100644 --- a/src/libs/vpatterndb/variables/vlineangle.cpp +++ b/src/libs/vpatterndb/variables/vlineangle.cpp @@ -28,23 +28,18 @@ #include "vlineangle.h" -#include #include #include #include #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "vinternalvariable.h" #include "vlineangle_p.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - //--------------------------------------------------------------------------------------------------------------------- VLineAngle::VLineAngle() :VInternalVariable(), d(new VLineAngleData) diff --git a/src/libs/vpatterndb/variables/vmeasurement.cpp b/src/libs/vpatterndb/variables/vmeasurement.cpp index 5fb7cb92c..3125cd142 100644 --- a/src/libs/vpatterndb/variables/vmeasurement.cpp +++ b/src/libs/vpatterndb/variables/vmeasurement.cpp @@ -28,7 +28,6 @@ #include "vmeasurement.h" -#include #include #include #include diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index ac29c42b5..fb85a8d8a 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -29,7 +29,6 @@ #include "vcontainer.h" #include -#include #include #include #include diff --git a/src/libs/vpatterndb/vdetail.cpp b/src/libs/vpatterndb/vdetail.cpp index 2fecbef00..555f54a83 100644 --- a/src/libs/vpatterndb/vdetail.cpp +++ b/src/libs/vpatterndb/vdetail.cpp @@ -28,7 +28,6 @@ #include "vdetail.h" -#include #include #include #include diff --git a/src/libs/vpatterndb/vformula.cpp b/src/libs/vpatterndb/vformula.cpp index 794bccc27..e754549eb 100644 --- a/src/libs/vpatterndb/vformula.cpp +++ b/src/libs/vpatterndb/vformula.cpp @@ -29,7 +29,6 @@ #include "vformula.h" #include -#include #include #include #include diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 299a9f1f2..62c66aa23 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -28,7 +28,6 @@ #include "vtranslatevars.h" -#include #include #include #include diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp index 48b8efc8e..194415fb6 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp @@ -48,6 +48,7 @@ #include "../../visualization/visualization.h" #include "../ifc/ifcdef.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/vmath.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vabstractmainwindow.h" #include "dialogtool.h" @@ -55,11 +56,6 @@ class QWidget; -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - //--------------------------------------------------------------------------------------------------------------------- DialogCubicBezierPath::DialogCubicBezierPath(const VContainer *data, const quint32 &toolId, QWidget *parent) : DialogTool(data, toolId, parent), diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index da8b9e7c4..fc53e805e 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index cb9b4632c..c4090d21f 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 5f9f01134..a4943d1a9 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -28,8 +28,6 @@ #include "vtoolspline.h" -#include -#include #include #include #include @@ -63,6 +61,7 @@ #include "../vgeometry/vpointf.h" #include "../vgeometry/vspline.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/vmath.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vcontrolpointspline.h" #include "../vwidgets/vmaingraphicsscene.h" @@ -75,11 +74,6 @@ class QGraphicsSceneContextMenuEvent; class QGraphicsSceneHoverEvent; class QGraphicsSceneMouseEvent; -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - const QString VToolSpline::ToolType = QStringLiteral("simpleInteractive"); const QString VToolSpline::OldToolType = QStringLiteral("simple"); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index 9f224c40f..e58082042 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -28,8 +28,6 @@ #include "vtoolsplinepath.h" -#include -#include #include #include #include @@ -67,6 +65,7 @@ #include "../vgeometry/vspline.h" #include "../vgeometry/vsplinepoint.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/vmath.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/../vgeometry/vsplinepath.h" #include "../vwidgets/vcontrolpointspline.h" @@ -80,11 +79,6 @@ class QGraphicsSceneContextMenuEvent; class QGraphicsSceneHoverEvent; class QGraphicsSceneMouseEvent; -#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) -# include "../vmisc/vmath.h" -#else -#endif - const QString VToolSplinePath::ToolType = QStringLiteral("pathInteractive"); const QString VToolSplinePath::OldToolType = QStringLiteral("path"); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp index cf3cfa868..1fd55fba5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp @@ -76,7 +76,8 @@ VToolLinePoint::VToolLinePoint(VAbstractPattern *doc, VContainer *data, const qu QPointF point1 = *data->GeometricObject(basePointId); QPointF point2 = *data->GeometricObject(id); mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); - mainLine->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, + mainLine->setPen(QPen(CorrectColor(lineColor), + qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, LineStyleToPenStyle(typeLine))); mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); } @@ -93,7 +94,7 @@ VToolLinePoint::~VToolLinePoint() */ void VToolLinePoint::RefreshGeometry() { - mainLine->setPen(QPen(CorrectColor(QColor(lineColor)), + mainLine->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, LineStyleToPenStyle(typeLine))); VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index c10126dc9..7a5bb7d55 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -28,7 +28,6 @@ #include "vtoolshoulderpoint.h" -#include #include #include #include diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index d63a3f884..e604a4a46 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -28,7 +28,6 @@ #include "vtoolpointofcontact.h" -#include #include #include #include diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 9424f58b5..5933c03f0 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -28,7 +28,6 @@ #include "vtooltriangle.h" -#include #include #include #include @@ -50,6 +49,7 @@ #include "../../../vabstracttool.h" #include "../../vdrawtool.h" #include "vtoolsinglepoint.h" +#include "../vmisc/vmath.h" class QDomElement; class QGraphicsSceneContextMenuEvent; diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index f51128217..2cdb5fc2f 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -29,7 +29,6 @@ #include "vdrawtool.h" #include -#include #include #include #include diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index d635858f5..7c9eeb849 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -28,7 +28,6 @@ #include "vtoolline.h" -#include #include #include #include @@ -85,7 +84,8 @@ VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint3 this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus this->setAcceptHoverEvents(true); - this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, + this->setPen(QPen(CorrectColor(lineColor), + qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, LineStyleToPenStyle(typeLine))); ToolCreation(typeCreation); @@ -233,7 +233,7 @@ void VToolLine::Disable(bool disable, const QString &namePP) { enabled = !CorrectDisable(disable, namePP); this->setEnabled(enabled); - this->setPen(QPen(CorrectColor(baseColor), + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, LineStyleToPenStyle(typeLine))); } diff --git a/src/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index 75d3b8b01..7a491b4e6 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -26,8 +26,6 @@ ** *************************************************************************/ -#include -#include #include #include #include @@ -41,6 +39,7 @@ #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" #include "vtextgraphicsitem.h" class QGraphicsSceneHoverEvent; diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index fc31d3272..92d3e8328 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 785171f60..2fb3b036d 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -29,7 +29,6 @@ #include "vtooluniondetails.h" #include -#include #include #include #include diff --git a/src/libs/vtools/visualization/line/visline.cpp b/src/libs/vtools/visualization/line/visline.cpp index d9c3f3791..b193352a0 100644 --- a/src/libs/vtools/visualization/line/visline.cpp +++ b/src/libs/vtools/visualization/line/visline.cpp @@ -28,7 +28,6 @@ #include "visline.h" -#include #include #include #include @@ -37,6 +36,7 @@ #include "../ifc/ifcdef.h" #include "../vgeometry/vgobject.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/vmath.h" #include "../vpatterndb/vcontainer.h" class QPointF; diff --git a/src/libs/vtools/visualization/line/vistooltriangle.cpp b/src/libs/vtools/visualization/line/vistooltriangle.cpp index 6eebec560..71feb80c0 100644 --- a/src/libs/vtools/visualization/line/vistooltriangle.cpp +++ b/src/libs/vtools/visualization/line/vistooltriangle.cpp @@ -28,7 +28,6 @@ #include "vistooltriangle.h" -#include #include #include #include @@ -41,6 +40,7 @@ #include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/vmath.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" #include "visline.h" diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp index 7c3ace47c..fabfca5f5 100644 --- a/src/libs/vtools/visualization/visualization.cpp +++ b/src/libs/vtools/visualization/visualization.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index 94569f451..fc5584462 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -28,7 +28,6 @@ #include "vmaingraphicsview.h" -#include #include #include #include @@ -48,6 +47,7 @@ #include #include "../vmisc/def.h" +#include "../vmisc/vmath.h" #include "vmaingraphicsscene.h" #include "vsimplecurve.h" diff --git a/src/libs/vwidgets/vsimplecurve.cpp b/src/libs/vwidgets/vsimplecurve.cpp index f8404afd7..08bf5cebb 100644 --- a/src/libs/vwidgets/vsimplecurve.cpp +++ b/src/libs/vwidgets/vsimplecurve.cpp @@ -29,7 +29,6 @@ #include "vsimplecurve.h" #include -#include #include #include #include diff --git a/src/test/ParserTest/main.cpp b/src/test/ParserTest/main.cpp index 14f522ee1..05e562d5c 100644 --- a/src/test/ParserTest/main.cpp +++ b/src/test/ParserTest/main.cpp @@ -27,7 +27,6 @@ *************************************************************************/ #include -#include #include #include #include "../qmuparser/qmuparsertest.h" diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index 3673f84c6..ab9dec109 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -50,7 +50,8 @@ SOURCES += \ tst_vabstractcurve.cpp \ tst_findpoint.cpp \ tst_vellipticalarc.cpp \ - tst_vcubicbezierpath.cpp + tst_vcubicbezierpath.cpp \ + tst_vgobject.cpp win32-msvc*:SOURCES += stable.cpp @@ -71,7 +72,8 @@ HEADERS += \ tst_vabstractcurve.h \ tst_findpoint.h \ tst_vellipticalarc.h \ - tst_vcubicbezierpath.h + tst_vcubicbezierpath.h \ + tst_vgobject.h # Set using ccache. Function enable_ccache() defined in common.pri. $$enable_ccache() diff --git a/src/test/ValentinaTest/qttestmainlambda.cpp b/src/test/ValentinaTest/qttestmainlambda.cpp index cbf42dd43..a1bf9628d 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -44,6 +44,7 @@ #include "tst_findpoint.h" #include "tst_vabstractcurve.h" #include "tst_vcubicbezierpath.h" +#include "tst_vgobject.h" #include "../vmisc/def.h" @@ -76,6 +77,7 @@ int main(int argc, char** argv) ASSERT_TEST(new TST_VCommandLine()); ASSERT_TEST(new TST_VAbstractCurve()); ASSERT_TEST(new TST_VCubicBezierPath()); + ASSERT_TEST(new TST_VGObject()); return status; } diff --git a/src/test/ValentinaTest/tst_vgobject.cpp b/src/test/ValentinaTest/tst_vgobject.cpp new file mode 100644 index 000000000..4cdadad0d --- /dev/null +++ b/src/test/ValentinaTest/tst_vgobject.cpp @@ -0,0 +1,138 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 16 8, 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_vgobject.h" + +#include + +#include "../vgeometry/vgobject.h" +#include "../vmisc/def.h" + +//--------------------------------------------------------------------------------------------------------------------- +TST_VGObject::TST_VGObject(QObject *parent) + :QObject(parent) +{} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VGObject::TestIsPointOnLineviaPDP_data() +{ + QTest::addColumn("p1"); + QTest::addColumn("p2"); + QTest::addColumn("t"); + QTest::addColumn("excpect"); + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(483.54330708661416, 1920.763653543307); + QTest::newRow("Point is on line, but not on segment.") << p1 << p2 << t << true; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(483.54330708661416, 2874.763653543307); + QTest::newRow("Point is on segment. On middle.") << p1 << p2 << t << true; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(483.54330708661416, 1929.763653543307); + QTest::newRow("Point is on segment. The end of segment.") << p1 << p2 << t << true; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(483.54330708661416 + VGObject::accuracyPointOnLine, 2874.763653543307); + QTest::newRow("Min accuracy gap. On middle.") << p1 << p2 << t << false; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(483.54330708661416 + VGObject::accuracyPointOnLine, 1929.763653543307); + QTest::newRow("Min accuracy gap.") << p1 << p2 << t << false; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(483.54330708661416 + VGObject::accuracyPointOnLine/2., 2874.763653543307); + QTest::newRow("Less than min accuracy gap. On middle.") << p1 << p2 << t << true; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(483.54330708661416 + VGObject::accuracyPointOnLine/2., 1929.763653543307); + QTest::newRow("Less than min accuracy gap.") << p1 << p2 << t << true; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(370.1574803149606, 2874.763653543307); + QTest::newRow("Issue 534 - 3 cm gap. On middle.") << p1 << p2 << t << false; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(370.1574803149606, 1929.763653543307); + QTest::newRow("Issue 534 - 3 cm gap.") << p1 << p2 << t << false; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(407.9527559055118, 2874.763653543307); + QTest::newRow("Issue 534 - 2 cm gap. On middle.") << p1 << p2 << t << false; + } + + { + const QPointF p1(483.54330708661416, 3819.527433070866); + const QPointF p2(483.54330708661416, 1929.763653543307); + const QPointF t(407.9527559055118, 1929.763653543307); + QTest::newRow("Issue 534 - 2 cm gap.") << p1 << p2 << t << false; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VGObject::TestIsPointOnLineviaPDP() const +{ + QFETCH(QPointF, p1); + QFETCH(QPointF, p2); + QFETCH(QPointF, t); + QFETCH(bool, excpect); + + const bool res = VGObject::IsPointOnLineviaPDP(t, p1, p2); + QCOMPARE(res, excpect); +} + diff --git a/src/test/ValentinaTest/tst_vgobject.h b/src/test/ValentinaTest/tst_vgobject.h new file mode 100644 index 000000000..9211f6b17 --- /dev/null +++ b/src/test/ValentinaTest/tst_vgobject.h @@ -0,0 +1,45 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 16 8, 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_VGOBJECT_H +#define TST_VGOBJECT_H + +#include + +class TST_VGObject : public QObject +{ + Q_OBJECT +public: + explicit TST_VGObject(QObject *parent = nullptr); + +private slots: + void TestIsPointOnLineviaPDP_data(); + void TestIsPointOnLineviaPDP() const; +}; + +#endif // TST_VGOBJECT_H