diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index 2788bcfcb..06a2bc5fa 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -37,6 +37,7 @@ #include "vabstractcurve_p.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/compatibility.h" VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode) :VGObject(type, idObject, mode), d (new VAbstractCurveData()) @@ -401,13 +402,9 @@ QVector VAbstractCurve::CurveIntersectLine(const QVector &poin for ( auto i = 0; i < points.count()-1; ++i ) { QPointF crosPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - const auto type = line.intersects(QLineF(points.at(i), points.at(i+1)), &crosPoint); -#else - const auto type = line.intersect(QLineF(points.at(i), points.at(i+1)), &crosPoint); -#endif + auto type = Intersects(line, QLineF(points.at(i), points.at(i+1)), &crosPoint); - if ( type == QLineF::BoundedIntersection ) + if (type == QLineF::BoundedIntersection) { intersections.append(crosPoint); } diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index 621c6e371..6a17f0416 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -35,6 +35,7 @@ #include "../vmisc/vmath.h" #include "../ifc/ifcdef.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/compatibility.h" #include "vabstractcurve.h" #include "vellipticalarc_p.h" #include "vspline.h" diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index 87cba67a7..380dc360d 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -38,6 +38,7 @@ #include "../vmisc/def.h" #include "../vmisc/vmath.h" +#include "../vmisc/compatibility.h" #include "../ifc/ifcdef.h" #include "vgobject_p.h" @@ -352,44 +353,28 @@ QPointF VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) qreal x1, y1, x2, y2; rec.getCoords(&x1, &y1, &x2, &y2); QPointF point; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point); -#else - QLineF::IntersectType type = line.intersect(QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point); -#endif + QLineF::IntersectType type = Intersects(line, QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point); if ( type == QLineF::BoundedIntersection ) { return point; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point); -#else - type = line.intersect(QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point); -#endif + type = Intersects(line, QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point); if ( type == QLineF::BoundedIntersection ) { return point; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - type = line.intersects(QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point); -#else - type = line.intersect(QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point); -#endif + type = Intersects(line, QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point); if ( type == QLineF::BoundedIntersection ) { return point; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - type = line.intersects(QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point); -#else - type = line.intersect(QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point); -#endif + type = Intersects(line, QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point); if ( type == QLineF::BoundedIntersection ) { @@ -502,11 +487,7 @@ QPointF VGObject::ClosestPoint(const QLineF &line, const QPointF &point) qreal y = b + point.y(); QLineF lin (point, QPointF(x, y)); QPointF p; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = line.intersects(lin, &p); -#else - QLineF::IntersectType intersect = line.intersect(lin, &p); -#endif + QLineF::IntersectType intersect = Intersects(line, lin, &p); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { diff --git a/src/libs/vgeometry/vsplinepath.cpp b/src/libs/vgeometry/vsplinepath.cpp index 015da4a3f..6c92ecee1 100644 --- a/src/libs/vgeometry/vsplinepath.cpp +++ b/src/libs/vgeometry/vsplinepath.cpp @@ -34,6 +34,7 @@ #include "../ifc/exception/vexception.h" #include "../vmisc/vmath.h" +#include "../vmisc/compatibility.h" #include "vabstractcurve.h" #include "vsplinepath_p.h" diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 00d3055cd..10767d0fb 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -32,6 +32,7 @@ #include "../vgeometry/vpointf.h" #include "../ifc/exception/vexception.h" #include "../vmisc/vmath.h" +#include "../vmisc/compatibility.h" #include "../vpatterndb/floatItemData/vgrainlinedata.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/calculator.h" @@ -108,11 +109,7 @@ QVector AngleByLength(QVector points, QPointF p1, QPoi // We do not check intersection type because intersection must alwayse exist QPointF px; cutLine.setAngle(cutLine.angle()+90); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType type = QLineF(sp1, sp2).intersects(cutLine, &px); -#else - QLineF::IntersectType type = QLineF(sp1, sp2).intersect(cutLine, &px); -#endif + QLineF::IntersectType type = Intersects(QLineF(sp1, sp2), cutLine, &px); if (type == QLineF::NoIntersection) { @@ -121,11 +118,7 @@ QVector AngleByLength(QVector points, QPointF p1, QPoi points.append(px); cutLine.setAngle(cutLine.angle()-180); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - type = QLineF(sp2, sp3).intersects(cutLine, &px); -#else - type = QLineF(sp2, sp3).intersect(cutLine, &px); -#endif + type = Intersects(QLineF(sp2, sp3), cutLine, &px); if (type == QLineF::NoIntersection) { @@ -236,11 +229,7 @@ QVector AngleByIntersection(const QVector &points, QPo QLineF edge2(p2, p3); QPointF px; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType type = edge2.intersects(bigLine1, &px); -#else - QLineF::IntersectType type = edge2.intersect(bigLine1, &px); -#endif + QLineF::IntersectType type = Intersects(edge2, bigLine1, &px); if (type == QLineF::NoIntersection) { @@ -275,12 +264,7 @@ QVector AngleByIntersection(const QVector &points, QPo // Second point QLineF edge1(p1, p2); - -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - type = edge1.intersects(bigLine2, &px); -#else - type = edge1.intersect(bigLine2, &px); -#endif + type = Intersects(edge1, bigLine2, &px); if (type == QLineF::NoIntersection) { @@ -330,11 +314,7 @@ QVector AngleByFirstSymmetry(const QVector &points, QP QLineF sEdge(VPointF::FlipPF(axis, bigLine2.p1()), VPointF::FlipPF(axis, bigLine2.p2())); QPointF px1; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType type = sEdge.intersects(bigLine1, &px1); -#else - QLineF::IntersectType type = sEdge.intersect(bigLine1, &px1); -#endif + QLineF::IntersectType type = Intersects(sEdge, bigLine1, &px1); if (type == QLineF::NoIntersection) { @@ -342,11 +322,7 @@ QVector AngleByFirstSymmetry(const QVector &points, QP } QPointF px2; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - type = sEdge.intersects(bigLine2, &px2); -#else - type = sEdge.intersect(bigLine2, &px2); -#endif + type = Intersects(sEdge, bigLine2, &px2); if (type == QLineF::NoIntersection) { @@ -419,11 +395,7 @@ QVector AngleBySecondSymmetry(const QVector &points, Q QLineF sEdge(VPointF::FlipPF(axis, bigLine1.p1()), VPointF::FlipPF(axis, bigLine1.p2())); QPointF px1; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType type = sEdge.intersects(bigLine1, &px1); -#else - QLineF::IntersectType type = sEdge.intersect(bigLine1, &px1); -#endif + QLineF::IntersectType type = Intersects(sEdge, bigLine1, &px1); if (type == QLineF::NoIntersection) { @@ -431,11 +403,7 @@ QVector AngleBySecondSymmetry(const QVector &points, Q } QPointF px2; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - type = sEdge.intersects(bigLine2, &px2); -#else - type = sEdge.intersect(bigLine2, &px2); -#endif + type = Intersects(sEdge, bigLine2, &px2); if (type == QLineF::NoIntersection) { @@ -505,11 +473,7 @@ QVector AngleByFirstRightAngle(const QVector &points, QLineF edge(p1, p2); QPointF px; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType type = edge.intersects(bigLine2, &px); -#else - QLineF::IntersectType type = edge.intersect(bigLine2, &px); -#endif + QLineF::IntersectType type = Intersects(edge, bigLine2, &px); if (type == QLineF::NoIntersection) { @@ -583,11 +547,7 @@ QVector AngleBySecondRightAngle(QVector points, QPoint QLineF edge(p2, p3); QPointF px; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType type = edge.intersects(bigLine1, &px); -#else - QLineF::IntersectType type = edge.intersect(bigLine1, &px); -#endif + QLineF::IntersectType type = Intersects(edge, bigLine1, &px); if (type == QLineF::NoIntersection) { @@ -859,11 +819,7 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width); QPointF px; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - edge.intersects(bigLine1, &px); -#else - edge.intersect(bigLine1, &px); -#endif + Intersects(edge, bigLine1, &px); ekvPoints.removeLast(); @@ -875,11 +831,7 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect const QLineF edge2(ekvPoints.at(0), ekvPoints.at(1)); QPointF crosPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - const QLineF::IntersectType type = edge1.intersects(edge2, &crosPoint ); -#else - const QLineF::IntersectType type = edge1.intersect(edge2, &crosPoint ); -#endif + const QLineF::IntersectType type = Intersects(edge1, edge2, &crosPoint ); if (type == QLineF::BoundedIntersection) { @@ -1311,11 +1263,7 @@ QVector VAbstractPiece::CheckLoops(const QVector &points) if (uniqueVertices.size() == 4) {// Lines are not neighbors -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - const QLineF::IntersectType intersect = line1.intersects(line2, &crosPoint); -#else - const QLineF::IntersectType intersect = line1.intersect(line2, &crosPoint); -#endif + const QLineF::IntersectType intersect = Intersects(line1, line2, &crosPoint); if (intersect == QLineF::NoIntersection) { // According to the documentation QLineF::NoIntersection indicates that the lines do not intersect; // i.e. they are parallel. But parallel also mean they can be on the same line. @@ -1395,11 +1343,7 @@ QVector VAbstractPiece::EkvPoint(QVector points, const } QPointF crosPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - const QLineF::IntersectType type = bigLine1.intersects( bigLine2, &crosPoint ); -#else - const QLineF::IntersectType type = bigLine1.intersect( bigLine2, &crosPoint ); -#endif + const QLineF::IntersectType type = Intersects(bigLine1, bigLine2, &crosPoint ); switch (type) {// There are at least three big cases @@ -1497,11 +1441,7 @@ QT_WARNING_POP const QLineF bigEdge = ParallelLine(p1Line1, p1Line2, localWidth ); QPointF px; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - const QLineF::IntersectType type = bigEdge.intersects(line, &px); -#else - const QLineF::IntersectType type = bigEdge.intersect(line, &px); -#endif + const QLineF::IntersectType type = Intersects(bigEdge, line, &px); if (type != QLineF::BoundedIntersection && line.length() < QLineF(p2Line1, px).length()) { points.append(crosPoint); @@ -1632,11 +1572,7 @@ bool VAbstractPiece::IsAllowanceValid(const QVector &base, const QVecto } QPointF crosPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - const auto type = baseSegment.intersects(allowanceSegment, &crosPoint); -#else - const auto type = baseSegment.intersect(allowanceSegment, &crosPoint); -#endif + const auto type = Intersects(baseSegment, allowanceSegment, &crosPoint); if (type == QLineF::BoundedIntersection && not VFuzzyComparePoints(baseSegment.p1(), crosPoint) @@ -1795,11 +1731,7 @@ QVector VAbstractPiece::RollbackSeamAllowance(QVector { QLineF segment(points.at(i), points.at(i-1)); QPointF crosPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - const QLineF::IntersectType type = cuttingEdge.intersects(segment, &crosPoint); -#else - const QLineF::IntersectType type = cuttingEdge.intersect(segment, &crosPoint); -#endif + const QLineF::IntersectType type = Intersects(cuttingEdge, segment, &crosPoint); if (type != QLineF::NoIntersection && VGObject::IsPointOnLineSegment(crosPoint, segment.p1(), segment.p2()) @@ -1820,11 +1752,7 @@ QVector VAbstractPiece::RollbackSeamAllowance(QVector { QPointF crosPoint; QLineF secondLast(points.at(points.size()-2), points.at(points.size()-1)); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType type = secondLast.intersects(cuttingEdge, &crosPoint); -#else - QLineF::IntersectType type = secondLast.intersect(cuttingEdge, &crosPoint); -#endif + QLineF::IntersectType type = Intersects(secondLast, cuttingEdge, &crosPoint); if (type != QLineF::NoIntersection && IsOutsidePoint(secondLast.p1(), secondLast.p2(), crosPoint)) { diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index cb5467b7b..62dcae9f0 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -49,6 +49,7 @@ #include "../vpatterndb/floatItemData/vpiecelabeldata.h" #include "../vmisc/vmath.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/compatibility.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/calculator.h" #include "../vpatterndb/vpassmark.h" diff --git a/src/libs/vmisc/compatibility.h b/src/libs/vmisc/compatibility.h new file mode 100644 index 000000000..b99e2ce69 --- /dev/null +++ b/src/libs/vmisc/compatibility.h @@ -0,0 +1,72 @@ +/************************************************************************ + ** + ** @file compatibility.h + ** @author Roman Telezhynskyi + ** @date 16 1, 2020 + ** + ** @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) 2020 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 COMPATIBILITY_H +#define COMPATIBILITY_H + +#include +#include +#include + +class QPointF; + +// Contains helpful methods to hide version dependent code. It can be deprecation of method or change in API + +//--------------------------------------------------------------------------------------------------------------------- +template class Cont> +inline const T& ConstFirst (const Cont &container) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + return container.constFirst(); +#else + return container.first(); // clazy:exclude=detaching-temporary +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +template +inline const T& ConstFirst (const C &container) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + return container.constFirst(); +#else + return container.first(); // clazy:exclude=detaching-temporary +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +template +inline typename T::IntersectType Intersects(const T &l1, const T &l2, QPointF *intersectionPoint) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + return l1.intersects(l2, intersectionPoint); +#else + return l1.intersect(l2, intersectionPoint); +#endif +} + +#endif // COMPATIBILITY_H diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 642113056..cff201756 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -360,26 +360,6 @@ enum class GSizes : quint8 { ALL, #endif // defined(__cplusplus) #endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0) -template class Cont> -inline const T& ConstFirst (const Cont &container) -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) - return container.constFirst(); -#else - return container.first(); // clazy:exclude=detaching-temporary -#endif -} - -template -inline const T& ConstFirst (const C &container) -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) - return container.constFirst(); -#else - return container.first(); // clazy:exclude=detaching-temporary -#endif -} - bool IsOptionSet(int argc, char *argv[], const char *option); void InitHighDpiScaling(int argc, char *argv[]); diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 7cb6e7cca..9cb09299c 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -44,6 +44,7 @@ #include "../vmisc/def.h" #include "../vmisc/vmath.h" +#include "../vmisc/compatibility.h" #include "../vpatterndb/pmsystems.h" namespace diff --git a/src/libs/vmisc/vmisc.pri b/src/libs/vmisc/vmisc.pri index 72704a513..e62231411 100644 --- a/src/libs/vmisc/vmisc.pri +++ b/src/libs/vmisc/vmisc.pri @@ -24,6 +24,7 @@ contains(DEFINES, APPIMAGE) { } HEADERS += \ + $$PWD/compatibility.h \ $$PWD/stable.h \ $$PWD/def.h \ $$PWD/vmath.h \ diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp index c4b6059cb..1732cbe5f 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp @@ -46,6 +46,7 @@ #include "../ifc/xml/vabstractpattern.h" #include "../vgeometry/vpointf.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/compatibility.h" #include "../vpatterndb/vcontainer.h" #include "dialogtool.h" #include "ui_dialoglineintersect.h" @@ -239,11 +240,7 @@ void DialogLineIntersect::PointNameChanged() QLineF line1(static_cast(*p1Line1), static_cast(*p2Line1)); QLineF line2(static_cast(*p1Line2), static_cast(*p2Line2)); QPointF fPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = line1.intersects(line2, &fPoint); -#else - QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); -#endif + QLineF::IntersectType intersect = Intersects(line1, line2, &fPoint); flagError = not (set.size() < 3 || intersect == QLineF::NoIntersection); @@ -285,11 +282,7 @@ bool DialogLineIntersect::CheckIntersecion() QLineF line1(static_cast(*p1L1), static_cast(*p2L1)); QLineF line2(static_cast(*p1L2), static_cast(*p2L2)); QPointF fPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = line1.intersects(line2, &fPoint); -#else - QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); -#endif + QLineF::IntersectType intersect = Intersects(line1, line2, &fPoint); return intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection; } catch (const VExceptionBadId &) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index ad8441e62..0c53db454 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -49,6 +49,7 @@ #include "../../../vabstracttool.h" #include "../../vdrawtool.h" #include "vtooldoublepoint.h" +#include "../vmisc/compatibility.h" template class QSharedPointer; @@ -78,11 +79,7 @@ void VToolTrueDarts::FindPoint(const QPointF &baseLineP1, const QPointF &baseLin QLineF d2blP2(dartP2, baseLineP2); d2blP2.setAngle(d2blP2.angle()+degrees); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - if (QLineF(baseLineP1, d2blP2.p2()).intersects(d2d1, &p1) == QLineF::NoIntersection) -#else - if (QLineF(baseLineP1, d2blP2.p2()).intersect(d2d1, &p1) == QLineF::NoIntersection) -#endif + if (Intersects(QLineF(baseLineP1, d2blP2.p2()), d2d1, &p1) == QLineF::NoIntersection) { p1 = QPointF(0, 0); p2 = QPointF(0, 0); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 8bf63a84f..e1a38fe0b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -51,6 +51,7 @@ #include "../../../../vabstracttool.h" #include "../../../vdrawtool.h" #include "vtoollinepoint.h" +#include "../vmisc/compatibility.h" template class QSharedPointer; @@ -180,11 +181,7 @@ bool VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line, Q SCASSERT(intersectionPoint != nullptr) QPointF fPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = axis.intersects(line, &fPoint); -#else - QLineF::IntersectType intersect = axis.intersect(line, &fPoint); -#endif + QLineF::IntersectType intersect = Intersects(axis, line, &fPoint); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index fa4b4274b..94583e5b2 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -51,6 +51,7 @@ #include "../../../vabstracttool.h" #include "../../vdrawtool.h" #include "vtoolsinglepoint.h" +#include "../vmisc/compatibility.h" template class QSharedPointer; @@ -141,11 +142,7 @@ VToolLineIntersect* VToolLineIntersect::Create(VToolLineIntersectInitData initDa QLineF line1(static_cast(*p1Line1), static_cast(*p2Line1)); QLineF line2(static_cast(*p1Line2), static_cast(*p2Line2)); QPointF fPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - const QLineF::IntersectType intersect = line1.intersects(line2, &fPoint); -#else - const QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); -#endif + const QLineF::IntersectType intersect = Intersects(line1, line2, &fPoint); if (intersect == QLineF::NoIntersection) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 5437b2583..4935966f7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -51,6 +51,7 @@ #include "../../vdrawtool.h" #include "vtoolsinglepoint.h" #include "../vmisc/vmath.h" +#include "../vmisc/compatibility.h" template class QSharedPointer; @@ -201,11 +202,7 @@ bool VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, cons QLineF hypotenuse(firstPoint, secondPoint); QPointF startPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = axis.intersects(hypotenuse, &startPoint); -#else - QLineF::IntersectType intersect = axis.intersect(hypotenuse, &startPoint); -#endif + QLineF::IntersectType intersect = Intersects(axis, hypotenuse, &startPoint); if (intersect != QLineF::UnboundedIntersection && intersect != QLineF::BoundedIntersection) { diff --git a/src/libs/vtools/visualization/line/vistoolheight.cpp b/src/libs/vtools/visualization/line/vistoolheight.cpp index 1db72e474..48c727013 100644 --- a/src/libs/vtools/visualization/line/vistoolheight.cpp +++ b/src/libs/vtools/visualization/line/vistoolheight.cpp @@ -41,6 +41,7 @@ #include "../vpatterndb/vcontainer.h" #include "../visualization.h" #include "visline.h" +#include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent) @@ -116,11 +117,7 @@ void VisToolHeight::setLineP2Id(const quint32 &value) void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line) { QPointF p; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = height_line.intersects(base_line, &p); -#else - QLineF::IntersectType intersect = height_line.intersect(base_line, &p); -#endif + QLineF::IntersectType intersect = Intersects(height_line, base_line, &p); if (intersect == QLineF::UnboundedIntersection) { diff --git a/src/libs/vtools/visualization/line/vistoollineintersect.cpp b/src/libs/vtools/visualization/line/vistoollineintersect.cpp index f17906906..fc0d59fbf 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersect.cpp +++ b/src/libs/vtools/visualization/line/vistoollineintersect.cpp @@ -40,6 +40,7 @@ #include "../vpatterndb/vcontainer.h" #include "../visualization.h" #include "visline.h" +#include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent) @@ -87,11 +88,7 @@ void VisToolLineIntersect::RefreshGeometry() QLineF l1(static_cast(*first), static_cast(*second)); QLineF l2(static_cast(*third), Visualization::scenePos); QPointF fPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = l1.intersects(l2, &fPoint); -#else - QLineF::IntersectType intersect = l1.intersect(l2, &fPoint); -#endif + QLineF::IntersectType intersect = Intersects(l1, l2, &fPoint); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { @@ -108,11 +105,7 @@ void VisToolLineIntersect::RefreshGeometry() QLineF l1(static_cast(*first), static_cast(*second)); QLineF l2(static_cast(*third), static_cast(*forth)); QPointF fPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = l1.intersects(l2, &fPoint); -#else - QLineF::IntersectType intersect = l1.intersect(l2, &fPoint); -#endif + QLineF::IntersectType intersect = Intersects(l1, l2, &fPoint); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { diff --git a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp index 7a7e3f65e..e4eee6a63 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp +++ b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp @@ -43,6 +43,7 @@ #include "../visualization.h" #include "visline.h" #include "../vmisc/vmodifierkey.h" +#include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent) @@ -140,11 +141,7 @@ void VisToolLineIntersectAxis::setAxisPointId(const quint32 &value) void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line) { QPointF p; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = axis_line.intersects(base_line, &p); -#else - QLineF::IntersectType intersect = axis_line.intersect(base_line, &p); -#endif + QLineF::IntersectType intersect = Intersects(axis_line, base_line, &p); if (intersect == QLineF::UnboundedIntersection) { diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp index 39eec28d5..59bec9d1e 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp @@ -41,6 +41,7 @@ #include "../vpatterndb/vcontainer.h" #include "../visualization.h" #include "visline.h" +#include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, QGraphicsItem *parent) @@ -97,11 +98,7 @@ void VisToolPointOfIntersection::setPoint2Id(const quint32 &value) void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color) { QPointF p; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QLineF::IntersectType intersect = axis1.intersects(axis2, &p); -#else - QLineF::IntersectType intersect = axis1.intersect(axis2, &p); -#endif + QLineF::IntersectType intersect = Intersects(axis1, axis2, &p); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) {