diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp index ec955836a..a675e274e 100644 --- a/src/libs/qmuparser/qmuparser.cpp +++ b/src/libs/qmuparser/qmuparser.cpp @@ -115,7 +115,7 @@ qreal CSR(qreal length, qreal split, qreal arcLength) const qreal arcAngle = sign > 0 ? line.angleTo(radius): radius.angleTo(line); arcL = (M_PI*radius.length())/180.0 * arcAngle; } - while(qAbs(arcL - arcLength) > (0.5/*mm*/ / 25.4) * PRINTDPI); + while(qAbs(arcL - arcLength) > (0.5/*mm*/ / 25.4) * PrintDPI); return angle; } @@ -262,9 +262,9 @@ qreal QmuParser::R2CM(qreal v) //--------------------------------------------------------------------------------------------------------------------- qreal QmuParser::CSRCm(qreal length, qreal split, qreal arcLength) { - length = ((length * 10.0) / 25.4) * PRINTDPI; - split = ((split * 10.0) / 25.4) * PRINTDPI; - arcLength = ((arcLength * 10.0) / 25.4) * PRINTDPI; + length = ((length * 10.0) / 25.4) * PrintDPI; + split = ((split * 10.0) / 25.4) * PrintDPI; + arcLength = ((arcLength * 10.0) / 25.4) * PrintDPI; return CSR(length, split, arcLength); } @@ -272,9 +272,9 @@ qreal QmuParser::CSRCm(qreal length, qreal split, qreal arcLength) //--------------------------------------------------------------------------------------------------------------------- qreal QmuParser::CSRInch(qreal length, qreal split, qreal arcLength) { - length = length * PRINTDPI; - split = split * PRINTDPI; - arcLength = arcLength * PRINTDPI; + length = length * PrintDPI; + split = split * PrintDPI; + arcLength = arcLength * PrintDPI; return CSR(length, split, arcLength); } diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index 18f61e463..573b5da3e 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -40,8 +40,6 @@ #include "../ifc/ifcdef.h" #include "vgobject_p.h" -const double VGObject::accuracyPointOnLine = (0.12/*mm*/ / 25.4) * PrintDPI; - //--------------------------------------------------------------------------------------------------------------------- /** * @brief VGObject default constructor. diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h index 4a5b1c441..74eccac8f 100644 --- a/src/libs/vgeometry/vgobject.h +++ b/src/libs/vgeometry/vgobject.h @@ -102,8 +102,6 @@ public: template static QVector GetReversePoints(const QVector &points); static int GetLengthContour(const QVector &contour, const QVector &newPoints); - - static const double accuracyPointOnLine; protected: static QTransform FlippingMatrix(const QLineF &axis); private: diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 6fe8186e9..92b99fc09 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1256,7 +1256,7 @@ bool VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &pr return (VGObject::IsPointOnLineviaPDP(iPoint, prevPoint, nextPoint) && VGObject::IsPointOnLineviaPDP(bigLine1.p2(), bigLine1.p1(), bigLine2.p2()) && VGObject::IsPointOnLineviaPDP(bigLine2.p1(), bigLine1.p1(), bigLine2.p2()) - && qAbs(prevPoint.GetSAAfter(tmpWidth) - nextPoint.GetSABefore(tmpWidth)) < VGObject::accuracyPointOnLine); + && qAbs(prevPoint.GetSAAfter(tmpWidth) - nextPoint.GetSABefore(tmpWidth)) < accuracyPointOnLine); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 45578fd42..243224570 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -279,8 +279,7 @@ QVector VAbstractPiece::RemoveDublicates(const QVector &points, bool remov { // Path can't be closed // See issue #686 - if ((qAbs(p.first().x() - p.last().x()) < VGObject::accuracyPointOnLine) - && (qAbs(p.first().y() - p.last().y()) < VGObject::accuracyPointOnLine)) + if (VFuzzyComparePoints(p.first(), p.last())) { p.removeLast(); } @@ -289,8 +288,7 @@ QVector VAbstractPiece::RemoveDublicates(const QVector &points, bool remov for (int i = 0; i < p.size()-1; ++i) { - if ((qAbs(p.at(i).x() - p.at(i+1).x()) < VGObject::accuracyPointOnLine) - && (qAbs(p.at(i).y() - p.at(i+1).y()) < VGObject::accuracyPointOnLine)) + if (VFuzzyComparePoints(p.at(i), p.at(i+1))) { if (not removeFirstAndLast && (i == p.size()-1)) { diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 9c37c1974..2dbc0f1d9 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -463,6 +463,14 @@ static inline bool VFuzzyComparePossibleNulls(double p1, double p2) } } +Q_DECL_CONSTEXPR qreal accuracyPointOnLine = (0.12/*mm*/ / 25.4) * PrintDPI; + +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline bool VFuzzyComparePoints(const QPointF &p1, const QPointF &p2); +Q_DECL_CONSTEXPR static inline bool VFuzzyComparePoints(const QPointF &p1, const QPointF &p2) +{ + return qAbs(p1.x() - p2.x()) <= accuracyPointOnLine && qAbs(p1.y() - p2.y()) <= accuracyPointOnLine; +} + /** * @brief The CustomSA struct contains record about custom seam allowanse (SA). */ diff --git a/src/libs/vmisc/defglobal.cpp b/src/libs/vmisc/defglobal.cpp deleted file mode 100644 index 1d6e37156..000000000 --- a/src/libs/vmisc/defglobal.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/************************************************************************ - ** - ** @file global.cpp - ** @author Roman Telezhynskyi - ** @date 13 11, 2017 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentina project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2017 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 "defglobal.h" - -const qreal PrintDPI = PRINTDPI; diff --git a/src/libs/vmisc/defglobal.h b/src/libs/vmisc/defglobal.h index 2314093d0..9984ae9ea 100644 --- a/src/libs/vmisc/defglobal.h +++ b/src/libs/vmisc/defglobal.h @@ -32,8 +32,7 @@ #include "backport/qoverload.h" -#define PRINTDPI 96.0 -extern const qreal PrintDPI; +Q_DECL_CONSTEXPR qreal PrintDPI = 96.0; #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) // this adds const to non-const objects (like std::as_const) diff --git a/src/libs/vmisc/vmisc.pri b/src/libs/vmisc/vmisc.pri index 8fad3378f..e6a02431c 100644 --- a/src/libs/vmisc/vmisc.pri +++ b/src/libs/vmisc/vmisc.pri @@ -12,7 +12,6 @@ SOURCES += \ $$PWD/qxtcsvmodel.cpp \ $$PWD/vtablesearch.cpp \ $$PWD/dialogs/dialogexporttocsv.cpp \ - $$PWD/defglobal.cpp \ $$PWD/literals.cpp *msvc*:SOURCES += $$PWD/stable.cpp diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 8c9484d2b..eb75c3408 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -1107,8 +1107,7 @@ bool VPiece::GetSeamPassmarkSAPoint(const VSAPoint &previousSAPoint, const VSAPo if (IsEkvPointOnLine(passmarkSAPoint, previousSAPoint, nextSAPoint)// see issue #665 || (IsEkvPointOnLine(static_cast(passmarkSAPoint), static_cast(previousSAPoint), static_cast(nextSAPoint)) - && qAbs(passmarkSAPoint.GetSABefore(width) - - passmarkSAPoint.GetSAAfter(width)) < VGObject::accuracyPointOnLine)) + && qAbs(passmarkSAPoint.GetSABefore(width) - passmarkSAPoint.GetSAAfter(width)) < accuracyPointOnLine)) { QLineF line (passmarkSAPoint, nextSAPoint); line.setAngle(line.angle() + 90); diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index 4a1f238b0..ee4ba2a19 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -69,8 +69,7 @@ void AbstractTest::Comparison(const QVector &ekv, const QVector