Skip to content

Commit

Permalink
Renovate usages of QLineF intersections (#719)
Browse files Browse the repository at this point in the history
* Renovate usages of QLineF intersections

* Assign intersection type to a variable
  • Loading branch information
YakoYakoYokuYoku committed Dec 11, 2021
1 parent a029915 commit f5742cd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Engine/RotoContext.cpp
Expand Up @@ -4476,7 +4476,12 @@ RotoContextPrivate::bezulate(double time,
QPointF intersectionPoint;
for (; cur != polygon.end(); ++cur, ++last_pt) {
QLineF polygonSegment( QPointF(last_pt->x, last_pt->y), QPointF(cur->x, cur->y) );
if (line.intersect(polygonSegment, &intersectionPoint) == QLineF::BoundedIntersection) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType intersectType = line.intersects(polygonSegment, &intersectionPoint);
#else
QLineF::IntersectType intersectType = line.intersect(polygonSegment, &intersectionPoint);
#endif
if (intersectType == QLineF::BoundedIntersection) {
intersections.insert(intersectionPoint);
}
if (intersections.size() > 2) {
Expand Down
20 changes: 20 additions & 0 deletions Gui/Edge.cpp
Expand Up @@ -487,7 +487,11 @@ Edge::initLine()

if (dest) {
for (int i = 0; i < 4; ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType type = dstEdges[i].intersects(line(), &dstIntersection);
#else
QLineF::IntersectType type = dstEdges[i].intersect(line(), &dstIntersection);
#endif
if (type == QLineF::BoundedIntersection) {
setLine( QLineF( dstIntersection, line().p2() ) );
foundDstIntersection = true;
Expand All @@ -502,7 +506,11 @@ Edge::initLine()
if (foundDstIntersection) {
///Find the intersection with the source bbox
for (int i = 0; i < 4; ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType type = srcEdges[i].intersects(line(), &srcInteresect);
#else
QLineF::IntersectType type = srcEdges[i].intersect(line(), &srcInteresect);
#endif
if (type == QLineF::BoundedIntersection) {
foundSrcIntersection = true;
break;
Expand Down Expand Up @@ -544,7 +552,11 @@ Edge::initLine()
QPointF intersection;
bool foundIntersection = false;
for (int i = 0; i < 4; ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType type = dstEdges[i].intersects(line(), &intersection);
#else
QLineF::IntersectType type = dstEdges[i].intersect(line(), &intersection);
#endif
if (type == QLineF::BoundedIntersection) {
setLine( QLineF( intersection, line().p2() ) );
foundIntersection = true;
Expand Down Expand Up @@ -884,7 +896,11 @@ LinkArrow::refreshPosition()
QPointF slaveIntersect;
bool foundIntersection = false;
for (int i = 0; i < 4; ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType type = slaveEdges[i].intersects(line(), &slaveIntersect);
#else
QLineF::IntersectType type = slaveEdges[i].intersect(line(), &slaveIntersect);
#endif
if (type == QLineF::BoundedIntersection) {
foundIntersection = true;
break;
Expand All @@ -900,7 +916,11 @@ LinkArrow::refreshPosition()

foundIntersection = false;
for (int i = 0; i < 4; ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType type = masterEdges[i].intersects(line(), &masterIntersect);
#else
QLineF::IntersectType type = masterEdges[i].intersect(line(), &masterIntersect);
#endif
if (type == QLineF::BoundedIntersection) {
foundIntersection = true;
break;
Expand Down
14 changes: 12 additions & 2 deletions Gui/NodeGui.cpp
Expand Up @@ -1868,7 +1868,12 @@ NodeGui::hasEdgeNearbyRect(const QRectF & rect)
edgeLine.setP1( (*it)->mapToScene( edgeLine.p1() ) );
edgeLine.setP2( (*it)->mapToScene( edgeLine.p2() ) );
for (int j = 0; j < 4; ++j) {
if (edgeLine.intersect(rectEdges[j], &intersection) == QLineF::BoundedIntersection) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType intersectType = edgeLine.intersects(rectEdges[j], &intersection);
#else
QLineF::IntersectType intersectType = edgeLine.intersect(rectEdges[j], &intersection);
#endif
if (intersectType == QLineF::BoundedIntersection) {
if (!closest) {
closest = *it;
closestSquareDist = ( intersection.x() - middleRect.x() ) * ( intersection.x() - middleRect.x() )
Expand All @@ -1895,7 +1900,12 @@ NodeGui::hasEdgeNearbyRect(const QRectF & rect)
edgeLine.setP1( (_outputEdge)->mapToScene( edgeLine.p1() ) );
edgeLine.setP2( (_outputEdge)->mapToScene( edgeLine.p2() ) );
for (int j = 0; j < 4; ++j) {
if (edgeLine.intersect(rectEdges[j], &intersection) == QLineF::BoundedIntersection) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType intersectType = edgeLine.intersects(rectEdges[j], &intersection);
#else
QLineF::IntersectType intersectType = edgeLine.intersect(rectEdges[j], &intersection);
#endif
if (intersectType == QLineF::BoundedIntersection) {
return _outputEdge;
}
}
Expand Down
16 changes: 16 additions & 0 deletions Gui/ViewerGLPrivate.cpp
Expand Up @@ -564,7 +564,11 @@ ViewerGL::Implementation::getWipePolygon(const RectD & texRectClipped,
if (crossProd11 * crossProd21 < 0) {
QLineF e(texRectClipped.x1, texRectClipped.y1, texRectClipped.x2, texRectClipped.y1);
QPointF p;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType t = inter.intersects(e, &p);
#else
QLineF::IntersectType t = inter.intersect(e, &p);
#endif
if (t == QLineF::BoundedIntersection) {
*polygonPoints << p;
}
Expand All @@ -575,7 +579,11 @@ ViewerGL::Implementation::getWipePolygon(const RectD & texRectClipped,
if (crossProd21 * crossProd22 < 0) {
QLineF e(texRectClipped.x2, texRectClipped.y1, texRectClipped.x2, texRectClipped.y2);
QPointF p;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType t = inter.intersects(e, &p);
#else
QLineF::IntersectType t = inter.intersect(e, &p);
#endif
if (t == QLineF::BoundedIntersection) {
*polygonPoints << p;
}
Expand All @@ -586,7 +594,11 @@ ViewerGL::Implementation::getWipePolygon(const RectD & texRectClipped,
if (crossProd22 * crossProd12 < 0) {
QLineF e(texRectClipped.x2, texRectClipped.y2, texRectClipped.x1, texRectClipped.y2);
QPointF p;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType t = inter.intersects(e, &p);
#else
QLineF::IntersectType t = inter.intersect(e, &p);
#endif
if (t == QLineF::BoundedIntersection) {
*polygonPoints << p;
}
Expand All @@ -597,7 +609,11 @@ ViewerGL::Implementation::getWipePolygon(const RectD & texRectClipped,
if (crossProd12 * crossProd11 < 0) {
QLineF e(texRectClipped.x1, texRectClipped.y2, texRectClipped.x1, texRectClipped.y1);
QPointF p;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectionType t = inter.intersects(e, &p);
#else
QLineF::IntersectType t = inter.intersect(e, &p);
#endif
if (t == QLineF::BoundedIntersection) {
*polygonPoints << p;
}
Expand Down

0 comments on commit f5742cd

Please sign in to comment.