| 873 | } |
| 874 | |
| 875 | void |
| 876 | LinkArrow::refreshPosition() |
| 877 | { |
| 878 | NodeGuiPtr slave = _slave.lock(); |
| 879 | NodeGuiPtr master = _master.lock(); |
| 880 | QRectF bboxSlave; |
| 881 | |
| 882 | if (slave) { |
| 883 | bboxSlave = mapFromItem( slave.get(), slave->boundingRect() ).boundingRect(); |
| 884 | } |
| 885 | |
| 886 | ///like the box master in kfc! was bound to name it so I'm hungry atm |
| 887 | QRectF boxMaster; |
| 888 | if (master) { |
| 889 | boxMaster = mapFromItem( master.get(), master->boundingRect() ).boundingRect(); |
| 890 | } |
| 891 | QPointF dst = boxMaster.center(); |
| 892 | QPointF src = bboxSlave.center(); |
| 893 | |
| 894 | setLine( QLineF(src, dst) ); |
| 895 | |
| 896 | ///Get the intersections of the line with the nodes |
| 897 | std::vector<QLineF> masterEdges; |
| 898 | std::vector<QLineF> slaveEdges; |
| 899 | makeEdges(bboxSlave, slaveEdges); |
| 900 | makeEdges(boxMaster, masterEdges); |
| 901 | |
| 902 | |
| 903 | QPointF masterIntersect; |
| 904 | QPointF slaveIntersect; |
| 905 | bool foundIntersection = false; |
| 906 | for (int i = 0; i < 4; ++i) { |
| 907 | #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) |
| 908 | QLineF::IntersectionType type = slaveEdges[i].intersects(line(), &slaveIntersect); |
| 909 | #else |
| 910 | QLineF::IntersectType type = slaveEdges[i].intersect(line(), &slaveIntersect); |
| 911 | #endif |
| 912 | if (type == QLineF::BoundedIntersection) { |
| 913 | foundIntersection = true; |
| 914 | break; |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | if (!foundIntersection) { |
| 919 | ///Don't bother continuing, there's no intersection that means the line is contained in the node bbox |
| 920 | |
| 921 | ///hence that the 2 nodes are overlapping on the nodegraph so probably we wouldn't see the link anyway. |
| 922 | return; |
| 923 | } |
| 924 | |
| 925 | foundIntersection = false; |
| 926 | for (int i = 0; i < 4; ++i) { |
| 927 | #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) |
| 928 | QLineF::IntersectionType type = masterEdges[i].intersects(line(), &masterIntersect); |
| 929 | #else |
| 930 | QLineF::IntersectType type = masterEdges[i].intersect(line(), &masterIntersect); |
| 931 | #endif |
| 932 | if (type == QLineF::BoundedIntersection) { |
no test coverage detected